diff --git a/packages/bundlers/default/src/DefaultBundler.js b/packages/bundlers/default/src/DefaultBundler.js index 2b1c5772f3d..9e018a18226 100644 --- a/packages/bundlers/default/src/DefaultBundler.js +++ b/packages/bundlers/default/src/DefaultBundler.js @@ -19,6 +19,7 @@ import {ContentGraph, Graph} from '@parcel/graph'; import invariant from 'assert'; import {ALL_EDGE_TYPES} from '@parcel/graph'; import {Bundler} from '@parcel/plugin'; +import logger from '@parcel/logger'; import {setEqual, validateSchema, DefaultMap, BitSet} from '@parcel/utils'; import nullthrows from 'nullthrows'; import {encodeJSONKeyComponent} from '@parcel/diagnostic'; @@ -28,12 +29,14 @@ type BundlerConfig = {| minBundles?: number, minBundleSize?: number, maxParallelRequests?: number, + disableSharedBundles?: boolean, |}; type ResolvedBundlerConfig = {| minBundles: number, minBundleSize: number, maxParallelRequests: number, + disableSharedBundles: boolean, |}; // Default options by http version. @@ -42,11 +45,13 @@ const HTTP_OPTIONS = { minBundles: 1, minBundleSize: 30000, maxParallelRequests: 6, + disableSharedBundles: false, }, '2': { minBundles: 1, minBundleSize: 20000, maxParallelRequests: 25, + disableSharedBundles: false, }, }; @@ -919,42 +924,46 @@ function createIdealGraph( // if a bundle b is a subgraph of another bundle f, reuse it, drawing an edge between the two let canReuse: Set = new Set(); - for (let candidateSourceBundleRoot of reachable) { - let candidateSourceBundleId = nullthrows( - bundleRoots.get(candidateSourceBundleRoot), - )[0]; - if (candidateSourceBundleRoot.env.isIsolated()) { - continue; - } - let reuseableBundleId = bundles.get(asset.id); - if (reuseableBundleId != null) { - canReuse.add(candidateSourceBundleRoot); - bundleGraph.addEdge(candidateSourceBundleId, reuseableBundleId); - - let reusableBundle = bundleGraph.getNode(reuseableBundleId); - invariant(reusableBundle !== 'root' && reusableBundle != null); - reusableBundle.sourceBundles.add(candidateSourceBundleId); - } else { - // Asset is not a bundleRoot, but if its ancestor bundle (in the asset's reachable) can be - // reused as a subgraph of another bundleRoot in its reachable, reuse it - for (let otherReuseCandidate of reachable) { - if (candidateSourceBundleRoot === otherReuseCandidate) continue; - let reusableCandidateReachable = getReachableBundleRoots( - otherReuseCandidate, - reachableRoots, - ).filter(b => !ancestorAssets.get(b)?.has(otherReuseCandidate)); - if (reusableCandidateReachable.includes(candidateSourceBundleRoot)) { - let reusableBundleId = nullthrows( - bundles.get(otherReuseCandidate.id), - ); - canReuse.add(candidateSourceBundleRoot); - bundleGraph.addEdge( - nullthrows(bundles.get(candidateSourceBundleRoot.id)), - reusableBundleId, - ); - let reusableBundle = bundleGraph.getNode(reusableBundleId); - invariant(reusableBundle !== 'root' && reusableBundle != null); - reusableBundle.sourceBundles.add(candidateSourceBundleId); + if (config.disableSharedBundles === false) { + for (let candidateSourceBundleRoot of reachable) { + let candidateSourceBundleId = nullthrows( + bundleRoots.get(candidateSourceBundleRoot), + )[0]; + if (candidateSourceBundleRoot.env.isIsolated()) { + continue; + } + let reuseableBundleId = bundles.get(asset.id); + if (reuseableBundleId != null) { + canReuse.add(candidateSourceBundleRoot); + bundleGraph.addEdge(candidateSourceBundleId, reuseableBundleId); + + let reusableBundle = bundleGraph.getNode(reuseableBundleId); + invariant(reusableBundle !== 'root' && reusableBundle != null); + reusableBundle.sourceBundles.add(candidateSourceBundleId); + } else { + // Asset is not a bundleRoot, but if its ancestor bundle (in the asset's reachable) can be + // reused as a subgraph of another bundleRoot in its reachable, reuse it + for (let otherReuseCandidate of reachable) { + if (candidateSourceBundleRoot === otherReuseCandidate) continue; + let reusableCandidateReachable = getReachableBundleRoots( + otherReuseCandidate, + reachableRoots, + ).filter(b => !ancestorAssets.get(b)?.has(otherReuseCandidate)); + if ( + reusableCandidateReachable.includes(candidateSourceBundleRoot) + ) { + let reusableBundleId = nullthrows( + bundles.get(otherReuseCandidate.id), + ); + canReuse.add(candidateSourceBundleRoot); + bundleGraph.addEdge( + nullthrows(bundles.get(candidateSourceBundleRoot.id)), + reusableBundleId, + ); + let reusableBundle = bundleGraph.getNode(reusableBundleId); + invariant(reusableBundle !== 'root' && reusableBundle != null); + reusableBundle.sourceBundles.add(candidateSourceBundleId); + } } } } @@ -971,8 +980,10 @@ function createIdealGraph( entryBundle.size += asset.stats.size; } - // Create shared bundles for splittable bundles. - if (reachable.length > config.minBundles) { + if ( + config.disableSharedBundles === false && + reachable.length > config.minBundles + ) { let sourceBundles = reachable.map(a => nullthrows(bundleRoots.get(a))[0]); let key = reachable.map(a => a.id).join(','); let bundleId = bundles.get(key); @@ -1023,7 +1034,10 @@ function createIdealGraph( value: bundle, type: 'bundle', }); - } else if (reachable.length <= config.minBundles) { + } else if ( + config.disableSharedBundles === true || + reachable.length <= config.minBundles + ) { for (let root of reachable) { let bundle = nullthrows( bundleGraph.getNode(nullthrows(bundleRoots.get(root))[0]), @@ -1051,98 +1065,100 @@ function createIdealGraph( let modifiedSourceBundles = new Set(); // Step Remove Shared Bundles: Remove shared bundles from bundle groups that hit the parallel request limit. - for (let bundleGroupId of bundleGraph.getNodeIdsConnectedFrom(rootNodeId)) { - // Find shared bundles in this bundle group. - let bundleId = bundleGroupId; - - // We should include "bundle reuse" as shared bundles that may be removed but the bundle itself would have to be retained - let bundleIdsInGroup = getBundlesForBundleGroup(bundleId); //get all bundlegrups this bundle is an ancestor of - - // Filter out inline assests as they should not contribute to PRL - let numBundlesContributingToPRL = bundleIdsInGroup.reduce((count, b) => { - let bundle = nullthrows(bundleGraph.getNode(b)); - invariant(bundle !== 'root'); - return count + (bundle.bundleBehavior !== 'inline'); - }, 0); - - if (numBundlesContributingToPRL > config.maxParallelRequests) { - let sharedBundleIdsInBundleGroup = bundleIdsInGroup.filter(b => { - let bundle = nullthrows(bundleGraph.getNode(b)); - // shared bundles must have source bundles, we could have a bundle - // connected to another bundle that isnt a shared bundle, so check - return ( - bundle !== 'root' && bundle.sourceBundles.size > 0 && bundleId != b - ); - }); + if (config.disableSharedBundles === false) { + for (let bundleGroupId of bundleGraph.getNodeIdsConnectedFrom(rootNodeId)) { + // Find shared bundles in this bundle group. + let bundleId = bundleGroupId; - // Sort the bundles so the smallest ones are removed first. - let sharedBundlesInGroup = sharedBundleIdsInBundleGroup - .map(id => ({ - id, - bundle: nullthrows(bundleGraph.getNode(id)), - })) - .map(({id, bundle}) => { - // For Flow - invariant(bundle !== 'root'); - return {id, bundle}; - }) - .sort((a, b) => b.bundle.size - a.bundle.size); - - // Remove bundles until the bundle group is within the parallel request limit. - while ( - sharedBundlesInGroup.length > 0 && - numBundlesContributingToPRL > config.maxParallelRequests - ) { - let bundleTuple = sharedBundlesInGroup.pop(); - let bundleToRemove = bundleTuple.bundle; - let bundleIdToRemove = bundleTuple.id; - //TODO add integration test where bundles in bunlde group > max parallel request limit & only remove a couple shared bundles - // but total # bundles still exceeds limit due to non shared bundles - - // Add all assets in the shared bundle into the source bundles that are within this bundle group. - let sourceBundles = [...bundleToRemove.sourceBundles].filter(b => - bundleIdsInGroup.includes(b), - ); + // We should include "bundle reuse" as shared bundles that may be removed but the bundle itself would have to be retained + let bundleIdsInGroup = getBundlesForBundleGroup(bundleId); //get all bundlegrups this bundle is an ancestor of - for (let sourceBundleId of sourceBundles) { - let sourceBundle = nullthrows(bundleGraph.getNode(sourceBundleId)); - invariant(sourceBundle !== 'root'); - modifiedSourceBundles.add(sourceBundle); - bundleToRemove.sourceBundles.delete(sourceBundleId); - for (let asset of bundleToRemove.assets) { - sourceBundle.assets.add(asset); - sourceBundle.size += asset.stats.size; - } - //This case is specific to reused bundles, which can have shared bundles attached to it - for (let childId of bundleGraph.getNodeIdsConnectedFrom( - bundleIdToRemove, - )) { - let child = bundleGraph.getNode(childId); - invariant(child !== 'root' && child != null); - child.sourceBundles.add(sourceBundleId); - bundleGraph.addEdge(sourceBundleId, childId); - } - // needs to add test case where shared bundle is removed from ONE bundlegroup but not from the whole graph! - // Remove the edge from this bundle group to the shared bundle. - // If there is now only a single bundle group that contains this bundle, - // merge it into the remaining source bundles. If it is orphaned entirely, remove it. - let incomingNodeCount = - bundleGraph.getNodeIdsConnectedTo(bundleIdToRemove).length; + // Filter out inline assests as they should not contribute to PRL + let numBundlesContributingToPRL = bundleIdsInGroup.reduce((count, b) => { + let bundle = nullthrows(bundleGraph.getNode(b)); + invariant(bundle !== 'root'); + return count + (bundle.bundleBehavior !== 'inline'); + }, 0); + + if (numBundlesContributingToPRL > config.maxParallelRequests) { + let sharedBundleIdsInBundleGroup = bundleIdsInGroup.filter(b => { + let bundle = nullthrows(bundleGraph.getNode(b)); + // shared bundles must have source bundles, we could have a bundle + // connected to another bundle that isnt a shared bundle, so check + return ( + bundle !== 'root' && bundle.sourceBundles.size > 0 && bundleId != b + ); + }); - if ( - incomingNodeCount <= 2 && - //Never fully remove reused bundles - bundleToRemove.mainEntryAsset == null - ) { - // If one bundle group removes a shared bundle, but the other *can* keep it, still remove because that shared bundle is pointless (only one source bundle) - removeBundle(bundleGraph, bundleIdToRemove, assetReference); - // Stop iterating through bundleToRemove's sourceBundles as the bundle has been removed. - break; - } else { - bundleGraph.removeEdge(sourceBundleId, bundleIdToRemove); + // Sort the bundles so the smallest ones are removed first. + let sharedBundlesInGroup = sharedBundleIdsInBundleGroup + .map(id => ({ + id, + bundle: nullthrows(bundleGraph.getNode(id)), + })) + .map(({id, bundle}) => { + // For Flow + invariant(bundle !== 'root'); + return {id, bundle}; + }) + .sort((a, b) => b.bundle.size - a.bundle.size); + + // Remove bundles until the bundle group is within the parallel request limit. + while ( + sharedBundlesInGroup.length > 0 && + numBundlesContributingToPRL > config.maxParallelRequests + ) { + let bundleTuple = sharedBundlesInGroup.pop(); + let bundleToRemove = bundleTuple.bundle; + let bundleIdToRemove = bundleTuple.id; + //TODO add integration test where bundles in bunlde group > max parallel request limit & only remove a couple shared bundles + // but total # bundles still exceeds limit due to non shared bundles + + // Add all assets in the shared bundle into the source bundles that are within this bundle group. + let sourceBundles = [...bundleToRemove.sourceBundles].filter(b => + bundleIdsInGroup.includes(b), + ); + + for (let sourceBundleId of sourceBundles) { + let sourceBundle = nullthrows(bundleGraph.getNode(sourceBundleId)); + invariant(sourceBundle !== 'root'); + modifiedSourceBundles.add(sourceBundle); + bundleToRemove.sourceBundles.delete(sourceBundleId); + for (let asset of bundleToRemove.assets) { + sourceBundle.assets.add(asset); + sourceBundle.size += asset.stats.size; + } + //This case is specific to reused bundles, which can have shared bundles attached to it + for (let childId of bundleGraph.getNodeIdsConnectedFrom( + bundleIdToRemove, + )) { + let child = bundleGraph.getNode(childId); + invariant(child !== 'root' && child != null); + child.sourceBundles.add(sourceBundleId); + bundleGraph.addEdge(sourceBundleId, childId); + } + // needs to add test case where shared bundle is removed from ONE bundlegroup but not from the whole graph! + // Remove the edge from this bundle group to the shared bundle. + // If there is now only a single bundle group that contains this bundle, + // merge it into the remaining source bundles. If it is orphaned entirely, remove it. + let incomingNodeCount = + bundleGraph.getNodeIdsConnectedTo(bundleIdToRemove).length; + + if ( + incomingNodeCount <= 2 && + //Never fully remove reused bundles + bundleToRemove.mainEntryAsset == null + ) { + // If one bundle group removes a shared bundle, but the other *can* keep it, still remove because that shared bundle is pointless (only one source bundle) + removeBundle(bundleGraph, bundleIdToRemove, assetReference); + // Stop iterating through bundleToRemove's sourceBundles as the bundle has been removed. + break; + } else { + bundleGraph.removeEdge(sourceBundleId, bundleIdToRemove); + } } + numBundlesContributingToPRL--; } - numBundlesContributingToPRL--; } } } @@ -1290,6 +1306,9 @@ const CONFIG_SCHEMA: SchemaEntity = { maxParallelRequests: { type: 'number', }, + disableSharedBundles: { + type: 'boolean', + }, }, additionalProperties: false, }; @@ -1370,6 +1389,39 @@ async function loadBundlerConfig( invariant(conf?.contents != null); + // minBundles will be ignored if shared bundles are disabled + if ( + conf.contents.minBundles != null && + conf.contents.disableSharedBundles === true + ) { + logger.warn({ + origin: '@parcel/bundler-default', + message: `The value of "${conf.contents.minBundles}" set for minBundles will not be used as shared bundles have been disabled`, + }); + } + + // minBundleSize will be ignored if shared bundles are disabled + if ( + conf.contents.minBundleSize != null && + conf.contents.disableSharedBundles === true + ) { + logger.warn({ + origin: '@parcel/bundler-default', + message: `The value of "${conf.contents.minBundleSize}" set for minBundleSize will not be used as shared bundles have been disabled`, + }); + } + + // maxParallelRequests will be ignored if shared bundles are disabled + if ( + conf.contents.maxParallelRequests != null && + conf.contents.disableSharedBundles === true + ) { + logger.warn({ + origin: '@parcel/bundler-default', + message: `The value of "${conf.contents.maxParallelRequests}" set for maxParallelRequests will not be used as shared bundles have been disabled`, + }); + } + validateSchema.diagnostic( CONFIG_SCHEMA, { @@ -1390,6 +1442,8 @@ async function loadBundlerConfig( minBundleSize: conf.contents.minBundleSize ?? defaults.minBundleSize, maxParallelRequests: conf.contents.maxParallelRequests ?? defaults.maxParallelRequests, + disableSharedBundles: + conf.contents.disableSharedBundles ?? defaults.disableSharedBundles, }; } diff --git a/packages/core/integration-tests/test/bundler.js b/packages/core/integration-tests/test/bundler.js index 16e706a009e..1c1f11518c1 100644 --- a/packages/core/integration-tests/test/bundler.js +++ b/packages/core/integration-tests/test/bundler.js @@ -1,8 +1,319 @@ import path from 'path'; import assert from 'assert'; +import Logger from '@parcel/logger'; import {bundle, assertBundles, findAsset} from '@parcel/test-utils'; describe('bundler', function () { + it('should not create shared bundles when a bundle is being reused and disableSharedBundles is enabled', async function () { + let b = await bundle( + path.join( + __dirname, + 'integration/disable-shared-bundle-single-source/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['a.js', 'b.js', 'foo.js', 'bar.js'], + }, + ]); + }); + + it('should not create shared bundles and should warn when disableSharedBundles is set to true with maxParallelRequests set', async function () { + let messages = []; + let loggerDisposable = Logger.onLog(message => { + messages.push(message); + }); + let b = await bundle( + path.join( + __dirname, + 'integration/disable-shared-bundles-true-parallel/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + loggerDisposable.dispose(); + + assert.deepEqual(messages, [ + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "100" set for maxParallelRequests will not be used as shared bundles have been disabled', + }, + ], + }, + ]); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['bar.js', 'a.js', 'b.js'], + }, + ]); + }); + + it('should not create shared bundles and should warn when disableSharedBundles is set to true with minBundleSize set', async function () { + let messages = []; + let loggerDisposable = Logger.onLog(message => { + messages.push(message); + }); + let b = await bundle( + path.join( + __dirname, + 'integration/disable-shared-bundles-true-min-bundleSize/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + loggerDisposable.dispose(); + + assert.deepEqual(messages, [ + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "200" set for minBundleSize will not be used as shared bundles have been disabled', + }, + ], + }, + ]); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['bar.js', 'a.js', 'b.js'], + }, + ]); + }); + + it('should not create shared bundles and should warn when disableSharedBundles is set to true with minBundles set', async function () { + let messages = []; + let loggerDisposable = Logger.onLog(message => { + messages.push(message); + }); + let b = await bundle( + path.join( + __dirname, + 'integration/disable-shared-bundles-true-min-bundles/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + loggerDisposable.dispose(); + + assert.deepEqual(messages, [ + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "0" set for minBundles will not be used as shared bundles have been disabled', + }, + ], + }, + ]); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['bar.js', 'a.js', 'b.js'], + }, + ]); + }); + + it('should not create shared bundles and should warn when disableSharedBundles is set to true with minBundles, minBundleSize and maxParallelRequests set', async function () { + let messages = []; + let loggerDisposable = Logger.onLog(message => { + messages.push(message); + }); + let b = await bundle( + path.join( + __dirname, + 'integration/disable-shared-bundles-true-min-bundles-parallel/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + loggerDisposable.dispose(); + + assert.deepEqual(messages, [ + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "0" set for minBundles will not be used as shared bundles have been disabled', + }, + ], + }, + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "200" set for minBundleSize will not be used as shared bundles have been disabled', + }, + ], + }, + { + type: 'log', + level: 'warn', + diagnostics: [ + { + origin: '@parcel/bundler-default', + message: + 'The value of "100" set for maxParallelRequests will not be used as shared bundles have been disabled', + }, + ], + }, + ]); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['bar.js', 'a.js', 'b.js'], + }, + ]); + }); + + it('should create shared bundles and should not throw a warning when disableSharedBundles is set to false', async function () { + let messages = []; + let loggerDisposable = Logger.onLog(message => { + messages.push(message); + }); + let b = await bundle( + path.join(__dirname, 'integration/disable-shared-bundles-false/index.js'), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + loggerDisposable.dispose(); + + assert.deepEqual(messages, []); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['foo.js'], + }, + { + assets: ['bar.js'], + }, + { + assets: ['a.js', 'b.js'], + }, + ]); + }); + it('should not count inline assests towards parallel request limit', async function () { // Shared bundle should not be removed in this case let b = await bundle( diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/a.js new file mode 100644 index 00000000000..c53064a98bf --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/a.js @@ -0,0 +1,3 @@ +import foo from './foo'; + +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/package.json new file mode 100644 index 00000000000..078980a0a9f --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/package.json @@ -0,0 +1,8 @@ +{ + "@parcel/bundler-default": { + "minBundles": 0, + "minBundleSize": 200, + "maxParallelRequests": 100, + "disableSharedBundles": true + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundle-single-source/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/a.js new file mode 100644 index 00000000000..8d144a54b3e --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/a.js @@ -0,0 +1 @@ +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/package.json new file mode 100644 index 00000000000..777d3fbf681 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/package.json @@ -0,0 +1,8 @@ +{ + "@parcel/bundler-default": { + "minBundles": 0, + "minBundleSize": 200, + "maxParallelRequests": 100, + "disableSharedBundles": false + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-false/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundles-false/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/a.js new file mode 100644 index 00000000000..8d144a54b3e --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/a.js @@ -0,0 +1 @@ +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/package.json new file mode 100644 index 00000000000..b5915811843 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/package.json @@ -0,0 +1,6 @@ +{ + "@parcel/bundler-default": { + "minBundleSize": 200, + "disableSharedBundles": true + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundleSize/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/a.js new file mode 100644 index 00000000000..8d144a54b3e --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/a.js @@ -0,0 +1 @@ +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/package.json new file mode 100644 index 00000000000..078980a0a9f --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/package.json @@ -0,0 +1,8 @@ +{ + "@parcel/bundler-default": { + "minBundles": 0, + "minBundleSize": 200, + "maxParallelRequests": 100, + "disableSharedBundles": true + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles-parallel/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/a.js new file mode 100644 index 00000000000..8d144a54b3e --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/a.js @@ -0,0 +1 @@ +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/package.json new file mode 100644 index 00000000000..585c70677ae --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/package.json @@ -0,0 +1,6 @@ +{ + "@parcel/bundler-default": { + "minBundles": 0, + "disableSharedBundles": true + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-min-bundles/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/a.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/a.js new file mode 100644 index 00000000000..8d144a54b3e --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/a.js @@ -0,0 +1 @@ +export default 5; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/b.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/b.js new file mode 100644 index 00000000000..04514102e60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/b.js @@ -0,0 +1 @@ +export default 4; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/bar.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/bar.js new file mode 100644 index 00000000000..f08fcacacf1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/bar.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 3; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/foo.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/foo.js new file mode 100644 index 00000000000..288a2e69559 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/foo.js @@ -0,0 +1,4 @@ +import a from './a'; +import b from './b'; + +export default 2; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/index.js b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/index.js new file mode 100644 index 00000000000..1059a9a2bf6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/index.js @@ -0,0 +1,4 @@ +import('./foo'); +import('./bar'); + +export default 1; diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/package.json b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/package.json new file mode 100644 index 00000000000..1ddb759de0f --- /dev/null +++ b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/package.json @@ -0,0 +1,6 @@ +{ + "@parcel/bundler-default": { + "maxParallelRequests": 100, + "disableSharedBundles": true + } +} diff --git a/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/yarn.lock b/packages/core/integration-tests/test/integration/disable-shared-bundles-true-parallel/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d