Skip to content

Commit 7de9a56

Browse files
feat: Use fs, module and process polyfills in next compute build
- Also improve preset config.
1 parent 3e89438 commit 7de9a56

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/presets/custom/next/compute/config.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { getAbsoluteLibDirPath, generateWebpackBanner } from '#utils';
77

88
const require = createRequire(import.meta.url);
99
const libDirPath = getAbsoluteLibDirPath();
10-
const nodePolyfillsPath = `${libDirPath}/build/polyfills/node`;
10+
const polyfillsPath = `${libDirPath}/build/polyfills`;
11+
const nodePolyfillsPath = `${polyfillsPath}/node`;
1112
const nextNodePresetPath = `${libDirPath}/presets/custom/next/compute/node`;
1213

1314
/**
@@ -41,12 +42,12 @@ const config = {
4142
// or core nodejs modules needed for your application.
4243
new webpack.ProvidePlugin({
4344
Buffer: ['buffer', 'Buffer'],
44-
process: 'process',
4545
}),
4646
new webpack.BannerPlugin({
4747
banner: generateWebpackBanner([
4848
`${nodePolyfillsPath}/globals/navigator.js`,
4949
`${nodePolyfillsPath}/globals/performance.js`,
50+
`${nodePolyfillsPath}/globals/process.js`,
5051
]),
5152
raw: true,
5253
}),
@@ -61,28 +62,26 @@ const config = {
6162
resolve: {
6263
mainFields: ['browser', 'main', 'module'],
6364
alias: {
64-
'next/dist/compiled/raw-body': require.resolve('raw-body'),
6565
util: require.resolve('util/'),
6666
},
6767
fallback: {
6868
async_hooks: false,
6969
tls: false,
7070
net: false,
71-
fs: false,
7271
http: require.resolve('stream-http'),
7372
buffer: require.resolve('buffer/'),
7473
crypto: require.resolve('crypto-browserify/'),
7574
events: require.resolve('events/'),
7675
os: require.resolve('os-browserify/browser'),
7776
path: require.resolve('path-browserify'),
78-
process: require.resolve('process/browser'),
7977
querystring: require.resolve('querystring-es3'),
8078
stream: require.resolve('stream-browserify'),
8179
url: require.resolve('url/'),
82-
util: require.resolve('util/'),
8380
zlib: require.resolve('browserify-zlib'),
8481
dns: `${nodePolyfillsPath}/dns.js`,
8582
http2: `${nodePolyfillsPath}/http2.js`,
83+
module: `${nodePolyfillsPath}/module.js`,
84+
fs: `${nodePolyfillsPath}/fs.js`,
8685
'next/dist/compiled/etag': `${nextNodePresetPath}/custom-server/12.3.1/util/etag.js`,
8786
'@fastly/http-compute-js': require.resolve('@fastly/http-compute-js'),
8887
accepts: require.resolve('accepts'),

0 commit comments

Comments
 (0)