From ebcd65265204e8bc6101165e0ffcc3a1474aecc0 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 14 Feb 2020 07:22:54 +0100 Subject: [PATCH] [v2.0.0] Remove experimentalOptimizeChunks (#3343) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [v2.0.0] Update minimum required Node version to 10 (#3346) * Update CI to only run on Node 10 and 12, add engines to package.json * Update TypeScript target * Remove Bublé as a transpilation option from tests (it is still needed in sourcemap tests) * Remove minNodeVersion form tests * Reformat package.json * [v2.0.0] Bundle chokidar (#3331) * Create a separate chunk for watch mode via a dynamic import * Bundle chokidar * Handle conditional fsevents import * Only run tests on Node 10 and 12 as we want to do this anyway and chokidar depends on utils.promisify * Improve chunking * Refactor and simplify watcher * Make watcher a proper parameter * Only unwatch and watch on Linux systems * No longer run JS files through TypeScript for improved bundling performance * [v2.0.0] Remove active deprecations (#3352) * Remove active deprecations * Make inactive deprecations active * Improve coverage * Improve coverage * Refine transformer * Improve coverage * Refactoring option normalization * Improve coverage * Remove experimentalOptimizeChunks * Remove more unused code --- build-plugins/fix-acorn-esm-import.js | 23 +++ docs/01-command-line-reference.md | 2 - docs/02-javascript-api.md | 2 - docs/999-big-list-of-options.md | 14 -- src/Chunk.ts | 137 ----------------- src/chunk-optimization.ts | 138 ------------------ src/rollup/rollup.ts | 19 --- src/rollup/types.d.ts | 2 - src/utils/parseOptions.ts | 2 - src/watch/watch.ts | 5 +- .../samples/grouping-multiple/_config.js | 8 - .../_expected/amd/generated-dep3.js | 13 -- .../grouping-multiple/_expected/amd/main1.js | 7 - .../grouping-multiple/_expected/amd/main2.js | 7 - .../grouping-multiple/_expected/amd/main3.js | 7 - .../_expected/cjs/generated-dep3.js | 11 -- .../grouping-multiple/_expected/cjs/main1.js | 7 - .../grouping-multiple/_expected/cjs/main2.js | 7 - .../grouping-multiple/_expected/cjs/main3.js | 7 - .../_expected/es/generated-dep3.js | 7 - .../grouping-multiple/_expected/es/main1.js | 5 - .../grouping-multiple/_expected/es/main2.js | 5 - .../grouping-multiple/_expected/es/main3.js | 5 - .../_expected/system/generated-dep3.js | 14 -- .../_expected/system/main1.js | 15 -- .../_expected/system/main2.js | 15 -- .../_expected/system/main3.js | 15 -- .../samples/grouping-multiple/dep1.js | 1 - .../samples/grouping-multiple/dep2.js | 1 - .../samples/grouping-multiple/dep3.js | 1 - .../samples/grouping-multiple/main1.js | 4 - .../samples/grouping-multiple/main2.js | 4 - .../samples/grouping-multiple/main3.js | 4 - .../samples/grouping-size/_config.js | 8 - .../_expected/amd/generated-dep1.js | 8 - .../_expected/amd/generated-dep3.js | 10 -- .../grouping-size/_expected/amd/main1.js | 7 - .../grouping-size/_expected/amd/main2.js | 7 - .../grouping-size/_expected/amd/main3.js | 7 - .../_expected/cjs/generated-dep1.js | 6 - .../_expected/cjs/generated-dep3.js | 8 - .../grouping-size/_expected/cjs/main1.js | 8 - .../grouping-size/_expected/cjs/main2.js | 8 - .../grouping-size/_expected/cjs/main3.js | 7 - .../_expected/es/generated-dep1.js | 4 - .../_expected/es/generated-dep3.js | 5 - .../grouping-size/_expected/es/main1.js | 6 - .../grouping-size/_expected/es/main2.js | 6 - .../grouping-size/_expected/es/main3.js | 5 - .../_expected/system/generated-dep1.js | 11 -- .../_expected/system/generated-dep3.js | 12 -- .../grouping-size/_expected/system/main1.js | 16 -- .../grouping-size/_expected/system/main2.js | 16 -- .../grouping-size/_expected/system/main3.js | 15 -- .../samples/grouping-size/dep1.js | 2 - .../samples/grouping-size/dep2.js | 1 - .../samples/grouping-size/dep3.js | 1 - .../samples/grouping-size/main1.js | 4 - .../samples/grouping-size/main2.js | 4 - .../samples/grouping-size/main3.js | 4 - .../inline-imports-with-optimize/_config.js | 12 -- .../inline-imports-with-optimize/lib.js | 1 - .../inline-imports-with-optimize/main.js | 1 - .../optimize-chunks/_config.js | 12 -- .../preserve-modules/optimize-chunks/lib.js | 1 - .../preserve-modules/optimize-chunks/main.js | 3 - test/misc/optionList.js | 4 +- test/watch/index.js | 40 +++++ 68 files changed, 68 insertions(+), 716 deletions(-) create mode 100644 build-plugins/fix-acorn-esm-import.js delete mode 100644 src/chunk-optimization.ts delete mode 100644 test/chunking-form/samples/grouping-multiple/_config.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/amd/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/cjs/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/cjs/main1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/cjs/main2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/cjs/main3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/es/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/es/main1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/es/main2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/es/main3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/system/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/system/main1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/system/main2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/_expected/system/main3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/dep1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/dep2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/dep3.js delete mode 100644 test/chunking-form/samples/grouping-multiple/main1.js delete mode 100644 test/chunking-form/samples/grouping-multiple/main2.js delete mode 100644 test/chunking-form/samples/grouping-multiple/main3.js delete mode 100644 test/chunking-form/samples/grouping-size/_config.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/amd/generated-dep1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/amd/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/amd/main1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/amd/main2.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/amd/main3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/cjs/main1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/cjs/main2.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/cjs/main3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/es/generated-dep1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/es/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/es/main1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/es/main2.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/es/main3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/system/generated-dep1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/system/generated-dep3.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/system/main1.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/system/main2.js delete mode 100644 test/chunking-form/samples/grouping-size/_expected/system/main3.js delete mode 100644 test/chunking-form/samples/grouping-size/dep1.js delete mode 100644 test/chunking-form/samples/grouping-size/dep2.js delete mode 100644 test/chunking-form/samples/grouping-size/dep3.js delete mode 100644 test/chunking-form/samples/grouping-size/main1.js delete mode 100644 test/chunking-form/samples/grouping-size/main2.js delete mode 100644 test/chunking-form/samples/grouping-size/main3.js delete mode 100644 test/function/samples/inline-imports-with-optimize/_config.js delete mode 100644 test/function/samples/inline-imports-with-optimize/lib.js delete mode 100644 test/function/samples/inline-imports-with-optimize/main.js delete mode 100644 test/function/samples/preserve-modules/optimize-chunks/_config.js delete mode 100644 test/function/samples/preserve-modules/optimize-chunks/lib.js delete mode 100644 test/function/samples/preserve-modules/optimize-chunks/main.js diff --git a/build-plugins/fix-acorn-esm-import.js b/build-plugins/fix-acorn-esm-import.js new file mode 100644 index 00000000000..bdb5284ce98 --- /dev/null +++ b/build-plugins/fix-acorn-esm-import.js @@ -0,0 +1,23 @@ +const expectedAcornImport = "import acorn, { Parser } from 'acorn';"; +const newAcornImport = "import * as acorn from 'acorn';\nimport { Parser } from 'acorn';"; + +// by default, rollup-plugin-commonjs will translate require statements as default imports +// which can cause issues for secondary tools that use the ESM version of acorn +export default function fixAcornEsmImport() { + let found = false; + + return { + name: 'fix-acorn-esm-import', + renderChunk(code) { + return code.replace(expectedAcornImport, () => { + found = true; + return newAcornImport; + }); + }, + writeBundle() { + if (!found) { + this.error('Could not find expected acorn import, please examine generated code.'); + } + } + }; +} diff --git a/docs/01-command-line-reference.md b/docs/01-command-line-reference.md index 382d39c4651..596efd12c5a 100755 --- a/docs/01-command-line-reference.md +++ b/docs/01-command-line-reference.md @@ -53,9 +53,7 @@ export default { // can be an array (for multiple inputs) treeshake, // experimental - chunkGroupingSize, experimentalCacheExpiry, - experimentalOptimizeChunks, perf, output: { // required (can be an array, for multiple outputs) diff --git a/docs/02-javascript-api.md b/docs/02-javascript-api.md index 7f207c67c56..7b4463b2812 100755 --- a/docs/02-javascript-api.md +++ b/docs/02-javascript-api.md @@ -96,9 +96,7 @@ const inputOptions = { treeshake, // experimental - chunkGroupingSize, experimentalCacheExpiry, - experimentalOptimizeChunks, perf }; ``` diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index 4881a091b98..ba13b941828 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -1053,13 +1053,6 @@ In the example, the last line is always retained as accessing the `element` prop These options reflect new features that have not yet been fully finalized. Availability, behaviour and usage may therefore be subject to change between minor versions. -#### chunkGroupingSize -Type: `number`
-CLI: `--chunkGroupingSize `
-Default: `5000` - -The total source length allowed to be loaded unnecessarily when using `experimentalOptimizeChunks`. - #### experimentalCacheExpiry Type: `number`
CLI: `--experimentalCacheExpiry `
@@ -1067,13 +1060,6 @@ Default: `10` Determines after how many runs cached assets that are no longer used by plugins should be removed. -#### experimentalOptimizeChunks -Type: `boolean`
-CLI: `--experimentalOptimizeChunks`/`--no-experimentalOptimizeChunks`
-Default: `false` - -Experimental feature to optimize chunk groupings. When a large number of chunks are generated, this allows smaller chunks to group together as long as they are within the `chunkGroupingSize` limit. It results in unnecessary code being loaded in some cases in order to have a smaller number of chunks overall. Disabled by default as it may cause unwanted side effects when loading unexpected code. - #### perf Type: `boolean`
CLI: `--perf`/`--no-perf`
diff --git a/src/Chunk.ts b/src/Chunk.ts index 84829b086ef..465c996e030 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -167,7 +167,6 @@ export default class Chunk { private renderedHash: string = undefined as any; private renderedModuleSources = new Map(); private renderedSource: MagicStringBundle | null = null; - private renderedSourceLength: number = undefined as any; private sortedExportNames: string[] | null = null; constructor(graph: Graph, orderedModules: Module[]) { @@ -383,11 +382,6 @@ export default class Chunk { return (this.renderedHash = hash.digest('hex')); } - getRenderedSourceLength() { - if (this.renderedSourceLength !== undefined) return this.renderedSourceLength; - return (this.renderedSourceLength = (this.renderedSource as MagicStringBundle).length()); - } - getVariableExportName(variable: Variable): string { if (this.graph.preserveModules && variable instanceof NamespaceVariable) { return '*'; @@ -406,119 +400,6 @@ export default class Chunk { } } - /* - * Performs a full merge of another chunk into this chunk - * chunkList allows updating references in other chunks for the merged chunk to this chunk - * A new facade will be added to chunkList if tainting exports of either as an entry point - */ - merge(chunk: Chunk, chunkList: Chunk[], options: OutputOptions, inputBase: string) { - if (this.facadeModule !== null || chunk.facadeModule !== null) - throw new Error('Internal error: Code splitting chunk merges not supported for facades'); - - for (const module of chunk.orderedModules) { - module.chunk = this; - this.orderedModules.push(module); - } - - for (const variable of chunk.imports) { - if (!this.imports.has(variable) && (variable.module as Module).chunk !== this) { - this.imports.add(variable); - } - } - - // NB detect when exported variables are orphaned by the merge itself - // (involves reverse tracing dependents) - for (const variable of chunk.exports) { - if (!this.exports.has(variable)) { - this.exports.add(variable); - } - } - - const thisOldExportNames = this.exportNames; - - // regenerate internal names - this.generateInternalExports(options); - - const updateRenderedDeclaration = ( - dep: ModuleDeclarationDependency, - oldExportNames: Record - ) => { - if (dep.imports) { - for (const impt of dep.imports) { - impt.imported = this.getVariableExportName(oldExportNames[impt.imported]); - } - } - if (dep.reexports) { - for (const reexport of dep.reexports) { - reexport.imported = this.getVariableExportName(oldExportNames[reexport.imported]); - } - } - }; - - const mergeRenderedDeclaration = ( - into: ModuleDeclarationDependency, - from: ModuleDeclarationDependency - ) => { - if (from.imports) { - if (!into.imports) { - into.imports = from.imports; - } else { - into.imports = into.imports.concat(from.imports); - } - } - if (from.reexports) { - if (!into.reexports) { - into.reexports = from.reexports; - } else { - into.reexports = into.reexports.concat(from.reexports); - } - } - if (!into.exportsNames && from.exportsNames) { - into.exportsNames = true; - } - if (!into.exportsDefault && from.exportsDefault) { - into.exportsDefault = true; - } - into.name = this.variableName; - }; - - // go through the other chunks and update their dependencies - // also update their import and reexport names in the process - for (const c of chunkList) { - let includedDeclaration: ModuleDeclarationDependency = undefined as any; - const dependencies = Array.from(c.dependencies); - const renderedDependencies = dependencies.map(dep => c.renderedDependencies!.get(dep)); - for (let i = 0; i < dependencies.length; i++) { - const dep = dependencies[i]; - if ((dep === chunk || dep === this) && includedDeclaration) { - const duplicateDeclaration = renderedDependencies[i]!; - updateRenderedDeclaration( - duplicateDeclaration, - dep === chunk ? chunk.exportNames : thisOldExportNames - ); - mergeRenderedDeclaration(includedDeclaration, duplicateDeclaration); - renderedDependencies.splice(i, 1); - dependencies.splice(i--, 1); - } else if (dep === chunk) { - dependencies[i] = this; - includedDeclaration = renderedDependencies[i]!; - updateRenderedDeclaration(includedDeclaration, chunk.exportNames); - } else if (dep === this) { - includedDeclaration = renderedDependencies[i]!; - updateRenderedDeclaration(includedDeclaration, thisOldExportNames); - } - } - c.dependencies = new Set(dependencies); - c.renderedDependencies = new Map(); - for (let i = 0; i < dependencies.length; i++) { - c.renderedDependencies.set(dependencies[i], renderedDependencies[i]!); - } - } - - // re-render the merged chunk - this.preRender(options, inputBase); - } - // prerender allows chunk hashes and names to be generated before finalizing preRender(options: OutputOptions, inputBase: string) { timeStart('render modules', 3); @@ -601,7 +482,6 @@ export default class Chunk { this.renderedSource = magicString.trim(); } - this.renderedSourceLength = undefined as any; this.renderedHash = undefined as any; if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) { @@ -749,23 +629,6 @@ export default class Chunk { }); } - visitStaticDependenciesUntilCondition( - isConditionSatisfied: (dep: Chunk | ExternalModule) => any - ): boolean { - const seen = new Set(); - function visitDep(dep: Chunk | ExternalModule): boolean { - if (seen.has(dep)) return undefined as any; - seen.add(dep); - if (dep instanceof Chunk) { - for (const subDep of dep.dependencies) { - if (visitDep(subDep)) return true; - } - } - return isConditionSatisfied(dep) === true; - } - return visitDep(this); - } - private addDependenciesToChunk( moduleDependencies: Set, chunkDependencies: Set diff --git a/src/chunk-optimization.ts b/src/chunk-optimization.ts deleted file mode 100644 index 3a71f131ced..00000000000 --- a/src/chunk-optimization.ts +++ /dev/null @@ -1,138 +0,0 @@ -import Chunk from './Chunk'; -import ExternalModule from './ExternalModule'; -import { OutputOptions } from './rollup/types'; - -/* - * Given a chunk list, perform optimizations on that chunk list - * to reduce the mumber of chunks. Mutates the chunks array. - * - * Manual chunks (with chunk.chunkAlias already set) are preserved - * Entry points are carefully preserved as well - * - */ -export function optimizeChunks( - chunks: Chunk[], - options: OutputOptions, - CHUNK_GROUPING_SIZE: number, - inputBase: string -): Chunk[] { - for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) { - const mainChunk = chunks[chunkIndex]; - const execGroup: Chunk[] = []; - mainChunk.visitStaticDependenciesUntilCondition(dep => { - if (dep instanceof Chunk) { - execGroup.push(dep); - } - }); - - if (execGroup.length < 2) { - continue; - } - - let execGroupIndex = 1; - let seekingFirstMergeCandidate = true; - let lastChunk: Chunk = undefined as any, - chunk = execGroup[0], - nextChunk = execGroup[1]; - - const isMergeCandidate = (chunk: Chunk) => { - if (chunk.facadeModule !== null || chunk.manualChunkAlias !== null) { - return false; - } - if (!nextChunk || nextChunk.facadeModule !== null) { - return false; - } - if (chunk.getRenderedSourceLength() > CHUNK_GROUPING_SIZE) { - return false; - } - // if (!chunk.isPure()) continue; - return true; - }; - - do { - if (seekingFirstMergeCandidate) { - if (isMergeCandidate(chunk)) { - seekingFirstMergeCandidate = false; - } - continue; - } - - let remainingSize = - CHUNK_GROUPING_SIZE - lastChunk.getRenderedSourceLength() - chunk.getRenderedSourceLength(); - if (remainingSize <= 0) { - if (!isMergeCandidate(chunk)) { - seekingFirstMergeCandidate = true; - } - continue; - } - // if (!chunk.isPure()) continue; - - const chunkDependencies = new Set(); - chunk.visitStaticDependenciesUntilCondition(dep => chunkDependencies.add(dep)); - - const ignoreSizeChunks = new Set([chunk, lastChunk]); - if ( - lastChunk.visitStaticDependenciesUntilCondition(dep => { - if (dep === chunk || dep === lastChunk) { - return false; - } - if (chunkDependencies.has(dep)) { - return false; - } - if (dep instanceof ExternalModule) { - return true; - } - remainingSize -= dep.getRenderedSourceLength(); - if (remainingSize <= 0) { - return true; - } - ignoreSizeChunks.add(dep); - }) - ) { - if (!isMergeCandidate(chunk)) { - seekingFirstMergeCandidate = true; - } - continue; - } - - if ( - chunk.visitStaticDependenciesUntilCondition(dep => { - if (ignoreSizeChunks.has(dep)) { - return false; - } - if (dep instanceof ExternalModule) { - return true; - } - remainingSize -= dep.getRenderedSourceLength(); - if (remainingSize <= 0) { - return true; - } - }) - ) { - if (!isMergeCandidate(chunk)) { - seekingFirstMergeCandidate = true; - } - continue; - } - - // within the size limit -> merge! - const optimizedChunkIndex = chunks.indexOf(chunk); - if (optimizedChunkIndex <= chunkIndex) chunkIndex--; - chunks.splice(optimizedChunkIndex, 1); - - lastChunk.merge(chunk, chunks, options, inputBase); - - execGroup.splice(--execGroupIndex, 1); - - chunk = lastChunk; - // keep going to see if we can merge this with the next again - if (nextChunk && !isMergeCandidate(nextChunk)) { - seekingFirstMergeCandidate = true; - } - } while ( - ((lastChunk = chunk), (chunk = nextChunk), (nextChunk = execGroup[++execGroupIndex]), chunk) - ); - } - - return chunks; -} diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index 06708b20c8b..d8af45ed66f 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -1,6 +1,5 @@ import { version as rollupVersion } from 'package.json'; import Chunk from '../Chunk'; -import { optimizeChunks } from '../chunk-optimization'; import Graph from '../Graph'; import { createAddons } from '../utils/addons'; import { assignChunkIds } from '../utils/assignChunkIds'; @@ -82,12 +81,6 @@ function getInputOptions(rawInputOptions: GenericConfigObject): InputOptions { code: 'INVALID_OPTION', message: '"manualChunks" option is not supported for "inlineDynamicImports".' }); - - if (inputOptions.experimentalOptimizeChunks) - return error({ - code: 'INVALID_OPTION', - message: '"experimentalOptimizeChunks" option is not supported for "inlineDynamicImports".' - }); if ( (inputOptions.input instanceof Array && inputOptions.input.length > 1) || (typeof inputOptions.input === 'object' && Object.keys(inputOptions.input).length > 1) @@ -102,11 +95,6 @@ function getInputOptions(rawInputOptions: GenericConfigObject): InputOptions { code: 'INVALID_OPTION', message: '"preserveModules" does not support the "manualChunks" option.' }); - if (inputOptions.experimentalOptimizeChunks) - return error({ - code: 'INVALID_OPTION', - message: '"preserveModules" does not support the "experimentalOptimizeChunks" option.' - }); } return inputOptions; @@ -182,9 +170,6 @@ export async function rollupInternal( timeEnd('BUILD', 1); - // ensure we only do one optimization pass per build - let optimized = false; - function getOutputOptionsAndPluginDriver( rawOutputOptions: GenericConfigObject ): { outputOptions: OutputOptions; outputPluginDriver: PluginDriver } { @@ -230,10 +215,6 @@ export async function rollupInternal( for (const chunk of chunks) { chunk.preRender(outputOptions, inputBase); } - if (!optimized && inputOptions.experimentalOptimizeChunks) { - optimizeChunks(chunks, outputOptions, inputOptions.chunkGroupingSize!, inputBase); - optimized = true; - } assignChunkIds( chunks, inputOptions, diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 79c997045d8..87a2a36186e 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -389,10 +389,8 @@ export interface InputOptions { acorn?: any; acornInjectPlugins?: Function[]; cache?: false | RollupCache; - chunkGroupingSize?: number; context?: string; experimentalCacheExpiry?: number; - experimentalOptimizeChunks?: boolean; external?: ExternalOption; inlineDynamicImports?: boolean; input?: InputOption; diff --git a/src/utils/parseOptions.ts b/src/utils/parseOptions.ts index 9c2d9fd7a74..b8cc9ac7e48 100644 --- a/src/utils/parseOptions.ts +++ b/src/utils/parseOptions.ts @@ -99,10 +99,8 @@ export function parseInputOptions( acorn: config.acorn, acornInjectPlugins: config.acornInjectPlugins as any, cache: getOption('cache'), - chunkGroupingSize: getOption('chunkGroupingSize', 5000), context: getOption('context'), experimentalCacheExpiry: getOption('experimentalCacheExpiry', 10), - experimentalOptimizeChunks: getOption('experimentalOptimizeChunks'), external: getExternal(config, overrides) as any, inlineDynamicImports: getOption('inlineDynamicImports', false), input: getOption('input', []), diff --git a/src/watch/watch.ts b/src/watch/watch.ts index 7bf3981ebfb..3d7ad03d3ed 100644 --- a/src/watch/watch.ts +++ b/src/watch/watch.ts @@ -193,8 +193,9 @@ export class Task { } } if (error.id) { - this.cache.modules = this.cache.modules.filter(module => module.id !== error.id); - }throw error; + this.cache.modules = this.cache.modules.filter(module => module.id !== error.id); + } + throw error; } } diff --git a/test/chunking-form/samples/grouping-multiple/_config.js b/test/chunking-form/samples/grouping-multiple/_config.js deleted file mode 100644 index e3084e471c8..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'chunk grouping multiple chunks', - options: { - experimentalOptimizeChunks: true, - chunkGroupingSize: 5000, - input: ['main1.js', 'main2.js', 'main3.js'] - } -}; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/generated-dep3.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/generated-dep3.js deleted file mode 100644 index 2840be01777..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/generated-dep3.js +++ /dev/null @@ -1,13 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const x = 1; - - const y = 2; - - const z = 3; - - exports.x = x; - exports.y = y; - exports.z = z; - -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js deleted file mode 100644 index f72ae9595ae..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main1.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep3'], function (dep1) { 'use strict'; - - var main1 = dep1.x + dep1.y; - - return main1; - -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js deleted file mode 100644 index cd2e2da56fa..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep3'], function (dep1) { 'use strict'; - - var main2 = dep1.x + dep1.z; - - return main2; - -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js b/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js deleted file mode 100644 index d350c7f13da..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/amd/main3.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep3'], function (dep1) { 'use strict'; - - var main3 = dep1.y + dep1.z; - - return main3; - -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/cjs/generated-dep3.js b/test/chunking-form/samples/grouping-multiple/_expected/cjs/generated-dep3.js deleted file mode 100644 index 3e073ec8373..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/cjs/generated-dep3.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -const x = 1; - -const y = 2; - -const z = 3; - -exports.x = x; -exports.y = y; -exports.z = z; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main1.js b/test/chunking-form/samples/grouping-multiple/_expected/cjs/main1.js deleted file mode 100644 index 74fc4840ff8..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main1.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep3.js'); - -var main1 = dep1.x + dep1.y; - -module.exports = main1; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main2.js b/test/chunking-form/samples/grouping-multiple/_expected/cjs/main2.js deleted file mode 100644 index a27a78410d3..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main2.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep3.js'); - -var main2 = dep1.x + dep1.z; - -module.exports = main2; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main3.js b/test/chunking-form/samples/grouping-multiple/_expected/cjs/main3.js deleted file mode 100644 index 4cde9988a58..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/cjs/main3.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep3.js'); - -var main3 = dep1.y + dep1.z; - -module.exports = main3; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/es/generated-dep3.js b/test/chunking-form/samples/grouping-multiple/_expected/es/generated-dep3.js deleted file mode 100644 index 1b0cff90bad..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/es/generated-dep3.js +++ /dev/null @@ -1,7 +0,0 @@ -const x = 1; - -const y = 2; - -const z = 3; - -export { x, y, z }; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/es/main1.js b/test/chunking-form/samples/grouping-multiple/_expected/es/main1.js deleted file mode 100644 index 171ce283868..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/es/main1.js +++ /dev/null @@ -1,5 +0,0 @@ -import { x, y } from './generated-dep3.js'; - -var main1 = x + y; - -export default main1; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/es/main2.js b/test/chunking-form/samples/grouping-multiple/_expected/es/main2.js deleted file mode 100644 index eafaf36a946..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/es/main2.js +++ /dev/null @@ -1,5 +0,0 @@ -import { x, z } from './generated-dep3.js'; - -var main2 = x + z; - -export default main2; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/es/main3.js b/test/chunking-form/samples/grouping-multiple/_expected/es/main3.js deleted file mode 100644 index 27a13fc9109..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/es/main3.js +++ /dev/null @@ -1,5 +0,0 @@ -import { y, z } from './generated-dep3.js'; - -var main3 = y + z; - -export default main3; diff --git a/test/chunking-form/samples/grouping-multiple/_expected/system/generated-dep3.js b/test/chunking-form/samples/grouping-multiple/_expected/system/generated-dep3.js deleted file mode 100644 index 64d530f72b8..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/system/generated-dep3.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const x = exports('x', 1); - - const y = exports('y', 2); - - const z = exports('z', 3); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/system/main1.js b/test/chunking-form/samples/grouping-multiple/_expected/system/main1.js deleted file mode 100644 index 297ef97c4cb..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/system/main1.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-dep3.js'], function (exports) { - 'use strict'; - var x, y; - return { - setters: [function (module) { - x = module.x; - y = module.y; - }], - execute: function () { - - var main1 = exports('default', x + y); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/system/main2.js b/test/chunking-form/samples/grouping-multiple/_expected/system/main2.js deleted file mode 100644 index c79b02efd87..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/system/main2.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-dep3.js'], function (exports) { - 'use strict'; - var x, z; - return { - setters: [function (module) { - x = module.x; - z = module.z; - }], - execute: function () { - - var main2 = exports('default', x + z); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-multiple/_expected/system/main3.js b/test/chunking-form/samples/grouping-multiple/_expected/system/main3.js deleted file mode 100644 index b691d6096e2..00000000000 --- a/test/chunking-form/samples/grouping-multiple/_expected/system/main3.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-dep3.js'], function (exports) { - 'use strict'; - var y, z; - return { - setters: [function (module) { - y = module.y; - z = module.z; - }], - execute: function () { - - var main3 = exports('default', y + z); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-multiple/dep1.js b/test/chunking-form/samples/grouping-multiple/dep1.js deleted file mode 100644 index 856e96622db..00000000000 --- a/test/chunking-form/samples/grouping-multiple/dep1.js +++ /dev/null @@ -1 +0,0 @@ -export const x = 1; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-multiple/dep2.js b/test/chunking-form/samples/grouping-multiple/dep2.js deleted file mode 100644 index 434156a7aeb..00000000000 --- a/test/chunking-form/samples/grouping-multiple/dep2.js +++ /dev/null @@ -1 +0,0 @@ -export const y = 2; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-multiple/dep3.js b/test/chunking-form/samples/grouping-multiple/dep3.js deleted file mode 100644 index 9084d1938d3..00000000000 --- a/test/chunking-form/samples/grouping-multiple/dep3.js +++ /dev/null @@ -1 +0,0 @@ -export const z = 3; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-multiple/main1.js b/test/chunking-form/samples/grouping-multiple/main1.js deleted file mode 100644 index 8ff6b9c52bf..00000000000 --- a/test/chunking-form/samples/grouping-multiple/main1.js +++ /dev/null @@ -1,4 +0,0 @@ -import { x } from './dep1.js'; -import { y } from './dep2.js'; - -export default x + y; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-multiple/main2.js b/test/chunking-form/samples/grouping-multiple/main2.js deleted file mode 100644 index cac0299ea75..00000000000 --- a/test/chunking-form/samples/grouping-multiple/main2.js +++ /dev/null @@ -1,4 +0,0 @@ -import { x } from './dep1.js'; -import { z } from './dep3.js'; - -export default x + z; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-multiple/main3.js b/test/chunking-form/samples/grouping-multiple/main3.js deleted file mode 100644 index 7e898f09c92..00000000000 --- a/test/chunking-form/samples/grouping-multiple/main3.js +++ /dev/null @@ -1,4 +0,0 @@ -import { y } from './dep2.js'; -import { z } from './dep3.js'; - -export default y + z; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-size/_config.js b/test/chunking-form/samples/grouping-size/_config.js deleted file mode 100644 index 3a662b0a187..00000000000 --- a/test/chunking-form/samples/grouping-size/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'chunk grouping size threshold', - options: { - experimentalOptimizeChunks: true, - chunkGroupingSize: 42, - input: ['main1.js', 'main2.js', 'main3.js'] - } -}; diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep1.js b/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep1.js deleted file mode 100644 index 1cd77e8dea0..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep1.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const x = 1; - console.log('too large for grouping'); - - exports.x = x; - -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep3.js b/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep3.js deleted file mode 100644 index b8413a4f9d0..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/amd/generated-dep3.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const y = 2; - - const z = 3; - - exports.y = y; - exports.z = z; - -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main1.js b/test/chunking-form/samples/grouping-size/_expected/amd/main1.js deleted file mode 100644 index 4f472918845..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main1.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep1', './generated-dep3'], function (dep1, dep2) { 'use strict'; - - var main1 = dep1.x + dep2.y; - - return main1; - -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main2.js b/test/chunking-form/samples/grouping-size/_expected/amd/main2.js deleted file mode 100644 index 14edb878030..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep1', './generated-dep3'], function (dep1, dep2) { 'use strict'; - - var main2 = dep1.x + dep2.z; - - return main2; - -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/amd/main3.js b/test/chunking-form/samples/grouping-size/_expected/amd/main3.js deleted file mode 100644 index 9250229bf8d..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/amd/main3.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./generated-dep3'], function (dep2) { 'use strict'; - - var main3 = dep2.y + dep2.z; - - return main3; - -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep1.js deleted file mode 100644 index 88e26c26c70..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep1.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -const x = 1; -console.log('too large for grouping'); - -exports.x = x; diff --git a/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep3.js b/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep3.js deleted file mode 100644 index b798212265f..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/cjs/generated-dep3.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -const y = 2; - -const z = 3; - -exports.y = y; -exports.z = z; diff --git a/test/chunking-form/samples/grouping-size/_expected/cjs/main1.js b/test/chunking-form/samples/grouping-size/_expected/cjs/main1.js deleted file mode 100644 index 1e013c8c562..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/cjs/main1.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep1.js'); -var dep2 = require('./generated-dep3.js'); - -var main1 = dep1.x + dep2.y; - -module.exports = main1; diff --git a/test/chunking-form/samples/grouping-size/_expected/cjs/main2.js b/test/chunking-form/samples/grouping-size/_expected/cjs/main2.js deleted file mode 100644 index 2aba4b69579..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/cjs/main2.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep1.js'); -var dep2 = require('./generated-dep3.js'); - -var main2 = dep1.x + dep2.z; - -module.exports = main2; diff --git a/test/chunking-form/samples/grouping-size/_expected/cjs/main3.js b/test/chunking-form/samples/grouping-size/_expected/cjs/main3.js deleted file mode 100644 index 71eb5e920f7..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/cjs/main3.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep2 = require('./generated-dep3.js'); - -var main3 = dep2.y + dep2.z; - -module.exports = main3; diff --git a/test/chunking-form/samples/grouping-size/_expected/es/generated-dep1.js b/test/chunking-form/samples/grouping-size/_expected/es/generated-dep1.js deleted file mode 100644 index 14b4dd4d8fe..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/es/generated-dep1.js +++ /dev/null @@ -1,4 +0,0 @@ -const x = 1; -console.log('too large for grouping'); - -export { x }; diff --git a/test/chunking-form/samples/grouping-size/_expected/es/generated-dep3.js b/test/chunking-form/samples/grouping-size/_expected/es/generated-dep3.js deleted file mode 100644 index edaf39d391f..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/es/generated-dep3.js +++ /dev/null @@ -1,5 +0,0 @@ -const y = 2; - -const z = 3; - -export { y, z }; diff --git a/test/chunking-form/samples/grouping-size/_expected/es/main1.js b/test/chunking-form/samples/grouping-size/_expected/es/main1.js deleted file mode 100644 index a5da120e3f0..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/es/main1.js +++ /dev/null @@ -1,6 +0,0 @@ -import { x } from './generated-dep1.js'; -import { y } from './generated-dep3.js'; - -var main1 = x + y; - -export default main1; diff --git a/test/chunking-form/samples/grouping-size/_expected/es/main2.js b/test/chunking-form/samples/grouping-size/_expected/es/main2.js deleted file mode 100644 index dc474b4b2fc..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/es/main2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { x } from './generated-dep1.js'; -import { z } from './generated-dep3.js'; - -var main2 = x + z; - -export default main2; diff --git a/test/chunking-form/samples/grouping-size/_expected/es/main3.js b/test/chunking-form/samples/grouping-size/_expected/es/main3.js deleted file mode 100644 index 27a13fc9109..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/es/main3.js +++ /dev/null @@ -1,5 +0,0 @@ -import { y, z } from './generated-dep3.js'; - -var main3 = y + z; - -export default main3; diff --git a/test/chunking-form/samples/grouping-size/_expected/system/generated-dep1.js b/test/chunking-form/samples/grouping-size/_expected/system/generated-dep1.js deleted file mode 100644 index bfb6fbeec36..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/system/generated-dep1.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const x = exports('x', 1); - console.log('too large for grouping'); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/system/generated-dep3.js b/test/chunking-form/samples/grouping-size/_expected/system/generated-dep3.js deleted file mode 100644 index aa8e4c3b599..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/system/generated-dep3.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const y = exports('y', 2); - - const z = exports('z', 3); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/system/main1.js b/test/chunking-form/samples/grouping-size/_expected/system/main1.js deleted file mode 100644 index 27aca0a7647..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/system/main1.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./generated-dep1.js', './generated-dep3.js'], function (exports) { - 'use strict'; - var x, y; - return { - setters: [function (module) { - x = module.x; - }, function (module) { - y = module.y; - }], - execute: function () { - - var main1 = exports('default', x + y); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/system/main2.js b/test/chunking-form/samples/grouping-size/_expected/system/main2.js deleted file mode 100644 index 9b1886c4026..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/system/main2.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./generated-dep1.js', './generated-dep3.js'], function (exports) { - 'use strict'; - var x, z; - return { - setters: [function (module) { - x = module.x; - }, function (module) { - z = module.z; - }], - execute: function () { - - var main2 = exports('default', x + z); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-size/_expected/system/main3.js b/test/chunking-form/samples/grouping-size/_expected/system/main3.js deleted file mode 100644 index b691d6096e2..00000000000 --- a/test/chunking-form/samples/grouping-size/_expected/system/main3.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-dep3.js'], function (exports) { - 'use strict'; - var y, z; - return { - setters: [function (module) { - y = module.y; - z = module.z; - }], - execute: function () { - - var main3 = exports('default', y + z); - - } - }; -}); diff --git a/test/chunking-form/samples/grouping-size/dep1.js b/test/chunking-form/samples/grouping-size/dep1.js deleted file mode 100644 index 9e2f3aca5bb..00000000000 --- a/test/chunking-form/samples/grouping-size/dep1.js +++ /dev/null @@ -1,2 +0,0 @@ -export const x = 1; -console.log('too large for grouping'); diff --git a/test/chunking-form/samples/grouping-size/dep2.js b/test/chunking-form/samples/grouping-size/dep2.js deleted file mode 100644 index 434156a7aeb..00000000000 --- a/test/chunking-form/samples/grouping-size/dep2.js +++ /dev/null @@ -1 +0,0 @@ -export const y = 2; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-size/dep3.js b/test/chunking-form/samples/grouping-size/dep3.js deleted file mode 100644 index 9084d1938d3..00000000000 --- a/test/chunking-form/samples/grouping-size/dep3.js +++ /dev/null @@ -1 +0,0 @@ -export const z = 3; \ No newline at end of file diff --git a/test/chunking-form/samples/grouping-size/main1.js b/test/chunking-form/samples/grouping-size/main1.js deleted file mode 100644 index 183af82de98..00000000000 --- a/test/chunking-form/samples/grouping-size/main1.js +++ /dev/null @@ -1,4 +0,0 @@ -import { x } from './dep1.js'; -import { y } from './dep2.js'; - -export default x + y; diff --git a/test/chunking-form/samples/grouping-size/main2.js b/test/chunking-form/samples/grouping-size/main2.js deleted file mode 100644 index dd521b74f98..00000000000 --- a/test/chunking-form/samples/grouping-size/main2.js +++ /dev/null @@ -1,4 +0,0 @@ -import { x } from './dep1.js'; -import { z } from './dep3.js'; - -export default x + z; diff --git a/test/chunking-form/samples/grouping-size/main3.js b/test/chunking-form/samples/grouping-size/main3.js deleted file mode 100644 index 1c9baf40014..00000000000 --- a/test/chunking-form/samples/grouping-size/main3.js +++ /dev/null @@ -1,4 +0,0 @@ -import { y } from './dep2.js'; -import { z } from './dep3.js'; - -export default y + z; diff --git a/test/function/samples/inline-imports-with-optimize/_config.js b/test/function/samples/inline-imports-with-optimize/_config.js deleted file mode 100644 index 5e350bebd32..00000000000 --- a/test/function/samples/inline-imports-with-optimize/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'Optimizing chunks is not supported when inlining dynamic imports', - options: { - input: ['main.js'], - inlineDynamicImports: true, - experimentalOptimizeChunks: true - }, - error: { - code: 'INVALID_OPTION', - message: '"experimentalOptimizeChunks" option is not supported for "inlineDynamicImports".' - } -}; diff --git a/test/function/samples/inline-imports-with-optimize/lib.js b/test/function/samples/inline-imports-with-optimize/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/inline-imports-with-optimize/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/inline-imports-with-optimize/main.js b/test/function/samples/inline-imports-with-optimize/main.js deleted file mode 100644 index 4869dc82f38..00000000000 --- a/test/function/samples/inline-imports-with-optimize/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./lib').then(({value}) => assert.equal(value, 42)); diff --git a/test/function/samples/preserve-modules/optimize-chunks/_config.js b/test/function/samples/preserve-modules/optimize-chunks/_config.js deleted file mode 100644 index ef6bc94f059..00000000000 --- a/test/function/samples/preserve-modules/optimize-chunks/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'Optimizing chunks fails when preserving modules', - options: { - input: ['main.js'], - preserveModules: true, - experimentalOptimizeChunks: true - }, - error: { - code: 'INVALID_OPTION', - message: '"preserveModules" does not support the "experimentalOptimizeChunks" option.' - } -}; diff --git a/test/function/samples/preserve-modules/optimize-chunks/lib.js b/test/function/samples/preserve-modules/optimize-chunks/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/preserve-modules/optimize-chunks/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/preserve-modules/optimize-chunks/main.js b/test/function/samples/preserve-modules/optimize-chunks/main.js deleted file mode 100644 index 0786352d0f9..00000000000 --- a/test/function/samples/preserve-modules/optimize-chunks/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './lib'; - -assert.equal(value, 42); diff --git a/test/misc/optionList.js b/test/misc/optionList.js index 9332c129202..7c8bf40a37f 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,3 +1,3 @@ -exports.input = 'acorn, acornInjectPlugins, cache, chunkGroupingSize, context, experimentalCacheExpiry, experimentalOptimizeChunks, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; -exports.flags = 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, chunkGroupingSize, compact, config, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalOptimizeChunks, exports, extend, external, externalLiveBindings, f, file, footer, format, freeze, g, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, paths, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, treeshake, v, w, watch'; +exports.input = 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; +exports.flags = 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, file, footer, format, freeze, g, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, paths, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, treeshake, v, w, watch'; exports.output = 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportFunction, entryFileNames, esModule, exports, extend, externalLiveBindings, file, footer, format, freeze, globals, hoistTransitiveImports, indent, interop, intro, name, namespaceToStringTag, noConflict, outro, paths, plugins, preferConst, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, strict'; diff --git a/test/watch/index.js b/test/watch/index.js index 81bc9fb3ee6..d27e4f41c0d 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -491,6 +491,46 @@ describe('rollup.watch', () => { }); }); + it('recovers from an error even when erroring dependency was "renamed" (#38)', () => { + return sander + .copydir('test/watch/samples/dependency') + .to('test/_tmp/input') + .then(() => { + watcher = rollup.watch({ + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + } + }); + + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + sander.unlinkSync('test/_tmp/input/dep.js'); + sander.writeFileSync('test/_tmp/input/dep.js', 'export nope;'); + }, + 'START', + 'BUNDLE_START', + 'ERROR', + () => { + sander.unlinkSync('test/_tmp/input/dep.js'); + sander.writeFileSync('test/_tmp/input/dep.js', 'export const value = 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run('../_tmp/output/bundle.js'), 44); + } + ]); + }); + }); it('handles closing the watcher during a build', () => { return sander .copydir('test/watch/samples/basic')