rollup 3.20.7 → 3.21.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/LICENSE.md +1 -1
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +238 -117
- package/dist/es/shared/watch.js +19 -29
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +18 -28
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +238 -119
- package/dist/shared/watch-cli.js +285 -261
- package/dist/shared/watch-proxy.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +36 -37
package/LICENSE.md
CHANGED
|
@@ -611,7 +611,7 @@ Repository: https://github.com/tapjs/signal-exit.git
|
|
|
611
611
|
|
|
612
612
|
> The ISC License
|
|
613
613
|
>
|
|
614
|
-
> Copyright (c) 2015, Contributors
|
|
614
|
+
> Copyright (c) 2015-2023 Benjamin Coe, Isaac Z. Schlueter, and Contributors
|
|
615
615
|
>
|
|
616
616
|
> Permission to use, copy, modify, and/or distribute this software
|
|
617
617
|
> for any purpose with or without fee is hereby granted, provided
|
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.21.1
|
|
4
|
+
Sat, 29 Apr 2023 05:15:23 GMT - commit e01f0a2e7264e0bae267b2fab4b2231d7671d4c2
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.
|
|
19
|
+
var version$1 = "3.21.1";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -2861,12 +2861,6 @@ function getAugmentedNamespace(n) {
|
|
|
2861
2861
|
return a;
|
|
2862
2862
|
}
|
|
2863
2863
|
|
|
2864
|
-
var picomatchExports = {};
|
|
2865
|
-
var picomatch$1 = {
|
|
2866
|
-
get exports(){ return picomatchExports; },
|
|
2867
|
-
set exports(v){ picomatchExports = v; },
|
|
2868
|
-
};
|
|
2869
|
-
|
|
2870
2864
|
var utils$3 = {};
|
|
2871
2865
|
|
|
2872
2866
|
const path$1 = require$$0$1;
|
|
@@ -3110,7 +3104,7 @@ var constants$2 = {
|
|
|
3110
3104
|
output = `(?:^(?!${output}).*$)`;
|
|
3111
3105
|
}
|
|
3112
3106
|
return output;
|
|
3113
|
-
};
|
|
3107
|
+
};
|
|
3114
3108
|
} (utils$3));
|
|
3115
3109
|
|
|
3116
3110
|
const utils$2 = utils$3;
|
|
@@ -4615,9 +4609,9 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
|
4615
4609
|
* @api public
|
|
4616
4610
|
*/
|
|
4617
4611
|
|
|
4618
|
-
const picomatch = (glob, options, returnState = false) => {
|
|
4612
|
+
const picomatch$1 = (glob, options, returnState = false) => {
|
|
4619
4613
|
if (Array.isArray(glob)) {
|
|
4620
|
-
const fns = glob.map(input => picomatch(input, options, returnState));
|
|
4614
|
+
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
|
4621
4615
|
const arrayMatcher = str => {
|
|
4622
4616
|
for (const isMatch of fns) {
|
|
4623
4617
|
const state = isMatch(str);
|
|
@@ -4637,8 +4631,8 @@ const picomatch = (glob, options, returnState = false) => {
|
|
|
4637
4631
|
const opts = options || {};
|
|
4638
4632
|
const posix = utils.isWindows(options);
|
|
4639
4633
|
const regex = isState
|
|
4640
|
-
? picomatch.compileRe(glob, options)
|
|
4641
|
-
: picomatch.makeRe(glob, options, false, true);
|
|
4634
|
+
? picomatch$1.compileRe(glob, options)
|
|
4635
|
+
: picomatch$1.makeRe(glob, options, false, true);
|
|
4642
4636
|
|
|
4643
4637
|
const state = regex.state;
|
|
4644
4638
|
delete regex.state;
|
|
@@ -4646,11 +4640,11 @@ const picomatch = (glob, options, returnState = false) => {
|
|
|
4646
4640
|
let isIgnored = () => false;
|
|
4647
4641
|
if (opts.ignore) {
|
|
4648
4642
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
4649
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
4643
|
+
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
|
4650
4644
|
}
|
|
4651
4645
|
|
|
4652
4646
|
const matcher = (input, returnObject = false) => {
|
|
4653
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
4647
|
+
const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
|
|
4654
4648
|
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
4655
4649
|
|
|
4656
4650
|
if (typeof opts.onResult === 'function') {
|
|
@@ -4700,7 +4694,7 @@ const picomatch = (glob, options, returnState = false) => {
|
|
|
4700
4694
|
* @api public
|
|
4701
4695
|
*/
|
|
4702
4696
|
|
|
4703
|
-
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
4697
|
+
picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
|
4704
4698
|
if (typeof input !== 'string') {
|
|
4705
4699
|
throw new TypeError('Expected input to be a string');
|
|
4706
4700
|
}
|
|
@@ -4721,7 +4715,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
4721
4715
|
|
|
4722
4716
|
if (match === false || opts.capture === true) {
|
|
4723
4717
|
if (opts.matchBase === true || opts.basename === true) {
|
|
4724
|
-
match = picomatch.matchBase(input, regex, options, posix);
|
|
4718
|
+
match = picomatch$1.matchBase(input, regex, options, posix);
|
|
4725
4719
|
} else {
|
|
4726
4720
|
match = regex.exec(output);
|
|
4727
4721
|
}
|
|
@@ -4744,8 +4738,8 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
4744
4738
|
* @api public
|
|
4745
4739
|
*/
|
|
4746
4740
|
|
|
4747
|
-
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
4748
|
-
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
4741
|
+
picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
4742
|
+
const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
|
|
4749
4743
|
return regex.test(path.basename(input));
|
|
4750
4744
|
};
|
|
4751
4745
|
|
|
@@ -4766,7 +4760,7 @@ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) =
|
|
|
4766
4760
|
* @api public
|
|
4767
4761
|
*/
|
|
4768
4762
|
|
|
4769
|
-
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
4763
|
+
picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
|
|
4770
4764
|
|
|
4771
4765
|
/**
|
|
4772
4766
|
* Parse a glob pattern to create the source string for a regular
|
|
@@ -4782,8 +4776,8 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
|
|
|
4782
4776
|
* @api public
|
|
4783
4777
|
*/
|
|
4784
4778
|
|
|
4785
|
-
picomatch.parse = (pattern, options) => {
|
|
4786
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
4779
|
+
picomatch$1.parse = (pattern, options) => {
|
|
4780
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
|
|
4787
4781
|
return parse$1(pattern, { ...options, fastpaths: false });
|
|
4788
4782
|
};
|
|
4789
4783
|
|
|
@@ -4814,7 +4808,7 @@ picomatch.parse = (pattern, options) => {
|
|
|
4814
4808
|
* @api public
|
|
4815
4809
|
*/
|
|
4816
4810
|
|
|
4817
|
-
picomatch.scan = (input, options) => scan(input, options);
|
|
4811
|
+
picomatch$1.scan = (input, options) => scan(input, options);
|
|
4818
4812
|
|
|
4819
4813
|
/**
|
|
4820
4814
|
* Compile a regular expression from the `state` object returned by the
|
|
@@ -4828,7 +4822,7 @@ picomatch.scan = (input, options) => scan(input, options);
|
|
|
4828
4822
|
* @api public
|
|
4829
4823
|
*/
|
|
4830
4824
|
|
|
4831
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
4825
|
+
picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
4832
4826
|
if (returnOutput === true) {
|
|
4833
4827
|
return state.output;
|
|
4834
4828
|
}
|
|
@@ -4842,7 +4836,7 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
|
|
|
4842
4836
|
source = `^(?!${source}).*$`;
|
|
4843
4837
|
}
|
|
4844
4838
|
|
|
4845
|
-
const regex = picomatch.toRegex(source, options);
|
|
4839
|
+
const regex = picomatch$1.toRegex(source, options);
|
|
4846
4840
|
if (returnState === true) {
|
|
4847
4841
|
regex.state = state;
|
|
4848
4842
|
}
|
|
@@ -4869,7 +4863,7 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
|
|
|
4869
4863
|
* @api public
|
|
4870
4864
|
*/
|
|
4871
4865
|
|
|
4872
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
4866
|
+
picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
4873
4867
|
if (!input || typeof input !== 'string') {
|
|
4874
4868
|
throw new TypeError('Expected a non-empty string');
|
|
4875
4869
|
}
|
|
@@ -4884,7 +4878,7 @@ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = fal
|
|
|
4884
4878
|
parsed = parse$1(input, options);
|
|
4885
4879
|
}
|
|
4886
4880
|
|
|
4887
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
4881
|
+
return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
|
|
4888
4882
|
};
|
|
4889
4883
|
|
|
4890
4884
|
/**
|
|
@@ -4904,7 +4898,7 @@ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = fal
|
|
|
4904
4898
|
* @api public
|
|
4905
4899
|
*/
|
|
4906
4900
|
|
|
4907
|
-
picomatch.toRegex = (source, options) => {
|
|
4901
|
+
picomatch$1.toRegex = (source, options) => {
|
|
4908
4902
|
try {
|
|
4909
4903
|
const opts = options || {};
|
|
4910
4904
|
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
@@ -4919,20 +4913,17 @@ picomatch.toRegex = (source, options) => {
|
|
|
4919
4913
|
* @return {Object}
|
|
4920
4914
|
*/
|
|
4921
4915
|
|
|
4922
|
-
picomatch.constants = constants;
|
|
4916
|
+
picomatch$1.constants = constants;
|
|
4923
4917
|
|
|
4924
4918
|
/**
|
|
4925
4919
|
* Expose "picomatch"
|
|
4926
4920
|
*/
|
|
4927
4921
|
|
|
4928
|
-
var picomatch_1 = picomatch;
|
|
4929
|
-
|
|
4930
|
-
(function (module) {
|
|
4922
|
+
var picomatch_1 = picomatch$1;
|
|
4931
4923
|
|
|
4932
|
-
|
|
4933
|
-
} (picomatch$1));
|
|
4924
|
+
var picomatch = picomatch_1;
|
|
4934
4925
|
|
|
4935
|
-
const pm = /*@__PURE__*/getDefaultExportFromCjs(
|
|
4926
|
+
const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
|
|
4936
4927
|
|
|
4937
4928
|
const extractors = {
|
|
4938
4929
|
ArrayPattern(names, param) {
|
|
@@ -8612,10 +8603,14 @@ class FunctionBase extends NodeBase {
|
|
|
8612
8603
|
}
|
|
8613
8604
|
else if (parameter instanceof Identifier) {
|
|
8614
8605
|
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
8606
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
8615
8607
|
}
|
|
8616
8608
|
else if (parameter) {
|
|
8617
8609
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
8618
8610
|
}
|
|
8611
|
+
else {
|
|
8612
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
8613
|
+
}
|
|
8619
8614
|
}
|
|
8620
8615
|
}
|
|
8621
8616
|
else {
|
|
@@ -8695,6 +8690,7 @@ class FunctionBase extends NodeBase {
|
|
|
8695
8690
|
}
|
|
8696
8691
|
super.parseNode(esTreeNode);
|
|
8697
8692
|
}
|
|
8693
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
8698
8694
|
applyDeoptimizations() { }
|
|
8699
8695
|
}
|
|
8700
8696
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
@@ -8946,10 +8942,26 @@ class AssignmentPattern extends NodeBase {
|
|
|
8946
8942
|
class ArgumentsVariable extends LocalVariable {
|
|
8947
8943
|
constructor(context) {
|
|
8948
8944
|
super('arguments', null, UNKNOWN_EXPRESSION, context);
|
|
8945
|
+
this.deoptimizedArguments = [];
|
|
8946
|
+
}
|
|
8947
|
+
addArgumentToBeDeoptimized(argument) {
|
|
8948
|
+
if (this.included) {
|
|
8949
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
8950
|
+
}
|
|
8951
|
+
else {
|
|
8952
|
+
this.deoptimizedArguments.push(argument);
|
|
8953
|
+
}
|
|
8949
8954
|
}
|
|
8950
8955
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8951
8956
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8952
8957
|
}
|
|
8958
|
+
include() {
|
|
8959
|
+
super.include();
|
|
8960
|
+
for (const argument of this.deoptimizedArguments) {
|
|
8961
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
8962
|
+
}
|
|
8963
|
+
this.deoptimizedArguments.length = 0;
|
|
8964
|
+
}
|
|
8953
8965
|
}
|
|
8954
8966
|
|
|
8955
8967
|
class ThisVariable extends ParameterVariable {
|
|
@@ -9047,6 +9059,9 @@ class FunctionNode extends FunctionBase {
|
|
|
9047
9059
|
super.initialise();
|
|
9048
9060
|
this.id?.declare('function', this);
|
|
9049
9061
|
}
|
|
9062
|
+
addArgumentToBeDeoptimized(argument) {
|
|
9063
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
9064
|
+
}
|
|
9050
9065
|
getObjectEntity() {
|
|
9051
9066
|
if (this.objectEntity !== null) {
|
|
9052
9067
|
return this.objectEntity;
|
|
@@ -10985,6 +11000,74 @@ function getToStringTagValue(getObject) {
|
|
|
10985
11000
|
});
|
|
10986
11001
|
}
|
|
10987
11002
|
|
|
11003
|
+
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
11004
|
+
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
11005
|
+
}
|
|
11006
|
+
|
|
11007
|
+
class VariableDeclarator extends NodeBase {
|
|
11008
|
+
declareDeclarator(kind) {
|
|
11009
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
11010
|
+
}
|
|
11011
|
+
deoptimizePath(path) {
|
|
11012
|
+
this.id.deoptimizePath(path);
|
|
11013
|
+
}
|
|
11014
|
+
hasEffects(context) {
|
|
11015
|
+
if (!this.deoptimized)
|
|
11016
|
+
this.applyDeoptimizations();
|
|
11017
|
+
const initEffect = this.init?.hasEffects(context);
|
|
11018
|
+
this.id.markDeclarationReached();
|
|
11019
|
+
return initEffect || this.id.hasEffects(context);
|
|
11020
|
+
}
|
|
11021
|
+
include(context, includeChildrenRecursively) {
|
|
11022
|
+
const { deoptimized, id, init } = this;
|
|
11023
|
+
if (!deoptimized)
|
|
11024
|
+
this.applyDeoptimizations();
|
|
11025
|
+
this.included = true;
|
|
11026
|
+
init?.include(context, includeChildrenRecursively);
|
|
11027
|
+
id.markDeclarationReached();
|
|
11028
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
11029
|
+
id.include(context, includeChildrenRecursively);
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
render(code, options) {
|
|
11033
|
+
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
11034
|
+
const { end, id, init, start } = this;
|
|
11035
|
+
const renderId = id.included;
|
|
11036
|
+
if (renderId) {
|
|
11037
|
+
id.render(code, options);
|
|
11038
|
+
}
|
|
11039
|
+
else {
|
|
11040
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
11041
|
+
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
11042
|
+
}
|
|
11043
|
+
if (init) {
|
|
11044
|
+
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
11045
|
+
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
11046
|
+
if (renderedVariable !== id.name) {
|
|
11047
|
+
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
11051
|
+
}
|
|
11052
|
+
else if (id instanceof Identifier &&
|
|
11053
|
+
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
11054
|
+
code.appendLeft(end, `${_}=${_}void 0`);
|
|
11055
|
+
}
|
|
11056
|
+
}
|
|
11057
|
+
applyDeoptimizations() {
|
|
11058
|
+
this.deoptimized = true;
|
|
11059
|
+
const { id, init } = this;
|
|
11060
|
+
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
11061
|
+
const { name, variable } = id;
|
|
11062
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
11063
|
+
if (accessedVariable !== variable) {
|
|
11064
|
+
accessedVariable.forbidName(name);
|
|
11065
|
+
}
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
}
|
|
11069
|
+
}
|
|
11070
|
+
|
|
10988
11071
|
// TODO once ImportExpression follows official ESTree specs with "null" as
|
|
10989
11072
|
// default, keys.ts should be updated
|
|
10990
11073
|
class ImportExpression extends NodeBase {
|
|
@@ -11001,6 +11084,79 @@ class ImportExpression extends NodeBase {
|
|
|
11001
11084
|
bind() {
|
|
11002
11085
|
this.source.bind();
|
|
11003
11086
|
}
|
|
11087
|
+
/**
|
|
11088
|
+
* Get imported variables for deterministic usage, valid cases are:
|
|
11089
|
+
*
|
|
11090
|
+
* - `const { foo } = await import('bar')`.
|
|
11091
|
+
* - `(await import('bar')).foo`
|
|
11092
|
+
* - `import('bar').then(({ foo }) => {})`
|
|
11093
|
+
*
|
|
11094
|
+
* Returns empty array if it's side-effect only import.
|
|
11095
|
+
* Returns undefined if it's not fully deterministic.
|
|
11096
|
+
*/
|
|
11097
|
+
getDeterministicImportedNames() {
|
|
11098
|
+
const parent1 = this.parent;
|
|
11099
|
+
// Side-effect only: import('bar')
|
|
11100
|
+
if (parent1 instanceof ExpressionStatement) {
|
|
11101
|
+
return EMPTY_ARRAY;
|
|
11102
|
+
}
|
|
11103
|
+
if (parent1 instanceof AwaitExpression) {
|
|
11104
|
+
const parent2 = parent1.parent;
|
|
11105
|
+
// Side-effect only: await import('bar')
|
|
11106
|
+
if (parent2 instanceof ExpressionStatement) {
|
|
11107
|
+
return EMPTY_ARRAY;
|
|
11108
|
+
}
|
|
11109
|
+
// Case 1: const { foo } = await import('bar')
|
|
11110
|
+
if (parent2 instanceof VariableDeclarator) {
|
|
11111
|
+
const declaration = parent2.id;
|
|
11112
|
+
return declaration instanceof ObjectPattern
|
|
11113
|
+
? getDeterministicObjectDestructure(declaration)
|
|
11114
|
+
: undefined;
|
|
11115
|
+
}
|
|
11116
|
+
// Case 2: (await import('bar')).foo
|
|
11117
|
+
if (parent2 instanceof MemberExpression) {
|
|
11118
|
+
const id = parent2.property;
|
|
11119
|
+
if (!parent2.computed && id instanceof Identifier) {
|
|
11120
|
+
return [id.name];
|
|
11121
|
+
}
|
|
11122
|
+
}
|
|
11123
|
+
return;
|
|
11124
|
+
}
|
|
11125
|
+
// Case 3: import('bar').then(({ foo }) => {})
|
|
11126
|
+
if (parent1 instanceof MemberExpression) {
|
|
11127
|
+
const callExpression = parent1.parent;
|
|
11128
|
+
const property = parent1.property;
|
|
11129
|
+
if (!(callExpression instanceof CallExpression) || !(property instanceof Identifier)) {
|
|
11130
|
+
return;
|
|
11131
|
+
}
|
|
11132
|
+
const memberName = property.name;
|
|
11133
|
+
// side-effect only, when only chaining .catch or .finally
|
|
11134
|
+
if (callExpression.parent instanceof ExpressionStatement &&
|
|
11135
|
+
['catch', 'finally'].includes(memberName)) {
|
|
11136
|
+
return EMPTY_ARRAY;
|
|
11137
|
+
}
|
|
11138
|
+
if (memberName !== 'then')
|
|
11139
|
+
return;
|
|
11140
|
+
// Side-effect only: import('bar').then()
|
|
11141
|
+
if (callExpression.arguments.length === 0) {
|
|
11142
|
+
return EMPTY_ARRAY;
|
|
11143
|
+
}
|
|
11144
|
+
const argument = callExpression.arguments[0];
|
|
11145
|
+
if (callExpression.arguments.length !== 1 ||
|
|
11146
|
+
!(argument instanceof ArrowFunctionExpression || argument instanceof FunctionExpression)) {
|
|
11147
|
+
return;
|
|
11148
|
+
}
|
|
11149
|
+
// Side-effect only: import('bar').then(() => {})
|
|
11150
|
+
if (argument.params.length === 0) {
|
|
11151
|
+
return EMPTY_ARRAY;
|
|
11152
|
+
}
|
|
11153
|
+
const declaration = argument.params[0];
|
|
11154
|
+
if (argument.params.length === 1 && declaration instanceof ObjectPattern) {
|
|
11155
|
+
return getDeterministicObjectDestructure(declaration);
|
|
11156
|
+
}
|
|
11157
|
+
return;
|
|
11158
|
+
}
|
|
11159
|
+
}
|
|
11004
11160
|
hasEffects() {
|
|
11005
11161
|
return true;
|
|
11006
11162
|
}
|
|
@@ -11192,6 +11348,15 @@ const accessedImportGlobals = {
|
|
|
11192
11348
|
cjs: ['require'],
|
|
11193
11349
|
system: ['module']
|
|
11194
11350
|
};
|
|
11351
|
+
function getDeterministicObjectDestructure(objectPattern) {
|
|
11352
|
+
const variables = [];
|
|
11353
|
+
for (const property of objectPattern.properties) {
|
|
11354
|
+
if (property.type === 'RestElement' || property.computed || property.key.type !== 'Identifier')
|
|
11355
|
+
return;
|
|
11356
|
+
variables.push(property.key.name);
|
|
11357
|
+
}
|
|
11358
|
+
return variables;
|
|
11359
|
+
}
|
|
11195
11360
|
|
|
11196
11361
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
11197
11362
|
applyDeoptimizations() { }
|
|
@@ -12436,10 +12601,6 @@ class UpdateExpression extends NodeBase {
|
|
|
12436
12601
|
}
|
|
12437
12602
|
}
|
|
12438
12603
|
|
|
12439
|
-
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
12440
|
-
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
12441
|
-
}
|
|
12442
|
-
|
|
12443
12604
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
12444
12605
|
for (const declarator of declarations) {
|
|
12445
12606
|
if (!declarator.id.included)
|
|
@@ -12616,70 +12777,6 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
12616
12777
|
return singleSystemExport;
|
|
12617
12778
|
}
|
|
12618
12779
|
|
|
12619
|
-
class VariableDeclarator extends NodeBase {
|
|
12620
|
-
declareDeclarator(kind) {
|
|
12621
|
-
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12622
|
-
}
|
|
12623
|
-
deoptimizePath(path) {
|
|
12624
|
-
this.id.deoptimizePath(path);
|
|
12625
|
-
}
|
|
12626
|
-
hasEffects(context) {
|
|
12627
|
-
if (!this.deoptimized)
|
|
12628
|
-
this.applyDeoptimizations();
|
|
12629
|
-
const initEffect = this.init?.hasEffects(context);
|
|
12630
|
-
this.id.markDeclarationReached();
|
|
12631
|
-
return initEffect || this.id.hasEffects(context);
|
|
12632
|
-
}
|
|
12633
|
-
include(context, includeChildrenRecursively) {
|
|
12634
|
-
const { deoptimized, id, init } = this;
|
|
12635
|
-
if (!deoptimized)
|
|
12636
|
-
this.applyDeoptimizations();
|
|
12637
|
-
this.included = true;
|
|
12638
|
-
init?.include(context, includeChildrenRecursively);
|
|
12639
|
-
id.markDeclarationReached();
|
|
12640
|
-
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12641
|
-
id.include(context, includeChildrenRecursively);
|
|
12642
|
-
}
|
|
12643
|
-
}
|
|
12644
|
-
render(code, options) {
|
|
12645
|
-
const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
|
|
12646
|
-
const { end, id, init, start } = this;
|
|
12647
|
-
const renderId = id.included;
|
|
12648
|
-
if (renderId) {
|
|
12649
|
-
id.render(code, options);
|
|
12650
|
-
}
|
|
12651
|
-
else {
|
|
12652
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end);
|
|
12653
|
-
code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1));
|
|
12654
|
-
}
|
|
12655
|
-
if (init) {
|
|
12656
|
-
if (id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12657
|
-
const renderedVariable = id.variable.getName(getPropertyAccess);
|
|
12658
|
-
if (renderedVariable !== id.name) {
|
|
12659
|
-
code.appendLeft(init.start + 5, ` ${id.name}`);
|
|
12660
|
-
}
|
|
12661
|
-
}
|
|
12662
|
-
init.render(code, options, renderId ? BLANK : { renderedSurroundingElement: ExpressionStatement$1 });
|
|
12663
|
-
}
|
|
12664
|
-
else if (id instanceof Identifier &&
|
|
12665
|
-
isReassignedExportsMember(id.variable, exportNamesByVariable)) {
|
|
12666
|
-
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12667
|
-
}
|
|
12668
|
-
}
|
|
12669
|
-
applyDeoptimizations() {
|
|
12670
|
-
this.deoptimized = true;
|
|
12671
|
-
const { id, init } = this;
|
|
12672
|
-
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12673
|
-
const { name, variable } = id;
|
|
12674
|
-
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
12675
|
-
if (accessedVariable !== variable) {
|
|
12676
|
-
accessedVariable.forbidName(name);
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
}
|
|
12680
|
-
}
|
|
12681
|
-
}
|
|
12682
|
-
|
|
12683
12780
|
class WhileStatement extends NodeBase {
|
|
12684
12781
|
hasEffects(context) {
|
|
12685
12782
|
if (this.test.hasEffects(context))
|
|
@@ -12880,7 +12977,9 @@ class NamespaceVariable extends Variable {
|
|
|
12880
12977
|
renderBlock(options) {
|
|
12881
12978
|
const { exportNamesByVariable, format, freeze, indent: t, namespaceToStringTag, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
|
|
12882
12979
|
const memberVariables = this.getMemberVariables();
|
|
12883
|
-
const members = Object.entries(memberVariables)
|
|
12980
|
+
const members = Object.entries(memberVariables)
|
|
12981
|
+
.filter(([_, variable]) => variable.included)
|
|
12982
|
+
.map(([name, original]) => {
|
|
12884
12983
|
if (this.referencedEarly || original.isReassigned) {
|
|
12885
12984
|
return [
|
|
12886
12985
|
null,
|
|
@@ -13582,6 +13681,28 @@ class Module {
|
|
|
13582
13681
|
this.ast.include(createInclusionContext(), true);
|
|
13583
13682
|
this.includeAllExports(false);
|
|
13584
13683
|
}
|
|
13684
|
+
includeExportsByNames(names) {
|
|
13685
|
+
if (!this.isExecuted) {
|
|
13686
|
+
markModuleAndImpureDependenciesAsExecuted(this);
|
|
13687
|
+
this.graph.needsTreeshakingPass = true;
|
|
13688
|
+
}
|
|
13689
|
+
let includeNamespaceMembers = false;
|
|
13690
|
+
for (const name of names) {
|
|
13691
|
+
const variable = this.getVariableForExportName(name)[0];
|
|
13692
|
+
if (variable) {
|
|
13693
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
13694
|
+
if (!variable.included) {
|
|
13695
|
+
this.includeVariable(variable);
|
|
13696
|
+
}
|
|
13697
|
+
}
|
|
13698
|
+
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
13699
|
+
includeNamespaceMembers = true;
|
|
13700
|
+
}
|
|
13701
|
+
}
|
|
13702
|
+
if (includeNamespaceMembers) {
|
|
13703
|
+
this.namespace.setMergedNamespaces(this.includeAndGetAdditionalMergedNamespaces());
|
|
13704
|
+
}
|
|
13705
|
+
}
|
|
13585
13706
|
isIncluded() {
|
|
13586
13707
|
// Modules where this.ast is missing have been loaded via this.load and are
|
|
13587
13708
|
// not yet fully processed, hence they cannot be included.
|
|
@@ -13974,7 +14095,15 @@ class Module {
|
|
|
13974
14095
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
13975
14096
|
if (resolution instanceof Module) {
|
|
13976
14097
|
resolution.includedDynamicImporters.push(this);
|
|
13977
|
-
|
|
14098
|
+
const importedNames = this.options.treeshake
|
|
14099
|
+
? node.getDeterministicImportedNames()
|
|
14100
|
+
: undefined;
|
|
14101
|
+
if (importedNames) {
|
|
14102
|
+
resolution.includeExportsByNames(importedNames);
|
|
14103
|
+
}
|
|
14104
|
+
else {
|
|
14105
|
+
resolution.includeAllExports(true);
|
|
14106
|
+
}
|
|
13978
14107
|
}
|
|
13979
14108
|
}
|
|
13980
14109
|
includeVariable(variable) {
|
|
@@ -14250,12 +14379,6 @@ function updateExtensionForRelativeAmdId(id, forceJsExtensionForImports) {
|
|
|
14250
14379
|
return forceJsExtensionForImports ? addJsExtension(id) : removeJsExtension(id);
|
|
14251
14380
|
}
|
|
14252
14381
|
|
|
14253
|
-
var _staticExports = {};
|
|
14254
|
-
var _static = {
|
|
14255
|
-
get exports(){ return _staticExports; },
|
|
14256
|
-
set exports(v){ _staticExports = v; },
|
|
14257
|
-
};
|
|
14258
|
-
|
|
14259
14382
|
const require$$0 = [
|
|
14260
14383
|
"assert",
|
|
14261
14384
|
"async_hooks",
|
|
@@ -14300,11 +14423,9 @@ const require$$0 = [
|
|
|
14300
14423
|
"zlib"
|
|
14301
14424
|
];
|
|
14302
14425
|
|
|
14303
|
-
|
|
14304
|
-
module.exports = require$$0;
|
|
14305
|
-
} (_static));
|
|
14426
|
+
var _static = require$$0;
|
|
14306
14427
|
|
|
14307
|
-
const builtinModules = /*@__PURE__*/getDefaultExportFromCjs(
|
|
14428
|
+
const builtinModules = /*@__PURE__*/getDefaultExportFromCjs(_static);
|
|
14308
14429
|
|
|
14309
14430
|
const nodeBuiltins = new Set([
|
|
14310
14431
|
...builtinModules,
|
|
@@ -26167,4 +26288,4 @@ async function watchInternal(configs, emitter) {
|
|
|
26167
26288
|
new Watcher(watchOptionsList, emitter);
|
|
26168
26289
|
}
|
|
26169
26290
|
|
|
26170
|
-
export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace,
|
|
26291
|
+
export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, picomatch, rollup, rollupInternal, version$1 as version, watch };
|