EcmaScript Modules in NodeJS // Upgrade your Projects to ES Modules

preview_player
Показать описание
After a number of years since the standardization of JavaScript modules nodejs finally has native support for import statements. However the way it works is by making simple but critical changes to your existing code.

So in this tutorial, we will look at what these changes are and how TypeScript also supports them 🌹

Related

🏷 #basarat #5MinutesOrLess #NodeJs #JavaScript #TypeScript

👇 ❤️ Subscribe for MOORE ❤️ 👇

**Feel Free To Read This Lot**

I'm Basarat, and I love helping developers. More about me:

Microsoft MVP for TypeScript
200K contributions on Stackoverflow. Top Contributor for TypeScript.
Book Author: Beginning NodeJS
Book Author: TypeScript Deep Dive
Creator of multiple hot ✨ed Github Open Source projects

Рекомендации по теме
Комментарии
Автор

Thank you for this video! As someone coming to ts/js from the jvm ecosystem; modules, imports and exports are confusing. This video goes a long way to help clear things up.

shashydass
Автор

YOur videos just rock. I am not sure why I don't just search your channel instead of wasting so much time in Google....

jamesfoley
Автор

Great video as usual. I encountered this issue last month and did another workaround. Cheers Basarat.

antonioquintero-felizzola
Автор

Hi, thanks for the video, it was really helpful. I was wondering If there is any solution to resolve module paths without writing file extensions. I'd love to use the "directory import" pattern and also it's a bit counterintuitive to specify "js" file extensions inside "ts" files. Thanks in advance!

vadymbarabanov
Автор

Did you cut your hair between takes? 😂 that got me good.

rtl
Автор

This is a _huge_ refactor for existing projects ... and thus, bitrot.
And thus, we end up maintaining legacy code, that becomes legacy quite often, after just a few months.

The entire JS ecosystem is fundamentally broken, because it changes far too often for many to keep up.
We seem to be spending more time refactoring our code to keep up or just letting our codebases rot - and every other week, some new way of doing things "catches on" and we re-invent part of our toolchain.

It's unsustainable in the long term, but I guess it keeps us all in a job ... ;)

As for npm package dependency hell - well, yes, I can hear the crying, the tears, the frustration as I type this - it is a _horror_ show.

When _will_ JS grow up?

I can clearly see it is impacting you too, Basarat, you lost your hair during the filming of this video - JS devs across the globe understand your pain.

matthewtrow
Автор

I don't like that we have to import from a ".js" file on a TypeScript project. 😕

SudeeptoDutta
Автор

Nice content..
Buddy do you know any tool/lib which automatically converts jsx to tsx.. for react project?

pranavpatil
Автор

Does it mean it eliminates the need of having a bundler like webpack if "bundling" is all we use it for?

NaqqashLatif
Автор

thank you a lot sir really helpful video for me <3

rajwindersingh
Автор

i like ES modules, but if i switch my package into a ES module, that cuts off alot of common js users of my package.

gamertike
Автор

I thought I'm trippin when I saw your hair to bald transition.

BonBonInoc
Автор

How come you are using Typescript file extensions but not utilising Typescript? Just wondering as this could seem odd to less experienced devs.

phil_jc_dev
Автор

Not sure I like this….. can we outline the pros of this?

cas