Skip to content

Commit c5c7965

Browse files
committed
Fix compilation failure with using Ably on Next.js with turbopack
Using `serverComponentsExternalPackages` nextjs config option to fix "Module not found" errors during compilation when running nextjs with turbopack (`next dev --turbo`). See explanation for the issue and the solution at ably/ably-js#1699 (comment). Also removes the need to use `overrides` in package.json and `webpack` field in next.config.js introduced in 3d51768 to fix `Critical dependency: the request of a dependency is an expression` warnings
1 parent 94c5f64 commit c5c7965

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

next.config.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ const nextConfig = {
99
dangerouslyAllowSVG: true,
1010
domains: ['static.ably.dev'],
1111
},
12-
webpack: (config) => {
13-
config.externals.push({
14-
'utf-8-validate': 'commonjs utf-8-validate',
15-
'bufferutil': 'commonjs bufferutil',
16-
})
17-
return config
18-
},
19-
}
12+
experimental: {
13+
serverComponentsExternalPackages: ['ably'],
14+
},
15+
};
2016

21-
module.exports = nextConfig
17+
module.exports = nextConfig;

package-lock.json

Lines changed: 7 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@types/node": "20.6.5",
1414
"@types/react": "18.2.22",
1515
"@types/react-dom": "18.2.7",
16-
"ably": "1.2.44",
16+
"ably": "^1.2.44",
1717
"dotenv": "^16.0.3",
1818
"eslint": "8.50.0",
1919
"flowbite": "^1.8.1",
@@ -31,10 +31,5 @@
3131
"eslint-plugin-react-hooks": "^4.6.0",
3232
"postcss": "^8.4.28",
3333
"tailwindcss": "^3.3.3"
34-
},
35-
"overrides": {
36-
"cacheable-request": {
37-
"keyv": "npm:@keyvhq/core@~1.6.6"
38-
}
3934
}
40-
}
35+
}

0 commit comments

Comments
 (0)