rollup 2.32.1 → 2.33.3
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/CHANGELOG.md +41 -0
- package/README.md +2 -2
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +49 -30
- package/dist/es/shared/watch.js +53 -25
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.d.ts +19 -7
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +49 -30
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +53 -25
- package/package.json +1 -1
package/dist/rollup.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ interface ModuleInfo {
|
|
|
171
171
|
isEntry: boolean;
|
|
172
172
|
isExternal: boolean;
|
|
173
173
|
meta: CustomPluginOptions;
|
|
174
|
+
syntheticNamedExports: boolean | string;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
@@ -195,6 +196,7 @@ export interface PluginContext extends MinimalPluginContext {
|
|
|
195
196
|
getFileName: (fileReferenceId: string) => string;
|
|
196
197
|
getModuleIds: () => IterableIterator<string>;
|
|
197
198
|
getModuleInfo: GetModuleInfo;
|
|
199
|
+
getWatchFiles: () => string[];
|
|
198
200
|
/** @deprecated Use `this.resolve` instead */
|
|
199
201
|
isExternal: IsExternal;
|
|
200
202
|
/** @deprecated Use `this.getModuleIds` instead */
|
|
@@ -318,6 +320,9 @@ export type ResolveFileUrlHook = (
|
|
|
318
320
|
export type AddonHookFunction = (this: PluginContext) => string | Promise<string>;
|
|
319
321
|
export type AddonHook = string | AddonHookFunction;
|
|
320
322
|
|
|
323
|
+
export type ChangeEvent = 'create' | 'update' | 'delete'
|
|
324
|
+
export type WatchChangeHook = (this: PluginContext, id: string, change: {event: ChangeEvent}) => void
|
|
325
|
+
|
|
321
326
|
/**
|
|
322
327
|
* use this type for plugin annotation
|
|
323
328
|
* @example
|
|
@@ -345,13 +350,17 @@ export interface OutputBundleWithPlaceholders {
|
|
|
345
350
|
export interface PluginHooks extends OutputPluginHooks {
|
|
346
351
|
buildEnd: (this: PluginContext, err?: Error) => Promise<void> | void;
|
|
347
352
|
buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise<void> | void;
|
|
353
|
+
closeWatcher: (this: PluginContext) => void;
|
|
348
354
|
load: LoadHook;
|
|
349
355
|
moduleParsed: ModuleParsedHook;
|
|
350
|
-
options: (
|
|
356
|
+
options: (
|
|
357
|
+
this: MinimalPluginContext,
|
|
358
|
+
options: InputOptions
|
|
359
|
+
) => Promise<InputOptions | null | undefined> | InputOptions | null | undefined;
|
|
351
360
|
resolveDynamicImport: ResolveDynamicImportHook;
|
|
352
361
|
resolveId: ResolveIdHook;
|
|
353
362
|
transform: TransformHook;
|
|
354
|
-
watchChange:
|
|
363
|
+
watchChange: WatchChangeHook;
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
interface OutputPluginHooks {
|
|
@@ -391,6 +400,7 @@ interface OutputPluginHooks {
|
|
|
391
400
|
}
|
|
392
401
|
|
|
393
402
|
export type AsyncPluginHooks =
|
|
403
|
+
| 'options'
|
|
394
404
|
| 'buildEnd'
|
|
395
405
|
| 'buildStart'
|
|
396
406
|
| 'generateBundle'
|
|
@@ -419,6 +429,7 @@ export type FirstPluginHooks =
|
|
|
419
429
|
|
|
420
430
|
export type SequentialPluginHooks =
|
|
421
431
|
| 'augmentChunkHash'
|
|
432
|
+
| 'closeWatcher'
|
|
422
433
|
| 'generateBundle'
|
|
423
434
|
| 'options'
|
|
424
435
|
| 'outputOptions'
|
|
@@ -783,9 +794,9 @@ export interface RollupWatchOptions extends InputOptions {
|
|
|
783
794
|
watch?: WatcherOptions | false;
|
|
784
795
|
}
|
|
785
796
|
|
|
786
|
-
interface TypedEventEmitter<T> {
|
|
797
|
+
interface TypedEventEmitter<T extends {[event: string]: (...args: any) => any}> {
|
|
787
798
|
addListener<K extends keyof T>(event: K, listener: T[K]): this;
|
|
788
|
-
emit<K extends keyof T>(event: K, ...args:
|
|
799
|
+
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
|
|
789
800
|
eventNames(): Array<keyof T>;
|
|
790
801
|
getMaxListeners(): number;
|
|
791
802
|
listenerCount(type: keyof T): number;
|
|
@@ -803,11 +814,11 @@ interface TypedEventEmitter<T> {
|
|
|
803
814
|
|
|
804
815
|
export type RollupWatcherEvent =
|
|
805
816
|
| { code: 'START' }
|
|
806
|
-
| { code: 'BUNDLE_START'; input
|
|
817
|
+
| { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
|
|
807
818
|
| {
|
|
808
819
|
code: 'BUNDLE_END';
|
|
809
820
|
duration: number;
|
|
810
|
-
input
|
|
821
|
+
input?: InputOption;
|
|
811
822
|
output: readonly string[];
|
|
812
823
|
result: RollupBuild;
|
|
813
824
|
}
|
|
@@ -816,7 +827,8 @@ export type RollupWatcherEvent =
|
|
|
816
827
|
|
|
817
828
|
export interface RollupWatcher
|
|
818
829
|
extends TypedEventEmitter<{
|
|
819
|
-
change: (id: string) => void;
|
|
830
|
+
change: (id: string, change: {event: ChangeEvent}) => void;
|
|
831
|
+
close: () => void;
|
|
820
832
|
event: (event: RollupWatcherEvent) => void;
|
|
821
833
|
restart: () => void;
|
|
822
834
|
}> {
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
Wed,
|
|
3
|
+
Rollup.js v2.33.3
|
|
4
|
+
Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -19,7 +19,7 @@ function _interopNamespaceDefaultOnly(e) {
|
|
|
19
19
|
return {__proto__: null, 'default': e};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
var version = "2.
|
|
22
|
+
var version = "2.33.3";
|
|
23
23
|
|
|
24
24
|
function ensureArray(items) {
|
|
25
25
|
if (Array.isArray(items)) {
|
|
@@ -2415,7 +2415,8 @@ class ExternalModule {
|
|
|
2415
2415
|
},
|
|
2416
2416
|
isEntry: false,
|
|
2417
2417
|
isExternal: true,
|
|
2418
|
-
meta
|
|
2418
|
+
meta,
|
|
2419
|
+
syntheticNamedExports: false
|
|
2419
2420
|
};
|
|
2420
2421
|
}
|
|
2421
2422
|
getVariableForExportName(name) {
|
|
@@ -4590,7 +4591,7 @@ class NamespaceVariable extends Variable {
|
|
|
4590
4591
|
}
|
|
4591
4592
|
const memberVariables = Object.create(null);
|
|
4592
4593
|
for (const name of this.context.getExports().concat(this.context.getReexports())) {
|
|
4593
|
-
if (name[0] !== '*' && name !== this.module.syntheticNamedExports) {
|
|
4594
|
+
if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
|
|
4594
4595
|
memberVariables[name] = this.context.traceExport(name);
|
|
4595
4596
|
}
|
|
4596
4597
|
}
|
|
@@ -4969,6 +4970,16 @@ function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings
|
|
|
4969
4970
|
return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
|
|
4970
4971
|
}
|
|
4971
4972
|
|
|
4973
|
+
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
4974
|
+
// The assumption is that this makes sense for all relative ids:
|
|
4975
|
+
// https://requirejs.org/docs/api.html#jsfiles
|
|
4976
|
+
function removeExtensionFromRelativeAmdId(id) {
|
|
4977
|
+
if (id[0] === '.' && id.endsWith('.js')) {
|
|
4978
|
+
return id.slice(0, -3);
|
|
4979
|
+
}
|
|
4980
|
+
return id;
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4972
4983
|
const builtins$1 = {
|
|
4973
4984
|
assert: true,
|
|
4974
4985
|
buffer: true,
|
|
@@ -5009,15 +5020,6 @@ function warnOnBuiltins(warn, dependencies) {
|
|
|
5009
5020
|
});
|
|
5010
5021
|
}
|
|
5011
5022
|
|
|
5012
|
-
// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
|
|
5013
|
-
// The assumption is that this makes sense for all relative ids:
|
|
5014
|
-
// https://requirejs.org/docs/api.html#jsfiles
|
|
5015
|
-
function removeExtensionFromRelativeAmdId(id) {
|
|
5016
|
-
if (id[0] === '.' && id.endsWith('.js')) {
|
|
5017
|
-
return id.slice(0, -3);
|
|
5018
|
-
}
|
|
5019
|
-
return id;
|
|
5020
|
-
}
|
|
5021
5023
|
function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
|
|
5022
5024
|
warnOnBuiltins(warn, dependencies);
|
|
5023
5025
|
const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
@@ -5812,7 +5814,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
|
|
|
5812
5814
|
});
|
|
5813
5815
|
}
|
|
5814
5816
|
warnOnBuiltins(warn, dependencies);
|
|
5815
|
-
const amdDeps = dependencies.map(m => `'${m.id}'`);
|
|
5817
|
+
const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
|
|
5816
5818
|
const cjsDeps = dependencies.map(m => `require('${m.id}')`);
|
|
5817
5819
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
5818
5820
|
const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar));
|
|
@@ -8789,6 +8791,7 @@ class TryStatement extends NodeBase {
|
|
|
8789
8791
|
constructor() {
|
|
8790
8792
|
super(...arguments);
|
|
8791
8793
|
this.directlyIncluded = false;
|
|
8794
|
+
this.includedLabelsAfterBlock = null;
|
|
8792
8795
|
}
|
|
8793
8796
|
hasEffects(context) {
|
|
8794
8797
|
return ((this.context.options.treeshake.tryCatchDeoptimization
|
|
@@ -8804,8 +8807,16 @@ class TryStatement extends NodeBase {
|
|
|
8804
8807
|
this.included = true;
|
|
8805
8808
|
this.directlyIncluded = true;
|
|
8806
8809
|
this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
8810
|
+
if (context.includedLabels.size > 0) {
|
|
8811
|
+
this.includedLabelsAfterBlock = [...context.includedLabels];
|
|
8812
|
+
}
|
|
8807
8813
|
context.brokenFlow = brokenFlow;
|
|
8808
8814
|
}
|
|
8815
|
+
else if (this.includedLabelsAfterBlock) {
|
|
8816
|
+
for (const label of this.includedLabelsAfterBlock) {
|
|
8817
|
+
context.includedLabels.add(label);
|
|
8818
|
+
}
|
|
8819
|
+
}
|
|
8809
8820
|
if (this.handler !== null) {
|
|
8810
8821
|
this.handler.include(context, includeChildrenRecursively);
|
|
8811
8822
|
context.brokenFlow = brokenFlow;
|
|
@@ -9724,7 +9735,6 @@ class Module {
|
|
|
9724
9735
|
this.graph = graph;
|
|
9725
9736
|
this.id = id;
|
|
9726
9737
|
this.options = options;
|
|
9727
|
-
this.syntheticNamedExports = syntheticNamedExports;
|
|
9728
9738
|
this.ast = null;
|
|
9729
9739
|
this.chunkFileNames = new Set();
|
|
9730
9740
|
this.chunkName = null;
|
|
@@ -9794,7 +9804,8 @@ class Module {
|
|
|
9794
9804
|
},
|
|
9795
9805
|
isEntry,
|
|
9796
9806
|
isExternal: false,
|
|
9797
|
-
meta
|
|
9807
|
+
meta,
|
|
9808
|
+
syntheticNamedExports
|
|
9798
9809
|
};
|
|
9799
9810
|
}
|
|
9800
9811
|
basename() {
|
|
@@ -9892,7 +9903,7 @@ class Module {
|
|
|
9892
9903
|
}
|
|
9893
9904
|
const exportNamesByVariable = new Map();
|
|
9894
9905
|
for (const exportName of this.getAllExportNames()) {
|
|
9895
|
-
if (exportName === this.syntheticNamedExports)
|
|
9906
|
+
if (exportName === this.info.syntheticNamedExports)
|
|
9896
9907
|
continue;
|
|
9897
9908
|
let tracedVariable = this.getVariableForExportName(exportName);
|
|
9898
9909
|
if (tracedVariable instanceof ExportDefaultVariable) {
|
|
@@ -9951,14 +9962,17 @@ class Module {
|
|
|
9951
9962
|
getSyntheticNamespace() {
|
|
9952
9963
|
if (this.syntheticNamespace === null) {
|
|
9953
9964
|
this.syntheticNamespace = undefined;
|
|
9954
|
-
this.syntheticNamespace = this.getVariableForExportName(typeof this.syntheticNamedExports === 'string'
|
|
9965
|
+
this.syntheticNamespace = this.getVariableForExportName(typeof this.info.syntheticNamedExports === 'string'
|
|
9966
|
+
? this.info.syntheticNamedExports
|
|
9967
|
+
: 'default');
|
|
9955
9968
|
}
|
|
9956
9969
|
if (!this.syntheticNamespace) {
|
|
9957
9970
|
return error({
|
|
9958
9971
|
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
9959
9972
|
id: this.id,
|
|
9960
|
-
message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.syntheticNamedExports)}' needs ${typeof this.syntheticNamedExports === 'string' &&
|
|
9961
|
-
|
|
9973
|
+
message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.info.syntheticNamedExports)}' needs ${typeof this.info.syntheticNamedExports === 'string' &&
|
|
9974
|
+
this.info.syntheticNamedExports !== 'default'
|
|
9975
|
+
? `an export named "${this.info.syntheticNamedExports}"`
|
|
9962
9976
|
: 'a default export'}.`
|
|
9963
9977
|
});
|
|
9964
9978
|
}
|
|
@@ -10002,7 +10016,7 @@ class Module {
|
|
|
10002
10016
|
// we don't want to create shims when we are just
|
|
10003
10017
|
// probing export * modules for exports
|
|
10004
10018
|
if (!isExportAllSearch) {
|
|
10005
|
-
if (this.syntheticNamedExports) {
|
|
10019
|
+
if (this.info.syntheticNamedExports) {
|
|
10006
10020
|
let syntheticExport = this.syntheticExports.get(name);
|
|
10007
10021
|
if (!syntheticExport) {
|
|
10008
10022
|
const syntheticNamespace = this.getSyntheticNamespace();
|
|
@@ -10034,7 +10048,7 @@ class Module {
|
|
|
10034
10048
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
10035
10049
|
}
|
|
10036
10050
|
for (const exportName of this.getExports()) {
|
|
10037
|
-
if (includeNamespaceMembers || exportName !== this.syntheticNamedExports) {
|
|
10051
|
+
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
10038
10052
|
const variable = this.getVariableForExportName(exportName);
|
|
10039
10053
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
10040
10054
|
if (!variable.included) {
|
|
@@ -10160,7 +10174,7 @@ class Module {
|
|
|
10160
10174
|
warn: this.warn.bind(this)
|
|
10161
10175
|
};
|
|
10162
10176
|
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
10163
|
-
this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
|
|
10177
|
+
this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports);
|
|
10164
10178
|
this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
|
|
10165
10179
|
this.info.ast = ast;
|
|
10166
10180
|
timeEnd('analyse ast', 3);
|
|
@@ -10179,7 +10193,7 @@ class Module {
|
|
|
10179
10193
|
originalSourcemap: this.originalSourcemap,
|
|
10180
10194
|
resolvedIds: this.resolvedIds,
|
|
10181
10195
|
sourcemapChain: this.sourcemapChain,
|
|
10182
|
-
syntheticNamedExports: this.syntheticNamedExports,
|
|
10196
|
+
syntheticNamedExports: this.info.syntheticNamedExports,
|
|
10183
10197
|
transformDependencies: this.transformDependencies,
|
|
10184
10198
|
transformFiles: this.transformFiles
|
|
10185
10199
|
};
|
|
@@ -10208,7 +10222,7 @@ class Module {
|
|
|
10208
10222
|
this.info.hasModuleSideEffects = moduleSideEffects;
|
|
10209
10223
|
}
|
|
10210
10224
|
if (syntheticNamedExports != null) {
|
|
10211
|
-
this.syntheticNamedExports = syntheticNamedExports;
|
|
10225
|
+
this.info.syntheticNamedExports = syntheticNamedExports;
|
|
10212
10226
|
}
|
|
10213
10227
|
if (meta != null) {
|
|
10214
10228
|
this.info.meta = { ...this.info.meta, ...meta };
|
|
@@ -10358,7 +10372,7 @@ class Module {
|
|
|
10358
10372
|
this.imports.add(externalVariable);
|
|
10359
10373
|
mergedNamespaces.push(externalVariable);
|
|
10360
10374
|
}
|
|
10361
|
-
else if (module.syntheticNamedExports) {
|
|
10375
|
+
else if (module.info.syntheticNamedExports) {
|
|
10362
10376
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
10363
10377
|
syntheticNamespace.include();
|
|
10364
10378
|
this.imports.add(syntheticNamespace);
|
|
@@ -10978,7 +10992,7 @@ class Chunk$1 {
|
|
|
10978
10992
|
if (!chunkModules.has(importer)) {
|
|
10979
10993
|
this.dynamicEntryModules.push(module);
|
|
10980
10994
|
// Modules with synthetic exports need an artificial namespace for dynamic imports
|
|
10981
|
-
if (module.syntheticNamedExports && !outputOptions.preserveModules) {
|
|
10995
|
+
if (module.info.syntheticNamedExports && !outputOptions.preserveModules) {
|
|
10982
10996
|
includedNamespaces.add(module);
|
|
10983
10997
|
this.exports.add(module.namespace);
|
|
10984
10998
|
}
|
|
@@ -11101,7 +11115,7 @@ class Chunk$1 {
|
|
|
11101
11115
|
}
|
|
11102
11116
|
}
|
|
11103
11117
|
for (const module of this.dynamicEntryModules) {
|
|
11104
|
-
if (module.syntheticNamedExports)
|
|
11118
|
+
if (module.info.syntheticNamedExports)
|
|
11105
11119
|
continue;
|
|
11106
11120
|
if (!this.facadeModule && this.canModuleBeFacade(module, exposedVariables)) {
|
|
11107
11121
|
this.facadeModule = module;
|
|
@@ -18523,6 +18537,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
|
|
|
18523
18537
|
getFileName: fileEmitter.getFileName,
|
|
18524
18538
|
getModuleIds: () => graph.modulesById.keys(),
|
|
18525
18539
|
getModuleInfo: graph.getModuleInfo,
|
|
18540
|
+
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
18526
18541
|
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
18527
18542
|
meta: {
|
|
18528
18543
|
rollupVersion: version,
|
|
@@ -18564,6 +18579,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
|
|
|
18564
18579
|
const inputHookNames = {
|
|
18565
18580
|
buildEnd: 1,
|
|
18566
18581
|
buildStart: 1,
|
|
18582
|
+
closeWatcher: 1,
|
|
18567
18583
|
load: 1,
|
|
18568
18584
|
moduleParsed: 1,
|
|
18569
18585
|
options: 1,
|
|
@@ -18806,10 +18822,13 @@ class Graph {
|
|
|
18806
18822
|
});
|
|
18807
18823
|
if (watcher) {
|
|
18808
18824
|
this.watchMode = true;
|
|
18809
|
-
const handleChange = (
|
|
18825
|
+
const handleChange = (...args) => this.pluginDriver.hookSeqSync('watchChange', args);
|
|
18826
|
+
const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []);
|
|
18810
18827
|
watcher.on('change', handleChange);
|
|
18828
|
+
watcher.on('close', handleClose);
|
|
18811
18829
|
watcher.once('restart', () => {
|
|
18812
18830
|
watcher.removeListener('change', handleChange);
|
|
18831
|
+
watcher.removeListener('close', handleClose);
|
|
18813
18832
|
});
|
|
18814
18833
|
}
|
|
18815
18834
|
this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
Wed,
|
|
3
|
+
Rollup.js v2.33.3
|
|
4
|
+
Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -565,7 +565,7 @@ class FileWatcher {
|
|
|
565
565
|
const task = this.task;
|
|
566
566
|
const isLinux = require$$1.platform() === 'linux';
|
|
567
567
|
const isTransformDependency = transformWatcherId !== null;
|
|
568
|
-
const handleChange = (id) => {
|
|
568
|
+
const handleChange = (id, event) => {
|
|
569
569
|
const changedId = transformWatcherId || id;
|
|
570
570
|
if (isLinux) {
|
|
571
571
|
// unwatching and watching fixes an issue with chokidar where on certain systems,
|
|
@@ -574,22 +574,39 @@ class FileWatcher {
|
|
|
574
574
|
watcher.unwatch(changedId);
|
|
575
575
|
watcher.add(changedId);
|
|
576
576
|
}
|
|
577
|
-
task.invalidate(changedId, isTransformDependency);
|
|
577
|
+
task.invalidate(changedId, { isTransformDependency, event });
|
|
578
578
|
};
|
|
579
579
|
const watcher = index.chokidar
|
|
580
580
|
.watch([], this.chokidarOptions)
|
|
581
|
-
.on('add', handleChange)
|
|
582
|
-
.on('change', handleChange)
|
|
583
|
-
.on('unlink', handleChange);
|
|
581
|
+
.on('add', id => handleChange(id, 'create'))
|
|
582
|
+
.on('change', id => handleChange(id, 'update'))
|
|
583
|
+
.on('unlink', id => handleChange(id, 'delete'));
|
|
584
584
|
return watcher;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
+
const eventsRewrites = {
|
|
589
|
+
create: {
|
|
590
|
+
create: 'buggy',
|
|
591
|
+
delete: null,
|
|
592
|
+
update: 'create',
|
|
593
|
+
},
|
|
594
|
+
delete: {
|
|
595
|
+
create: 'update',
|
|
596
|
+
delete: 'buggy',
|
|
597
|
+
update: 'buggy',
|
|
598
|
+
},
|
|
599
|
+
update: {
|
|
600
|
+
create: 'buggy',
|
|
601
|
+
delete: 'delete',
|
|
602
|
+
update: 'update',
|
|
603
|
+
}
|
|
604
|
+
};
|
|
588
605
|
class Watcher {
|
|
589
606
|
constructor(configs, emitter) {
|
|
590
607
|
this.buildDelay = 0;
|
|
591
608
|
this.buildTimeout = null;
|
|
592
|
-
this.invalidatedIds = new
|
|
609
|
+
this.invalidatedIds = new Map();
|
|
593
610
|
this.rerun = false;
|
|
594
611
|
this.emitter = emitter;
|
|
595
612
|
emitter.close = this.close.bind(this);
|
|
@@ -606,14 +623,25 @@ class Watcher {
|
|
|
606
623
|
for (const task of this.tasks) {
|
|
607
624
|
task.close();
|
|
608
625
|
}
|
|
626
|
+
this.emitter.emit('close');
|
|
609
627
|
this.emitter.removeAllListeners();
|
|
610
628
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
629
|
+
invalidate(file) {
|
|
630
|
+
if (file) {
|
|
631
|
+
const prevEvent = this.invalidatedIds.get(file.id);
|
|
632
|
+
const event = prevEvent
|
|
633
|
+
? eventsRewrites[prevEvent][file.event]
|
|
634
|
+
: file.event;
|
|
635
|
+
if (event === 'buggy') {
|
|
636
|
+
//TODO: throws or warn? Currently just ignore, uses new event
|
|
637
|
+
this.invalidatedIds.set(file.id, file.event);
|
|
638
|
+
}
|
|
639
|
+
else if (event === null) {
|
|
640
|
+
this.invalidatedIds.delete(file.id);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
this.invalidatedIds.set(file.id, event);
|
|
644
|
+
}
|
|
617
645
|
}
|
|
618
646
|
if (this.running) {
|
|
619
647
|
this.rerun = true;
|
|
@@ -623,17 +651,17 @@ class Watcher {
|
|
|
623
651
|
clearTimeout(this.buildTimeout);
|
|
624
652
|
this.buildTimeout = setTimeout(() => {
|
|
625
653
|
this.buildTimeout = null;
|
|
626
|
-
for (const id of this.invalidatedIds) {
|
|
627
|
-
this.emit('change', id);
|
|
654
|
+
for (const [id, event] of this.invalidatedIds.entries()) {
|
|
655
|
+
this.emitter.emit('change', id, { event });
|
|
628
656
|
}
|
|
629
657
|
this.invalidatedIds.clear();
|
|
630
|
-
this.emit('restart');
|
|
658
|
+
this.emitter.emit('restart');
|
|
631
659
|
this.run();
|
|
632
660
|
}, this.buildDelay);
|
|
633
661
|
}
|
|
634
662
|
async run() {
|
|
635
663
|
this.running = true;
|
|
636
|
-
this.emit('event', {
|
|
664
|
+
this.emitter.emit('event', {
|
|
637
665
|
code: 'START'
|
|
638
666
|
});
|
|
639
667
|
try {
|
|
@@ -641,13 +669,13 @@ class Watcher {
|
|
|
641
669
|
await task.run();
|
|
642
670
|
}
|
|
643
671
|
this.running = false;
|
|
644
|
-
this.emit('event', {
|
|
672
|
+
this.emitter.emit('event', {
|
|
645
673
|
code: 'END'
|
|
646
674
|
});
|
|
647
675
|
}
|
|
648
676
|
catch (error) {
|
|
649
677
|
this.running = false;
|
|
650
|
-
this.emit('event', {
|
|
678
|
+
this.emitter.emit('event', {
|
|
651
679
|
code: 'ERROR',
|
|
652
680
|
error
|
|
653
681
|
});
|
|
@@ -686,9 +714,9 @@ class Task {
|
|
|
686
714
|
this.closed = true;
|
|
687
715
|
this.fileWatcher.close();
|
|
688
716
|
}
|
|
689
|
-
invalidate(id,
|
|
717
|
+
invalidate(id, details) {
|
|
690
718
|
this.invalidated = true;
|
|
691
|
-
if (isTransformDependency) {
|
|
719
|
+
if (details.isTransformDependency) {
|
|
692
720
|
for (const module of this.cache.modules) {
|
|
693
721
|
if (module.transformDependencies.indexOf(id) === -1)
|
|
694
722
|
continue;
|
|
@@ -696,7 +724,7 @@ class Task {
|
|
|
696
724
|
module.originalCode = null;
|
|
697
725
|
}
|
|
698
726
|
}
|
|
699
|
-
this.watcher.invalidate(id);
|
|
727
|
+
this.watcher.invalidate({ id, event: details.event });
|
|
700
728
|
}
|
|
701
729
|
async run() {
|
|
702
730
|
if (!this.invalidated)
|
|
@@ -707,7 +735,7 @@ class Task {
|
|
|
707
735
|
cache: this.cache
|
|
708
736
|
};
|
|
709
737
|
const start = Date.now();
|
|
710
|
-
this.watcher.emit('event', {
|
|
738
|
+
this.watcher.emitter.emit('event', {
|
|
711
739
|
code: 'BUNDLE_START',
|
|
712
740
|
input: this.options.input,
|
|
713
741
|
output: this.outputFiles
|
|
@@ -719,7 +747,7 @@ class Task {
|
|
|
719
747
|
}
|
|
720
748
|
this.updateWatchedFiles(result);
|
|
721
749
|
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
|
|
722
|
-
this.watcher.emit('event', {
|
|
750
|
+
this.watcher.emitter.emit('event', {
|
|
723
751
|
code: 'BUNDLE_END',
|
|
724
752
|
duration: Date.now() - start,
|
|
725
753
|
input: this.options.input,
|