Skip to content

Commit ae1d9f8

Browse files
committed
Fix build for Node 22
1 parent df0be67 commit ae1d9f8

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

.config/rollup.base.config.mjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,8 @@ function ${SOCKET_INTEROP}(e) {
293293
).map(o => ({
294294
...o,
295295
chunkFileNames: '[name].js',
296-
manualChunks(id_) {
297-
const id = normalizeId(id_)
298-
if (
299-
id.includes(SLASH_NODE_MODULES_SLASH) &&
300-
!id.includes('@babel/runtime/')
301-
) {
302-
return 'vendor'
303-
}
304-
}
296+
manualChunks: id =>
297+
id.includes(SLASH_NODE_MODULES_SLASH) ? 'vendor' : null
305298
}))
306299

307300
// Replace hard-coded absolute paths in source with hard-coded relative paths.

.config/rollup.dist.config.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ function modifyConstantsModuleExportsSync(distPath) {
5454
const filepath = path.join(distPath, CONSTANTS_JS)
5555
let code = readFileSync(filepath, 'utf8')
5656
code = code
57-
// Remove @babel/runtime helpers from code.
58-
.replace(
59-
/function getDefaultExportFromCjs[\s\S]+?constants\$\d+\.default = void 0;?\n/,
60-
''
61-
)
62-
// Remove @babel/runtime and @rollup/commonjs interop from code.
57+
// Remove @rollup/commonjs interop from code.
58+
.replace(/var constants\$\d+ = {};?\n+/, '')
59+
.replace(/Object\.defineProperty\(constants\$\d+[\s\S]+?\}\);?\n/, '')
6360
.replace(/^(?:exports.[$\w]+|[$\w]+\.default)\s*=.*(?:\n|$)/gm, '')
6461
code = code + 'module.exports = constants\n'
6562
writeFileSync(filepath, code, 'utf8')

scripts/utils/packages.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ function isEsmId(id_, parentId_) {
104104
pkgJson.type === 'module' &&
105105
!entryExports?.require &&
106106
!entryExports?.node?.require &&
107-
!entryExports?.node?.default?.endsWith('.cjs') &&
107+
!entryExports?.node?.default?.endsWith?.('.cjs') &&
108108
!entryExports?.['.']?.require &&
109109
!entryExports?.['.']?.node?.require &&
110-
!entryExports?.['.']?.node?.default?.endsWith('.cjs')
110+
!entryExports?.['.']?.node?.default?.endsWith?.('.cjs') &&
111+
!entryExports?.['.']?.node?.default?.default?.endsWith?.('.cjs')
111112
) {
112113
return true
113114
}

0 commit comments

Comments
 (0)