Is there a way of using importmap on node.js? Not only the default functionality of node_modules but also any imported script on my project?
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
Import maps are not supported in NodeJS yet.
@danielvega646 Жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thanks a lot for taking the time to answer me, master!
@brod5153 жыл бұрын
So if you are deploying this webpage the node_modules folder has to be available in the distribution.
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
Or you use a build tool that brings in the imported scripts.
@Anandgupta-cp6xo Жыл бұрын
Does it allow tree shaking?
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
Depends what you mean "allow tree shaking" With ES Modules, it is the export statements that have most of the control. Only items that are exported are allowed to be read by the importing file. If you `import *` then you are getting all the modules. If you use specific identifiers in your import statement then you are only importing those specific items from the module. The first step in the process is the links being created between the export and import where the names match. If a link doesn't exist it doesn't get imported... you are manually doing the tree shaking when you write the export and import statements. If you put all your code in the export file inside a single namespace and export that namespace then your only choice is to import the entirety of the code. No tree-shaking is possible.
@blokche_dev3 жыл бұрын
I was getting some errors before trying in incognito mode ("An import map is added after module script load was triggered.") 🧐 Some extensions and scripts may cause trouble I guess. Anyway, thanks for sharing!
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
The import map should come before your modules in the HTML. And this is a fairly new feature.