Skip to content

Commit

Permalink
chore: webpack does not support .mjs by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd committed Oct 27, 2023
1 parent 65d9726 commit 21eecc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ const nextConfig = {
// as we already check it on the CI within each Pull Request
// we also configure ESLint to run its lint checking on all files (next lint)
eslint: { dirs: ['.'], ignoreDuringBuilds: true },
// Next.js WebPack Bundler does not know how to handle `.mjs` files on `node_modules`
// This is not an issue when using TurboPack as it uses SWC and it is ESM-only
// Once we migrate to Next.js 14 we might be able to remove this
webpack: function (config) {
config.module.rules.push({
test: /\.m?js$/,
type: 'javascript/auto',
resolve: { fullySpecified: false },
});
return config;
},
experimental: {
// Some of our static pages from `getStaticProps` have a lot of data
// since we pass the fully-compiled MDX page from `MDXRemote` through
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts:release-post": "cross-env NODE_NO_WARNINGS=1 node scripts/release-post/index.mjs",
"scripts:generate-next-data": "cross-env NODE_NO_WARNINGS=1 node scripts/generate-next-data/index.mjs",
"preserve": "npm run scripts:generate-next-data",
"serve": "cross-env NODE_NO_WARNINGS=1 next dev --turbo",
"serve": "cross-env NODE_NO_WARNINGS=1 next dev",
"prebuild": "npm run scripts:generate-next-data",
"build": "cross-env NODE_NO_WARNINGS=1 next build",
"start": "cross-env NODE_NO_WARNINGS=1 next start",
Expand Down

0 comments on commit 21eecc4

Please sign in to comment.