Skip to content

estrella doesn't seem to be working within ESM context #51

Open
@danielberndt

Description

@danielberndt

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:

    export const isCLI = module.id == "." || process.mainModule.filename == __filename

    process.mainModule does not seem to exist in ESM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions