Skip to content

Commit cb3c18a

Browse files
committed
Bundle ink as self-contained external module
Add ink.mjs wrapper to bundle ink with all its dependencies into a single self-contained file, similar to ink-table and yoga-layout. Update rollup config to bundle each external module separately to avoid code splitting and shared chunks.
1 parent 7bf1136 commit cb3c18a

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

.config/rollup.dist.config.mjs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,57 @@ export default async () => {
411411
}),
412412
// Bundle external wrapper modules separately
413413
// Each external module gets its own self-contained bundle
414-
// Note: Using the base configuration to handle these properly
414+
// Bundle each one individually to avoid code splitting
415415
baseConfig({
416-
input: {
417-
'external/ink-table': `${srcPath}/external/ink-table.mjs`,
418-
'external/yoga-layout': `${srcPath}/external/yoga-layout.mjs`,
416+
input: `${srcPath}/external/ink.mjs`,
417+
output: {
418+
file: path.join(path.relative(rootPath, distPath), 'external/ink.js'),
419+
format: 'cjs',
420+
exports: 'auto',
421+
externalLiveBindings: false,
422+
generatedCode: {
423+
preset: 'es2015',
424+
arrowFunctions: true,
425+
constBindings: true,
426+
objectShorthand: true
427+
},
428+
compact: true,
429+
sourcemap: false,
430+
inlineDynamicImports: true,
431+
},
432+
// Override external to bundle dependencies for these modules
433+
external(id) {
434+
// Only externalize Node.js built-ins
435+
return isBuiltin(id)
436+
},
437+
}),
438+
baseConfig({
439+
input: `${srcPath}/external/ink-table.mjs`,
440+
output: {
441+
file: path.join(path.relative(rootPath, distPath), 'external/ink-table.js'),
442+
format: 'cjs',
443+
exports: 'auto',
444+
externalLiveBindings: false,
445+
generatedCode: {
446+
preset: 'es2015',
447+
arrowFunctions: true,
448+
constBindings: true,
449+
objectShorthand: true
450+
},
451+
compact: true,
452+
sourcemap: false,
453+
inlineDynamicImports: true,
454+
},
455+
// Override external to bundle dependencies for these modules
456+
external(id) {
457+
// Only externalize Node.js built-ins
458+
return isBuiltin(id)
419459
},
460+
}),
461+
baseConfig({
462+
input: `${srcPath}/external/yoga-layout.mjs`,
420463
output: {
421-
dir: path.relative(rootPath, distPath),
422-
entryFileNames: '[name].js',
464+
file: path.join(path.relative(rootPath, distPath), 'external/yoga-layout.js'),
423465
format: 'cjs',
424466
exports: 'auto',
425467
externalLiveBindings: false,
@@ -431,6 +473,7 @@ export default async () => {
431473
},
432474
compact: true,
433475
sourcemap: false,
476+
inlineDynamicImports: true,
434477
},
435478
// Override external to bundle dependencies for these modules
436479
external(id) {

src/external/ink.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @fileoverview ink wrapper for proper bundling with dependencies.
3+
*
4+
* This ensures ink and all its dependencies are properly bundled.
5+
*/
6+
7+
// ink doesn't have a default export, just named exports
8+
export * from 'ink'

0 commit comments

Comments
 (0)