Using Import Maps with ES Modules

  Рет қаралды 4,627

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

Пікірлер
@danielvega646
@danielvega646 Жыл бұрын
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
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
Import maps are not supported in NodeJS yet.
@danielvega646
@danielvega646 Жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thanks a lot for taking the time to answer me, master!
@brod515
@brod515 3 жыл бұрын
So if you are deploying this webpage the node_modules folder has to be available in the distribution.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Or you use a build tool that brings in the imported scripts.
@Anandgupta-cp6xo
@Anandgupta-cp6xo Жыл бұрын
Does it allow tree shaking?
@SteveGriffith-Prof3ssorSt3v3
@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_dev
@blokche_dev 3 жыл бұрын
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-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
The import map should come before your modules in the HTML. And this is a fairly new feature.
@froneotm9565
@froneotm9565 3 жыл бұрын
You're my js daddy rn
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Lol
@Youssef-lv6wp
@Youssef-lv6wp 3 жыл бұрын
Thanks u
Importing ES Modules for Side Effects
6:55
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 4,1 М.
Package JSON Demystified - The 'Exports' Keyword
14:46
A shot of code
Рет қаралды 4 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 52 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Import maps - HTTP 203
20:16
Chrome for Developers
Рет қаралды 18 М.
ES6 Iterator & Generator Fundamentals
18:18
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 31 М.
Why can’t i just use “import” in Node.js
12:43
Require vs Import Javascript
22:39
Monsterlessons Academy
Рет қаралды 80 М.
Javascript ImportMaps - Bye Bye Build Tools??
15:34
A shot of code
Рет қаралды 1,3 М.
Dynamic Module Imports in JavaScript
9:37
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 6 М.
Custom Events Dispatched from Web Components
20:32
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 2,5 М.
JavaScript Modules 101 - Still need to bundle your browser code?
21:14
Andrew Connell
Рет қаралды 1,3 М.
Enhance your Coding with JSDoc
19:37
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 10 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 52 МЛН