question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exporting as ES Module Syntax (ESM)

See original GitHub issue

Please, export "module" entry point in the package.json as ES Module Syntax (ESM).

More info about it here: https://www.pikapkg.com/about/

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:21 (17 by maintainers)

github_iconTop GitHub Comments

5reactions
Splaktarcommented, Jul 18, 2020

I am running into this same issue with an app built using apollo-client. It gives this error with Angular CLI version 10:

WARNING in /Users/splaktar/Git/my-app/node_modules/zen-observable-ts/lib/bundle.esm.js depends on 'zen-observable'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

https://angular.io/guide/build#configuring-commonjs-dependencies has some good links to explain why CommonJS modules don’t support tree shaking and how ES Modules work.

zen-observable-ts is importing correctly:

import zenObservable from 'zen-observable';

But due to the lacking "module": "esm.js", that ends up getting the CommonJS module (index.js) instead of the ES Module.

It looks like the approach in PR https://github.com/zenparsing/zen-observable/pull/74 should solve this and hopefully avoid any of the pitfalls that were faced in the past.

3reactions
zenparsingcommented, Oct 16, 2019

Sounds cool - I’ll give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

module.exports and ES modules (ESM) import export in Node.js
import export syntax​​ in ESM, export serves to export functions or objects from a module, and it has two types of export: Named...
Read more >
ES Modules may not assign module.exports or exports.*, Use ...
I get this error when I try to export a function with module.exports and when I import it inside another file. I tried...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Modules are defined using a variety of import and export statements. The following example of an ES module exports a function:
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
Using ECMAScript modules (ESM) with Node.js
Learn about using ES modules in Node.js today and get a closer look at how you ... We can only have one default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found