@pie-element/cli 0.1.2-next.0 → 0.1.2-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,17 @@ export const DEFAULT_PATHS = {
7
7
  PIE_LIB: '../pie-lib',
8
8
  PIE_ELEMENTS_NG: '.',
9
9
  };
10
+ /**
11
+ * Module source substituted for `debug` in per-element IIFE builds. Carries the
12
+ * module-level `debug.log` and the instance methods element code calls.
13
+ */
14
+ export const IIFE_DEBUG_SHIM_SOURCE = "const noop = () => {}; function debug() { const log = function () {}; log.enabled = false; log.log = noop; log.extend = () => log; log.destroy = noop; return log; } debug.log = noop; debug.enable = noop; debug.disable = () => ''; debug.enabled = () => false; export default debug;";
15
+ /**
16
+ * Module source substituted for `prop-types` in per-element IIFE builds. It mirrors
17
+ * prop-types' production shims: every validator is callable and carries `isRequired`,
18
+ * so `PropTypes.oneOf([...]).isRequired` evaluates at module load.
19
+ */
20
+ export const IIFE_PROP_TYPES_SHIM_SOURCE = 'const shim = function () { return null; }; shim.isRequired = shim; const getShim = () => shim; export const array = shim, bigint = shim, bool = shim, func = shim, number = shim, object = shim, string = shim, symbol = shim, any = shim, element = shim, elementType = shim, node = shim; export const arrayOf = getShim, instanceOf = getShim, objectOf = getShim, oneOf = getShim, oneOfType = getShim, shape = getShim, exact = getShim; export const checkPropTypes = () => {}; export const resetWarningCache = () => {}; const types = { array, bigint, bool, func, number, object, string, symbol, any, element, elementType, node, arrayOf, instanceOf, objectOf, oneOf, oneOfType, shape, exact, checkPropTypes, resetWarningCache }; types.PropTypes = types; export { types as PropTypes }; export default types;';
10
21
  // Workspace dependency patterns
11
22
  export const WORKSPACE = {
12
23
  VERSION: 'workspace:*',
@@ -19,16 +30,19 @@ export const WORKSPACE = {
19
30
  export const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'];
20
31
  // Upstream @pie-lib packages intentionally excluded from sync.
21
32
  // math-rendering stays local (wrapper re-exports shared MathJax adapter).
22
- export const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering'];
33
+ // translator lives in packages/shared: its strings serve the Svelte elements too.
34
+ export const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering', 'translator'];
23
35
  // Build tool versions
24
36
  export const BUILD_TOOLS = {
25
37
  VITE: '^8.0.1',
26
38
  TYPESCRIPT: '^5.9.3',
27
39
  VITE_REACT_PLUGIN: '^6.0.1',
28
40
  };
29
- // React versions
41
+ // React versions. Element packages also depend on React from ^18.2.0, the browser ESM policy
42
+ // version, so their peer range starts there.
30
43
  export const REACT = {
31
- VERSION: '^18.0.0',
44
+ ELEMENT_PEER_RANGE: '^18.2.0 || ^19.0.0',
45
+ LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',
32
46
  TYPES_VERSION: '^18.2.0',
33
47
  };
34
48
  // Directory patterns to skip
@@ -51,6 +65,7 @@ export const PACKAGE_DEFAULTS = {
51
65
  };
52
66
  // Build scripts
53
67
  export const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';
68
+ export const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG = '../../../tools/vite/element-browser-editor-runtime.config.ts';
54
69
  export const ELEMENT_LEGACY_PRINT_VITE_CONFIG = '../../../tools/vite/element-legacy-print.config.ts';
55
70
  /**
56
71
  * Compose a synced element's build script from the lanes it needs.
@@ -67,6 +82,9 @@ export function composeElementBuildScript(lanes = {}) {
67
82
  const steps = ['bun x vite build'];
68
83
  if (lanes.browser) {
69
84
  steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);
85
+ if (lanes.editorRuntime) {
86
+ steps.push(`bun x vite build --config ${ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG}`);
87
+ }
70
88
  }
71
89
  if (lanes.legacyPrint) {
72
90
  steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);
@@ -1 +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CAChB,CAAC;AAEX,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,wBAAwB;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC","sourcesContent":["/**\n * Shared constants for upstream sync operations\n */\n\n// Default repository paths\nexport const DEFAULT_PATHS = {\n PIE_ELEMENTS: '../pie-elements',\n PIE_LIB: '../pie-lib',\n PIE_ELEMENTS_NG: '.',\n} as const;\n\n// Workspace dependency patterns\nexport const WORKSPACE = {\n VERSION: 'workspace:*',\n PIE_LIB_PREFIX: '@pie-lib/',\n PIE_ELEMENT_PREFIX: '@pie-element/',\n PIE_FRAMEWORK_PREFIX: '@pie-framework/',\n} as const;\n\n// Upstream element packages intentionally excluded from sync.\n// These templates are not used in pie-elements-ng runtime.\nexport const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'] as const;\n\n// Upstream @pie-lib packages intentionally excluded from sync.\n// math-rendering stays local (wrapper re-exports shared MathJax adapter).\nexport const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering'] as const;\n\n// Build tool versions\nexport const BUILD_TOOLS = {\n VITE: '^8.0.1',\n TYPESCRIPT: '^5.9.3',\n VITE_REACT_PLUGIN: '^6.0.1',\n} as const;\n\n// React versions\nexport const REACT = {\n VERSION: '^18.0.0',\n TYPES_VERSION: '^18.2.0',\n} as const;\n\n// Directory patterns to skip\nexport const SKIP_PATTERNS = {\n TEST_DIRS: ['__tests__', '__mocks__'],\n FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],\n} as const;\n\n// File types\nexport const FILE_TYPES = {\n JS: '.js',\n JSX: '.jsx',\n TS: '.ts',\n TSX: '.tsx',\n} as const;\n\n// Package.json defaults\nexport const PACKAGE_DEFAULTS = {\n TYPE: 'module',\n SIDE_EFFECTS: false,\n FILES: ['dist', 'src'],\n} as const;\n\n// Build scripts\nexport const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';\nexport const ELEMENT_LEGACY_PRINT_VITE_CONFIG =\n '../../../tools/vite/element-legacy-print.config.ts';\n\nexport type ElementBuildLanes = {\n /** dist/browser/** - the browser ESM surface consumed by pie-players. */\n browser?: boolean;\n /**\n * module/print.js - a self-contained print bundle (React inlined, zero\n * externals) for the unmodified @pie-framework/pie-print client loader, which\n * uses a bare import() with no import map and so cannot read exports[\"./print\"].\n * See PIE-839 and docs/PRINT_SUPPORT.md.\n */\n legacyPrint?: boolean;\n /** dist/index.iife.js - the fully self-contained script-tag surface. */\n iife?: boolean;\n};\n\n/**\n * Compose a synced element's build script from the lanes it needs.\n *\n * Composed rather than enumerated on purpose. This used to be four hardcoded\n * constants covering the browser/iife combinations, so when PIE-839 added the\n * legacy print lane there was nowhere for it to live: it was written straight\n * into the twelve print-enabled manifests, and the next sync regenerated\n * `scripts.build` from the constants and silently dropped it. Print then broke\n * for every synced element with no failing check. Adding a lane here keeps it in\n * the generated output instead of relying on a hand-edited manifest surviving.\n */\nexport function composeElementBuildScript(lanes: ElementBuildLanes = {}): string {\n const steps = ['bun x vite build'];\n if (lanes.browser) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);\n }\n if (lanes.legacyPrint) {\n steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);\n }\n if (lanes.iife) {\n steps.push('bun x vite build --config vite.config.iife.ts');\n }\n steps.push('bun x tsc --emitDeclarationOnly');\n return steps.join(' && ');\n}\n\n// Derived from composeElementBuildScript so the named variants cannot drift from\n// the composer. Prefer calling the composer directly for new lane combinations.\nexport const SCRIPTS = {\n BUILD: composeElementBuildScript(),\n BUILD_WITH_BROWSER: composeElementBuildScript({ browser: true }),\n BUILD_WITH_IIFE: composeElementBuildScript({ iife: true }),\n BUILD_WITH_IIFE_AND_BROWSER: composeElementBuildScript({ browser: true, iife: true }),\n DEV: 'bun x vite',\n DEMO: 'bun x vite --mode demo',\n TEST: 'bun x vitest run',\n} as const;\n\n// Compatibility report file\nexport const COMPATIBILITY_FILE = './.compatibility/report.json';\n\n// Upstream history file\nexport const HISTORY_FILE = '.upstream-sync-history.json';\n"]}
1
+ {"version":3,"file":"sync-constants.js","sourceRoot":"","sources":["../../../src/lib/upstream/sync-constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,iBAAiB;IAC/B,OAAO,EAAE,YAAY;IACrB,eAAe,EAAE,GAAG;CACZ,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,0RAA0R,CAAC;AAE7R;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,gyBAAgyB,CAAC;AAEnyB,gCAAgC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,WAAW;IAC3B,kBAAkB,EAAE,eAAe;IACnC,oBAAoB,EAAE,iBAAiB;CAC/B,CAAC;AAEX,8DAA8D;AAC9D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,uBAAuB,CAAU,CAAC;AAE7E,+DAA+D;AAC/D,0EAA0E;AAC1E,kFAAkF;AAClF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,gBAAgB,EAAE,YAAY,CAAU,CAAC;AAE5F,sBAAsB;AACtB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,iBAAiB,EAAE,QAAQ;CACnB,CAAC;AAEX,6FAA6F;AAC7F,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,aAAa,EAAE,SAAS;CAChB,CAAC;AAEX,6BAA6B;AAC7B,MAAM,CAAC,MAAM,aAAa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AAC,iCAAiC,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,iFAAiF;AACjF,gFAAgF;AAChF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,yBAAyB,EAAE;IAClC,kBAAkB,EAAE,yBAAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChE,eAAe,EAAE,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1D,2BAA2B,EAAE,yBAAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrF,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,kBAAkB;CAChB,CAAC;AAEX,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,wBAAwB;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC","sourcesContent":["/**\n * Shared constants for upstream sync operations\n */\n\n// Default repository paths\nexport const DEFAULT_PATHS = {\n PIE_ELEMENTS: '../pie-elements',\n PIE_LIB: '../pie-lib',\n PIE_ELEMENTS_NG: '.',\n} as const;\n\n/**\n * Module source substituted for `debug` in per-element IIFE builds. Carries the\n * module-level `debug.log` and the instance methods element code calls.\n */\nexport const IIFE_DEBUG_SHIM_SOURCE =\n \"const noop = () => {}; function debug() { const log = function () {}; log.enabled = false; log.log = noop; log.extend = () => log; log.destroy = noop; return log; } debug.log = noop; debug.enable = noop; debug.disable = () => ''; debug.enabled = () => false; export default debug;\";\n\n/**\n * Module source substituted for `prop-types` in per-element IIFE builds. It mirrors\n * prop-types' production shims: every validator is callable and carries `isRequired`,\n * so `PropTypes.oneOf([...]).isRequired` evaluates at module load.\n */\nexport const IIFE_PROP_TYPES_SHIM_SOURCE =\n 'const shim = function () { return null; }; shim.isRequired = shim; const getShim = () => shim; export const array = shim, bigint = shim, bool = shim, func = shim, number = shim, object = shim, string = shim, symbol = shim, any = shim, element = shim, elementType = shim, node = shim; export const arrayOf = getShim, instanceOf = getShim, objectOf = getShim, oneOf = getShim, oneOfType = getShim, shape = getShim, exact = getShim; export const checkPropTypes = () => {}; export const resetWarningCache = () => {}; const types = { array, bigint, bool, func, number, object, string, symbol, any, element, elementType, node, arrayOf, instanceOf, objectOf, oneOf, oneOfType, shape, exact, checkPropTypes, resetWarningCache }; types.PropTypes = types; export { types as PropTypes }; export default types;';\n\n// Workspace dependency patterns\nexport const WORKSPACE = {\n VERSION: 'workspace:*',\n PIE_LIB_PREFIX: '@pie-lib/',\n PIE_ELEMENT_PREFIX: '@pie-element/',\n PIE_FRAMEWORK_PREFIX: '@pie-framework/',\n} as const;\n\n// Upstream element packages intentionally excluded from sync.\n// These templates are not used in pie-elements-ng runtime.\nexport const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'] as const;\n\n// Upstream @pie-lib packages intentionally excluded from sync.\n// math-rendering stays local (wrapper re-exports shared MathJax adapter).\n// translator lives in packages/shared: its strings serve the Svelte elements too.\nexport const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering', 'translator'] as const;\n\n// Build tool versions\nexport const BUILD_TOOLS = {\n VITE: '^8.0.1',\n TYPESCRIPT: '^5.9.3',\n VITE_REACT_PLUGIN: '^6.0.1',\n} as const;\n\n// React versions. Element packages also depend on React from ^18.2.0, the browser ESM policy\n// version, so their peer range starts there.\nexport const REACT = {\n ELEMENT_PEER_RANGE: '^18.2.0 || ^19.0.0',\n LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',\n TYPES_VERSION: '^18.2.0',\n} as const;\n\n// Directory patterns to skip\nexport const SKIP_PATTERNS = {\n TEST_DIRS: ['__tests__', '__mocks__'],\n FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],\n} as const;\n\n// File types\nexport const FILE_TYPES = {\n JS: '.js',\n JSX: '.jsx',\n TS: '.ts',\n TSX: '.tsx',\n} as const;\n\n// Package.json defaults\nexport const PACKAGE_DEFAULTS = {\n TYPE: 'module',\n SIDE_EFFECTS: false,\n FILES: ['dist', 'src'],\n} as const;\n\n// Build scripts\nexport const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';\nexport const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG =\n '../../../tools/vite/element-browser-editor-runtime.config.ts';\nexport const ELEMENT_LEGACY_PRINT_VITE_CONFIG =\n '../../../tools/vite/element-legacy-print.config.ts';\n\nexport type ElementBuildLanes = {\n /** dist/browser/** - the browser ESM surface consumed by pie-players. */\n browser?: boolean;\n /**\n * dist/browser/editor-runtime/** - the browser build with the editor engine imported from\n * @pie-element/shared-editor-runtime, declared in pie.browserEditorRuntime. Needs `browser`.\n */\n editorRuntime?: boolean;\n /**\n * module/print.js - a self-contained print bundle (React inlined, zero\n * externals) for the unmodified @pie-framework/pie-print client loader, which\n * uses a bare import() with no import map and so cannot read exports[\"./print\"].\n * See PIE-839 and docs/PRINT_SUPPORT.md.\n */\n legacyPrint?: boolean;\n /** dist/index.iife.js - the fully self-contained script-tag surface. */\n iife?: boolean;\n};\n\n/**\n * Compose a synced element's build script from the lanes it needs.\n *\n * Composed rather than enumerated on purpose. This used to be four hardcoded\n * constants covering the browser/iife combinations, so when PIE-839 added the\n * legacy print lane there was nowhere for it to live: it was written straight\n * into the twelve print-enabled manifests, and the next sync regenerated\n * `scripts.build` from the constants and silently dropped it. Print then broke\n * for every synced element with no failing check. Adding a lane here keeps it in\n * the generated output instead of relying on a hand-edited manifest surviving.\n */\nexport function composeElementBuildScript(lanes: ElementBuildLanes = {}): string {\n const steps = ['bun x vite build'];\n if (lanes.browser) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);\n if (lanes.editorRuntime) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG}`);\n }\n }\n if (lanes.legacyPrint) {\n steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);\n }\n if (lanes.iife) {\n steps.push('bun x vite build --config vite.config.iife.ts');\n }\n steps.push('bun x tsc --emitDeclarationOnly');\n return steps.join(' && ');\n}\n\n// Derived from composeElementBuildScript so the named variants cannot drift from\n// the composer. Prefer calling the composer directly for new lane combinations.\nexport const SCRIPTS = {\n BUILD: composeElementBuildScript(),\n BUILD_WITH_BROWSER: composeElementBuildScript({ browser: true }),\n BUILD_WITH_IIFE: composeElementBuildScript({ iife: true }),\n BUILD_WITH_IIFE_AND_BROWSER: composeElementBuildScript({ browser: true, iife: true }),\n DEV: 'bun x vite',\n DEMO: 'bun x vite --mode demo',\n TEST: 'bun x vitest run',\n} as const;\n\n// Compatibility report file\nexport const COMPATIBILITY_FILE = './.compatibility/report.json';\n\n// Upstream history file\nexport const HISTORY_FILE = '.upstream-sync-history.json';\n"]}
@@ -66,6 +66,20 @@ export declare const transformLodashToLodashEs: typeof transformLodashToVendored
66
66
  * entrypoint, so synced source should prefer it over the CommonJS-era package.
67
67
  */
68
68
  export declare function transformClassnamesToClsx(content: string): string;
69
+ /**
70
+ * Rewrite js-combinatorics 0.5 `combination(seed, size)` calls to the 2.x `Combination` class.
71
+ *
72
+ * Upstream depends on 0.5, a UMD script with no ESM entrypoint; synced packages depend on 2.x,
73
+ * where `combination(n, k)` counts combinations as a BigInt and throws when given an array.
74
+ * `new Combination(seed, size)` enumerates the same pairs in the same order.
75
+ */
76
+ export declare function transformJsCombinatoricsToV2(content: string): string;
77
+ /**
78
+ * Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
79
+ * destructure, so `import { camelizeKeys } from 'humps'` becomes
80
+ * `import humps from 'humps'; const { camelizeKeys } = humps;`.
81
+ */
82
+ export declare function transformCommonJsNamedImports(content: string): string;
69
83
  /**
70
84
  * Replace react-input-autosize with the local ESM autosize input component.
71
85
  *
@@ -422,6 +422,112 @@ export const transformLodashToLodashEs = transformLodashToVendoredLodash;
422
422
  export function transformClassnamesToClsx(content) {
423
423
  return rewriteModuleSpecifiers(content, (specifier) => specifier === 'classnames' ? 'clsx' : undefined);
424
424
  }
425
+ /**
426
+ * Rewrite js-combinatorics 0.5 `combination(seed, size)` calls to the 2.x `Combination` class.
427
+ *
428
+ * Upstream depends on 0.5, a UMD script with no ESM entrypoint; synced packages depend on 2.x,
429
+ * where `combination(n, k)` counts combinations as a BigInt and throws when given an array.
430
+ * `new Combination(seed, size)` enumerates the same pairs in the same order.
431
+ */
432
+ export function transformJsCombinatoricsToV2(content) {
433
+ if (!content.includes('js-combinatorics')) {
434
+ return content;
435
+ }
436
+ const sourceFile = ts.createSourceFile('source.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
437
+ const edits = [];
438
+ const callees = new Map();
439
+ for (const statement of sourceFile.statements) {
440
+ if (!ts.isImportDeclaration(statement) ||
441
+ !ts.isStringLiteral(statement.moduleSpecifier) ||
442
+ statement.moduleSpecifier.text !== 'js-combinatorics') {
443
+ continue;
444
+ }
445
+ const bindings = statement.importClause?.namedBindings;
446
+ if (!bindings || !ts.isNamedImports(bindings)) {
447
+ continue;
448
+ }
449
+ for (const element of bindings.elements) {
450
+ if ((element.propertyName ?? element.name).text !== 'combination') {
451
+ continue;
452
+ }
453
+ const local = element.name.text;
454
+ const aliased = local !== 'combination';
455
+ callees.set(local, aliased ? local : 'Combination');
456
+ edits.push({
457
+ start: element.getStart(sourceFile),
458
+ end: element.getEnd(),
459
+ text: aliased ? `Combination as ${local}` : 'Combination',
460
+ });
461
+ }
462
+ }
463
+ if (callees.size === 0) {
464
+ return content;
465
+ }
466
+ const visit = (node) => {
467
+ if (ts.isCallExpression(node) &&
468
+ ts.isIdentifier(node.expression) &&
469
+ callees.has(node.expression.text)) {
470
+ edits.push({
471
+ start: node.expression.getStart(sourceFile),
472
+ end: node.expression.getEnd(),
473
+ text: `new ${callees.get(node.expression.text)}`,
474
+ });
475
+ }
476
+ ts.forEachChild(node, visit);
477
+ };
478
+ visit(sourceFile);
479
+ return applySourceEdits(content, edits);
480
+ }
481
+ /**
482
+ * CommonJS packages whose exports Node's ESM loader cannot detect, mapped to the binding the
483
+ * rewrite imports them as. A named import from one of them fails to link when a host imports
484
+ * the built controller in Node; a default import is `module.exports` in Node and in bundlers.
485
+ */
486
+ const COMMONJS_DEFAULT_IMPORTS = {
487
+ humps: 'humps',
488
+ };
489
+ /**
490
+ * Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
491
+ * destructure, so `import { camelizeKeys } from 'humps'` becomes
492
+ * `import humps from 'humps'; const { camelizeKeys } = humps;`.
493
+ */
494
+ export function transformCommonJsNamedImports(content) {
495
+ if (!Object.keys(COMMONJS_DEFAULT_IMPORTS).some((name) => content.includes(name))) {
496
+ return content;
497
+ }
498
+ const sourceFile = ts.createSourceFile('source.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
499
+ const edits = [];
500
+ for (const statement of sourceFile.statements) {
501
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
502
+ continue;
503
+ }
504
+ const specifier = statement.moduleSpecifier.text;
505
+ if (!Object.hasOwn(COMMONJS_DEFAULT_IMPORTS, specifier)) {
506
+ continue;
507
+ }
508
+ const clause = statement.importClause;
509
+ const bindings = clause?.namedBindings;
510
+ if (!clause ||
511
+ clause.isTypeOnly ||
512
+ !bindings ||
513
+ !ts.isNamedImports(bindings) ||
514
+ bindings.elements.length === 0 ||
515
+ bindings.elements.some((element) => element.isTypeOnly)) {
516
+ continue;
517
+ }
518
+ const moduleBinding = clause.name?.text ?? COMMONJS_DEFAULT_IMPORTS[specifier];
519
+ const properties = bindings.elements.map((element) => element.propertyName
520
+ ? `${element.propertyName.text}: ${element.name.text}`
521
+ : element.name.text);
522
+ const quoted = quoteLike(specifier, statement.moduleSpecifier.getText(sourceFile));
523
+ edits.push({
524
+ start: statement.getStart(sourceFile),
525
+ end: statement.getEnd(),
526
+ text: `import ${moduleBinding} from ${quoted};\nconst { ${properties.join(', ')} } = ${moduleBinding};`,
527
+ });
528
+ }
529
+ return applySourceEdits(content, edits);
530
+ }
425
531
  /**
426
532
  * Replace react-input-autosize with the local ESM autosize input component.
427
533
  *