Skip to content

Commit

Permalink
fix(SSR): disable esmExternals until we support ES modules to fix l…
Browse files Browse the repository at this point in the history
…ocalized URLs SSR markup
  • Loading branch information
nbouvrette committed Jan 6, 2022
1 parent 864075a commit 26ddb22
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ module.exports = {
localeDetection: false,
},
poweredByHeader: false,
/* This is required since Next.js 11.1.3-canary.69 until we support ESM. */
experimental: {
esmExternals: false,
},
webpack(config, { isServer }) {
if (isServer) {
config.resolve.alias['next-multilingual/link$'] = require.resolve(
Expand Down
46 changes: 23 additions & 23 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,14 @@ export function getConfig(
localeDetection: false, // This is important to use the improved language detection feature.
};

/* This is required since Next.js 11.1.3-canary.69 until we support ESM. */
if (typeof nextConfig.experimental !== 'undefined') {
nextConfig.experimental.esmExternals = false;
} else {
nextConfig.experimental = {};
nextConfig.experimental.esmExternals = false;
}

// Set Webpack config.
nextConfig.webpack = (config, { isServer }) => {
// Overwrite the `link` component for SSR.
Expand Down

0 comments on commit 26ddb22

Please sign in to comment.