@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
|
@@ -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
|
|
|
@@ -16,7 +16,7 @@ import native from '../../native.js';
|
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version = "4.0.0-
|
|
19
|
+
var version = "4.0.0-14";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1738,7 +1738,7 @@ class ExternalChunk {
|
|
|
1738
1738
|
this.namespaceVariableName = '';
|
|
1739
1739
|
this.variableName = '';
|
|
1740
1740
|
this.fileName = null;
|
|
1741
|
-
this.
|
|
1741
|
+
this.importAttributes = null;
|
|
1742
1742
|
this.id = module.id;
|
|
1743
1743
|
this.moduleInfo = module.info;
|
|
1744
1744
|
this.renormalizeRenderPath = module.renormalizeRenderPath;
|
|
@@ -1753,10 +1753,10 @@ class ExternalChunk {
|
|
|
1753
1753
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
1754
1754
|
(this.renormalizeRenderPath ? normalize(relative$1(this.inputBase, this.id)) : this.id));
|
|
1755
1755
|
}
|
|
1756
|
-
|
|
1757
|
-
return (this.
|
|
1758
|
-
this.options.
|
|
1759
|
-
this.moduleInfo.
|
|
1756
|
+
getImportAttributes(snippets) {
|
|
1757
|
+
return (this.importAttributes || (this.importAttributes = formatAttributes$1(this.options.format === 'es' &&
|
|
1758
|
+
this.options.externalImportAttributes &&
|
|
1759
|
+
this.moduleInfo.attributes, snippets)));
|
|
1760
1760
|
}
|
|
1761
1761
|
getImportPath(importer) {
|
|
1762
1762
|
return escapeId(this.renormalizeRenderPath
|
|
@@ -1764,11 +1764,11 @@ class ExternalChunk {
|
|
|
1764
1764
|
: this.getFileName());
|
|
1765
1765
|
}
|
|
1766
1766
|
}
|
|
1767
|
-
function
|
|
1768
|
-
if (!
|
|
1767
|
+
function formatAttributes$1(attributes, { getObject }) {
|
|
1768
|
+
if (!attributes) {
|
|
1769
1769
|
return null;
|
|
1770
1770
|
}
|
|
1771
|
-
const assertionEntries = Object.entries(
|
|
1771
|
+
const assertionEntries = Object.entries(attributes).map(([key, value]) => [key, `'${value}'`]);
|
|
1772
1772
|
if (assertionEntries.length > 0) {
|
|
1773
1773
|
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
1774
1774
|
}
|
|
@@ -2262,6 +2262,7 @@ const URL_OUTPUT_DIR = 'configuration-options/#output-dir';
|
|
|
2262
2262
|
const URL_OUTPUT_DYNAMICIMPORTFUNCTION = 'configuration-options/#output-dynamicimportfunction';
|
|
2263
2263
|
const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
|
|
2264
2264
|
const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
|
|
2265
|
+
const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = 'configuration-options/#output-externalimportattributes';
|
|
2265
2266
|
const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
|
|
2266
2267
|
const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
|
|
2267
2268
|
const URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION = 'configuration-options/#output-experimentaldeepdynamicchunkoptimization';
|
|
@@ -2311,7 +2312,7 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
2311
2312
|
}
|
|
2312
2313
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
2313
2314
|
// error code below
|
|
2314
|
-
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_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', 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',
|
|
2315
|
+
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_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', 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_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_EXPORT = 'MISSING_EXPORT', 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', 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';
|
|
2315
2316
|
function logAddonNotGenerated(message, hook, plugin) {
|
|
2316
2317
|
return {
|
|
2317
2318
|
code: ADDON_ERROR,
|
|
@@ -2486,14 +2487,14 @@ function logIllegalImportReassignment(name, importingId) {
|
|
|
2486
2487
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
2487
2488
|
};
|
|
2488
2489
|
}
|
|
2489
|
-
function
|
|
2490
|
+
function logInconsistentImportAttributes(existingAttributes, newAttributes, source, importer) {
|
|
2490
2491
|
return {
|
|
2491
|
-
code:
|
|
2492
|
-
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${
|
|
2492
|
+
code: INCONSISTENT_IMPORT_ATTRIBUTES,
|
|
2493
|
+
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAttributes(newAttributes)} attributes, but it was already imported elsewhere with ${formatAttributes(existingAttributes)} attributes. Please ensure that import attributes for the same module are always consistent.`
|
|
2493
2494
|
};
|
|
2494
2495
|
}
|
|
2495
|
-
const
|
|
2496
|
-
const entries = Object.entries(
|
|
2496
|
+
const formatAttributes = (attributes) => {
|
|
2497
|
+
const entries = Object.entries(attributes);
|
|
2497
2498
|
if (entries.length === 0)
|
|
2498
2499
|
return 'no';
|
|
2499
2500
|
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
@@ -2530,6 +2531,18 @@ function logInternalIdCannotBeExternal(source, importer) {
|
|
|
2530
2531
|
message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
|
|
2531
2532
|
};
|
|
2532
2533
|
}
|
|
2534
|
+
function logImportOptionsAreInvalid(importer) {
|
|
2535
|
+
return {
|
|
2536
|
+
code: INVALID_IMPORT_ATTRIBUTE,
|
|
2537
|
+
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.`
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
function logImportAttributeIsInvalid(importer) {
|
|
2541
|
+
return {
|
|
2542
|
+
code: INVALID_IMPORT_ATTRIBUTE,
|
|
2543
|
+
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.`
|
|
2544
|
+
};
|
|
2545
|
+
}
|
|
2533
2546
|
function logInvalidLogPosition(plugin) {
|
|
2534
2547
|
return {
|
|
2535
2548
|
code: INVALID_LOG_POSITION,
|
|
@@ -2873,7 +2886,7 @@ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation,
|
|
|
2873
2886
|
}
|
|
2874
2887
|
|
|
2875
2888
|
class ExternalModule {
|
|
2876
|
-
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath,
|
|
2889
|
+
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, attributes) {
|
|
2877
2890
|
this.options = options;
|
|
2878
2891
|
this.id = id;
|
|
2879
2892
|
this.renormalizeRenderPath = renormalizeRenderPath;
|
|
@@ -2889,8 +2902,8 @@ class ExternalModule {
|
|
|
2889
2902
|
this.suggestedVariableName = makeLegal(id.split(/[/\\]/).pop());
|
|
2890
2903
|
const { importers, dynamicImporters } = this;
|
|
2891
2904
|
const info = (this.info = {
|
|
2892
|
-
assertions,
|
|
2893
2905
|
ast: null,
|
|
2906
|
+
attributes,
|
|
2894
2907
|
code: null,
|
|
2895
2908
|
dynamicallyImportedIdResolutions: EMPTY_ARRAY,
|
|
2896
2909
|
dynamicallyImportedIds: EMPTY_ARRAY,
|
|
@@ -5455,6 +5468,7 @@ const convertProgram = (buffer, readString) => convertNode(0, new Uint32Array(bu
|
|
|
5455
5468
|
const convertNode = (position, buffer, readString) => {
|
|
5456
5469
|
const nodeType = buffer[position];
|
|
5457
5470
|
const converter = nodeConverters[nodeType];
|
|
5471
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
5458
5472
|
if (!converter) {
|
|
5459
5473
|
console.trace();
|
|
5460
5474
|
throw new Error(`Unknown node type: ${nodeType}`);
|
|
@@ -5748,14 +5762,14 @@ const nodeConverters = [
|
|
|
5748
5762
|
const end = buffer[position++];
|
|
5749
5763
|
const exportedPosition = buffer[position++];
|
|
5750
5764
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
5751
|
-
const
|
|
5765
|
+
const attributes = convertNodeList(buffer[position], buffer, readString);
|
|
5752
5766
|
return {
|
|
5753
5767
|
type: 'ExportAllDeclaration',
|
|
5754
5768
|
start,
|
|
5755
5769
|
end,
|
|
5756
5770
|
exported: exportedPosition ? convertNode(exportedPosition, buffer, readString) : null,
|
|
5757
5771
|
source,
|
|
5758
|
-
|
|
5772
|
+
attributes
|
|
5759
5773
|
};
|
|
5760
5774
|
},
|
|
5761
5775
|
// index:21; ExportDefaultDeclaration
|
|
@@ -5776,7 +5790,7 @@ const nodeConverters = [
|
|
|
5776
5790
|
const end = buffer[position++];
|
|
5777
5791
|
const declarationPosition = buffer[position++];
|
|
5778
5792
|
const sourcePosition = buffer[position++];
|
|
5779
|
-
const
|
|
5793
|
+
const attributes = convertNodeList(buffer[position++], buffer, readString);
|
|
5780
5794
|
const specifiers = convertNodeList(position, buffer, readString);
|
|
5781
5795
|
return {
|
|
5782
5796
|
type: 'ExportNamedDeclaration',
|
|
@@ -5787,7 +5801,7 @@ const nodeConverters = [
|
|
|
5787
5801
|
: null,
|
|
5788
5802
|
source: sourcePosition ? convertNode(sourcePosition, buffer, readString) : null,
|
|
5789
5803
|
specifiers,
|
|
5790
|
-
|
|
5804
|
+
attributes
|
|
5791
5805
|
};
|
|
5792
5806
|
},
|
|
5793
5807
|
// index:23; ExportSpecifier
|
|
@@ -5966,7 +5980,7 @@ const nodeConverters = [
|
|
|
5966
5980
|
const start = buffer[position++];
|
|
5967
5981
|
const end = buffer[position++];
|
|
5968
5982
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
5969
|
-
const
|
|
5983
|
+
const attributes = convertNodeList(buffer[position++], buffer, readString);
|
|
5970
5984
|
const specifiers = convertNodeList(position, buffer, readString);
|
|
5971
5985
|
return {
|
|
5972
5986
|
type: 'ImportDeclaration',
|
|
@@ -5974,7 +5988,7 @@ const nodeConverters = [
|
|
|
5974
5988
|
end,
|
|
5975
5989
|
source,
|
|
5976
5990
|
specifiers,
|
|
5977
|
-
|
|
5991
|
+
attributes
|
|
5978
5992
|
};
|
|
5979
5993
|
},
|
|
5980
5994
|
// index:34; ImportDefaultSpecifier
|
|
@@ -5993,14 +6007,14 @@ const nodeConverters = [
|
|
|
5993
6007
|
(position, buffer, readString) => {
|
|
5994
6008
|
const start = buffer[position++];
|
|
5995
6009
|
const end = buffer[position++];
|
|
5996
|
-
const
|
|
6010
|
+
const optionsPosition = buffer[position++];
|
|
5997
6011
|
const source = convertNode(position, buffer, readString);
|
|
5998
6012
|
return {
|
|
5999
6013
|
type: 'ImportExpression',
|
|
6000
6014
|
start,
|
|
6001
6015
|
end,
|
|
6002
6016
|
source,
|
|
6003
|
-
|
|
6017
|
+
options: optionsPosition ? convertNode(optionsPosition, buffer, readString) : null
|
|
6004
6018
|
};
|
|
6005
6019
|
},
|
|
6006
6020
|
// index:36; ImportNamespaceSpecifier
|
|
@@ -6618,9 +6632,6 @@ const ANNOTATION_KEY = '_rollupAnnotations';
|
|
|
6618
6632
|
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
6619
6633
|
|
|
6620
6634
|
const keys = {
|
|
6621
|
-
// TODO this should be removed once ImportExpression follows official ESTree
|
|
6622
|
-
// specs with "null" as default
|
|
6623
|
-
ImportExpression: ['arguments'],
|
|
6624
6635
|
Literal: [],
|
|
6625
6636
|
Program: ['body']
|
|
6626
6637
|
};
|
|
@@ -6725,11 +6736,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
6725
6736
|
* initialised
|
|
6726
6737
|
*/
|
|
6727
6738
|
initialise() { }
|
|
6728
|
-
insertSemicolon(code) {
|
|
6729
|
-
if (code.original[this.end - 1] !== ';') {
|
|
6730
|
-
code.appendLeft(this.end, ';');
|
|
6731
|
-
}
|
|
6732
|
-
}
|
|
6733
6739
|
parseNode(esTreeNode, keepEsTreeNodeKeys) {
|
|
6734
6740
|
for (const [key, value] of Object.entries(esTreeNode)) {
|
|
6735
6741
|
// That way, we can override this function to add custom initialisation and then call super.parseNode
|
|
@@ -8506,7 +8512,17 @@ const knownGlobals = {
|
|
|
8506
8512
|
CSSSupportsRule: C,
|
|
8507
8513
|
CustomElementRegistry: C,
|
|
8508
8514
|
customElements: O,
|
|
8509
|
-
CustomEvent:
|
|
8515
|
+
CustomEvent: {
|
|
8516
|
+
__proto__: null,
|
|
8517
|
+
[ValueProperties]: {
|
|
8518
|
+
deoptimizeArgumentsOnCall({ args }) {
|
|
8519
|
+
args[2]?.deoptimizePath(['detail']);
|
|
8520
|
+
},
|
|
8521
|
+
getLiteralValue: getTruthyLiteralValue,
|
|
8522
|
+
hasEffectsWhenCalled: returnFalse
|
|
8523
|
+
},
|
|
8524
|
+
prototype: O
|
|
8525
|
+
},
|
|
8510
8526
|
DataTransfer: C,
|
|
8511
8527
|
DataTransferItem: C,
|
|
8512
8528
|
DataTransferItemList: C,
|
|
@@ -9450,8 +9466,9 @@ class ExpressionStatement extends NodeBase {
|
|
|
9450
9466
|
}
|
|
9451
9467
|
render(code, options) {
|
|
9452
9468
|
super.render(code, options);
|
|
9453
|
-
if (this.
|
|
9454
|
-
this.
|
|
9469
|
+
if (code.original[this.end - 1] !== ';') {
|
|
9470
|
+
code.appendLeft(this.end, ';');
|
|
9471
|
+
}
|
|
9455
9472
|
}
|
|
9456
9473
|
shouldBeIncluded(context) {
|
|
9457
9474
|
if (this.directive && this.directive !== 'use strict')
|
|
@@ -11769,7 +11786,7 @@ class ImportAttribute extends NodeBase {
|
|
|
11769
11786
|
}
|
|
11770
11787
|
|
|
11771
11788
|
class ImportDeclaration extends NodeBase {
|
|
11772
|
-
// Do not bind specifiers or
|
|
11789
|
+
// Do not bind specifiers or attributes
|
|
11773
11790
|
bind() { }
|
|
11774
11791
|
hasEffects() {
|
|
11775
11792
|
return false;
|
|
@@ -11795,6 +11812,7 @@ const INTEROP_NAMESPACE_COMPAT_VARIABLE = '_interopNamespaceCompat';
|
|
|
11795
11812
|
const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
|
|
11796
11813
|
const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
|
|
11797
11814
|
const MERGE_NAMESPACES_VARIABLE = '_mergeNamespaces';
|
|
11815
|
+
const DOCUMENT_CURRENT_SCRIPT = '_documentCurrentScript';
|
|
11798
11816
|
const defaultInteropHelpersByInteropType = {
|
|
11799
11817
|
auto: INTEROP_DEFAULT_VARIABLE,
|
|
11800
11818
|
compat: INTEROP_DEFAULT_COMPAT_VARIABLE,
|
|
@@ -11824,6 +11842,9 @@ const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, l
|
|
|
11824
11842
|
: '').join('');
|
|
11825
11843
|
};
|
|
11826
11844
|
const HELPER_GENERATORS = {
|
|
11845
|
+
[DOCUMENT_CURRENT_SCRIPT](_t, { _, n }) {
|
|
11846
|
+
return `var${_}${DOCUMENT_CURRENT_SCRIPT}${_}=${_}typeof${_}document${_}!==${_}'undefined'${_}?${_}document.currentScript${_}:${_}null;${n}`;
|
|
11847
|
+
},
|
|
11827
11848
|
[INTEROP_DEFAULT_COMPAT_VARIABLE](_t, snippets, liveBindings) {
|
|
11828
11849
|
const { _, getDirectReturnFunction, n } = snippets;
|
|
11829
11850
|
const [left, right] = getDirectReturnFunction(['e'], {
|
|
@@ -12064,19 +12085,17 @@ class VariableDeclarator extends NodeBase {
|
|
|
12064
12085
|
}
|
|
12065
12086
|
}
|
|
12066
12087
|
|
|
12067
|
-
// TODO once ImportExpression follows official ESTree specs with "null" as
|
|
12068
|
-
// default, keys.ts should be updated
|
|
12069
12088
|
class ImportExpression extends NodeBase {
|
|
12070
12089
|
constructor() {
|
|
12071
12090
|
super(...arguments);
|
|
12072
12091
|
this.inlineNamespace = null;
|
|
12073
|
-
this.
|
|
12092
|
+
this.attributes = null;
|
|
12074
12093
|
this.mechanism = null;
|
|
12075
12094
|
this.namespaceExportName = undefined;
|
|
12076
12095
|
this.resolution = null;
|
|
12077
12096
|
this.resolutionString = null;
|
|
12078
12097
|
}
|
|
12079
|
-
// Do not bind
|
|
12098
|
+
// Do not bind attributes
|
|
12080
12099
|
bind() {
|
|
12081
12100
|
this.source.bind();
|
|
12082
12101
|
}
|
|
@@ -12200,24 +12219,24 @@ class ImportExpression extends NodeBase {
|
|
|
12200
12219
|
else {
|
|
12201
12220
|
this.source.render(code, options);
|
|
12202
12221
|
}
|
|
12203
|
-
if (this.
|
|
12204
|
-
if (this.
|
|
12222
|
+
if (this.attributes !== true) {
|
|
12223
|
+
if (this.options) {
|
|
12205
12224
|
code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true });
|
|
12206
12225
|
}
|
|
12207
|
-
if (this.
|
|
12208
|
-
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.
|
|
12226
|
+
if (this.attributes) {
|
|
12227
|
+
code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.attributes]], {
|
|
12209
12228
|
lineBreakIndent: null
|
|
12210
12229
|
})}`);
|
|
12211
12230
|
}
|
|
12212
12231
|
}
|
|
12213
12232
|
}
|
|
12214
|
-
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName,
|
|
12233
|
+
setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
|
|
12215
12234
|
const { format } = options;
|
|
12216
12235
|
this.inlineNamespace = null;
|
|
12217
12236
|
this.resolution = resolution;
|
|
12218
12237
|
this.resolutionString = resolutionString;
|
|
12219
12238
|
this.namespaceExportName = namespaceExportName;
|
|
12220
|
-
this.
|
|
12239
|
+
this.attributes = attributes;
|
|
12221
12240
|
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
|
|
12222
12241
|
let helper;
|
|
12223
12242
|
({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
|
|
@@ -12573,8 +12592,10 @@ class MetaProperty extends NodeBase {
|
|
|
12573
12592
|
}
|
|
12574
12593
|
}
|
|
12575
12594
|
}
|
|
12576
|
-
render(code,
|
|
12577
|
-
const {
|
|
12595
|
+
render(code, renderOptions) {
|
|
12596
|
+
const { format, pluginDriver, snippets } = renderOptions;
|
|
12597
|
+
const { context: { module }, meta: { name }, metaProperty, parent, preliminaryChunkId, referenceId, start, end } = this;
|
|
12598
|
+
const { id: moduleId } = module;
|
|
12578
12599
|
if (name !== IMPORT)
|
|
12579
12600
|
return;
|
|
12580
12601
|
const chunkId = preliminaryChunkId;
|
|
@@ -12587,10 +12608,14 @@ class MetaProperty extends NodeBase {
|
|
|
12587
12608
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
12588
12609
|
return;
|
|
12589
12610
|
}
|
|
12590
|
-
|
|
12611
|
+
let replacement = pluginDriver.hookFirstSync('resolveImportMeta', [
|
|
12591
12612
|
metaProperty,
|
|
12592
12613
|
{ chunkId, format, moduleId }
|
|
12593
|
-
])
|
|
12614
|
+
]);
|
|
12615
|
+
if (!replacement) {
|
|
12616
|
+
replacement = importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
|
|
12617
|
+
renderOptions.accessedDocumentCurrentScript || (renderOptions.accessedDocumentCurrentScript = formatsMaybeAccessDocumentCurrentScript.includes(format) && replacement !== 'undefined');
|
|
12618
|
+
}
|
|
12594
12619
|
if (typeof replacement === 'string') {
|
|
12595
12620
|
if (parent instanceof MemberExpression) {
|
|
12596
12621
|
code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
|
|
@@ -12608,13 +12633,14 @@ class MetaProperty extends NodeBase {
|
|
|
12608
12633
|
}
|
|
12609
12634
|
}
|
|
12610
12635
|
}
|
|
12636
|
+
const formatsMaybeAccessDocumentCurrentScript = ['cjs', 'iife', 'umd'];
|
|
12611
12637
|
const accessedMetaUrlGlobals = {
|
|
12612
12638
|
amd: ['document', 'module', 'URL'],
|
|
12613
|
-
cjs: ['document', 'require', 'URL'],
|
|
12639
|
+
cjs: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT],
|
|
12614
12640
|
es: [],
|
|
12615
|
-
iife: ['document', 'URL'],
|
|
12641
|
+
iife: ['document', 'URL', DOCUMENT_CURRENT_SCRIPT],
|
|
12616
12642
|
system: ['module'],
|
|
12617
|
-
umd: ['document', 'require', 'URL']
|
|
12643
|
+
umd: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT]
|
|
12618
12644
|
};
|
|
12619
12645
|
const accessedFileUrlGlobals = {
|
|
12620
12646
|
amd: ['document', 'require', 'URL'],
|
|
@@ -12636,7 +12662,7 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
|
|
|
12636
12662
|
};
|
|
12637
12663
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
|
12638
12664
|
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
|
|
12639
|
-
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(
|
|
12665
|
+
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)`;
|
|
12640
12666
|
const relativeUrlMechanisms = {
|
|
12641
12667
|
amd: relativePath => {
|
|
12642
12668
|
if (relativePath[0] !== '.')
|
|
@@ -14154,11 +14180,23 @@ function getOriginalLocation(sourcemapChain, location) {
|
|
|
14154
14180
|
return location;
|
|
14155
14181
|
}
|
|
14156
14182
|
|
|
14157
|
-
|
|
14158
|
-
|
|
14183
|
+
const ATTRIBUTE_KEYWORDS = new Set(['assert', 'with']);
|
|
14184
|
+
function getAttributesFromImportExpression(node) {
|
|
14185
|
+
const { context, options, start } = node;
|
|
14186
|
+
if (!(options instanceof ObjectExpression)) {
|
|
14187
|
+
if (options) {
|
|
14188
|
+
context.module.log(LOGLEVEL_WARN, logImportAttributeIsInvalid(context.module.id), start);
|
|
14189
|
+
}
|
|
14190
|
+
return EMPTY_OBJECT;
|
|
14191
|
+
}
|
|
14192
|
+
const assertProperty = options.properties.find((property) => ATTRIBUTE_KEYWORDS.has(getPropertyKey(property)))?.value;
|
|
14159
14193
|
if (!assertProperty) {
|
|
14160
14194
|
return EMPTY_OBJECT;
|
|
14161
14195
|
}
|
|
14196
|
+
if (!(assertProperty instanceof ObjectExpression)) {
|
|
14197
|
+
context.module.log(LOGLEVEL_WARN, logImportOptionsAreInvalid(context.module.id), start);
|
|
14198
|
+
return EMPTY_OBJECT;
|
|
14199
|
+
}
|
|
14162
14200
|
const assertFields = assertProperty.properties
|
|
14163
14201
|
.map(property => {
|
|
14164
14202
|
const key = getPropertyKey(property);
|
|
@@ -14166,6 +14204,7 @@ function getAssertionsFromImportExpression(node) {
|
|
|
14166
14204
|
typeof property.value.value === 'string') {
|
|
14167
14205
|
return [key, property.value.value];
|
|
14168
14206
|
}
|
|
14207
|
+
context.module.log(LOGLEVEL_WARN, logImportAttributeIsInvalid(context.module.id), property.start);
|
|
14169
14208
|
return null;
|
|
14170
14209
|
})
|
|
14171
14210
|
.filter((property) => !!property);
|
|
@@ -14176,14 +14215,14 @@ function getAssertionsFromImportExpression(node) {
|
|
|
14176
14215
|
}
|
|
14177
14216
|
const getPropertyKey = (property) => {
|
|
14178
14217
|
const key = property.key;
|
|
14179
|
-
return key && (key.name || key.value);
|
|
14218
|
+
return (key && !property.computed && (key.name || key.value));
|
|
14180
14219
|
};
|
|
14181
|
-
function
|
|
14182
|
-
return
|
|
14183
|
-
? Object.fromEntries(
|
|
14220
|
+
function getAttributesFromImportExportDeclaration(attributes) {
|
|
14221
|
+
return attributes?.length
|
|
14222
|
+
? Object.fromEntries(attributes.map(assertion => [getPropertyKey(assertion), assertion.value.value]))
|
|
14184
14223
|
: EMPTY_OBJECT;
|
|
14185
14224
|
}
|
|
14186
|
-
function
|
|
14225
|
+
function doAttributesDiffer(assertionA, assertionB) {
|
|
14187
14226
|
const keysA = Object.keys(assertionA);
|
|
14188
14227
|
return (keysA.length !== Object.keys(assertionB).length ||
|
|
14189
14228
|
keysA.some(key => assertionA[key] !== assertionB[key]));
|
|
@@ -14265,6 +14304,9 @@ const TIMED_PLUGIN_HOOKS = [
|
|
|
14265
14304
|
'writeBundle'
|
|
14266
14305
|
];
|
|
14267
14306
|
function getPluginWithTimers(plugin, index) {
|
|
14307
|
+
if (plugin._hasTimer)
|
|
14308
|
+
return plugin;
|
|
14309
|
+
plugin._hasTimer = true;
|
|
14268
14310
|
for (const hook of TIMED_PLUGIN_HOOKS) {
|
|
14269
14311
|
if (hook in plugin) {
|
|
14270
14312
|
let timerLabel = `plugin ${index}`;
|
|
@@ -14370,7 +14412,7 @@ function getAndExtendSideEffectModules(variable, module) {
|
|
|
14370
14412
|
return sideEffectModules;
|
|
14371
14413
|
}
|
|
14372
14414
|
class Module {
|
|
14373
|
-
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta,
|
|
14415
|
+
constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta, attributes) {
|
|
14374
14416
|
this.graph = graph;
|
|
14375
14417
|
this.id = id;
|
|
14376
14418
|
this.options = options;
|
|
@@ -14395,7 +14437,7 @@ class Module {
|
|
|
14395
14437
|
this.isUserDefinedEntryPoint = false;
|
|
14396
14438
|
this.needsExportShim = false;
|
|
14397
14439
|
this.sideEffectDependenciesByVariable = new Map();
|
|
14398
|
-
this.
|
|
14440
|
+
this.sourcesWithAttributes = new Map();
|
|
14399
14441
|
this.allExportNames = null;
|
|
14400
14442
|
this.ast = null;
|
|
14401
14443
|
this.exportAllModules = [];
|
|
@@ -14415,10 +14457,10 @@ class Module {
|
|
|
14415
14457
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
14416
14458
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
14417
14459
|
const module = this;
|
|
14418
|
-
const { dynamicImports, dynamicImporters, exportAllSources, exports, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions,
|
|
14460
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exports, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAttributes } = this;
|
|
14419
14461
|
this.info = {
|
|
14420
|
-
assertions,
|
|
14421
14462
|
ast: null,
|
|
14463
|
+
attributes,
|
|
14422
14464
|
code: null,
|
|
14423
14465
|
get dynamicallyImportedIdResolutions() {
|
|
14424
14466
|
return dynamicImports
|
|
@@ -14472,13 +14514,13 @@ class Module {
|
|
|
14472
14514
|
},
|
|
14473
14515
|
get importedIdResolutions() {
|
|
14474
14516
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
14475
|
-
return Array.from(
|
|
14517
|
+
return Array.from(sourcesWithAttributes.keys(), source => module.resolvedIds[source]).filter(Boolean);
|
|
14476
14518
|
},
|
|
14477
14519
|
get importedIds() {
|
|
14478
14520
|
// We cannot use this.dependencies because this is needed before
|
|
14479
14521
|
// dependencies are populated
|
|
14480
14522
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
14481
|
-
return Array.from(
|
|
14523
|
+
return Array.from(sourcesWithAttributes.keys(), source => module.resolvedIds[source]?.id).filter(Boolean);
|
|
14482
14524
|
},
|
|
14483
14525
|
get importers() {
|
|
14484
14526
|
return importers.sort();
|
|
@@ -14910,8 +14952,8 @@ class Module {
|
|
|
14910
14952
|
}
|
|
14911
14953
|
toJSON() {
|
|
14912
14954
|
return {
|
|
14913
|
-
assertions: this.info.assertions,
|
|
14914
14955
|
ast: this.info.ast,
|
|
14956
|
+
attributes: this.info.attributes,
|
|
14915
14957
|
code: this.info.code,
|
|
14916
14958
|
customTransformCache: this.customTransformCache,
|
|
14917
14959
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
@@ -15108,15 +15150,15 @@ class Module {
|
|
|
15108
15150
|
addSideEffectDependencies(alwaysCheckedDependencies);
|
|
15109
15151
|
}
|
|
15110
15152
|
addSource(source, declaration) {
|
|
15111
|
-
const
|
|
15112
|
-
const
|
|
15113
|
-
if (
|
|
15114
|
-
if (
|
|
15115
|
-
this.log(LOGLEVEL_WARN,
|
|
15153
|
+
const parsedAttributes = getAttributesFromImportExportDeclaration(declaration.attributes);
|
|
15154
|
+
const existingAttributes = this.sourcesWithAttributes.get(source);
|
|
15155
|
+
if (existingAttributes) {
|
|
15156
|
+
if (doAttributesDiffer(existingAttributes, parsedAttributes)) {
|
|
15157
|
+
this.log(LOGLEVEL_WARN, logInconsistentImportAttributes(existingAttributes, parsedAttributes, source, this.id), declaration.start);
|
|
15116
15158
|
}
|
|
15117
15159
|
}
|
|
15118
15160
|
else {
|
|
15119
|
-
this.
|
|
15161
|
+
this.sourcesWithAttributes.set(source, parsedAttributes);
|
|
15120
15162
|
}
|
|
15121
15163
|
}
|
|
15122
15164
|
getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
|
|
@@ -15644,8 +15686,8 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
|
|
|
15644
15686
|
}
|
|
15645
15687
|
function getImportBlock(dependencies, { _ }) {
|
|
15646
15688
|
const importBlock = [];
|
|
15647
|
-
for (const { importPath, reexports, imports, name,
|
|
15648
|
-
const assertion =
|
|
15689
|
+
for (const { importPath, reexports, imports, name, attributes } of dependencies) {
|
|
15690
|
+
const assertion = attributes ? `${_}assert${_}${attributes}` : '';
|
|
15649
15691
|
const pathWithAssertion = `'${importPath}'${assertion};`;
|
|
15650
15692
|
if (!reexports && !imports) {
|
|
15651
15693
|
importBlock.push(`import${_}${pathWithAssertion}`);
|
|
@@ -16514,6 +16556,7 @@ class Chunk {
|
|
|
16514
16556
|
this.needsExportsShim = false;
|
|
16515
16557
|
this.preRenderedChunkInfo = null;
|
|
16516
16558
|
this.preliminaryFileName = null;
|
|
16559
|
+
this.preliminarySourcemapFileName = null;
|
|
16517
16560
|
this.renderedChunkInfo = null;
|
|
16518
16561
|
this.renderedDependencies = null;
|
|
16519
16562
|
this.renderedModules = Object.create(null);
|
|
@@ -16588,7 +16631,7 @@ class Chunk {
|
|
|
16588
16631
|
}
|
|
16589
16632
|
return true;
|
|
16590
16633
|
}
|
|
16591
|
-
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
16634
|
+
finalizeChunk(code, map, sourcemapFileName, hashesByPlaceholder) {
|
|
16592
16635
|
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
16593
16636
|
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
16594
16637
|
const preliminaryFileName = renderedChunkInfo.fileName;
|
|
@@ -16606,7 +16649,8 @@ class Chunk {
|
|
|
16606
16649
|
imports: renderedChunkInfo.imports.map(finalize),
|
|
16607
16650
|
map,
|
|
16608
16651
|
preliminaryFileName,
|
|
16609
|
-
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
16652
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize),
|
|
16653
|
+
sourcemapFileName
|
|
16610
16654
|
};
|
|
16611
16655
|
}
|
|
16612
16656
|
generateExports() {
|
|
@@ -16747,6 +16791,30 @@ class Chunk {
|
|
|
16747
16791
|
// Caching is essential to not conflict with the file name reservation above
|
|
16748
16792
|
return (this.preliminaryFileName = { fileName, hashPlaceholder });
|
|
16749
16793
|
}
|
|
16794
|
+
getPreliminarySourcemapFileName() {
|
|
16795
|
+
if (this.preliminarySourcemapFileName) {
|
|
16796
|
+
return this.preliminarySourcemapFileName;
|
|
16797
|
+
}
|
|
16798
|
+
let sourcemapFileName = null;
|
|
16799
|
+
let hashPlaceholder = null;
|
|
16800
|
+
const { sourcemapFileNames, format } = this.outputOptions;
|
|
16801
|
+
if (sourcemapFileNames) {
|
|
16802
|
+
const [pattern, patternName] = [sourcemapFileNames, 'output.sourcemapFileNames'];
|
|
16803
|
+
sourcemapFileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
|
|
16804
|
+
chunkhash: () => this.getPreliminaryFileName().hashPlaceholder || '',
|
|
16805
|
+
format: () => format,
|
|
16806
|
+
hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
|
|
16807
|
+
name: () => this.getChunkName()
|
|
16808
|
+
});
|
|
16809
|
+
if (!hashPlaceholder) {
|
|
16810
|
+
sourcemapFileName = makeUnique(sourcemapFileName, this.bundle);
|
|
16811
|
+
}
|
|
16812
|
+
}
|
|
16813
|
+
else {
|
|
16814
|
+
return null;
|
|
16815
|
+
}
|
|
16816
|
+
return (this.preliminarySourcemapFileName = { fileName: sourcemapFileName, hashPlaceholder });
|
|
16817
|
+
}
|
|
16750
16818
|
getRenderedChunkInfo() {
|
|
16751
16819
|
if (this.renderedChunkInfo) {
|
|
16752
16820
|
return this.renderedChunkInfo;
|
|
@@ -16789,6 +16857,7 @@ class Chunk {
|
|
|
16789
16857
|
}
|
|
16790
16858
|
}
|
|
16791
16859
|
const preliminaryFileName = this.getPreliminaryFileName();
|
|
16860
|
+
const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
|
|
16792
16861
|
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
16793
16862
|
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
16794
16863
|
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
@@ -16842,6 +16911,7 @@ class Chunk {
|
|
|
16842
16911
|
chunk: this,
|
|
16843
16912
|
magicString,
|
|
16844
16913
|
preliminaryFileName,
|
|
16914
|
+
preliminarySourcemapFileName,
|
|
16845
16915
|
usedModules
|
|
16846
16916
|
};
|
|
16847
16917
|
}
|
|
@@ -17039,14 +17109,14 @@ class Chunk {
|
|
|
17039
17109
|
.filter((resolution) => resolution !== this &&
|
|
17040
17110
|
(resolution instanceof Chunk || resolution instanceof ExternalChunk));
|
|
17041
17111
|
}
|
|
17042
|
-
|
|
17112
|
+
getDynamicImportStringAndAttributes(resolution, fileName) {
|
|
17043
17113
|
if (resolution instanceof ExternalModule) {
|
|
17044
17114
|
const chunk = this.externalChunkByModule.get(resolution);
|
|
17045
|
-
return [`'${chunk.getImportPath(fileName)}'`, chunk.
|
|
17115
|
+
return [`'${chunk.getImportPath(fileName)}'`, chunk.getImportAttributes(this.snippets)];
|
|
17046
17116
|
}
|
|
17047
17117
|
return [
|
|
17048
17118
|
resolution || '',
|
|
17049
|
-
(this.outputOptions.format === 'es' && this.outputOptions.
|
|
17119
|
+
(this.outputOptions.format === 'es' && this.outputOptions.externalImportAttributes) || null
|
|
17050
17120
|
];
|
|
17051
17121
|
}
|
|
17052
17122
|
getFallbackChunkName() {
|
|
@@ -17225,7 +17295,7 @@ class Chunk {
|
|
|
17225
17295
|
const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
|
|
17226
17296
|
const importPath = dep.getImportPath(fileName);
|
|
17227
17297
|
renderedDependencies.set(dep, {
|
|
17228
|
-
|
|
17298
|
+
attributes: dep instanceof ExternalChunk ? dep.getImportAttributes(this.snippets) : null,
|
|
17229
17299
|
defaultVariableName: dep.defaultVariableName,
|
|
17230
17300
|
globalName: dep instanceof ExternalChunk &&
|
|
17231
17301
|
(this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
|
|
@@ -17266,6 +17336,7 @@ class Chunk {
|
|
|
17266
17336
|
const accessedGlobals = new Set();
|
|
17267
17337
|
const renderedModuleSources = new Map();
|
|
17268
17338
|
const renderOptions = {
|
|
17339
|
+
accessedDocumentCurrentScript: false,
|
|
17269
17340
|
dynamicImportFunction,
|
|
17270
17341
|
exportNamesByVariable,
|
|
17271
17342
|
format,
|
|
@@ -17282,6 +17353,12 @@ class Chunk {
|
|
|
17282
17353
|
let source;
|
|
17283
17354
|
if (module.isIncluded() || includedNamespaces.has(module)) {
|
|
17284
17355
|
const rendered = module.render(renderOptions);
|
|
17356
|
+
if (!renderOptions.accessedDocumentCurrentScript &&
|
|
17357
|
+
formatsMaybeAccessDocumentCurrentScript.includes(format)) {
|
|
17358
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
17359
|
+
this.accessedGlobalsByScope.get(module.scope)?.delete(DOCUMENT_CURRENT_SCRIPT);
|
|
17360
|
+
}
|
|
17361
|
+
renderOptions.accessedDocumentCurrentScript = false;
|
|
17285
17362
|
({ source } = rendered);
|
|
17286
17363
|
usesTopLevelAwait || (usesTopLevelAwait = rendered.usesTopLevelAwait);
|
|
17287
17364
|
renderedLength = source.length();
|
|
@@ -17344,8 +17421,8 @@ class Chunk {
|
|
|
17344
17421
|
}
|
|
17345
17422
|
else {
|
|
17346
17423
|
const { node, resolution } = resolvedDynamicImport;
|
|
17347
|
-
const [resolutionString,
|
|
17348
|
-
node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false,
|
|
17424
|
+
const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName);
|
|
17425
|
+
node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
|
|
17349
17426
|
}
|
|
17350
17427
|
}
|
|
17351
17428
|
}
|
|
@@ -18422,8 +18499,8 @@ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
|
|
|
18422
18499
|
timeEnd('render chunks', 2);
|
|
18423
18500
|
timeStart('transform chunks', 2);
|
|
18424
18501
|
const chunkGraph = getChunkGraph(chunks);
|
|
18425
|
-
const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
|
|
18426
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
|
|
18502
|
+
const { initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
|
|
18503
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle);
|
|
18427
18504
|
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
18428
18505
|
timeEnd('transform chunks', 2);
|
|
18429
18506
|
}
|
|
@@ -18507,18 +18584,20 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
18507
18584
|
const nonHashedChunksWithPlaceholders = [];
|
|
18508
18585
|
const renderedChunksByPlaceholder = new Map();
|
|
18509
18586
|
const hashDependenciesByPlaceholder = new Map();
|
|
18587
|
+
const initialHashesByPlaceholder = new Map();
|
|
18510
18588
|
const placeholders = new Set();
|
|
18511
18589
|
for (const { preliminaryFileName: { hashPlaceholder } } of renderedChunks) {
|
|
18512
18590
|
if (hashPlaceholder)
|
|
18513
18591
|
placeholders.add(hashPlaceholder);
|
|
18514
18592
|
}
|
|
18515
|
-
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, magicString, usedModules }) => {
|
|
18593
|
+
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, preliminarySourcemapFileName, magicString, usedModules }) => {
|
|
18516
18594
|
const transformedChunk = {
|
|
18517
18595
|
chunk,
|
|
18518
18596
|
fileName,
|
|
18597
|
+
sourcemapFileName: preliminarySourcemapFileName?.fileName ?? null,
|
|
18519
18598
|
...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
|
|
18520
18599
|
};
|
|
18521
|
-
const { code } = transformedChunk;
|
|
18600
|
+
const { code, map } = transformedChunk;
|
|
18522
18601
|
if (hashPlaceholder) {
|
|
18523
18602
|
// To create a reproducible content-only hash, all placeholders are
|
|
18524
18603
|
// replaced with the same value before hashing
|
|
@@ -18542,15 +18621,23 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
18542
18621
|
else {
|
|
18543
18622
|
nonHashedChunksWithPlaceholders.push(transformedChunk);
|
|
18544
18623
|
}
|
|
18624
|
+
const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
|
|
18625
|
+
if (map && sourcemapHashPlaceholder) {
|
|
18626
|
+
initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, createHash()
|
|
18627
|
+
.update(map.toString())
|
|
18628
|
+
.digest('hex')
|
|
18629
|
+
.slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
|
|
18630
|
+
}
|
|
18545
18631
|
}));
|
|
18546
18632
|
return {
|
|
18547
18633
|
hashDependenciesByPlaceholder,
|
|
18634
|
+
initialHashesByPlaceholder,
|
|
18548
18635
|
nonHashedChunksWithPlaceholders,
|
|
18549
18636
|
renderedChunksByPlaceholder
|
|
18550
18637
|
};
|
|
18551
18638
|
}
|
|
18552
|
-
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
|
|
18553
|
-
const hashesByPlaceholder = new Map();
|
|
18639
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
|
|
18640
|
+
const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
|
|
18554
18641
|
for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
|
|
18555
18642
|
let hash = createHash();
|
|
18556
18643
|
const hashDependencyPlaceholders = new Set([placeholder]);
|
|
@@ -18578,21 +18665,29 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
18578
18665
|
return hashesByPlaceholder;
|
|
18579
18666
|
}
|
|
18580
18667
|
function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
|
|
18581
|
-
for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
|
|
18668
|
+
for (const { chunk, code, fileName, sourcemapFileName, map } of renderedChunksByPlaceholder.values()) {
|
|
18582
18669
|
let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
|
|
18583
18670
|
const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
|
|
18671
|
+
let finalSourcemapFileName = null;
|
|
18584
18672
|
if (map) {
|
|
18673
|
+
finalSourcemapFileName = sourcemapFileName
|
|
18674
|
+
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
18675
|
+
: `${finalFileName}.map`;
|
|
18585
18676
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
18586
|
-
updatedCode += emitSourceMapAndGetComment(
|
|
18677
|
+
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
18587
18678
|
}
|
|
18588
|
-
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
18679
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
18589
18680
|
}
|
|
18590
|
-
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
18681
|
+
for (const { chunk, code, fileName, sourcemapFileName, map } of nonHashedChunksWithPlaceholders) {
|
|
18591
18682
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
18683
|
+
let finalSourcemapFileName = null;
|
|
18592
18684
|
if (map) {
|
|
18593
|
-
|
|
18685
|
+
finalSourcemapFileName = sourcemapFileName
|
|
18686
|
+
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
18687
|
+
: `${fileName}.map`;
|
|
18688
|
+
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
18594
18689
|
}
|
|
18595
|
-
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
18690
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
18596
18691
|
}
|
|
18597
18692
|
}
|
|
18598
18693
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -18601,11 +18696,11 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
|
|
|
18601
18696
|
url = map.toUrl();
|
|
18602
18697
|
}
|
|
18603
18698
|
else {
|
|
18604
|
-
const sourcemapFileName =
|
|
18699
|
+
const sourcemapFileName = basename(fileName);
|
|
18605
18700
|
url = sourcemapBaseUrl
|
|
18606
18701
|
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
18607
18702
|
: sourcemapFileName;
|
|
18608
|
-
pluginDriver.emitFile({ fileName
|
|
18703
|
+
pluginDriver.emitFile({ fileName, source: map.toString(), type: 'asset' });
|
|
18609
18704
|
}
|
|
18610
18705
|
return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
|
|
18611
18706
|
}
|
|
@@ -18828,7 +18923,7 @@ function flru (max) {
|
|
|
18828
18923
|
};
|
|
18829
18924
|
}
|
|
18830
18925
|
|
|
18831
|
-
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
18926
|
+
function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
18832
18927
|
let skipped = null;
|
|
18833
18928
|
let replaceContext = null;
|
|
18834
18929
|
if (skip) {
|
|
@@ -18840,14 +18935,14 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
18840
18935
|
}
|
|
18841
18936
|
replaceContext = (pluginContext, plugin) => ({
|
|
18842
18937
|
...pluginContext,
|
|
18843
|
-
resolve: (source, importer, {
|
|
18938
|
+
resolve: (source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
18844
18939
|
});
|
|
18845
18940
|
}
|
|
18846
|
-
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, {
|
|
18941
|
+
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { attributes, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
18847
18942
|
}
|
|
18848
18943
|
|
|
18849
|
-
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
18850
|
-
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry,
|
|
18944
|
+
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes) {
|
|
18945
|
+
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, attributes);
|
|
18851
18946
|
if (pluginResult != null) {
|
|
18852
18947
|
const [resolveIdResult, plugin] = pluginResult;
|
|
18853
18948
|
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
@@ -19259,9 +19354,9 @@ class ModuleLoader {
|
|
|
19259
19354
|
this.modulesWithLoadedDependencies = new Set();
|
|
19260
19355
|
this.nextChunkNamePriority = 0;
|
|
19261
19356
|
this.nextEntryModuleIndex = 0;
|
|
19262
|
-
this.resolveId = async (source, importer, customOptions, isEntry,
|
|
19357
|
+
this.resolveId = async (source, importer, customOptions, isEntry, attributes, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
|
|
19263
19358
|
? false
|
|
19264
|
-
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer,
|
|
19359
|
+
: await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, attributes), importer, source), attributes);
|
|
19265
19360
|
this.hasModuleSideEffects = options.treeshake
|
|
19266
19361
|
? options.treeshake.moduleSideEffects
|
|
19267
19362
|
: () => true;
|
|
@@ -19421,11 +19516,11 @@ class ModuleLoader {
|
|
|
19421
19516
|
// Otherwise, if the module does not exist, it waits for the module and all
|
|
19422
19517
|
// its dependencies to be loaded.
|
|
19423
19518
|
// Otherwise, it returns immediately.
|
|
19424
|
-
async fetchModule({
|
|
19519
|
+
async fetchModule({ attributes, id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
|
|
19425
19520
|
const existingModule = this.modulesById.get(id);
|
|
19426
19521
|
if (existingModule instanceof Module) {
|
|
19427
|
-
if (importer &&
|
|
19428
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
19522
|
+
if (importer && doAttributesDiffer(attributes, existingModule.info.attributes)) {
|
|
19523
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(existingModule.info.attributes, attributes, id, importer));
|
|
19429
19524
|
}
|
|
19430
19525
|
await this.handleExistingModule(existingModule, isEntry, isPreload);
|
|
19431
19526
|
return existingModule;
|
|
@@ -19433,7 +19528,7 @@ class ModuleLoader {
|
|
|
19433
19528
|
if (existingModule instanceof ExternalModule) {
|
|
19434
19529
|
return error(logExternalModulesCannotBeTransformedToModules(existingModule.id));
|
|
19435
19530
|
}
|
|
19436
|
-
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta,
|
|
19531
|
+
const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta, attributes);
|
|
19437
19532
|
this.modulesById.set(id, module);
|
|
19438
19533
|
this.graph.watchFiles[id] = true;
|
|
19439
19534
|
const loadPromise = this.addModuleSource(id, importer, module).then(() => [
|
|
@@ -19470,17 +19565,17 @@ class ModuleLoader {
|
|
|
19470
19565
|
}
|
|
19471
19566
|
fetchResolvedDependency(source, importer, resolvedId) {
|
|
19472
19567
|
if (resolvedId.external) {
|
|
19473
|
-
const {
|
|
19568
|
+
const { attributes, external, id, moduleSideEffects, meta } = resolvedId;
|
|
19474
19569
|
let externalModule = this.modulesById.get(id);
|
|
19475
19570
|
if (!externalModule) {
|
|
19476
|
-
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id),
|
|
19571
|
+
externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id), attributes);
|
|
19477
19572
|
this.modulesById.set(id, externalModule);
|
|
19478
19573
|
}
|
|
19479
19574
|
else if (!(externalModule instanceof ExternalModule)) {
|
|
19480
19575
|
return error(logInternalIdCannotBeExternal(source, importer));
|
|
19481
19576
|
}
|
|
19482
|
-
else if (
|
|
19483
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
19577
|
+
else if (doAttributesDiffer(externalModule.info.attributes, attributes)) {
|
|
19578
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(externalModule.info.attributes, attributes, source, importer));
|
|
19484
19579
|
}
|
|
19485
19580
|
return Promise.resolve(externalModule);
|
|
19486
19581
|
}
|
|
@@ -19539,7 +19634,7 @@ class ModuleLoader {
|
|
|
19539
19634
|
return module.dynamicImports.map(async (dynamicImport) => {
|
|
19540
19635
|
const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
|
|
19541
19636
|
? dynamicImport.argument
|
|
19542
|
-
: dynamicImport.argument.esTreeNode, module.id,
|
|
19637
|
+
: dynamicImport.argument.esTreeNode, module.id, getAttributesFromImportExpression(dynamicImport.node));
|
|
19543
19638
|
if (resolvedId && typeof resolvedId === 'object') {
|
|
19544
19639
|
dynamicImport.id = resolvedId.id;
|
|
19545
19640
|
}
|
|
@@ -19548,20 +19643,20 @@ class ModuleLoader {
|
|
|
19548
19643
|
}
|
|
19549
19644
|
getResolveStaticDependencyPromises(module) {
|
|
19550
19645
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
19551
|
-
return Array.from(module.
|
|
19646
|
+
return Array.from(module.sourcesWithAttributes, async ([source, attributes]) => [
|
|
19552
19647
|
source,
|
|
19553
19648
|
(module.resolvedIds[source] =
|
|
19554
19649
|
module.resolvedIds[source] ||
|
|
19555
|
-
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false,
|
|
19650
|
+
this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes), source, module.id, attributes))
|
|
19556
19651
|
]);
|
|
19557
19652
|
}
|
|
19558
|
-
getResolvedIdWithDefaults(resolvedId,
|
|
19653
|
+
getResolvedIdWithDefaults(resolvedId, attributes) {
|
|
19559
19654
|
if (!resolvedId) {
|
|
19560
19655
|
return null;
|
|
19561
19656
|
}
|
|
19562
19657
|
const external = resolvedId.external || false;
|
|
19563
19658
|
return {
|
|
19564
|
-
|
|
19659
|
+
attributes: resolvedId.attributes || attributes,
|
|
19565
19660
|
external,
|
|
19566
19661
|
id: resolvedId.id,
|
|
19567
19662
|
meta: resolvedId.meta || {},
|
|
@@ -19587,14 +19682,14 @@ class ModuleLoader {
|
|
|
19587
19682
|
}
|
|
19588
19683
|
return this.fetchModuleDependencies(module, ...(await loadPromise));
|
|
19589
19684
|
}
|
|
19590
|
-
handleInvalidResolvedId(resolvedId, source, importer,
|
|
19685
|
+
handleInvalidResolvedId(resolvedId, source, importer, attributes) {
|
|
19591
19686
|
if (resolvedId === null) {
|
|
19592
19687
|
if (isRelative(source)) {
|
|
19593
19688
|
return error(logUnresolvedImport(source, importer));
|
|
19594
19689
|
}
|
|
19595
19690
|
this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer));
|
|
19596
19691
|
return {
|
|
19597
|
-
|
|
19692
|
+
attributes,
|
|
19598
19693
|
external: true,
|
|
19599
19694
|
id: source,
|
|
19600
19695
|
meta: {},
|
|
@@ -19627,11 +19722,11 @@ class ModuleLoader {
|
|
|
19627
19722
|
? resolveIdResult
|
|
19628
19723
|
: { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
|
|
19629
19724
|
}
|
|
19630
|
-
async resolveDynamicImport(module, specifier, importer,
|
|
19725
|
+
async resolveDynamicImport(module, specifier, importer, attributes) {
|
|
19631
19726
|
const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
19632
19727
|
specifier,
|
|
19633
19728
|
importer,
|
|
19634
|
-
{
|
|
19729
|
+
{ attributes }
|
|
19635
19730
|
]);
|
|
19636
19731
|
if (typeof specifier !== 'string') {
|
|
19637
19732
|
if (typeof resolution === 'string') {
|
|
@@ -19640,19 +19735,19 @@ class ModuleLoader {
|
|
|
19640
19735
|
if (!resolution) {
|
|
19641
19736
|
return null;
|
|
19642
19737
|
}
|
|
19643
|
-
return this.getResolvedIdWithDefaults(resolution,
|
|
19738
|
+
return this.getResolvedIdWithDefaults(resolution, attributes);
|
|
19644
19739
|
}
|
|
19645
19740
|
if (resolution == null) {
|
|
19646
19741
|
const existingResolution = module.resolvedIds[specifier];
|
|
19647
19742
|
if (existingResolution) {
|
|
19648
|
-
if (
|
|
19649
|
-
this.options.onLog(LOGLEVEL_WARN,
|
|
19743
|
+
if (doAttributesDiffer(existingResolution.attributes, attributes)) {
|
|
19744
|
+
this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAttributes(existingResolution.attributes, attributes, specifier, importer));
|
|
19650
19745
|
}
|
|
19651
19746
|
return existingResolution;
|
|
19652
19747
|
}
|
|
19653
|
-
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false,
|
|
19748
|
+
return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes), specifier, module.id, attributes));
|
|
19654
19749
|
}
|
|
19655
|
-
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier),
|
|
19750
|
+
return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), attributes), specifier, importer, attributes);
|
|
19656
19751
|
}
|
|
19657
19752
|
}
|
|
19658
19753
|
function normalizeRelativeExternalId(source, importer) {
|
|
@@ -19888,6 +19983,7 @@ class FileEmitter {
|
|
|
19888
19983
|
name: prebuiltChunk.fileName,
|
|
19889
19984
|
preliminaryFileName: prebuiltChunk.fileName,
|
|
19890
19985
|
referencedFiles: [],
|
|
19986
|
+
sourcemapFileName: prebuiltChunk.sourcemapFileName || null,
|
|
19891
19987
|
type: 'chunk'
|
|
19892
19988
|
};
|
|
19893
19989
|
}
|
|
@@ -20104,8 +20200,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
20104
20200
|
return wrappedModuleIds();
|
|
20105
20201
|
},
|
|
20106
20202
|
parse: graph.contextParse.bind(graph),
|
|
20107
|
-
resolve(source, importer, {
|
|
20108
|
-
return graph.moduleLoader.resolveId(source, importer, custom, isEntry,
|
|
20203
|
+
resolve(source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) {
|
|
20204
|
+
return graph.moduleLoader.resolveId(source, importer, custom, isEntry, attributes || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
|
|
20109
20205
|
},
|
|
20110
20206
|
setAssetSource: fileEmitter.setAssetSource,
|
|
20111
20207
|
warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
|
|
@@ -20869,6 +20965,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
20869
20965
|
const file = getFile(config, preserveModules, inputOptions);
|
|
20870
20966
|
const preferConst = getPreferConst(config, inputOptions);
|
|
20871
20967
|
const generatedCode = getGeneratedCode(config, preferConst);
|
|
20968
|
+
const externalImportAttributes = getExternalImportAttributes(config, inputOptions);
|
|
20872
20969
|
const outputOptions = {
|
|
20873
20970
|
amd: getAmd(config),
|
|
20874
20971
|
assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
|
|
@@ -20884,7 +20981,8 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
20884
20981
|
experimentalMinChunkSize: config.experimentalMinChunkSize ?? 1,
|
|
20885
20982
|
exports: getExports(config, unsetOptions),
|
|
20886
20983
|
extend: config.extend || false,
|
|
20887
|
-
externalImportAssertions:
|
|
20984
|
+
externalImportAssertions: externalImportAttributes,
|
|
20985
|
+
externalImportAttributes,
|
|
20888
20986
|
externalLiveBindings: config.externalLiveBindings ?? true,
|
|
20889
20987
|
file,
|
|
20890
20988
|
footer: getAddon(config, 'footer'),
|
|
@@ -20917,6 +21015,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
20917
21015
|
sourcemapBaseUrl: getSourcemapBaseUrl(config),
|
|
20918
21016
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
20919
21017
|
sourcemapFile: config.sourcemapFile,
|
|
21018
|
+
sourcemapFileNames: getSourcemapFileNames(config, unsetOptions),
|
|
20920
21019
|
sourcemapIgnoreList: typeof config.sourcemapIgnoreList === 'function'
|
|
20921
21020
|
? config.sourcemapIgnoreList
|
|
20922
21021
|
: config.sourcemapIgnoreList === false
|
|
@@ -21079,6 +21178,12 @@ function getExports(config, unsetOptions) {
|
|
|
21079
21178
|
}
|
|
21080
21179
|
return configExports || 'auto';
|
|
21081
21180
|
}
|
|
21181
|
+
const getExternalImportAttributes = (config, inputOptions) => {
|
|
21182
|
+
if (config.externalImportAssertions != undefined) {
|
|
21183
|
+
warnDeprecation(`The "output.externalImportAssertions" option is deprecated. Use the "output.externalImportAttributes" option instead.`, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, true, inputOptions);
|
|
21184
|
+
}
|
|
21185
|
+
return config.externalImportAttributes ?? config.externalImportAssertions ?? true;
|
|
21186
|
+
};
|
|
21082
21187
|
const getGeneratedCode = (config, preferConst) => {
|
|
21083
21188
|
const configWithPreset = getOptionWithPreset(config.generatedCode, generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '');
|
|
21084
21189
|
return {
|
|
@@ -21145,6 +21250,13 @@ const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
|
21145
21250
|
}
|
|
21146
21251
|
return generatedCode.symbols || false;
|
|
21147
21252
|
};
|
|
21253
|
+
const getSourcemapFileNames = (config, unsetOptions) => {
|
|
21254
|
+
const configSourcemapFileNames = config.sourcemapFileNames;
|
|
21255
|
+
if (configSourcemapFileNames == null) {
|
|
21256
|
+
unsetOptions.add('sourcemapFileNames');
|
|
21257
|
+
}
|
|
21258
|
+
return configSourcemapFileNames;
|
|
21259
|
+
};
|
|
21148
21260
|
const getSourcemapBaseUrl = (config) => {
|
|
21149
21261
|
const { sourcemapBaseUrl } = config;
|
|
21150
21262
|
if (sourcemapBaseUrl) {
|
|
@@ -21607,6 +21719,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
21607
21719
|
exports: getOption('exports'),
|
|
21608
21720
|
extend: getOption('extend'),
|
|
21609
21721
|
externalImportAssertions: getOption('externalImportAssertions'),
|
|
21722
|
+
externalImportAttributes: getOption('externalImportAttributes'),
|
|
21610
21723
|
externalLiveBindings: getOption('externalLiveBindings'),
|
|
21611
21724
|
file: getOption('file'),
|
|
21612
21725
|
footer: getOption('footer'),
|
|
@@ -21635,6 +21748,7 @@ async function mergeOutputOptions(config, overrides, log) {
|
|
|
21635
21748
|
sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
|
|
21636
21749
|
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
|
21637
21750
|
sourcemapFile: getOption('sourcemapFile'),
|
|
21751
|
+
sourcemapFileNames: getOption('sourcemapFileNames'),
|
|
21638
21752
|
sourcemapIgnoreList: getOption('sourcemapIgnoreList'),
|
|
21639
21753
|
sourcemapPathTransform: getOption('sourcemapPathTransform'),
|
|
21640
21754
|
strict: getOption('strict'),
|