Skip to content

Commit c4c6794

Browse files
committed
refactor: bundle external modules as separate self-contained builds
Move ink-table and yoga-layout bundling to separate rollup config that includes all dependencies in each bundle for proper isolation
1 parent b17f420 commit c4c6794

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

.config/rollup.dist.config.mjs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
2121
import baseConfig, { EXTERNAL_PACKAGES } from './rollup.base.config.mjs'
2222
import constants from '../scripts/constants.mjs'
2323
import socketModifyPlugin from '../scripts/rollup/socket-modify-plugin.mjs'
24-
import { normalizeId } from '../scripts/utils/packages.mjs'
24+
import { isBuiltin, normalizeId } from '../scripts/utils/packages.mjs'
2525

2626
const {
2727
CONSTANTS,
@@ -350,8 +350,6 @@ export default async () => {
350350
[SHADOW_NPM_INJECT]: `${srcPath}/shadow/npm/inject.mts`,
351351
[SHADOW_NPX_BIN]: `${srcPath}/shadow/npx/bin.mts`,
352352
[SHADOW_PNPM_BIN]: `${srcPath}/shadow/pnpm/bin.mts`,
353-
'external/ink-table': `${srcPath}/external/ink-table.mjs`,
354-
'external/yoga-layout': `${srcPath}/external/yoga-layout.mjs`,
355353
...(constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]
356354
? {
357355
[INSTRUMENT_WITH_SENTRY]: `${srcPath}/${INSTRUMENT_WITH_SENTRY}.mts`,
@@ -460,5 +458,34 @@ export default async () => {
460458
},
461459
],
462460
}),
461+
// Bundle external wrapper modules separately
462+
// Each external module gets its own self-contained bundle
463+
// Note: Using the base configuration to handle these properly
464+
baseConfig({
465+
input: {
466+
'external/ink-table': `${srcPath}/external/ink-table.mjs`,
467+
'external/yoga-layout': `${srcPath}/external/yoga-layout.mjs`,
468+
},
469+
output: {
470+
dir: path.relative(rootPath, distPath),
471+
entryFileNames: '[name].js',
472+
format: 'cjs',
473+
exports: 'auto',
474+
externalLiveBindings: false,
475+
generatedCode: {
476+
preset: 'es2015',
477+
arrowFunctions: true,
478+
constBindings: true,
479+
objectShorthand: true
480+
},
481+
compact: true,
482+
sourcemap: false,
483+
},
484+
// Override external to bundle dependencies for these modules
485+
external(id) {
486+
// Only externalize Node.js built-ins
487+
return isBuiltin(id)
488+
},
489+
}),
463490
]
464491
}

0 commit comments

Comments
 (0)