@rollup/wasm-node 4.0.0-13 → 4.0.0-14
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.
- package/dist/bin/rollup +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +247 -133
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +15 -7
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +247 -133
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch-proxy.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm.js +28 -28
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +24 -20
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.0.0-
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.0.0-14
|
|
4
|
+
Fri, 15 Sep 2023 12:33:30 GMT - commit ec2f8ec863d8d896aef0dd0097f2d73f59e8213a
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.0.0-
|
|
34
|
+
var version = "4.0.0-14";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -325,6 +325,7 @@ const URL_OUTPUT_DIR = 'configuration-options/#output-dir';
|
|
|
325
325
|
const URL_OUTPUT_DYNAMICIMPORTFUNCTION = 'configuration-options/#output-dynamicimportfunction';
|
|
326
326
|
const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
|
|
327
327
|
const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
|
|
328
|
+
const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = 'configuration-options/#output-externalimportattributes';
|
|
328
329
|
const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
|
|
329
330
|
const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
|
|
330
331
|
const URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION = 'configuration-options/#output-experimentaldeepdynamicchunkoptimization';
|
|
@@ -377,7 +378,7 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
377
378
|
}
|
|
378
379
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
379
380
|
// error code below
|
|
380
|
-
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT',
|
|
381
|
+
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
381
382
|
function logAddonNotGenerated(message, hook, plugin) {
|
|
382
383
|
return {
|
|
383
384
|
code: ADDON_ERROR,
|
|
@@ -564,14 +565,14 @@ function logIllegalImportReassignment(name, importingId) {
|
|
|
564
565
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
565
566
|
};
|
|
566
567
|
}
|
|
567
|
-
function
|
|
568
|
+
function logInconsistentImportAttributes(existingAttributes, newAttributes, source, importer) {
|
|
568
569
|
return {
|
|
569
|
-
code:
|
|
570
|
-
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${
|
|
570
|
+
code: INCONSISTENT_IMPORT_ATTRIBUTES,
|
|
571
|
+
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAttributes$1(newAttributes)} attributes, but it was already imported elsewhere with ${formatAttributes$1(existingAttributes)} attributes. Please ensure that import attributes for the same module are always consistent.`
|
|
571
572
|
};
|
|
572
573
|
}
|
|
573
|
-
const
|
|
574
|
-
const entries = Object.entries(
|
|
574
|
+
const formatAttributes$1 = (attributes) => {
|
|
575
|
+
const entries = Object.entries(attributes);
|
|
575
576
|
if (entries.length === 0)
|
|
576
577
|
return 'no';
|
|
577
578
|
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
@@ -635,6 +636,18 @@ function logInternalIdCannotBeExternal(source, importer) {
|
|
|
635
636
|
message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
|
|
636
637
|
};
|
|
637
638
|
}
|
|
639
|
+
function logImportOptionsAreInvalid(importer) {
|
|
640
|
+
return {
|
|
641
|
+
code: INVALID_IMPORT_ATTRIBUTE,
|
|
642
|
+
message: `Rollup could not statically analyze the options argument of a dynamic import in "${relativeId(importer)}". Dynamic import options need to be an object with a nested attributes object.`
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function logImportAttributeIsInvalid(importer) {
|
|
646
|
+
return {
|
|
647
|
+
code: INVALID_IMPORT_ATTRIBUTE,
|
|
648
|
+
message: `Rollup could not statically analyze an import attribute of a dynamic import in "${relativeId(importer)}". Import attributes need to have string keys and values. The attribute will be removed.`
|
|
649
|
+
};
|
|
650
|
+
}
|
|
638
651
|
function logInvalidLogPosition(plugin) {
|
|
639
652
|
return {
|
|
640
653
|
code: INVALID_LOG_POSITION,
|
|
@@ -1289,6 +1302,7 @@ class FileEmitter {
|
|
|
1289
1302
|
name: prebuiltChunk.fileName,
|
|
1290
1303
|
preliminaryFileName: prebuiltChunk.fileName,
|
|
1291
1304
|
referencedFiles: [],
|
|
1305
|
+
sourcemapFileName: prebuiltChunk.sourcemapFileName || null,
|
|
1292
1306
|
type: 'chunk'
|
|
1293
1307
|
};
|
|
1294
1308
|
}
|
|
@@ -1746,8 +1760,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
1746
1760
|
return wrappedModuleIds();
|
|
1747
1761
|
},
|
|
1748
1762
|
parse: graph.contextParse.bind(graph),
|
|
1749
|
-
resolve(source, importer, {
|
|
1750
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry,
|
|
1763
|
+
resolve(source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) {
|
|
1764
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
1751
1765
|
},
|
|
1752
1766
|
setAssetSource: fileEmitter.setAssetSource,
|
|
1753
1767
|
warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
|
|
@@ -2185,6 +2199,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
2185
2199
|
exports: getOption('exports'),
|
|
2186
2200
|
extend: getOption('extend'),
|
|
2187
2201
|
externalImportAssertions: getOption('externalImportAssertions'),
|
|
2202
|
+
externalImportAttributes: getOption('externalImportAttributes'),
|
|
2188
2203
|
externalLiveBindings: getOption('externalLiveBindings'),
|
|
2189
2204
|
file: getOption('file'),
|
|
2190
2205
|
footer: getOption('footer'),
|
|
@@ -2213,6 +2228,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
2213
2228
|
sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
|
|
2214
2229
|
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
|
2215
2230
|
sourcemapFile: getOption('sourcemapFile'),
|
|
2231
|
+
sourcemapFileNames: getOption('sourcemapFileNames'),
|
|
2216
2232
|
sourcemapIgnoreList: getOption('sourcemapIgnoreList'),
|
|
2217
2233
|
sourcemapPathTransform: getOption('sourcemapPathTransform'),
|
|
2218
2234
|
strict: getOption('strict'),
|
|
@@ -4059,7 +4075,7 @@ class ExternalChunk {
|
|
|
4059
4075
|
this.namespaceVariableName = '';
|
|
4060
4076
|
this.variableName = '';
|
|
4061
4077
|
this.fileName = null;
|
|
4062
|
-
this.
|
|
4078
|
+
this.importAttributes = null;
|
|
4063
4079
|
this.id = module.id;
|
|
4064
4080
|
this.moduleInfo = module.info;
|
|
4065
4081
|
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
@@ -4074,10 +4090,10 @@ class ExternalChunk {
|
|
|
4074
4090
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
4075
4091
|
(this.renormalizeRenderPath ? normalize(node_path.relative(this.inputBase, this.id)) : this.id));
|
|
4076
4092
|
}
|
|
4077
|
-
|
|
4078
|
-
return (this.
|
|
4079
|
-
this.options.
|
|
4080
|
-
this.moduleInfo.
|
|
4093
|
+
getImportAttributes(snippets) {
|
|
4094
|
+
return (this.importAttributes || (this.importAttributes = formatAttributes(this.options.format === 'es' &&
|
|
4095
|
+
this.options.externalImportAttributes &&
|
|
4096
|
+
this.moduleInfo.attributes, snippets)));
|
|
4081
4097
|
}
|
|
4082
4098
|
getImportPath(importer) {
|
|
4083
4099
|
return escapeId(this.renormalizeRenderPath
|
|
@@ -4085,11 +4101,11 @@ class ExternalChunk {
|
|
|
4085
4101
|
: this.getFileName());
|
|
4086
4102
|
}
|
|
4087
4103
|
}
|
|
4088
|
-
function
|
|
4089
|
-
if (!
|
|
4104
|
+
function formatAttributes(attributes, { getObject }) {
|
|
4105
|
+
if (!attributes) {
|
|
4090
4106
|
return null;
|
|
4091
4107
|
}
|
|
4092
|
-
const assertionEntries = Object.entries(
|
|
4108
|
+
const assertionEntries = Object.entries(attributes).map(([key, value]) => [key, `'${value}'`]);
|
|
4093
4109
|
if (assertionEntries.length > 0) {
|
|
4094
4110
|
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
4095
4111
|
}
|
|
@@ -4382,7 +4398,7 @@ function makeLegal(value) {
|
|
|
4382
4398
|
}
|
|
4383
4399
|
|
|
4384
4400
|
class ExternalModule {
|
|
4385
|
-
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath,
|
|
4401
|
+
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, attributes) {
|
|
4386
4402
|
this.options = options;
|
|
4387
4403
|
this.id = id;
|
|
4388
4404
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
@@ -4398,8 +4414,8 @@ class ExternalModule {
|
|
|
4398
4414
|
this.suggestedVariableName = makeLegal(id.split(/[/\\]/).pop());
|
|
4399
4415
|
const { importers, dynamicImporters } = this;
|
|
4400
4416
|
const info = (this.info = {
|
|
4401
|
-
assertions,
|
|
4402
4417
|
ast: null,
|
|
4418
|
+
attributes,
|
|
4403
4419
|
code: null,
|
|
4404
4420
|
dynamicallyImportedIdResolutions: EMPTY_ARRAY,
|
|
4405
4421
|
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
@@ -6964,6 +6980,7 @@ const convertProgram = (buffer, readString) => convertNode(0, new Uint32Array(bu
|
|
|
6964
6980
|
const convertNode = (position, buffer, readString) => {
|
|
6965
6981
|
const nodeType = buffer[position];
|
|
6966
6982
|
const converter = nodeConverters[nodeType];
|
|
6983
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
6967
6984
|
if (!converter) {
|
|
6968
6985
|
console.trace();
|
|
6969
6986
|
throw new Error(`Unknown node type: ${nodeType}`);
|
|
@@ -7257,14 +7274,14 @@ const nodeConverters = [
|
|
|
7257
7274
|
const end = buffer[position++];
|
|
7258
7275
|
const exportedPosition = buffer[position++];
|
|
7259
7276
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
7260
|
-
const
|
|
7277
|
+
const attributes = convertNodeList(buffer[position], buffer, readString);
|
|
7261
7278
|
return {
|
|
7262
7279
|
type: 'ExportAllDeclaration',
|
|
7263
7280
|
start,
|
|
7264
7281
|
end,
|
|
7265
7282
|
exported: exportedPosition ? convertNode(exportedPosition, buffer, readString) : null,
|
|
7266
7283
|
source,
|
|
7267
|
-
|
|
7284
|
+
attributes
|
|
7268
7285
|
};
|
|
7269
7286
|
},
|
|
7270
7287
|
// index:21; ExportDefaultDeclaration
|
|
@@ -7285,7 +7302,7 @@ const nodeConverters = [
|
|
|
7285
7302
|
const end = buffer[position++];
|
|
7286
7303
|
const declarationPosition = buffer[position++];
|
|
7287
7304
|
const sourcePosition = buffer[position++];
|
|
7288
|
-
const
|
|
7305
|
+
const attributes = convertNodeList(buffer[position++], buffer, readString);
|
|
7289
7306
|
const specifiers = convertNodeList(position, buffer, readString);
|
|
7290
7307
|
return {
|
|
7291
7308
|
type: 'ExportNamedDeclaration',
|
|
@@ -7296,7 +7313,7 @@ const nodeConverters = [
|
|
|
7296
7313
|
: null,
|
|
7297
7314
|
source: sourcePosition ? convertNode(sourcePosition, buffer, readString) : null,
|
|
7298
7315
|
specifiers,
|
|
7299
|
-
|
|
7316
|
+
attributes
|
|
7300
7317
|
};
|
|
7301
7318
|
},
|
|
7302
7319
|
// index:23; ExportSpecifier
|
|
@@ -7475,7 +7492,7 @@ const nodeConverters = [
|
|
|
7475
7492
|
const start = buffer[position++];
|
|
7476
7493
|
const end = buffer[position++];
|
|
7477
7494
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
7478
|
-
const
|
|
7495
|
+
const attributes = convertNodeList(buffer[position++], buffer, readString);
|
|
7479
7496
|
const specifiers = convertNodeList(position, buffer, readString);
|
|
7480
7497
|
return {
|
|
7481
7498
|
type: 'ImportDeclaration',
|
|
@@ -7483,7 +7500,7 @@ const nodeConverters = [
|
|
|
7483
7500
|
end,
|
|
7484
7501
|
source,
|
|
7485
7502
|
specifiers,
|
|
7486
|
-
|
|
7503
|
+
attributes
|
|
7487
7504
|
};
|
|
7488
7505
|
},
|
|
7489
7506
|
// index:34; ImportDefaultSpecifier
|
|
@@ -7502,14 +7519,14 @@ const nodeConverters = [
|
|
|
7502
7519
|
(position, buffer, readString) => {
|
|
7503
7520
|
const start = buffer[position++];
|
|
7504
7521
|
const end = buffer[position++];
|
|
7505
|
-
const
|
|
7522
|
+
const optionsPosition = buffer[position++];
|
|
7506
7523
|
const source = convertNode(position, buffer, readString);
|
|
7507
7524
|
return {
|
|
7508
7525
|
type: 'ImportExpression',
|
|
7509
7526
|
start,
|
|
7510
7527
|
end,
|
|
7511
7528
|
source,
|
|
7512
|
-
|
|
7529
|
+
options: optionsPosition ? convertNode(optionsPosition, buffer, readString) : null
|
|
7513
7530
|
};
|
|
7514
7531
|
},
|
|
7515
7532
|
// index:36; ImportNamespaceSpecifier
|
|
@@ -8127,9 +8144,6 @@ const ANNOTATION_KEY = '_rollupAnnotations';
|
|
|
8127
8144
|
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
8128
8145
|
|
|
8129
8146
|
const keys = {
|
|
8130
|
-
// TODO this should be removed once ImportExpression follows official ESTree
|
|
8131
|
-
// specs with "null" as default
|
|
8132
|
-
ImportExpression: ['arguments'],
|
|
8133
8147
|
Literal: [],
|
|
8134
8148
|
Program: ['body']
|
|
8135
8149
|
};
|
|
@@ -8234,11 +8248,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
8234
8248
|
* initialised
|
|
8235
8249
|
*/
|
|
8236
8250
|
initialise() { }
|
|
8237
|
-
insertSemicolon(code) {
|
|
8238
|
-
if (code.original[this.end - 1] !== ';') {
|
|
8239
|
-
code.appendLeft(this.end, ';');
|
|
8240
|
-
}
|
|
8241
|
-
}
|
|
8242
8251
|
parseNode(esTreeNode, keepEsTreeNodeKeys) {
|
|
8243
8252
|
for (const [key, value] of Object.entries(esTreeNode)) {
|
|
8244
8253
|
// That way, we can override this function to add custom initialisation and then call super.parseNode
|
|
@@ -10001,7 +10010,17 @@ const knownGlobals = {
|
|
|
10001
10010
|
CSSSupportsRule: C,
|
|
10002
10011
|
CustomElementRegistry: C,
|
|
10003
10012
|
customElements: O,
|
|
10004
|
-
CustomEvent:
|
|
10013
|
+
CustomEvent: {
|
|
10014
|
+
__proto__: null,
|
|
10015
|
+
[ValueProperties]: {
|
|
10016
|
+
deoptimizeArgumentsOnCall({ args }) {
|
|
10017
|
+
args[2]?.deoptimizePath(['detail']);
|
|
10018
|
+
},
|
|
10019
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
10020
|
+
hasEffectsWhenCalled: returnFalse
|
|
10021
|
+
},
|
|
10022
|
+
prototype: O
|
|
10023
|
+
},
|
|
10005
10024
|
DataTransfer: C,
|
|
10006
10025
|
DataTransferItem: C,
|
|
10007
10026
|
DataTransferItemList: C,
|
|
@@ -10945,8 +10964,9 @@ class ExpressionStatement extends NodeBase {
|
|
|
10945
10964
|
}
|
|
10946
10965
|
render(code, options) {
|
|
10947
10966
|
super.render(code, options);
|
|
10948
|
-
if (this.
|
|
10949
|
-
this.
|
|
10967
|
+
if (code.original[this.end - 1] !== ';') {
|
|
10968
|
+
code.appendLeft(this.end, ';');
|
|
10969
|
+
}
|
|
10950
10970
|
}
|
|
10951
10971
|
shouldBeIncluded(context) {
|
|
10952
10972
|
if (this.directive && this.directive !== 'use strict')
|
|
@@ -13264,7 +13284,7 @@ class ImportAttribute extends NodeBase {
|
|
|
13264
13284
|
}
|
|
13265
13285
|
|
|
13266
13286
|
class ImportDeclaration extends NodeBase {
|
|
13267
|
-
// Do not bind specifiers or
|
|
13287
|
+
// Do not bind specifiers or attributes
|
|
13268
13288
|
bind() { }
|
|
13269
13289
|
hasEffects() {
|
|
13270
13290
|
return false;
|
|
@@ -13290,6 +13310,7 @@ const INTEROP_NAMESPACE_COMPAT_VARIABLE = '_interopNamespaceCompat';
|
|
|
13290
13310
|
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
13291
13311
|
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
13292
13312
|
const MERGE_NAMESPACES_VARIABLE = '_mergeNamespaces';
|
|
13313
|
+
const DOCUMENT_CURRENT_SCRIPT = '_documentCurrentScript';
|
|
13293
13314
|
const defaultInteropHelpersByInteropType = {
|
|
13294
13315
|
auto: INTEROP_DEFAULT_VARIABLE,
|
|
13295
13316
|
compat: INTEROP_DEFAULT_COMPAT_VARIABLE,
|
|
@@ -13319,6 +13340,9 @@ const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, l
|
|
|
13319
13340
|
: '').join('');
|
|
13320
13341
|
};
|
|
13321
13342
|
const HELPER_GENERATORS = {
|
|
13343
|
+
[DOCUMENT_CURRENT_SCRIPT](_t, { _, n }) {
|
|
13344
|
+
return `var${_}${DOCUMENT_CURRENT_SCRIPT}${_}=${_}typeof${_}document${_}!==${_}'undefined'${_}?${_}document.currentScript${_}:${_}null;${n}`;
|
|
13345
|
+
},
|
|
13322
13346
|
[INTEROP_DEFAULT_COMPAT_VARIABLE](_t, snippets, liveBindings) {
|
|
13323
13347
|
const { _, getDirectReturnFunction, n } = snippets;
|
|
13324
13348
|
const [left, right] = getDirectReturnFunction(['e'], {
|
|
@@ -13559,19 +13583,17 @@ class VariableDeclarator extends NodeBase {
|
|
|
13559
13583
|
}
|
|
13560
13584
|
}
|
|
13561
13585
|
|
|
13562
|
-
// TODO once ImportExpression follows official ESTree specs with "null" as
|
|
13563
|
-
// default, keys.ts should be updated
|
|
13564
13586
|
class ImportExpression extends NodeBase {
|
|
13565
13587
|
constructor() {
|
|
13566
13588
|
super(...arguments);
|
|
13567
13589
|
this.inlineNamespace = null;
|
|
13568
|
-
this.
|
|
13590
|
+
this.attributes = null;
|
|
13569
13591
|
this.mechanism = null;
|
|
13570
13592
|
this.namespaceExportName = undefined;
|
|
13571
13593
|
this.resolution = null;
|
|
13572
13594
|
this.resolutionString = null;
|
|
13573
13595
|
}
|
|
13574
|
-
// Do not bind
|
|
13596
|
+
// Do not bind attributes
|
|
13575
13597
|
bind() {
|
|
13576
13598
|
this.source.bind();
|
|
13577
13599
|
}
|
|
@@ -13695,24 +13717,24 @@ class ImportExpression extends NodeBase {
|
|
|
13695
13717
|
else {
|
|
13696
13718
|
this.source.render(code, options);
|
|
13697
13719
|
}
|
|
13698
|
-
if (this.
|
|
13699
|
-
if (this.
|
|
13720
|
+
if (this.attributes !== true) {
|
|
13721
|
+
if (this.options) {
|
|
13700
13722
|
code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true });
|
|
13701
13723
|
}
|
|
13702
|
-
if (this.
|
|
13703
|
-
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.
|
|
13724
|
+
if (this.attributes) {
|
|
13725
|
+
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.attributes]], {
|
|
13704
13726
|
lineBreakIndent: null
|
|
13705
13727
|
})}`);
|
|
13706
13728
|
}
|
|
13707
13729
|
}
|
|
13708
13730
|
}
|
|
13709
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName,
|
|
13731
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
|
|
13710
13732
|
const { format } = options;
|
|
13711
13733
|
this.inlineNamespace = null;
|
|
13712
13734
|
this.resolution = resolution;
|
|
13713
13735
|
this.resolutionString = resolutionString;
|
|
13714
13736
|
this.namespaceExportName = namespaceExportName;
|
|
13715
|
-
this.
|
|
13737
|
+
this.attributes = attributes;
|
|
13716
13738
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
13717
13739
|
let helper;
|
|
13718
13740
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -14068,8 +14090,10 @@ class MetaProperty extends NodeBase {
|
|
|
14068
14090
|
}
|
|
14069
14091
|
}
|
|
14070
14092
|
}
|
|
14071
|
-
render(code,
|
|
14072
|
-
const {
|
|
14093
|
+
render(code, renderOptions) {
|
|
14094
|
+
const { format, pluginDriver, snippets } = renderOptions;
|
|
14095
|
+
const { context: { module }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
14096
|
+
const { id: moduleId } = module;
|
|
14073
14097
|
if (name !== IMPORT)
|
|
14074
14098
|
return;
|
|
14075
14099
|
const chunkId = preliminaryChunkId;
|
|
@@ -14082,10 +14106,14 @@ class MetaProperty extends NodeBase {
|
|
|
14082
14106
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
14083
14107
|
return;
|
|
14084
14108
|
}
|
|
14085
|
-
|
|
14109
|
+
let replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
14086
14110
|
metaProperty,
|
|
14087
14111
|
{ chunkId, format, moduleId }
|
|
14088
|
-
])
|
|
14112
|
+
]);
|
|
14113
|
+
if (!replacement) {
|
|
14114
|
+
replacement = importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
14115
|
+
renderOptions.accessedDocumentCurrentScript || (renderOptions.accessedDocumentCurrentScript = formatsMaybeAccessDocumentCurrentScript.includes(format) && replacement !== 'undefined');
|
|
14116
|
+
}
|
|
14089
14117
|
if (typeof replacement === 'string') {
|
|
14090
14118
|
if (parent instanceof MemberExpression) {
|
|
14091
14119
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
@@ -14103,13 +14131,14 @@ class MetaProperty extends NodeBase {
|
|
|
14103
14131
|
}
|
|
14104
14132
|
}
|
|
14105
14133
|
}
|
|
14134
|
+
const formatsMaybeAccessDocumentCurrentScript = ['cjs', 'iife', 'umd'];
|
|
14106
14135
|
const accessedMetaUrlGlobals = {
|
|
14107
14136
|
amd: ['document', 'module', 'URL'],
|
|
14108
|
-
cjs: ['document', 'require', 'URL'],
|
|
14137
|
+
cjs: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT],
|
|
14109
14138
|
es: [],
|
|
14110
|
-
iife: ['document', 'URL'],
|
|
14139
|
+
iife: ['document', 'URL', DOCUMENT_CURRENT_SCRIPT],
|
|
14111
14140
|
system: ['module'],
|
|
14112
|
-
umd: ['document', 'require', 'URL']
|
|
14141
|
+
umd: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT]
|
|
14113
14142
|
};
|
|
14114
14143
|
const accessedFileUrlGlobals = {
|
|
14115
14144
|
amd: ['document', 'require', 'URL'],
|
|
@@ -14131,7 +14160,7 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
|
|
|
14131
14160
|
};
|
|
14132
14161
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
|
14133
14162
|
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
|
|
14134
|
-
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(
|
|
14163
|
+
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
|
|
14135
14164
|
const relativeUrlMechanisms = {
|
|
14136
14165
|
amd: relativePath => {
|
|
14137
14166
|
if (relativePath[0] !== '.')
|
|
@@ -15642,11 +15671,23 @@ function getOriginalLocation(sourcemapChain, location) {
|
|
|
15642
15671
|
return location;
|
|
15643
15672
|
}
|
|
15644
15673
|
|
|
15645
|
-
|
|
15646
|
-
|
|
15674
|
+
const ATTRIBUTE_KEYWORDS = new Set(['assert', 'with']);
|
|
15675
|
+
function getAttributesFromImportExpression(node) {
|
|
15676
|
+
const { context, options, start } = node;
|
|
15677
|
+
if (!(options instanceof ObjectExpression)) {
|
|
15678
|
+
if (options) {
|
|
15679
|
+
context.module.log(LOGLEVEL_WARN, logImportAttributeIsInvalid(context.module.id), start);
|
|
15680
|
+
}
|
|
15681
|
+
return EMPTY_OBJECT;
|
|
15682
|
+
}
|
|
15683
|
+
const assertProperty = options.properties.find((property) => ATTRIBUTE_KEYWORDS.has(getPropertyKey(property)))?.value;
|
|
15647
15684
|
if (!assertProperty) {
|
|
15648
15685
|
return EMPTY_OBJECT;
|
|
15649
15686
|
}
|
|
15687
|
+
if (!(assertProperty instanceof ObjectExpression)) {
|
|
15688
|
+
context.module.log(LOGLEVEL_WARN, logImportOptionsAreInvalid(context.module.id), start);
|
|
15689
|
+
return EMPTY_OBJECT;
|
|
15690
|
+
}
|
|
15650
15691
|
const assertFields = assertProperty.properties
|
|
15651
15692
|
.map(property => {
|
|
15652
15693
|
const key = getPropertyKey(property);
|
|
@@ -15654,6 +15695,7 @@ function getAssertionsFromImportExpression(node) {
|
|
|
15654
15695
|
typeof property.value.value === 'string') {
|
|
15655
15696
|
return [key, property.value.value];
|
|
15656
15697
|
}
|
|
15698
|
+
context.module.log(LOGLEVEL_WARN, logImportAttributeIsInvalid(context.module.id), property.start);
|
|
15657
15699
|
return null;
|
|
15658
15700
|
})
|
|
15659
15701
|
.filter((property) => !!property);
|
|
@@ -15664,14 +15706,14 @@ function getAssertionsFromImportExpression(node) {
|
|
|
15664
15706
|
}
|
|
15665
15707
|
const getPropertyKey = (property) => {
|
|
15666
15708
|
const key = property.key;
|
|
15667
|
-
return key && (key.name || key.value);
|
|
15709
|
+
return (key && !property.computed && (key.name || key.value));
|
|
15668
15710
|
};
|
|
15669
|
-
function
|
|
15670
|
-
return
|
|
15671
|
-
? Object.fromEntries(
|
|
15711
|
+
function getAttributesFromImportExportDeclaration(attributes) {
|
|
15712
|
+
return attributes?.length
|
|
15713
|
+
? Object.fromEntries(attributes.map(assertion => [getPropertyKey(assertion), assertion.value.value]))
|
|
15672
15714
|
: EMPTY_OBJECT;
|
|
15673
15715
|
}
|
|
15674
|
-
function
|
|
15716
|
+
function doAttributesDiffer(assertionA, assertionB) {
|
|
15675
15717
|
const keysA = Object.keys(assertionA);
|
|
15676
15718
|
return (keysA.length !== Object.keys(assertionB).length ||
|
|
15677
15719
|
keysA.some(key => assertionA[key] !== assertionB[key]));
|
|
@@ -15753,6 +15795,9 @@ const TIMED_PLUGIN_HOOKS = [
|
|
|
15753
15795
|
'writeBundle'
|
|
15754
15796
|
];
|
|
15755
15797
|
function getPluginWithTimers(plugin, index) {
|
|
15798
|
+
if (plugin._hasTimer)
|
|
15799
|
+
return plugin;
|
|
15800
|
+
plugin._hasTimer = true;
|
|
15756
15801
|
for (const hook of TIMED_PLUGIN_HOOKS) {
|
|
15757
15802
|
if (hook in plugin) {
|
|
15758
15803
|
let timerLabel = `plugin ${index}`;
|
|
@@ -15858,7 +15903,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
15858
15903
|
return sideEffectModules;
|
|
15859
15904
|
}
|
|
15860
15905
|
class Module {
|
|
15861
|
-
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta,
|
|
15906
|
+
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta, attributes) {
|
|
15862
15907
|
this.graph = graph;
|
|
15863
15908
|
this.id = id;
|
|
15864
15909
|
this.options = options;
|
|
@@ -15883,7 +15928,7 @@ class Module {
|
|
|
15883
15928
|
this.isUserDefinedEntryPoint = false;
|
|
15884
15929
|
this.needsExportShim = false;
|
|
15885
15930
|
this.sideEffectDependenciesByVariable = new Map();
|
|
15886
|
-
this.
|
|
15931
|
+
this.sourcesWithAttributes = new Map();
|
|
15887
15932
|
this.allExportNames = null;
|
|
15888
15933
|
this.ast = null;
|
|
15889
15934
|
this.exportAllModules = [];
|
|
@@ -15903,10 +15948,10 @@ class Module {
|
|
|
15903
15948
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
15904
15949
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
15905
15950
|
const module = this;
|
|
15906
|
-
const { dynamicImports, dynamicImporters, exportAllSources, exports, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions,
|
|
15951
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exports, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
15907
15952
|
this.info = {
|
|
15908
|
-
assertions,
|
|
15909
15953
|
ast: null,
|
|
15954
|
+
attributes,
|
|
15910
15955
|
code: null,
|
|
15911
15956
|
get dynamicallyImportedIdResolutions() {
|
|
15912
15957
|
return dynamicImports
|
|
@@ -15960,13 +16005,13 @@ class Module {
|
|
|
15960
16005
|
},
|
|
15961
16006
|
get importedIdResolutions() {
|
|
15962
16007
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
15963
|
-
return Array.from(
|
|
16008
|
+
return Array.from(sourcesWithAttributes.keys(), source => module.resolvedIds[source]).filter(Boolean);
|
|
15964
16009
|
},
|
|
15965
16010
|
get importedIds() {
|
|
15966
16011
|
// We cannot use this.dependencies because this is needed before
|
|
15967
16012
|
// dependencies are populated
|
|
15968
16013
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
15969
|
-
return Array.from(
|
|
16014
|
+
return Array.from(sourcesWithAttributes.keys(), source => module.resolvedIds[source]?.id).filter(Boolean);
|
|
15970
16015
|
},
|
|
15971
16016
|
get importers() {
|
|
15972
16017
|
return importers.sort();
|
|
@@ -16398,8 +16443,8 @@ class Module {
|
|
|
16398
16443
|
}
|
|
16399
16444
|
toJSON() {
|
|
16400
16445
|
return {
|
|
16401
|
-
assertions: this.info.assertions,
|
|
16402
16446
|
ast: this.info.ast,
|
|
16447
|
+
attributes: this.info.attributes,
|
|
16403
16448
|
code: this.info.code,
|
|
16404
16449
|
customTransformCache: this.customTransformCache,
|
|
16405
16450
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
@@ -16596,15 +16641,15 @@ class Module {
|
|
|
16596
16641
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
16597
16642
|
}
|
|
16598
16643
|
addSource(source, declaration) {
|
|
16599
|
-
const
|
|
16600
|
-
const
|
|
16601
|
-
if (
|
|
16602
|
-
if (
|
|
16603
|
-
this.log(LOGLEVEL_WARN,
|
|
16644
|
+
const parsedAttributes = getAttributesFromImportExportDeclaration(declaration.attributes);
|
|
16645
|
+
const existingAttributes = this.sourcesWithAttributes.get(source);
|
|
16646
|
+
if (existingAttributes) {
|
|
16647
|
+
if (doAttributesDiffer(existingAttributes, parsedAttributes)) {
|
|
16648
|
+
this.log(LOGLEVEL_WARN, logInconsistentImportAttributes(existingAttributes, parsedAttributes, source, this.id), declaration.start);
|
|
16604
16649
|
}
|
|
16605
16650
|
}
|
|
16606
16651
|
else {
|
|
16607
|
-
this.
|
|
16652
|
+
this.sourcesWithAttributes.set(source, parsedAttributes);
|
|
16608
16653
|
}
|
|
16609
16654
|
}
|
|
16610
16655
|
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
|
|
@@ -17132,8 +17177,8 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
17132
17177
|
}
|
|
17133
17178
|
function getImportBlock(dependencies, { _ }) {
|
|
17134
17179
|
const importBlock = [];
|
|
17135
|
-
for (const { importPath, reexports, imports, name,
|
|
17136
|
-
const assertion =
|
|
17180
|
+
for (const { importPath, reexports, imports, name, attributes } of dependencies) {
|
|
17181
|
+
const assertion = attributes ? `${_}assert${_}${attributes}` : '';
|
|
17137
17182
|
const pathWithAssertion = `'${importPath}'${assertion};`;
|
|
17138
17183
|
if (!reexports && !imports) {
|
|
17139
17184
|
importBlock.push(`import${_}${pathWithAssertion}`);
|
|
@@ -17897,6 +17942,7 @@ class Chunk {
|
|
|
17897
17942
|
this.needsExportsShim = false;
|
|
17898
17943
|
this.preRenderedChunkInfo = null;
|
|
17899
17944
|
this.preliminaryFileName = null;
|
|
17945
|
+
this.preliminarySourcemapFileName = null;
|
|
17900
17946
|
this.renderedChunkInfo = null;
|
|
17901
17947
|
this.renderedDependencies = null;
|
|
17902
17948
|
this.renderedModules = Object.create(null);
|
|
@@ -17971,7 +18017,7 @@ class Chunk {
|
|
|
17971
18017
|
}
|
|
17972
18018
|
return true;
|
|
17973
18019
|
}
|
|
17974
|
-
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
18020
|
+
finalizeChunk(code, map, sourcemapFileName, hashesByPlaceholder) {
|
|
17975
18021
|
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
17976
18022
|
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
17977
18023
|
const preliminaryFileName = renderedChunkInfo.fileName;
|
|
@@ -17989,7 +18035,8 @@ class Chunk {
|
|
|
17989
18035
|
imports: renderedChunkInfo.imports.map(finalize),
|
|
17990
18036
|
map,
|
|
17991
18037
|
preliminaryFileName,
|
|
17992
|
-
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
18038
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize),
|
|
18039
|
+
sourcemapFileName
|
|
17993
18040
|
};
|
|
17994
18041
|
}
|
|
17995
18042
|
generateExports() {
|
|
@@ -18130,6 +18177,30 @@ class Chunk {
|
|
|
18130
18177
|
// Caching is essential to not conflict with the file name reservation above
|
|
18131
18178
|
return (this.preliminaryFileName = { fileName, hashPlaceholder });
|
|
18132
18179
|
}
|
|
18180
|
+
getPreliminarySourcemapFileName() {
|
|
18181
|
+
if (this.preliminarySourcemapFileName) {
|
|
18182
|
+
return this.preliminarySourcemapFileName;
|
|
18183
|
+
}
|
|
18184
|
+
let sourcemapFileName = null;
|
|
18185
|
+
let hashPlaceholder = null;
|
|
18186
|
+
const { sourcemapFileNames, format } = this.outputOptions;
|
|
18187
|
+
if (sourcemapFileNames) {
|
|
18188
|
+
const [pattern, patternName] = [sourcemapFileNames, 'output.sourcemapFileNames'];
|
|
18189
|
+
sourcemapFileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
18190
|
+
chunkhash: () => this.getPreliminaryFileName().hashPlaceholder || '',
|
|
18191
|
+
format: () => format,
|
|
18192
|
+
hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
|
|
18193
|
+
name: () => this.getChunkName()
|
|
18194
|
+
});
|
|
18195
|
+
if (!hashPlaceholder) {
|
|
18196
|
+
sourcemapFileName = makeUnique(sourcemapFileName, this.bundle);
|
|
18197
|
+
}
|
|
18198
|
+
}
|
|
18199
|
+
else {
|
|
18200
|
+
return null;
|
|
18201
|
+
}
|
|
18202
|
+
return (this.preliminarySourcemapFileName = { fileName: sourcemapFileName, hashPlaceholder });
|
|
18203
|
+
}
|
|
18133
18204
|
getRenderedChunkInfo() {
|
|
18134
18205
|
if (this.renderedChunkInfo) {
|
|
18135
18206
|
return this.renderedChunkInfo;
|
|
@@ -18172,6 +18243,7 @@ class Chunk {
|
|
|
18172
18243
|
}
|
|
18173
18244
|
}
|
|
18174
18245
|
const preliminaryFileName = this.getPreliminaryFileName();
|
|
18246
|
+
const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
|
|
18175
18247
|
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
18176
18248
|
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
18177
18249
|
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
@@ -18225,6 +18297,7 @@ class Chunk {
|
|
|
18225
18297
|
chunk: this,
|
|
18226
18298
|
magicString,
|
|
18227
18299
|
preliminaryFileName,
|
|
18300
|
+
preliminarySourcemapFileName,
|
|
18228
18301
|
usedModules
|
|
18229
18302
|
};
|
|
18230
18303
|
}
|
|
@@ -18422,14 +18495,14 @@ class Chunk {
|
|
|
18422
18495
|
.filter((resolution) => resolution !== this &&
|
|
18423
18496
|
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
18424
18497
|
}
|
|
18425
|
-
|
|
18498
|
+
getDynamicImportStringAndAttributes(resolution, fileName) {
|
|
18426
18499
|
if (resolution instanceof ExternalModule) {
|
|
18427
18500
|
const chunk = this.externalChunkByModule.get(resolution);
|
|
18428
|
-
return [`'${chunk.getImportPath(fileName)}'`, chunk.
|
|
18501
|
+
return [`'${chunk.getImportPath(fileName)}'`, chunk.getImportAttributes(this.snippets)];
|
|
18429
18502
|
}
|
|
18430
18503
|
return [
|
|
18431
18504
|
resolution || '',
|
|
18432
|
-
(this.outputOptions.format === 'es' && this.outputOptions.
|
|
18505
|
+
(this.outputOptions.format === 'es' && this.outputOptions.externalImportAttributes) || null
|
|
18433
18506
|
];
|
|
18434
18507
|
}
|
|
18435
18508
|
getFallbackChunkName() {
|
|
@@ -18608,7 +18681,7 @@ class Chunk {
|
|
|
18608
18681
|
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
18609
18682
|
const importPath = dep.getImportPath(fileName);
|
|
18610
18683
|
renderedDependencies.set(dep, {
|
|
18611
|
-
|
|
18684
|
+
attributes: dep instanceof ExternalChunk ? dep.getImportAttributes(this.snippets) : null,
|
|
18612
18685
|
defaultVariableName: dep.defaultVariableName,
|
|
18613
18686
|
globalName: dep instanceof ExternalChunk &&
|
|
18614
18687
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
@@ -18649,6 +18722,7 @@ class Chunk {
|
|
|
18649
18722
|
const accessedGlobals = new Set();
|
|
18650
18723
|
const renderedModuleSources = new Map();
|
|
18651
18724
|
const renderOptions = {
|
|
18725
|
+
accessedDocumentCurrentScript: false,
|
|
18652
18726
|
dynamicImportFunction,
|
|
18653
18727
|
exportNamesByVariable,
|
|
18654
18728
|
format,
|
|
@@ -18665,6 +18739,12 @@ class Chunk {
|
|
|
18665
18739
|
let source;
|
|
18666
18740
|
if (module.isIncluded() || includedNamespaces.has(module)) {
|
|
18667
18741
|
const rendered = module.render(renderOptions);
|
|
18742
|
+
if (!renderOptions.accessedDocumentCurrentScript &&
|
|
18743
|
+
formatsMaybeAccessDocumentCurrentScript.includes(format)) {
|
|
18744
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
18745
|
+
this.accessedGlobalsByScope.get(module.scope)?.delete(DOCUMENT_CURRENT_SCRIPT);
|
|
18746
|
+
}
|
|
18747
|
+
renderOptions.accessedDocumentCurrentScript = false;
|
|
18668
18748
|
({ source } = rendered);
|
|
18669
18749
|
usesTopLevelAwait || (usesTopLevelAwait = rendered.usesTopLevelAwait);
|
|
18670
18750
|
renderedLength = source.length();
|
|
@@ -18727,8 +18807,8 @@ class Chunk {
|
|
|
18727
18807
|
}
|
|
18728
18808
|
else {
|
|
18729
18809
|
const { node, resolution } = resolvedDynamicImport;
|
|
18730
|
-
const [resolutionString,
|
|
18731
|
-
node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false,
|
|
18810
|
+
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName);
|
|
18811
|
+
node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
|
|
18732
18812
|
}
|
|
18733
18813
|
}
|
|
18734
18814
|
}
|
|
@@ -19803,8 +19883,8 @@ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
|
|
|
19803
19883
|
timeEnd('render chunks', 2);
|
|
19804
19884
|
timeStart('transform chunks', 2);
|
|
19805
19885
|
const chunkGraph = getChunkGraph(chunks);
|
|
19806
|
-
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
|
|
19807
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
|
|
19886
|
+
const { initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
|
|
19887
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle);
|
|
19808
19888
|
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
19809
19889
|
timeEnd('transform chunks', 2);
|
|
19810
19890
|
}
|
|
@@ -19888,18 +19968,20 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
19888
19968
|
const nonHashedChunksWithPlaceholders = [];
|
|
19889
19969
|
const renderedChunksByPlaceholder = new Map();
|
|
19890
19970
|
const hashDependenciesByPlaceholder = new Map();
|
|
19971
|
+
const initialHashesByPlaceholder = new Map();
|
|
19891
19972
|
const placeholders = new Set();
|
|
19892
19973
|
for (const { preliminaryFileName: { hashPlaceholder } } of renderedChunks) {
|
|
19893
19974
|
if (hashPlaceholder)
|
|
19894
19975
|
placeholders.add(hashPlaceholder);
|
|
19895
19976
|
}
|
|
19896
|
-
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, magicString, usedModules }) => {
|
|
19977
|
+
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, preliminarySourcemapFileName, magicString, usedModules }) => {
|
|
19897
19978
|
const transformedChunk = {
|
|
19898
19979
|
chunk,
|
|
19899
19980
|
fileName,
|
|
19981
|
+
sourcemapFileName: preliminarySourcemapFileName?.fileName ?? null,
|
|
19900
19982
|
...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
|
|
19901
19983
|
};
|
|
19902
|
-
const { code } = transformedChunk;
|
|
19984
|
+
const { code, map } = transformedChunk;
|
|
19903
19985
|
if (hashPlaceholder) {
|
|
19904
19986
|
// To create a reproducible content-only hash, all placeholders are
|
|
19905
19987
|
// replaced with the same value before hashing
|
|
@@ -19923,15 +20005,23 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
19923
20005
|
else {
|
|
19924
20006
|
nonHashedChunksWithPlaceholders.push(transformedChunk);
|
|
19925
20007
|
}
|
|
20008
|
+
const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
|
|
20009
|
+
if (map && sourcemapHashPlaceholder) {
|
|
20010
|
+
initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, createHash()
|
|
20011
|
+
.update(map.toString())
|
|
20012
|
+
.digest('hex')
|
|
20013
|
+
.slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
|
|
20014
|
+
}
|
|
19926
20015
|
}));
|
|
19927
20016
|
return {
|
|
19928
20017
|
hashDependenciesByPlaceholder,
|
|
20018
|
+
initialHashesByPlaceholder,
|
|
19929
20019
|
nonHashedChunksWithPlaceholders,
|
|
19930
20020
|
renderedChunksByPlaceholder
|
|
19931
20021
|
};
|
|
19932
20022
|
}
|
|
19933
|
-
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
|
|
19934
|
-
const hashesByPlaceholder = new Map();
|
|
20023
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
|
|
20024
|
+
const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
|
|
19935
20025
|
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
19936
20026
|
let hash = createHash();
|
|
19937
20027
|
const hashDependencyPlaceholders = new Set([placeholder]);
|
|
@@ -19959,21 +20049,29 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
19959
20049
|
return hashesByPlaceholder;
|
|
19960
20050
|
}
|
|
19961
20051
|
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
19962
|
-
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
20052
|
+
for (const { chunk, code, fileName, sourcemapFileName, map } of renderedChunksByPlaceholder.values()) {
|
|
19963
20053
|
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
19964
20054
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
20055
|
+
let finalSourcemapFileName = null;
|
|
19965
20056
|
if (map) {
|
|
20057
|
+
finalSourcemapFileName = sourcemapFileName
|
|
20058
|
+
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
20059
|
+
: `${finalFileName}.map`;
|
|
19966
20060
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
19967
|
-
updatedCode += emitSourceMapAndGetComment(
|
|
20061
|
+
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
19968
20062
|
}
|
|
19969
|
-
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
20063
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
19970
20064
|
}
|
|
19971
|
-
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
20065
|
+
for (const { chunk, code, fileName, sourcemapFileName, map } of nonHashedChunksWithPlaceholders) {
|
|
19972
20066
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
20067
|
+
let finalSourcemapFileName = null;
|
|
19973
20068
|
if (map) {
|
|
19974
|
-
|
|
20069
|
+
finalSourcemapFileName = sourcemapFileName
|
|
20070
|
+
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
20071
|
+
: `${fileName}.map`;
|
|
20072
|
+
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
19975
20073
|
}
|
|
19976
|
-
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
20074
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
19977
20075
|
}
|
|
19978
20076
|
}
|
|
19979
20077
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -19982,11 +20080,11 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
|
|
|
19982
20080
|
url = map.toUrl();
|
|
19983
20081
|
}
|
|
19984
20082
|
else {
|
|
19985
|
-
const sourcemapFileName =
|
|
20083
|
+
const sourcemapFileName = node_path.basename(fileName);
|
|
19986
20084
|
url = sourcemapBaseUrl
|
|
19987
20085
|
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
19988
20086
|
: sourcemapFileName;
|
|
19989
|
-
pluginDriver.emitFile({ fileName
|
|
20087
|
+
pluginDriver.emitFile({ fileName, source: map.toString(), type: 'asset' });
|
|
19990
20088
|
}
|
|
19991
20089
|
return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
|
|
19992
20090
|
}
|
|
@@ -20209,7 +20307,7 @@ function flru (max) {
|
|
|
20209
20307
|
};
|
|
20210
20308
|
}
|
|
20211
20309
|
|
|
20212
|
-
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
20310
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
20213
20311
|
let skipped = null;
|
|
20214
20312
|
let replaceContext = null;
|
|
20215
20313
|
if (skip) {
|
|
@@ -20221,14 +20319,14 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
20221
20319
|
}
|
|
20222
20320
|
replaceContext = (pluginContext, plugin) => ({
|
|
20223
20321
|
...pluginContext,
|
|
20224
|
-
resolve: (source, importer, {
|
|
20322
|
+
resolve: (source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
20225
20323
|
});
|
|
20226
20324
|
}
|
|
20227
|
-
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, {
|
|
20325
|
+
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
20228
20326
|
}
|
|
20229
20327
|
|
|
20230
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
20231
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
20328
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
20329
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes);
|
|
20232
20330
|
if (pluginResult != null) {
|
|
20233
20331
|
const [resolveIdResult, plugin] = pluginResult;
|
|
20234
20332
|
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
@@ -20410,9 +20508,9 @@ class ModuleLoader {
|
|
|
20410
20508
|
this.modulesWithLoadedDependencies = new Set();
|
|
20411
20509
|
this.nextChunkNamePriority = 0;
|
|
20412
20510
|
this.nextEntryModuleIndex = 0;
|
|
20413
|
-
this.resolveId = async (source, importer, customOptions, isEntry,
|
|
20511
|
+
this.resolveId = async (source, importer, customOptions, isEntry, attributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
20414
20512
|
? false
|
|
20415
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer,
|
|
20513
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, attributes), importer, source), attributes);
|
|
20416
20514
|
this.hasModuleSideEffects = options.treeshake
|
|
20417
20515
|
? options.treeshake.moduleSideEffects
|
|
20418
20516
|
: () => true;
|
|
@@ -20572,11 +20670,11 @@ class ModuleLoader {
|
|
|
20572
20670
|
// Otherwise, if the module does not exist, it waits for the module and all
|
|
20573
20671
|
// its dependencies to be loaded.
|
|
20574
20672
|
// Otherwise, it returns immediately.
|
|
20575
|
-
async fetchModule({
|
|
20673
|
+
async fetchModule({ attributes, id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
|
|
20576
20674
|
const existingModule = this.modulesById.get(id);
|
|
20577
20675
|
if (existingModule instanceof Module) {
|
|
20578
|
-
if (importer &&
|
|
20579
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
20676
|
+
if (importer && doAttributesDiffer(attributes, existingModule.info.attributes)) {
|
|
20677
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(existingModule.info.attributes, attributes, id, importer));
|
|
20580
20678
|
}
|
|
20581
20679
|
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
20582
20680
|
return existingModule;
|
|
@@ -20584,7 +20682,7 @@ class ModuleLoader {
|
|
|
20584
20682
|
if (existingModule instanceof ExternalModule) {
|
|
20585
20683
|
return error(logExternalModulesCannotBeTransformedToModules(existingModule.id));
|
|
20586
20684
|
}
|
|
20587
|
-
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta,
|
|
20685
|
+
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta, attributes);
|
|
20588
20686
|
this.modulesById.set(id, module);
|
|
20589
20687
|
this.graph.watchFiles[id] = true;
|
|
20590
20688
|
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
@@ -20621,17 +20719,17 @@ class ModuleLoader {
|
|
|
20621
20719
|
}
|
|
20622
20720
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
20623
20721
|
if (resolvedId.external) {
|
|
20624
|
-
const {
|
|
20722
|
+
const { attributes, external, id, moduleSideEffects, meta } = resolvedId;
|
|
20625
20723
|
let externalModule = this.modulesById.get(id);
|
|
20626
20724
|
if (!externalModule) {
|
|
20627
|
-
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id),
|
|
20725
|
+
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id), attributes);
|
|
20628
20726
|
this.modulesById.set(id, externalModule);
|
|
20629
20727
|
}
|
|
20630
20728
|
else if (!(externalModule instanceof ExternalModule)) {
|
|
20631
20729
|
return error(logInternalIdCannotBeExternal(source, importer));
|
|
20632
20730
|
}
|
|
20633
|
-
else if (
|
|
20634
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
20731
|
+
else if (doAttributesDiffer(externalModule.info.attributes, attributes)) {
|
|
20732
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(externalModule.info.attributes, attributes, source, importer));
|
|
20635
20733
|
}
|
|
20636
20734
|
return Promise.resolve(externalModule);
|
|
20637
20735
|
}
|
|
@@ -20690,7 +20788,7 @@ class ModuleLoader {
|
|
|
20690
20788
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
20691
20789
|
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
20692
20790
|
? dynamicImport.argument
|
|
20693
|
-
: dynamicImport.argument.esTreeNode, module.id,
|
|
20791
|
+
: dynamicImport.argument.esTreeNode, module.id, getAttributesFromImportExpression(dynamicImport.node));
|
|
20694
20792
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
20695
20793
|
dynamicImport.id = resolvedId.id;
|
|
20696
20794
|
}
|
|
@@ -20699,20 +20797,20 @@ class ModuleLoader {
|
|
|
20699
20797
|
}
|
|
20700
20798
|
getResolveStaticDependencyPromises(module) {
|
|
20701
20799
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
20702
|
-
return Array.from(module.
|
|
20800
|
+
return Array.from(module.sourcesWithAttributes, async ([source, attributes]) => [
|
|
20703
20801
|
source,
|
|
20704
20802
|
(module.resolvedIds[source] =
|
|
20705
20803
|
module.resolvedIds[source] ||
|
|
20706
|
-
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false,
|
|
20804
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes), source, module.id, attributes))
|
|
20707
20805
|
]);
|
|
20708
20806
|
}
|
|
20709
|
-
getResolvedIdWithDefaults(resolvedId,
|
|
20807
|
+
getResolvedIdWithDefaults(resolvedId, attributes) {
|
|
20710
20808
|
if (!resolvedId) {
|
|
20711
20809
|
return null;
|
|
20712
20810
|
}
|
|
20713
20811
|
const external = resolvedId.external || false;
|
|
20714
20812
|
return {
|
|
20715
|
-
|
|
20813
|
+
attributes: resolvedId.attributes || attributes,
|
|
20716
20814
|
external,
|
|
20717
20815
|
id: resolvedId.id,
|
|
20718
20816
|
meta: resolvedId.meta || {},
|
|
@@ -20738,14 +20836,14 @@ class ModuleLoader {
|
|
|
20738
20836
|
}
|
|
20739
20837
|
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
20740
20838
|
}
|
|
20741
|
-
handleInvalidResolvedId(resolvedId, source, importer,
|
|
20839
|
+
handleInvalidResolvedId(resolvedId, source, importer, attributes) {
|
|
20742
20840
|
if (resolvedId === null) {
|
|
20743
20841
|
if (isRelative(source)) {
|
|
20744
20842
|
return error(logUnresolvedImport(source, importer));
|
|
20745
20843
|
}
|
|
20746
20844
|
this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer));
|
|
20747
20845
|
return {
|
|
20748
|
-
|
|
20846
|
+
attributes,
|
|
20749
20847
|
external: true,
|
|
20750
20848
|
id: source,
|
|
20751
20849
|
meta: {},
|
|
@@ -20778,11 +20876,11 @@ class ModuleLoader {
|
|
|
20778
20876
|
? resolveIdResult
|
|
20779
20877
|
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
20780
20878
|
}
|
|
20781
|
-
async resolveDynamicImport(module, specifier, importer,
|
|
20879
|
+
async resolveDynamicImport(module, specifier, importer, attributes) {
|
|
20782
20880
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
20783
20881
|
specifier,
|
|
20784
20882
|
importer,
|
|
20785
|
-
{
|
|
20883
|
+
{ attributes }
|
|
20786
20884
|
]);
|
|
20787
20885
|
if (typeof specifier !== 'string') {
|
|
20788
20886
|
if (typeof resolution === 'string') {
|
|
@@ -20791,19 +20889,19 @@ class ModuleLoader {
|
|
|
20791
20889
|
if (!resolution) {
|
|
20792
20890
|
return null;
|
|
20793
20891
|
}
|
|
20794
|
-
return this.getResolvedIdWithDefaults(resolution,
|
|
20892
|
+
return this.getResolvedIdWithDefaults(resolution, attributes);
|
|
20795
20893
|
}
|
|
20796
20894
|
if (resolution == null) {
|
|
20797
20895
|
const existingResolution = module.resolvedIds[specifier];
|
|
20798
20896
|
if (existingResolution) {
|
|
20799
|
-
if (
|
|
20800
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
20897
|
+
if (doAttributesDiffer(existingResolution.attributes, attributes)) {
|
|
20898
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(existingResolution.attributes, attributes, specifier, importer));
|
|
20801
20899
|
}
|
|
20802
20900
|
return existingResolution;
|
|
20803
20901
|
}
|
|
20804
|
-
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false,
|
|
20902
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes), specifier, module.id, attributes));
|
|
20805
20903
|
}
|
|
20806
|
-
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier),
|
|
20904
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), attributes), specifier, importer, attributes);
|
|
20807
20905
|
}
|
|
20808
20906
|
}
|
|
20809
20907
|
function normalizeRelativeExternalId(source, importer) {
|
|
@@ -21313,6 +21411,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
21313
21411
|
const file = getFile(config, preserveModules, inputOptions);
|
|
21314
21412
|
const preferConst = getPreferConst(config, inputOptions);
|
|
21315
21413
|
const generatedCode = getGeneratedCode(config, preferConst);
|
|
21414
|
+
const externalImportAttributes = getExternalImportAttributes(config, inputOptions);
|
|
21316
21415
|
const outputOptions = {
|
|
21317
21416
|
amd: getAmd(config),
|
|
21318
21417
|
assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
|
|
@@ -21328,7 +21427,8 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
21328
21427
|
experimentalMinChunkSize: config.experimentalMinChunkSize ?? 1,
|
|
21329
21428
|
exports: getExports(config, unsetOptions),
|
|
21330
21429
|
extend: config.extend || false,
|
|
21331
|
-
externalImportAssertions:
|
|
21430
|
+
externalImportAssertions: externalImportAttributes,
|
|
21431
|
+
externalImportAttributes,
|
|
21332
21432
|
externalLiveBindings: config.externalLiveBindings ?? true,
|
|
21333
21433
|
file,
|
|
21334
21434
|
footer: getAddon(config, 'footer'),
|
|
@@ -21361,6 +21461,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
21361
21461
|
sourcemapBaseUrl: getSourcemapBaseUrl(config),
|
|
21362
21462
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
21363
21463
|
sourcemapFile: config.sourcemapFile,
|
|
21464
|
+
sourcemapFileNames: getSourcemapFileNames(config, unsetOptions),
|
|
21364
21465
|
sourcemapIgnoreList: typeof config.sourcemapIgnoreList === 'function'
|
|
21365
21466
|
? config.sourcemapIgnoreList
|
|
21366
21467
|
: config.sourcemapIgnoreList === false
|
|
@@ -21523,6 +21624,12 @@ function getExports(config, unsetOptions) {
|
|
|
21523
21624
|
}
|
|
21524
21625
|
return configExports || 'auto';
|
|
21525
21626
|
}
|
|
21627
|
+
const getExternalImportAttributes = (config, inputOptions) => {
|
|
21628
|
+
if (config.externalImportAssertions != undefined) {
|
|
21629
|
+
warnDeprecation(`The "output.externalImportAssertions" option is deprecated. Use the "output.externalImportAttributes" option instead.`, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, true, inputOptions);
|
|
21630
|
+
}
|
|
21631
|
+
return config.externalImportAttributes ?? config.externalImportAssertions ?? true;
|
|
21632
|
+
};
|
|
21526
21633
|
const getGeneratedCode = (config, preferConst) => {
|
|
21527
21634
|
const configWithPreset = getOptionWithPreset(config.generatedCode, generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '');
|
|
21528
21635
|
return {
|
|
@@ -21589,6 +21696,13 @@ const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
|
21589
21696
|
}
|
|
21590
21697
|
return generatedCode.symbols || false;
|
|
21591
21698
|
};
|
|
21699
|
+
const getSourcemapFileNames = (config, unsetOptions) => {
|
|
21700
|
+
const configSourcemapFileNames = config.sourcemapFileNames;
|
|
21701
|
+
if (configSourcemapFileNames == null) {
|
|
21702
|
+
unsetOptions.add('sourcemapFileNames');
|
|
21703
|
+
}
|
|
21704
|
+
return configSourcemapFileNames;
|
|
21705
|
+
};
|
|
21592
21706
|
const getSourcemapBaseUrl = (config) => {
|
|
21593
21707
|
const { sourcemapBaseUrl } = config;
|
|
21594
21708
|
if (sourcemapBaseUrl) {
|