Skip to content

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.

1 participant