2021-03-03
3675
#node
Alexander Nnakwue
14680
Mar 3, 2021 â‹… 13 min read

Using ES modules in Node.js

Alexander Nnakwue Software engineer. React, Node.js, Python, and other developer tools and libraries.

Recent posts:

JavaScript logo representing the programming language used to implement a customizable and responsive signature pad in the article.

Implementing a signature pad with JavaScript

Signature pads are useful tools for capturing handwritten signatures in web applications. They enhance user interaction by allowing users to […]

Debjyoti Banerjee
Sep 30, 2024 â‹… 12 min read
This image features the iconic React logo—a blue atom-like symbol with a central dot and orbiting curves—superimposed on a background of a city skyline. The city appears to be shrouded in soft pink and purple hues, giving the image a modern, tech-focused atmosphere. This image symbolizex the use of React for building modular, scalable frontend architectures. React's component-based approach aligns with the principles of micro-frontends, where different parts of the user interface are independently developed and managed, similar to how microservices operate on the backend. The cityscape in the background represents the larger, complex web applications that can benefit from a structured, flexible frontend framework like React.

Practical guidance between vertical and horizontal micro-frontends

Micro-frontends, like microservices in backend development, divide frontend applications into modular, self-contained components that can be independently developed, tested, and […]

Peter Aideloje
Sep 27, 2024 â‹… 8 min read
Tauri Adoption Guide: Overview Examples, And Alternatives

Tauri adoption guide: Overview, examples, and alternatives

Tauri is an excellent toolkit for building lightweight, secure, and cross-platform desktop applications. Learn more in this guide.

Ikeh Akinyemi
Sep 26, 2024 â‹… 11 min read
Developing Modals Using Only CSS And The Popover API

Developing modals using only CSS and the Popover API

The Dialog and Popover approach to modals requires less code and and fewer files than using JavaScript method, making it less error-prone.

Daniel Schwarz
Sep 26, 2024 â‹… 7 min read
View all posts

4 Replies to "Using ES modules in Node.js"

  1. What about the performance decrease because of the esm modules resolution? I experienced a noticeable difference in the startup between the 13.1 and 13.7 versions (around 20%). I find this huge since I’m not using this feature anywhere yet.

  2. Hello Gergo, I haven’t seen any real life overhead in terms of performance in the new ESM resolution algorithm. Can you point me to how you got the stat you have mentioned above, and since this is not a known issue in the wide, also peeking at the issues tab in the source code (https://github.com/nodejs/node/issues?q=is%3Aissue+is%3Aopen+esm) does not point any issues relating to performance… You can learn more about the ESM algorithm here on the docs, https://nodejs.org/api/esm.html#esm_resolution_algorithm

  3. Hi Alexander,
    Thanks for checking. I couldn’t create a trustworthy benchmark, that’s why I asked. Using 13.8 I don’t see any big differences now.

  4. So how can you _usefully_ import an ES module into a CommonJS module? You make mention of dynamic import but that’s asynchronous and can only be called inside a function which means you can’t import anything into the top level with it since no top level ‘await’.

    Without an elegant solution to that basic interoperability it seems quite painful. I’m not an experienced JS developer and just getting Jasmine to run some tests against an ES module seems like an almighty undocumented ballache. I’ve spent more time trying to make sense of this than actually doing any work!

Leave a Reply