rollup 2.31.0 → 2.33.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/CHANGELOG.md +40 -0
- 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 +43 -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 +20 -8
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +6 -4
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +43 -30
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +53 -25
- package/package.json +5 -7
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'
|
|
@@ -494,7 +505,7 @@ export type GlobalsOption = { [name: string]: string } | ((name: string) => stri
|
|
|
494
505
|
export type InputOption = string | string[] | { [entryAlias: string]: string };
|
|
495
506
|
export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
|
|
496
507
|
export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
|
|
497
|
-
export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension';
|
|
508
|
+
export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
|
|
498
509
|
export type SourcemapPathTransformOption = (
|
|
499
510
|
relativeSourcePath: string,
|
|
500
511
|
sourcemapPath: string
|
|
@@ -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.33.1
|
|
4
|
+
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -212,6 +212,7 @@ const deferredHandlers = {
|
|
|
212
212
|
showTruncatedWarnings(warnings);
|
|
213
213
|
},
|
|
214
214
|
PLUGIN_WARNING(warnings) {
|
|
215
|
+
var _a;
|
|
215
216
|
const nestedByPlugin = nest(warnings, 'plugin');
|
|
216
217
|
for (const { key: plugin, items } of nestedByPlugin) {
|
|
217
218
|
const nestedByMessage = nest(items, 'message');
|
|
@@ -221,8 +222,9 @@ const deferredHandlers = {
|
|
|
221
222
|
for (const warning of items) {
|
|
222
223
|
if (warning.url && warning.url !== lastUrl)
|
|
223
224
|
info((lastUrl = warning.url));
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
const id = warning.id || ((_a = warning.loc) === null || _a === void 0 ? void 0 : _a.file);
|
|
226
|
+
if (id) {
|
|
227
|
+
let loc = rollup.relativeId(id);
|
|
226
228
|
if (warning.loc) {
|
|
227
229
|
loc += `: (${warning.loc.line}:${warning.loc.column})`;
|
|
228
230
|
}
|
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.33.1
|
|
4
|
+
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
|
|
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.1";
|
|
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
|
}
|
|
@@ -9724,7 +9725,6 @@ class Module {
|
|
|
9724
9725
|
this.graph = graph;
|
|
9725
9726
|
this.id = id;
|
|
9726
9727
|
this.options = options;
|
|
9727
|
-
this.syntheticNamedExports = syntheticNamedExports;
|
|
9728
9728
|
this.ast = null;
|
|
9729
9729
|
this.chunkFileNames = new Set();
|
|
9730
9730
|
this.chunkName = null;
|
|
@@ -9794,7 +9794,8 @@ class Module {
|
|
|
9794
9794
|
},
|
|
9795
9795
|
isEntry,
|
|
9796
9796
|
isExternal: false,
|
|
9797
|
-
meta
|
|
9797
|
+
meta,
|
|
9798
|
+
syntheticNamedExports
|
|
9798
9799
|
};
|
|
9799
9800
|
}
|
|
9800
9801
|
basename() {
|
|
@@ -9892,7 +9893,7 @@ class Module {
|
|
|
9892
9893
|
}
|
|
9893
9894
|
const exportNamesByVariable = new Map();
|
|
9894
9895
|
for (const exportName of this.getAllExportNames()) {
|
|
9895
|
-
if (exportName === this.syntheticNamedExports)
|
|
9896
|
+
if (exportName === this.info.syntheticNamedExports)
|
|
9896
9897
|
continue;
|
|
9897
9898
|
let tracedVariable = this.getVariableForExportName(exportName);
|
|
9898
9899
|
if (tracedVariable instanceof ExportDefaultVariable) {
|
|
@@ -9951,14 +9952,17 @@ class Module {
|
|
|
9951
9952
|
getSyntheticNamespace() {
|
|
9952
9953
|
if (this.syntheticNamespace === null) {
|
|
9953
9954
|
this.syntheticNamespace = undefined;
|
|
9954
|
-
this.syntheticNamespace = this.getVariableForExportName(typeof this.syntheticNamedExports === 'string'
|
|
9955
|
+
this.syntheticNamespace = this.getVariableForExportName(typeof this.info.syntheticNamedExports === 'string'
|
|
9956
|
+
? this.info.syntheticNamedExports
|
|
9957
|
+
: 'default');
|
|
9955
9958
|
}
|
|
9956
9959
|
if (!this.syntheticNamespace) {
|
|
9957
9960
|
return error({
|
|
9958
9961
|
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
|
|
9959
9962
|
id: this.id,
|
|
9960
|
-
message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.syntheticNamedExports)}' needs ${typeof this.syntheticNamedExports === 'string' &&
|
|
9961
|
-
|
|
9963
|
+
message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.info.syntheticNamedExports)}' needs ${typeof this.info.syntheticNamedExports === 'string' &&
|
|
9964
|
+
this.info.syntheticNamedExports !== 'default'
|
|
9965
|
+
? `an export named "${this.info.syntheticNamedExports}"`
|
|
9962
9966
|
: 'a default export'}.`
|
|
9963
9967
|
});
|
|
9964
9968
|
}
|
|
@@ -10002,7 +10006,7 @@ class Module {
|
|
|
10002
10006
|
// we don't want to create shims when we are just
|
|
10003
10007
|
// probing export * modules for exports
|
|
10004
10008
|
if (!isExportAllSearch) {
|
|
10005
|
-
if (this.syntheticNamedExports) {
|
|
10009
|
+
if (this.info.syntheticNamedExports) {
|
|
10006
10010
|
let syntheticExport = this.syntheticExports.get(name);
|
|
10007
10011
|
if (!syntheticExport) {
|
|
10008
10012
|
const syntheticNamespace = this.getSyntheticNamespace();
|
|
@@ -10034,7 +10038,7 @@ class Module {
|
|
|
10034
10038
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
10035
10039
|
}
|
|
10036
10040
|
for (const exportName of this.getExports()) {
|
|
10037
|
-
if (includeNamespaceMembers || exportName !== this.syntheticNamedExports) {
|
|
10041
|
+
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
10038
10042
|
const variable = this.getVariableForExportName(exportName);
|
|
10039
10043
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
10040
10044
|
if (!variable.included) {
|
|
@@ -10160,7 +10164,7 @@ class Module {
|
|
|
10160
10164
|
warn: this.warn.bind(this)
|
|
10161
10165
|
};
|
|
10162
10166
|
this.scope = new ModuleScope(this.graph.scope, this.astContext);
|
|
10163
|
-
this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
|
|
10167
|
+
this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports);
|
|
10164
10168
|
this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
|
|
10165
10169
|
this.info.ast = ast;
|
|
10166
10170
|
timeEnd('analyse ast', 3);
|
|
@@ -10179,7 +10183,7 @@ class Module {
|
|
|
10179
10183
|
originalSourcemap: this.originalSourcemap,
|
|
10180
10184
|
resolvedIds: this.resolvedIds,
|
|
10181
10185
|
sourcemapChain: this.sourcemapChain,
|
|
10182
|
-
syntheticNamedExports: this.syntheticNamedExports,
|
|
10186
|
+
syntheticNamedExports: this.info.syntheticNamedExports,
|
|
10183
10187
|
transformDependencies: this.transformDependencies,
|
|
10184
10188
|
transformFiles: this.transformFiles
|
|
10185
10189
|
};
|
|
@@ -10208,7 +10212,7 @@ class Module {
|
|
|
10208
10212
|
this.info.hasModuleSideEffects = moduleSideEffects;
|
|
10209
10213
|
}
|
|
10210
10214
|
if (syntheticNamedExports != null) {
|
|
10211
|
-
this.syntheticNamedExports = syntheticNamedExports;
|
|
10215
|
+
this.info.syntheticNamedExports = syntheticNamedExports;
|
|
10212
10216
|
}
|
|
10213
10217
|
if (meta != null) {
|
|
10214
10218
|
this.info.meta = { ...this.info.meta, ...meta };
|
|
@@ -10358,7 +10362,7 @@ class Module {
|
|
|
10358
10362
|
this.imports.add(externalVariable);
|
|
10359
10363
|
mergedNamespaces.push(externalVariable);
|
|
10360
10364
|
}
|
|
10361
|
-
else if (module.syntheticNamedExports) {
|
|
10365
|
+
else if (module.info.syntheticNamedExports) {
|
|
10362
10366
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
10363
10367
|
syntheticNamespace.include();
|
|
10364
10368
|
this.imports.add(syntheticNamespace);
|
|
@@ -10978,7 +10982,7 @@ class Chunk$1 {
|
|
|
10978
10982
|
if (!chunkModules.has(importer)) {
|
|
10979
10983
|
this.dynamicEntryModules.push(module);
|
|
10980
10984
|
// Modules with synthetic exports need an artificial namespace for dynamic imports
|
|
10981
|
-
if (module.syntheticNamedExports && !outputOptions.preserveModules) {
|
|
10985
|
+
if (module.info.syntheticNamedExports && !outputOptions.preserveModules) {
|
|
10982
10986
|
includedNamespaces.add(module);
|
|
10983
10987
|
this.exports.add(module.namespace);
|
|
10984
10988
|
}
|
|
@@ -11080,24 +11084,28 @@ class Chunk$1 {
|
|
|
11080
11084
|
if (requiredFacades.length === 0) {
|
|
11081
11085
|
requiredFacades.push({});
|
|
11082
11086
|
}
|
|
11083
|
-
if (!this.facadeModule
|
|
11084
|
-
|
|
11085
|
-
module.preserveSignature
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
this.
|
|
11091
|
-
this.
|
|
11087
|
+
if (!this.facadeModule) {
|
|
11088
|
+
const needsStrictFacade = module.preserveSignature === 'strict' ||
|
|
11089
|
+
(module.preserveSignature === 'exports-only' &&
|
|
11090
|
+
module.getExportNamesByVariable().size !== 0);
|
|
11091
|
+
if (!needsStrictFacade ||
|
|
11092
|
+
this.outputOptions.preserveModules ||
|
|
11093
|
+
this.canModuleBeFacade(module, exposedVariables)) {
|
|
11094
|
+
this.facadeModule = module;
|
|
11095
|
+
this.facadeChunkByModule.set(module, this);
|
|
11096
|
+
if (module.preserveSignature) {
|
|
11097
|
+
this.strictFacade = needsStrictFacade;
|
|
11098
|
+
this.ensureReexportsAreAvailableForModule(module);
|
|
11099
|
+
}
|
|
11100
|
+
this.assignFacadeName(requiredFacades.shift(), module);
|
|
11092
11101
|
}
|
|
11093
|
-
this.assignFacadeName(requiredFacades.shift(), module);
|
|
11094
11102
|
}
|
|
11095
11103
|
for (const facadeName of requiredFacades) {
|
|
11096
11104
|
facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
|
|
11097
11105
|
}
|
|
11098
11106
|
}
|
|
11099
11107
|
for (const module of this.dynamicEntryModules) {
|
|
11100
|
-
if (module.syntheticNamedExports)
|
|
11108
|
+
if (module.info.syntheticNamedExports)
|
|
11101
11109
|
continue;
|
|
11102
11110
|
if (!this.facadeModule && this.canModuleBeFacade(module, exposedVariables)) {
|
|
11103
11111
|
this.facadeModule = module;
|
|
@@ -18519,6 +18527,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
|
|
|
18519
18527
|
getFileName: fileEmitter.getFileName,
|
|
18520
18528
|
getModuleIds: () => graph.modulesById.keys(),
|
|
18521
18529
|
getModuleInfo: graph.getModuleInfo,
|
|
18530
|
+
getWatchFiles: () => Object.keys(graph.watchFiles),
|
|
18522
18531
|
isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
|
|
18523
18532
|
meta: {
|
|
18524
18533
|
rollupVersion: version,
|
|
@@ -18560,6 +18569,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
|
|
|
18560
18569
|
const inputHookNames = {
|
|
18561
18570
|
buildEnd: 1,
|
|
18562
18571
|
buildStart: 1,
|
|
18572
|
+
closeWatcher: 1,
|
|
18563
18573
|
load: 1,
|
|
18564
18574
|
moduleParsed: 1,
|
|
18565
18575
|
options: 1,
|
|
@@ -18802,10 +18812,13 @@ class Graph {
|
|
|
18802
18812
|
});
|
|
18803
18813
|
if (watcher) {
|
|
18804
18814
|
this.watchMode = true;
|
|
18805
|
-
const handleChange = (
|
|
18815
|
+
const handleChange = (...args) => this.pluginDriver.hookSeqSync('watchChange', args);
|
|
18816
|
+
const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []);
|
|
18806
18817
|
watcher.on('change', handleChange);
|
|
18818
|
+
watcher.on('close', handleClose);
|
|
18807
18819
|
watcher.once('restart', () => {
|
|
18808
18820
|
watcher.removeListener('change', handleChange);
|
|
18821
|
+
watcher.removeListener('close', handleClose);
|
|
18809
18822
|
});
|
|
18810
18823
|
}
|
|
18811
18824
|
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
|
-
|
|
3
|
+
Rollup.js v2.33.1
|
|
4
|
+
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
|
|
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,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.1",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
7
7
|
"typings": "dist/rollup.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"rollup": "
|
|
9
|
+
"rollup": "dist/bin/rollup"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "shx rm -rf dist && git rev-parse HEAD > .commithash && rollup -c && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
|
|
@@ -35,11 +35,6 @@
|
|
|
35
35
|
"test:coverage": "nyc --reporter html mocha",
|
|
36
36
|
"test:leak": "cross-os test:leak:os",
|
|
37
37
|
"test:package": "node scripts/test-package.js",
|
|
38
|
-
"test:leak:os": {
|
|
39
|
-
"darwin": "npm run test:leak:nix",
|
|
40
|
-
"linux": "npm run test:leak:nix",
|
|
41
|
-
"win32": "echo 'Skipping test:leak on Windows'"
|
|
42
|
-
},
|
|
43
38
|
"test:leak:nix": "npm i --silent --no-save weak@1 && node --expose-gc test/leak/index.js",
|
|
44
39
|
"test:only": "mocha",
|
|
45
40
|
"test:quick": "mocha -b",
|
|
@@ -148,5 +143,8 @@
|
|
|
148
143
|
"default": "./dist/es/rollup.browser.js"
|
|
149
144
|
},
|
|
150
145
|
"./dist/": "./dist/"
|
|
146
|
+
},
|
|
147
|
+
"dependencies": {
|
|
148
|
+
"fsevents": "~2.1.2"
|
|
151
149
|
}
|
|
152
150
|
}
|