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.

estrella doesn't seem to be working within ESM context

See original GitHub issue

As more and more dependencies are updating to ESM, I’ve figured it’s time to bite the bullet and make my project ESM-ready as well.

But adding "type": "module" to my project’s package.json leads to these two issues when running node build.js:

  1.   import {build, cliopts} from "estrella";
              ^^^^^
      SyntaxError: Named export 'build' not found. The requested module 'estrella' is a CommonJS module, which may not support all module.exports as named exports.
      CommonJS modules can always be imported via the default export, for example using:
      
      import pkg from 'estrella';
      const {build, cliopts} = pkg;
    

    the proposed workaround works though.

  2. TypeError: Cannot read properties of undefined (reading 'filename') this is due to this code:

    https://github.com/rsms/estrella/blob/e5b985bd3292ddaa87022b97062be2f18b15b182/src/util.js#L27

    process.mainModule does not seem to exist in ESM.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

6reactions
mhamanncommented, Feb 11, 2022

I proposed a fix via #53. it works locally for me and all tests pass.

2reactions
mhamanncommented, Feb 11, 2022

I’m experiencing the second issue (TypeError: Cannot read properties of undefined (reading 'filename')) as well on a project that worked fine with v1.3.x.

I need 1.4.x because I’m building a browser JS bundle and without the sourcesContent option, my sourcemaps are broken.

(@ptim ironically, I was using the same template for my use case)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modify Eleventy to work with ECMAScript Modules (ESM) by ...
Node accept the query params on files but doesn't reimport. I think it's bug again. So you can still copy files and rename...
Read more >
Meta: Native support for ES Modules - Rysolv
Since the module scope is gone in ESM, we need to move it somewhere. Adding it to import.meta seems natural - there's an...
Read more >
Comparing the New Generation of Build Tools - CSS-Tricks
Code splitting appears to be a work in progress, but is mostly there in the ESM output format, and it does look like...
Read more >
Collecting Repeated Data Over Time: Applying Experience ...
ESM involves collecting data in the context of the natural work environment and includes a procedure in which individuals complete a survey ...
Read more >
Recent Evolutions in the Economic and Monetary Union and ...
economic policies was introduced, a European Stability Mechanism (ESM) ... in a context in which it is unlikely that all non-euro area Member...
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