rollup 4.62.5 → 4.63.1
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/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +123 -55
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- 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/parseAst.js +2 -2
- package/dist/shared/rollup.js +123 -55
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +38 -38
package/dist/bin/rollup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
3
|
@license
|
|
4
|
-
Rollup.js v4.
|
|
5
|
-
|
|
4
|
+
Rollup.js v4.63.1
|
|
5
|
+
Fri, 28 Aug 2026 05:58:50 GMT - commit 78bfef0cb94479566f81012fafa372c84b90bd34
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ require('node:perf_hooks');
|
|
|
27
27
|
require('node:url');
|
|
28
28
|
require('../getLogFilter.js');
|
|
29
29
|
|
|
30
|
-
const help = "rollup version 4.
|
|
30
|
+
const help = "rollup version 4.63.1\n=====================================\n\nUsage: rollup [options] <entry file>\n\nOptions:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, Rollup will try to load configuration files in\n the following order:\n rollup.config.mjs -> rollup.config.cjs -> rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAttributes Omit import attributes in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--filterLogs <filter> Filter log messages\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--forceExit Force exit the process when done\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--hashCharacters <name> Use the specified character set for file hashes\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--importAttributesKey <name> Use the specified keyword for import attributes\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--logLevel <level> Which kind of logs to display\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapDebugIds Emit unique debug ids in source and sourcemaps\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.allowInputInsideOutputPath Whether the input path is allowed to be a\n subpath of the output path\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
package/dist/es/getLogFilter.js
CHANGED
package/dist/es/parseAst.js
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.1
|
|
4
|
+
Fri, 28 Aug 2026 05:58:50 GMT - commit 78bfef0cb94479566f81012fafa372c84b90bd34
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.
|
|
30
|
+
var version = "4.63.1";
|
|
31
31
|
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
@@ -344,13 +344,27 @@ var Chunk$1 = class Chunk {
|
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
//#endregion
|
|
347
|
+
//#region src/MagicStringError.ts
|
|
348
|
+
/**
|
|
349
|
+
* The single error type thrown by MagicString.
|
|
350
|
+
*
|
|
351
|
+
* Every message is prefixed with `[MagicString]` so its source is obvious at a
|
|
352
|
+
* glance, and is kept short and consistent in tone.
|
|
353
|
+
*/
|
|
354
|
+
var MagicStringError = class extends Error {
|
|
355
|
+
name = "MagicStringError";
|
|
356
|
+
constructor(message, options) {
|
|
357
|
+
super(`[MagicString] ${message}`, options);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
//#endregion
|
|
347
361
|
//#region src/SourceMap.ts
|
|
348
362
|
function getBtoa() {
|
|
349
363
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
350
364
|
const buffer = globalThis["Buffer"];
|
|
351
365
|
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
352
366
|
return () => {
|
|
353
|
-
throw new
|
|
367
|
+
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
354
368
|
};
|
|
355
369
|
}
|
|
356
370
|
const btoa = /* #__PURE__ */ getBtoa();
|
|
@@ -579,11 +593,11 @@ var MagicString = class MagicString {
|
|
|
579
593
|
},
|
|
580
594
|
byStart: {
|
|
581
595
|
writable: true,
|
|
582
|
-
value:
|
|
596
|
+
value: /* @__PURE__ */ new Map([[0, chunk]])
|
|
583
597
|
},
|
|
584
598
|
byEnd: {
|
|
585
599
|
writable: true,
|
|
586
|
-
value:
|
|
600
|
+
value: /* @__PURE__ */ new Map([[string.length, chunk]])
|
|
587
601
|
},
|
|
588
602
|
filename: {
|
|
589
603
|
writable: true,
|
|
@@ -612,10 +626,12 @@ var MagicString = class MagicString {
|
|
|
612
626
|
offset: {
|
|
613
627
|
writable: true,
|
|
614
628
|
value: options.offset || 0
|
|
629
|
+
},
|
|
630
|
+
hasMovedChunks: {
|
|
631
|
+
writable: true,
|
|
632
|
+
value: false
|
|
615
633
|
}
|
|
616
634
|
});
|
|
617
|
-
this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
|
|
618
|
-
this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
|
|
619
635
|
}
|
|
620
636
|
/**
|
|
621
637
|
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
@@ -627,7 +643,7 @@ var MagicString = class MagicString {
|
|
|
627
643
|
* Appends the specified content to the end of the string.
|
|
628
644
|
*/
|
|
629
645
|
append(content) {
|
|
630
|
-
if (typeof content !== "string") throw new
|
|
646
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
631
647
|
this.outro += content;
|
|
632
648
|
return this;
|
|
633
649
|
}
|
|
@@ -638,7 +654,7 @@ var MagicString = class MagicString {
|
|
|
638
654
|
*/
|
|
639
655
|
appendLeft(index, content) {
|
|
640
656
|
index = index + this.offset;
|
|
641
|
-
if (typeof content !== "string") throw new
|
|
657
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
642
658
|
this._split(index);
|
|
643
659
|
const chunk = this.byEnd.get(index);
|
|
644
660
|
if (chunk) chunk.appendLeft(content);
|
|
@@ -652,7 +668,7 @@ var MagicString = class MagicString {
|
|
|
652
668
|
*/
|
|
653
669
|
appendRight(index, content) {
|
|
654
670
|
index = index + this.offset;
|
|
655
|
-
if (typeof content !== "string") throw new
|
|
671
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
656
672
|
this._split(index);
|
|
657
673
|
const chunk = this.byStart.get(index);
|
|
658
674
|
if (chunk) chunk.appendRight(content);
|
|
@@ -665,6 +681,7 @@ var MagicString = class MagicString {
|
|
|
665
681
|
clone() {
|
|
666
682
|
const cloned = new MagicString(this.original, {
|
|
667
683
|
filename: this.filename,
|
|
684
|
+
ignoreList: this.ignoreList,
|
|
668
685
|
offset: this.offset
|
|
669
686
|
});
|
|
670
687
|
let originalChunk = this.firstChunk;
|
|
@@ -684,8 +701,10 @@ var MagicString = class MagicString {
|
|
|
684
701
|
cloned.lastChunk = clonedChunk;
|
|
685
702
|
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
686
703
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
704
|
+
cloned.storedNames = { ...this.storedNames };
|
|
687
705
|
cloned.intro = this.intro;
|
|
688
706
|
cloned.outro = this.outro;
|
|
707
|
+
cloned.hasMovedChunks = this.hasMovedChunks;
|
|
689
708
|
return cloned;
|
|
690
709
|
}
|
|
691
710
|
/**
|
|
@@ -814,7 +833,7 @@ var MagicString = class MagicString {
|
|
|
814
833
|
}
|
|
815
834
|
/** @internal */
|
|
816
835
|
insert() {
|
|
817
|
-
throw new
|
|
836
|
+
throw new MagicStringError("insert() is deprecated, use appendLeft() or prependRight()");
|
|
818
837
|
}
|
|
819
838
|
/** @internal */
|
|
820
839
|
insertLeft(index, content) {
|
|
@@ -840,12 +859,19 @@ var MagicString = class MagicString {
|
|
|
840
859
|
end = end + this.offset;
|
|
841
860
|
index = index + this.offset;
|
|
842
861
|
if (start === end) return this;
|
|
843
|
-
if (index >= start && index <= end) throw new
|
|
862
|
+
if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
|
|
844
863
|
this._split(start);
|
|
845
864
|
this._split(end);
|
|
846
865
|
this._split(index);
|
|
847
866
|
const first = this.byStart.get(start);
|
|
848
867
|
const last = this.byEnd.get(end);
|
|
868
|
+
if (this.hasMovedChunks) {
|
|
869
|
+
let cursor = first;
|
|
870
|
+
while (cursor !== last) {
|
|
871
|
+
cursor = cursor.next;
|
|
872
|
+
if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
849
875
|
const oldLeft = first.previous;
|
|
850
876
|
const oldRight = last.next;
|
|
851
877
|
const newRight = this.byStart.get(index);
|
|
@@ -864,6 +890,7 @@ var MagicString = class MagicString {
|
|
|
864
890
|
last.next = newRight || null;
|
|
865
891
|
if (!newLeft) this.firstChunk = first;
|
|
866
892
|
if (!newRight) this.lastChunk = last;
|
|
893
|
+
this.hasMovedChunks = true;
|
|
867
894
|
return this;
|
|
868
895
|
}
|
|
869
896
|
/**
|
|
@@ -893,13 +920,15 @@ var MagicString = class MagicString {
|
|
|
893
920
|
update(start, end, content, options) {
|
|
894
921
|
start = start + this.offset;
|
|
895
922
|
end = end + this.offset;
|
|
896
|
-
if (typeof content !== "string") throw new
|
|
923
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
897
924
|
if (this.original.length !== 0) {
|
|
898
925
|
while (start < 0) start += this.original.length;
|
|
899
926
|
while (end < 0) end += this.original.length;
|
|
900
927
|
}
|
|
901
|
-
if (
|
|
902
|
-
if (
|
|
928
|
+
if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
|
|
929
|
+
if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
|
|
930
|
+
if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
|
|
931
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
903
932
|
this._split(start);
|
|
904
933
|
this._split(end);
|
|
905
934
|
if (options === true) {
|
|
@@ -925,7 +954,7 @@ var MagicString = class MagicString {
|
|
|
925
954
|
if (first) {
|
|
926
955
|
let chunk = first;
|
|
927
956
|
while (chunk !== last) {
|
|
928
|
-
if (chunk.next !== this.byStart.get(chunk.end)) throw new
|
|
957
|
+
if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
|
|
929
958
|
chunk = chunk.next;
|
|
930
959
|
chunk.edit("", false);
|
|
931
960
|
}
|
|
@@ -941,7 +970,7 @@ var MagicString = class MagicString {
|
|
|
941
970
|
* Prepends the string with the specified content.
|
|
942
971
|
*/
|
|
943
972
|
prepend(content) {
|
|
944
|
-
if (typeof content !== "string") throw new
|
|
973
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
945
974
|
this.intro = content + this.intro;
|
|
946
975
|
return this;
|
|
947
976
|
}
|
|
@@ -950,7 +979,7 @@ var MagicString = class MagicString {
|
|
|
950
979
|
*/
|
|
951
980
|
prependLeft(index, content) {
|
|
952
981
|
index = index + this.offset;
|
|
953
|
-
if (typeof content !== "string") throw new
|
|
982
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
954
983
|
this._split(index);
|
|
955
984
|
const chunk = this.byEnd.get(index);
|
|
956
985
|
if (chunk) chunk.prependLeft(content);
|
|
@@ -962,7 +991,7 @@ var MagicString = class MagicString {
|
|
|
962
991
|
*/
|
|
963
992
|
prependRight(index, content) {
|
|
964
993
|
index = index + this.offset;
|
|
965
|
-
if (typeof content !== "string") throw new
|
|
994
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
966
995
|
this._split(index);
|
|
967
996
|
const chunk = this.byStart.get(index);
|
|
968
997
|
if (chunk) chunk.prependRight(content);
|
|
@@ -981,8 +1010,8 @@ var MagicString = class MagicString {
|
|
|
981
1010
|
while (end < 0) end += this.original.length;
|
|
982
1011
|
}
|
|
983
1012
|
if (start === end) return this;
|
|
984
|
-
if (start < 0 || end > this.original.length) throw new
|
|
985
|
-
if (start > end) throw new
|
|
1013
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
1014
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
986
1015
|
this._split(start);
|
|
987
1016
|
this._split(end);
|
|
988
1017
|
let chunk = this.byStart.get(start);
|
|
@@ -1005,8 +1034,8 @@ var MagicString = class MagicString {
|
|
|
1005
1034
|
while (end < 0) end += this.original.length;
|
|
1006
1035
|
}
|
|
1007
1036
|
if (start === end) return this;
|
|
1008
|
-
if (start < 0 || end > this.original.length) throw new
|
|
1009
|
-
if (start > end) throw new
|
|
1037
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
1038
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
1010
1039
|
this._split(start);
|
|
1011
1040
|
this._split(end);
|
|
1012
1041
|
let chunk = this.byStart.get(start);
|
|
@@ -1072,12 +1101,12 @@ var MagicString = class MagicString {
|
|
|
1072
1101
|
if (chunk.start < end && chunk.end >= end) return result;
|
|
1073
1102
|
chunk = chunk.next;
|
|
1074
1103
|
}
|
|
1075
|
-
if (chunk && chunk.edited && chunk.start !== start) throw new
|
|
1104
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
1076
1105
|
const startChunk = chunk;
|
|
1077
1106
|
while (chunk) {
|
|
1078
1107
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
1079
1108
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1080
|
-
if (containsEnd && chunk.edited && chunk.end !== end) throw new
|
|
1109
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
1081
1110
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1082
1111
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1083
1112
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
@@ -1113,7 +1142,7 @@ var MagicString = class MagicString {
|
|
|
1113
1142
|
_splitChunk(chunk, index) {
|
|
1114
1143
|
if (chunk.edited && chunk.content.length) {
|
|
1115
1144
|
const loc = getLocator(this.original)(index);
|
|
1116
|
-
throw new
|
|
1145
|
+
throw new MagicStringError(`cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
1117
1146
|
}
|
|
1118
1147
|
const newChunk = chunk.split(index);
|
|
1119
1148
|
this.byEnd.set(index, chunk);
|
|
@@ -1225,7 +1254,19 @@ var MagicString = class MagicString {
|
|
|
1225
1254
|
* Indicates if the string has been changed.
|
|
1226
1255
|
*/
|
|
1227
1256
|
hasChanged() {
|
|
1228
|
-
|
|
1257
|
+
if (this.intro || this.outro) return true;
|
|
1258
|
+
let outputIndex = 0;
|
|
1259
|
+
let chunk = this.firstChunk;
|
|
1260
|
+
while (chunk) {
|
|
1261
|
+
if (chunk.intro || chunk.outro) return true;
|
|
1262
|
+
if (!chunk.edited && chunk.start === outputIndex) outputIndex = chunk.end;
|
|
1263
|
+
else {
|
|
1264
|
+
if (!this.original.startsWith(chunk.content, outputIndex)) return true;
|
|
1265
|
+
outputIndex += chunk.content.length;
|
|
1266
|
+
}
|
|
1267
|
+
chunk = chunk.next;
|
|
1268
|
+
}
|
|
1269
|
+
return outputIndex !== this.original.length;
|
|
1229
1270
|
}
|
|
1230
1271
|
/** @internal */
|
|
1231
1272
|
_replaceRegexp(searchValue, replacement) {
|
|
@@ -1295,7 +1336,7 @@ var MagicString = class MagicString {
|
|
|
1295
1336
|
*/
|
|
1296
1337
|
replaceAll(searchValue, replacement) {
|
|
1297
1338
|
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
1298
|
-
if (!searchValue.global) throw new
|
|
1339
|
+
if (!searchValue.global) throw new MagicStringError("replaceAll() requires a global RegExp");
|
|
1299
1340
|
return this._replaceRegexp(searchValue, replacement);
|
|
1300
1341
|
}
|
|
1301
1342
|
};
|
|
@@ -1326,7 +1367,7 @@ var Bundle$1 = class Bundle {
|
|
|
1326
1367
|
filename: source.filename,
|
|
1327
1368
|
separator: this.separator
|
|
1328
1369
|
});
|
|
1329
|
-
if (!isObject(source) || !source.content) throw new
|
|
1370
|
+
if (!isObject(source) || !source.content) throw new MagicStringError("addSource() requires a `content` property that is a MagicString");
|
|
1330
1371
|
[
|
|
1331
1372
|
"filename",
|
|
1332
1373
|
"ignoreList",
|
|
@@ -1344,7 +1385,7 @@ var Bundle$1 = class Bundle {
|
|
|
1344
1385
|
});
|
|
1345
1386
|
} else {
|
|
1346
1387
|
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1347
|
-
if (source.content.original !== uniqueSource.content) throw new
|
|
1388
|
+
if (source.content.original !== uniqueSource.content) throw new MagicStringError(`duplicate filename "${source.filename}" with different content, use unique filenames`);
|
|
1348
1389
|
}
|
|
1349
1390
|
this.sources.push(source);
|
|
1350
1391
|
return this;
|
|
@@ -1365,6 +1406,8 @@ var Bundle$1 = class Bundle {
|
|
|
1365
1406
|
bundle.addSource({
|
|
1366
1407
|
filename: source.filename,
|
|
1367
1408
|
content: source.content.clone(),
|
|
1409
|
+
ignoreList: source.ignoreList,
|
|
1410
|
+
indentExclusionRanges: source.indentExclusionRanges,
|
|
1368
1411
|
separator: source.separator
|
|
1369
1412
|
});
|
|
1370
1413
|
});
|
|
@@ -1381,7 +1424,7 @@ var Bundle$1 = class Bundle {
|
|
|
1381
1424
|
const mappings = new Mappings(options.hires);
|
|
1382
1425
|
if (this.intro) mappings.advance(this.intro);
|
|
1383
1426
|
this.sources.forEach((source, i) => {
|
|
1384
|
-
if (i > 0) mappings.advance(this.separator);
|
|
1427
|
+
if (i > 0) mappings.advance(source.separator !== void 0 ? source.separator : this.separator);
|
|
1385
1428
|
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
1386
1429
|
const magicString = source.content;
|
|
1387
1430
|
const locate = getLocator(magicString.original);
|
|
@@ -1459,11 +1502,17 @@ var Bundle$1 = class Bundle {
|
|
|
1459
1502
|
}
|
|
1460
1503
|
isEmpty() {
|
|
1461
1504
|
if (this.intro.length && this.intro.trim()) return false;
|
|
1462
|
-
if (this.sources.some((source) =>
|
|
1505
|
+
if (this.sources.some((source, i) => {
|
|
1506
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
1507
|
+
return i > 0 && separator.trim() !== "" || !source.content.isEmpty();
|
|
1508
|
+
})) return false;
|
|
1463
1509
|
return true;
|
|
1464
1510
|
}
|
|
1465
1511
|
length() {
|
|
1466
|
-
return this.sources.reduce((length, source) =>
|
|
1512
|
+
return this.sources.reduce((length, source, i) => {
|
|
1513
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
1514
|
+
return length + (i > 0 ? separator.length : 0) + source.content.length();
|
|
1515
|
+
}, this.intro.length);
|
|
1467
1516
|
}
|
|
1468
1517
|
trimLines() {
|
|
1469
1518
|
return this.trim("[\\r\\n]");
|
|
@@ -9259,7 +9308,7 @@ function requireScan () {
|
|
|
9259
9308
|
const opts = options || {};
|
|
9260
9309
|
|
|
9261
9310
|
const length = input.length - 1;
|
|
9262
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
9311
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
9263
9312
|
const slashes = [];
|
|
9264
9313
|
const tokens = [];
|
|
9265
9314
|
const parts = [];
|
|
@@ -9393,15 +9442,21 @@ function requireScan () {
|
|
|
9393
9442
|
}
|
|
9394
9443
|
|
|
9395
9444
|
if (scanToEnd === true) {
|
|
9445
|
+
let parens = 0;
|
|
9446
|
+
|
|
9396
9447
|
while (eos() !== true && (code = advance())) {
|
|
9397
9448
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
9398
9449
|
backslashes = token.backslashes = true;
|
|
9399
|
-
|
|
9450
|
+
advance();
|
|
9400
9451
|
continue;
|
|
9401
9452
|
}
|
|
9402
9453
|
|
|
9403
|
-
if (code ===
|
|
9404
|
-
|
|
9454
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9455
|
+
parens++;
|
|
9456
|
+
continue;
|
|
9457
|
+
}
|
|
9458
|
+
|
|
9459
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9405
9460
|
finished = true;
|
|
9406
9461
|
break;
|
|
9407
9462
|
}
|
|
@@ -9466,14 +9521,21 @@ function requireScan () {
|
|
|
9466
9521
|
isGlob = token.isGlob = true;
|
|
9467
9522
|
|
|
9468
9523
|
if (scanToEnd === true) {
|
|
9524
|
+
let parens = 1;
|
|
9525
|
+
|
|
9469
9526
|
while (eos() !== true && (code = advance())) {
|
|
9470
|
-
if (code ===
|
|
9527
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
9471
9528
|
backslashes = token.backslashes = true;
|
|
9472
|
-
|
|
9529
|
+
advance();
|
|
9530
|
+
continue;
|
|
9531
|
+
}
|
|
9532
|
+
|
|
9533
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
9534
|
+
parens++;
|
|
9473
9535
|
continue;
|
|
9474
9536
|
}
|
|
9475
9537
|
|
|
9476
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
9538
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
9477
9539
|
finished = true;
|
|
9478
9540
|
break;
|
|
9479
9541
|
}
|
|
@@ -9560,7 +9622,7 @@ function requireScan () {
|
|
|
9560
9622
|
let prevIndex;
|
|
9561
9623
|
|
|
9562
9624
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
9563
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
9625
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9564
9626
|
const i = slashes[idx];
|
|
9565
9627
|
const value = input.slice(n, i);
|
|
9566
9628
|
if (opts.tokens) {
|
|
@@ -9573,21 +9635,20 @@ function requireScan () {
|
|
|
9573
9635
|
depth(tokens[idx]);
|
|
9574
9636
|
state.maxDepth += tokens[idx].depth;
|
|
9575
9637
|
}
|
|
9576
|
-
if (
|
|
9638
|
+
if (i >= start) {
|
|
9577
9639
|
parts.push(value);
|
|
9640
|
+
prevIndex = i;
|
|
9578
9641
|
}
|
|
9579
|
-
prevIndex = i;
|
|
9580
9642
|
}
|
|
9581
9643
|
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9644
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
9645
|
+
const value = input.slice(n);
|
|
9646
|
+
parts.push(value);
|
|
9585
9647
|
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
}
|
|
9648
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
9649
|
+
tokens[tokens.length - 1].value = value;
|
|
9650
|
+
depth(tokens[tokens.length - 1]);
|
|
9651
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
9591
9652
|
}
|
|
9592
9653
|
|
|
9593
9654
|
state.slashes = slashes;
|
|
@@ -10776,6 +10837,15 @@ function requireParse () {
|
|
|
10776
10837
|
consume('/**', 3);
|
|
10777
10838
|
}
|
|
10778
10839
|
|
|
10840
|
+
// A globstar followed only by balanced closing parens is at the logical end of patterns like
|
|
10841
|
+
// `test(/utils/**)` and `test?(/utils/**)`. Treat it as EOS so the trailing `/**` can match its
|
|
10842
|
+
// parent path, except in negated extglobs where that would change the exclusion semantics.
|
|
10843
|
+
const isEnd = eos() || (
|
|
10844
|
+
state.parens > 0
|
|
10845
|
+
&& rest === ')'.repeat(state.parens)
|
|
10846
|
+
&& !extglobs.some(extglob => extglob.type === 'negate')
|
|
10847
|
+
);
|
|
10848
|
+
|
|
10779
10849
|
if (prior.type === 'bos' && eos()) {
|
|
10780
10850
|
prev.type = 'globstar';
|
|
10781
10851
|
prev.value += value;
|
|
@@ -10786,7 +10856,7 @@ function requireParse () {
|
|
|
10786
10856
|
continue;
|
|
10787
10857
|
}
|
|
10788
10858
|
|
|
10789
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar &&
|
|
10859
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && isEnd) {
|
|
10790
10860
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
10791
10861
|
prior.output = `(?:${prior.output}`;
|
|
10792
10862
|
|
|
@@ -19299,7 +19369,6 @@ class Chunk {
|
|
|
19299
19369
|
const usedModules = [];
|
|
19300
19370
|
let hoistedSource = '';
|
|
19301
19371
|
const accessedGlobals = new Set();
|
|
19302
|
-
const renderedModuleSources = new Map();
|
|
19303
19372
|
const renderOptions = {
|
|
19304
19373
|
accessedDocumentCurrentScript: false,
|
|
19305
19374
|
exportNamesByVariable,
|
|
@@ -19329,7 +19398,6 @@ class Chunk {
|
|
|
19329
19398
|
if (renderedLength) {
|
|
19330
19399
|
if (compact && source.lastLine().includes('//'))
|
|
19331
19400
|
source.append('\n');
|
|
19332
|
-
renderedModuleSources.set(module, source);
|
|
19333
19401
|
magicString.addSource(source);
|
|
19334
19402
|
usedModules.push(module);
|
|
19335
19403
|
}
|
package/dist/es/shared/watch.js
CHANGED
package/dist/getLogFilter.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/parseAst.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED