From 55610bf05dff4417af3dfdd82f64e8d2b6971cf1 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 16 Oct 2020 06:41:11 +0200 Subject: [PATCH] Add "exports-only" option to preserveSignature --- docs/05-plugin-development.md | 2 +- docs/999-big-list-of-options.md | 3 +- src/Chunk.ts | 29 +++++++++++-------- src/rollup/types.d.ts | 2 +- .../allow-extension/_config.js | 2 +- .../exports-only-no-exports/_config.js | 6 ++++ .../_expected/amd/generated-dynamic.js | 5 ++++ .../_expected/amd/main.js | 13 +++++++++ .../_expected/cjs/generated-dynamic.js | 5 ++++ .../_expected/cjs/main.js | 11 +++++++ .../_expected/es/generated-dynamic.js | 3 ++ .../_expected/es/main.js | 7 +++++ .../_expected/system/generated-dynamic.js | 14 +++++++++ .../_expected/system/main.js | 14 +++++++++ .../exports-only-no-exports/dynamic.js | 3 ++ .../exports-only-no-exports/lib.js | 1 + .../exports-only-no-exports/main.js | 5 ++++ .../exports-only/_config.js | 6 ++++ .../_expected/amd/generated-dynamic.js | 5 ++++ .../_expected/amd/generated-main.js | 14 +++++++++ .../exports-only/_expected/amd/main.js | 10 +++++++ .../_expected/cjs/generated-dynamic.js | 5 ++++ .../_expected/cjs/generated-main.js | 12 ++++++++ .../exports-only/_expected/cjs/main.js | 10 +++++++ .../_expected/es/generated-dynamic.js | 3 ++ .../_expected/es/generated-main.js | 8 +++++ .../exports-only/_expected/es/main.js | 1 + .../_expected/system/generated-dynamic.js | 14 +++++++++ .../_expected/system/generated-main.js | 15 ++++++++++ .../exports-only/_expected/system/main.js | 16 ++++++++++ .../exports-only/dynamic.js | 3 ++ .../exports-only/lib.js | 1 + .../exports-only/main.js | 6 ++++ 33 files changed, 238 insertions(+), 16 deletions(-) create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/lib.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/dynamic.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/lib.js create mode 100644 test/chunking-form/samples/preserve-entry-signatures/exports-only/main.js diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md index 76fb911c02d..3e489b77f1b 100644 --- a/docs/05-plugin-development.md +++ b/docs/05-plugin-development.md @@ -524,7 +524,7 @@ Emits a new file that is included in the build output and returns a `referenceId fileName?: string, implicitlyLoadedAfterOneOf?: string[], importer?: string, - preserveSignature?: 'strict' | 'allow-extension' | false, + preserveSignature?: 'strict' | 'allow-extension' | 'exports-only' | false, } // EmittedAsset diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index b5a28d7297b..153aa16577b 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -925,7 +925,7 @@ export default ({ ``` #### preserveEntrySignatures -Type: `"strict" | "allow-extension" | false`
+Type: `"strict" | "allow-extension" | "exports-only" | false`
CLI: `--preserveEntrySignatures `/`--no-preserveEntrySignatures`
Default: `"strict"` @@ -933,6 +933,7 @@ Controls if Rollup tries to ensure that entry chunks have the same exports as th - If set to `"strict"`, Rollup will create exactly the same exports in the entry chunk as there are in the corresponding entry module. If this is not possible because additional internal exports need to be added to a chunk, Rollup will instead create a "facade" entry chunk that reexports just the necessary bindings from other chunks but contains no code otherwise. This is the recommended setting for libraries. - `"allow-extension"` will create all exports of the entry module in the entry chunk but may also add additional exports if necessary, avoiding a "facade" entry chunk. This setting makes sense for libraries where a strict signature is not required. +- `"exports-only"` behaves like `"strict"` if the entry module has exports, otherwise it behaves like `"allow-extension"`. - `false` will not add any exports of an entry module to the corresponding chunk and does not even include the corresponding code unless those exports are used elsewhere in the bundle. Internal exports may be added to entry chunks, though. This is the recommended setting for web apps where the entry chunks are to be placed in script tags as it may reduce both the number of chunks and possibly the bundle size. **Example**
diff --git a/src/Chunk.ts b/src/Chunk.ts index 8455846a00b..4c0b29ed52e 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -341,19 +341,24 @@ export default class Chunk { if (requiredFacades.length === 0) { requiredFacades.push({}); } - if ( - !this.facadeModule && - (this.outputOptions.preserveModules || - module.preserveSignature !== 'strict' || - this.canModuleBeFacade(module, exposedVariables)) - ) { - this.facadeModule = module; - this.facadeChunkByModule.set(module, this); - if (module.preserveSignature) { - this.strictFacade = module.preserveSignature === 'strict'; - this.ensureReexportsAreAvailableForModule(module); + if (!this.facadeModule) { + const needsStrictFacade = + module.preserveSignature === 'strict' || + (module.preserveSignature === 'exports-only' && + module.getExportNamesByVariable().size !== 0); + if ( + !needsStrictFacade || + this.outputOptions.preserveModules || + this.canModuleBeFacade(module, exposedVariables) + ) { + this.facadeModule = module; + this.facadeChunkByModule.set(module, this); + if (module.preserveSignature) { + this.strictFacade = needsStrictFacade; + this.ensureReexportsAreAvailableForModule(module); + } + this.assignFacadeName(requiredFacades.shift()!, module); } - this.assignFacadeName(requiredFacades.shift()!, module); } for (const facadeName of requiredFacades) { diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 7366eeac9de..7e7c4f1778f 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -494,7 +494,7 @@ export type GlobalsOption = { [name: string]: string } | ((name: string) => stri export type InputOption = string | string[] | { [entryAlias: string]: string }; export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk; export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects; -export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension'; +export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only'; export type SourcemapPathTransformOption = ( relativeSourcePath: string, sourcemapPath: string diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js index d0f90dd2fec..ea3e5f737cf 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js @@ -1,5 +1,5 @@ module.exports = { - description: 'Creates a facade if necessary for strict entry signatures', + description: 'Never creates facades for allow-extension', options: { preserveEntrySignatures: 'allow-extension' } diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js new file mode 100644 index 00000000000..6fb75a89816 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'Does not create a facade for exports-only if there are no exports', + options: { + preserveEntrySignatures: 'exports-only' + } +}; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js new file mode 100644 index 00000000000..e2dd062c8c8 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js @@ -0,0 +1,5 @@ +define(['./main'], function (main) { 'use strict'; + + globalThis.sharedDynamic = main.shared; + +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js new file mode 100644 index 00000000000..4bf088d0b94 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['require', 'exports'], function (require, exports) { 'use strict'; + + const shared = 'shared'; + + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + + globalThis.sharedStatic = shared; + + exports.shared = shared; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/generated-dynamic.js new file mode 100644 index 00000000000..7c3906d1d05 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/generated-dynamic.js @@ -0,0 +1,5 @@ +'use strict'; + +var main = require('./main.js'); + +globalThis.sharedDynamic = main.shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js new file mode 100644 index 00000000000..9b8458335f7 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +const shared = 'shared'; + +Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); + +globalThis.sharedStatic = shared; + +exports.shared = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/generated-dynamic.js new file mode 100644 index 00000000000..0e647607468 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/generated-dynamic.js @@ -0,0 +1,3 @@ +import { s as shared } from './main.js'; + +globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/main.js new file mode 100644 index 00000000000..ccc909e1487 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/es/main.js @@ -0,0 +1,7 @@ +const shared = 'shared'; + +import('./generated-dynamic.js'); + +globalThis.sharedStatic = shared; + +export { shared as s }; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js new file mode 100644 index 00000000000..908608f1e52 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js @@ -0,0 +1,14 @@ +System.register(['./main.js'], function () { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.s; + }], + execute: function () { + + globalThis.sharedDynamic = shared; + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js new file mode 100644 index 00000000000..fd31d2c3d4d --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const shared = exports('s', 'shared'); + + module.import('./generated-dynamic.js'); + + globalThis.sharedStatic = shared; + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/dynamic.js new file mode 100644 index 00000000000..d7a191e6ace --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/dynamic.js @@ -0,0 +1,3 @@ +import { shared } from './lib.js'; + +globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/lib.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/lib.js new file mode 100644 index 00000000000..cd35843de7a --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/lib.js @@ -0,0 +1 @@ +export const shared = 'shared'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/main.js new file mode 100644 index 00000000000..a21d5aec201 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/main.js @@ -0,0 +1,5 @@ +import { shared } from './lib.js'; + +import('./dynamic.js'); + +globalThis.sharedStatic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js new file mode 100644 index 00000000000..e00716aa766 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'Creates a facade if necessary for exports-only if there are exports', + options: { + preserveEntrySignatures: 'exports-only' + } +}; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js new file mode 100644 index 00000000000..6d87a0e4805 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js @@ -0,0 +1,5 @@ +define(['./generated-main'], function (main) { 'use strict'; + + globalThis.sharedDynamic = main.shared; + +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js new file mode 100644 index 00000000000..f1c6db85df8 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js @@ -0,0 +1,14 @@ +define(['require', 'exports'], function (require, exports) { 'use strict'; + + const shared = 'shared'; + + const unused = 'unused'; + const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + + globalThis.sharedStatic = shared; + + exports.dynamic = dynamic; + exports.shared = shared; + exports.unused = unused; + +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js new file mode 100644 index 00000000000..3189f6ac52e --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js @@ -0,0 +1,10 @@ +define(['exports', './generated-main'], function (exports, main) { 'use strict'; + + + + exports.dynamic = main.dynamic; + exports.unused = main.unused; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-dynamic.js new file mode 100644 index 00000000000..1f9e6d58c2f --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-dynamic.js @@ -0,0 +1,5 @@ +'use strict'; + +var main = require('./generated-main.js'); + +globalThis.sharedDynamic = main.shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-main.js new file mode 100644 index 00000000000..637f70585c5 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/generated-main.js @@ -0,0 +1,12 @@ +'use strict'; + +const shared = 'shared'; + +const unused = 'unused'; +const dynamic = Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); + +globalThis.sharedStatic = shared; + +exports.dynamic = dynamic; +exports.shared = shared; +exports.unused = unused; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js new file mode 100644 index 00000000000..85dcc48bca5 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js @@ -0,0 +1,10 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main = require('./generated-main.js'); + + + +exports.dynamic = main.dynamic; +exports.unused = main.unused; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-dynamic.js new file mode 100644 index 00000000000..3bae49ca2fb --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-dynamic.js @@ -0,0 +1,3 @@ +import { s as shared } from './generated-main.js'; + +globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-main.js new file mode 100644 index 00000000000..d9f2341943e --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/generated-main.js @@ -0,0 +1,8 @@ +const shared = 'shared'; + +const unused = 'unused'; +const dynamic = import('./generated-dynamic.js'); + +globalThis.sharedStatic = shared; + +export { dynamic as d, shared as s, unused as u }; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/main.js new file mode 100644 index 00000000000..16befeeb87a --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/es/main.js @@ -0,0 +1 @@ +export { d as dynamic, u as unused } from './generated-main.js'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js new file mode 100644 index 00000000000..187cb5f2c9f --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js @@ -0,0 +1,14 @@ +System.register(['./generated-main.js'], function () { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.s; + }], + execute: function () { + + globalThis.sharedDynamic = shared; + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js new file mode 100644 index 00000000000..c31de9052a8 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js @@ -0,0 +1,15 @@ +System.register([], function (exports, module) { + 'use strict'; + return { + execute: function () { + + const shared = exports('s', 'shared'); + + const unused = exports('u', 'unused'); + const dynamic = exports('d', module.import('./generated-dynamic.js')); + + globalThis.sharedStatic = shared; + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js new file mode 100644 index 00000000000..07c5c3e8995 --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js @@ -0,0 +1,16 @@ +System.register(['./generated-main.js'], function (exports) { + 'use strict'; + return { + setters: [function (module) { + var _setter = {}; + _setter.dynamic = module.d; + _setter.unused = module.u; + exports(_setter); + }], + execute: function () { + + + + } + }; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/dynamic.js new file mode 100644 index 00000000000..d7a191e6ace --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/dynamic.js @@ -0,0 +1,3 @@ +import { shared } from './lib.js'; + +globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/lib.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/lib.js new file mode 100644 index 00000000000..cd35843de7a --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/lib.js @@ -0,0 +1 @@ +export const shared = 'shared'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/main.js new file mode 100644 index 00000000000..c41f236edde --- /dev/null +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/main.js @@ -0,0 +1,6 @@ +import { shared } from './lib.js'; + +export const unused = 'unused'; +export const dynamic = import('./dynamic.js'); + +globalThis.sharedStatic = shared;