Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: .mjs imports in commonjs export #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

snitin315
Copy link
Contributor

@snitin315 snitin315 commented Feb 20, 2022

Currently, we have the following .mjs imports in the index.js file.

const chunkPathBasic = require.resolve('./entries/basic.mjs')
const chunkPathDevServer = require.resolve('./entries/devserver.mjs')

Since we are still exporting a .cjs export -

"main": "dist/index.cjs",

This leads to import of .mjs files inside the index.cjs file. Which leads to the following errors on starting -

On terminal -

Screenshot 2022-02-20 at 9 58 25 AM

On webpack-dev-server overlay -
Screenshot 2022-02-20 at 9 58 39 AM

And to fix it we need to add the following extra code in our webpack configuration -

module: {
      rules: [
        {
          test: /\.mjs$/,
          include: /node_modules/,
          type: "javascript/auto"
        }
      ]
    }

@snitin315 snitin315 marked this pull request as ready for review February 20, 2022 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant