@atlaspack/bundler-default
Advanced tools
Comparing version 2.12.1-dev.3520 to 2.12.1-dev.3565
@@ -115,2 +115,5 @@ "use strict"; | ||
type: 'boolean' | ||
}, | ||
loadConditionalBundlesInParallel: { | ||
type: 'boolean' | ||
} | ||
@@ -117,0 +120,0 @@ }, |
@@ -14,2 +14,9 @@ "use strict"; | ||
} | ||
function _featureFlags() { | ||
const data = require("@atlaspack/feature-flags"); | ||
_featureFlags = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _assert() { | ||
@@ -29,2 +36,3 @@ const data = _interopRequireDefault(require("assert")); | ||
} | ||
var _idealGraph = require("./idealGraph"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -160,2 +168,3 @@ function decorateLegacyGraph(idealGraph, bundleGraph) { | ||
for (let { | ||
type, | ||
from, | ||
@@ -176,4 +185,8 @@ to | ||
let legacyTargetBundle = (0, _nullthrows().default)(idealBundleToLegacyBundle.get(targetBundle)); | ||
bundleGraph.createBundleReference(legacySourceBundle, legacyTargetBundle); | ||
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && type === _idealGraph.idealBundleGraphEdges.conditional) { | ||
bundleGraph.createBundleConditionalReference(legacySourceBundle, legacyTargetBundle); | ||
} else { | ||
bundleGraph.createBundleReference(legacySourceBundle, legacyTargetBundle); | ||
} | ||
} | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.createIdealGraph = createIdealGraph; | ||
exports.idealBundleGraphEdges = void 0; | ||
function _path() { | ||
@@ -52,5 +53,2 @@ const data = _interopRequireDefault(require("path")); | ||
/* BundleRoot - An asset that is the main entry of a Bundle. */ | ||
// IdealGraph is the structure we will pass to decorate, | ||
// which mutates the assetGraph into the bundleGraph we would | ||
// expect from default bundler | ||
const dependencyPriorityEdges = { | ||
@@ -62,2 +60,11 @@ sync: 1, | ||
}; | ||
const idealBundleGraphEdges = exports.idealBundleGraphEdges = Object.freeze({ | ||
default: 1, | ||
conditional: 2 | ||
}); | ||
// IdealGraph is the structure we will pass to decorate, | ||
// which mutates the assetGraph into the bundleGraph we would | ||
// expect from default bundler | ||
function createIdealGraph(assetGraph, config, entries, logger) { | ||
@@ -270,8 +277,13 @@ // Asset to the bundle and group it's an entry of | ||
}), dependencyPriorityEdges[dependency.priority]); | ||
if ((config.loadConditionalBundlesInParallel ?? !bundle.env.shouldScopeHoist) && dependency.priority === 'conditional') { | ||
// When configured (or serving code in development), serve conditional bundles in parallel so we don't get module not found errors | ||
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && dependency.priority === 'conditional') { | ||
let [referencingBundleRoot, bundleGroupNodeId] = (0, _nullthrows().default)(stack[stack.length - 1]); | ||
let referencingBundleId = (0, _nullthrows().default)(bundleRoots.get(referencingBundleRoot))[0]; | ||
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]); | ||
bundleGraph.addEdge(referencingBundleId, bundleId); | ||
if (config.loadConditionalBundlesInParallel ?? !bundle.env.shouldScopeHoist) { | ||
// When configured (or serving code in development), serve conditional bundles in parallel so we don't get module not found errors | ||
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]); | ||
bundleGraph.addEdge(referencingBundleId, bundleId); | ||
} | ||
// Add conditional edge to track which bundles request each other | ||
bundleGraph.addEdge(referencingBundleId, bundleId, idealBundleGraphEdges.conditional); | ||
} | ||
@@ -278,0 +290,0 @@ } else if (dependency.priority === 'parallel' || childAsset.bundleBehavior === 'inline') { |
{ | ||
"name": "@atlaspack/bundler-default", | ||
"version": "2.12.1-dev.3520+8a5346e28", | ||
"version": "2.12.1-dev.3565+b31bc6b33", | ||
"license": "(MIT OR Apache-2.0)", | ||
@@ -15,15 +15,15 @@ "publishConfig": { | ||
"engines": { | ||
"node": ">= 16.0.0", | ||
"parcel": "^2.12.1-dev.3520+8a5346e28" | ||
"atlaspack": "^2.12.1-dev.3565+b31bc6b33", | ||
"node": ">= 16.0.0" | ||
}, | ||
"dependencies": { | ||
"@atlaspack/diagnostic": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/feature-flags": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/graph": "3.2.1-dev.3520+8a5346e28", | ||
"@atlaspack/plugin": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/rust": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/utils": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/feature-flags": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/graph": "3.2.1-dev.3565+b31bc6b33", | ||
"@atlaspack/plugin": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/rust": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/utils": "2.12.1-dev.3565+b31bc6b33", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "8a5346e28c1bb3b9cd40f1c4e77c66dd6666f1e4" | ||
"gitHead": "b31bc6b33de40c158b9f4d8ff177238be0de409d" | ||
} |
@@ -139,2 +139,5 @@ // @flow strict-local | ||
}, | ||
loadConditionalBundlesInParallel: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
@@ -141,0 +144,0 @@ additionalProperties: false, |
@@ -9,2 +9,3 @@ // @flow strict-local | ||
} from '@atlaspack/types'; | ||
import {getFeatureFlag} from '@atlaspack/feature-flags'; | ||
import invariant from 'assert'; | ||
@@ -14,2 +15,3 @@ import nullthrows from 'nullthrows'; | ||
import type {Bundle, IdealGraph} from './idealGraph'; | ||
import {idealBundleGraphEdges} from './idealGraph'; | ||
@@ -198,3 +200,3 @@ export function decorateLegacyGraph( | ||
for (let {from, to} of idealBundleGraph.getAllEdges()) { | ||
for (let {type, from, to} of idealBundleGraph.getAllEdges()) { | ||
let sourceBundle = nullthrows(idealBundleGraph.getNode(from)); | ||
@@ -218,4 +220,14 @@ if (sourceBundle === 'root') { | ||
); | ||
bundleGraph.createBundleReference(legacySourceBundle, legacyTargetBundle); | ||
if ( | ||
getFeatureFlag('conditionalBundlingApi') && | ||
type === idealBundleGraphEdges.conditional | ||
) { | ||
bundleGraph.createBundleConditionalReference( | ||
legacySourceBundle, | ||
legacyTargetBundle, | ||
); | ||
} else { | ||
bundleGraph.createBundleReference(legacySourceBundle, legacyTargetBundle); | ||
} | ||
} | ||
} |
@@ -58,2 +58,19 @@ // @flow strict-local | ||
const dependencyPriorityEdges = { | ||
sync: 1, | ||
parallel: 2, | ||
lazy: 3, | ||
conditional: 4, | ||
}; | ||
export const idealBundleGraphEdges = Object.freeze({ | ||
default: 1, | ||
conditional: 2, | ||
}); | ||
type IdealBundleGraph = Graph< | ||
Bundle | 'root', | ||
$Values<typeof idealBundleGraphEdges>, | ||
>; | ||
// IdealGraph is the structure we will pass to decorate, | ||
@@ -65,3 +82,3 @@ // which mutates the assetGraph into the bundleGraph we would | ||
assets: Array<Asset>, | ||
bundleGraph: Graph<Bundle | 'root'>, | ||
bundleGraph: IdealBundleGraph, | ||
bundleGroupBundleIds: Set<NodeId>, | ||
@@ -72,9 +89,2 @@ dependencyBundleGraph: DependencyBundleGraph, | ||
const dependencyPriorityEdges = { | ||
sync: 1, | ||
parallel: 2, | ||
lazy: 3, | ||
conditional: 4, | ||
}; | ||
export function createIdealGraph( | ||
@@ -97,3 +107,3 @@ assetGraph: MutableBundleGraph, | ||
// referencing Bundle. There are no actual BundleGroup nodes, just bundles that take on that role. | ||
let bundleGraph: Graph<Bundle | 'root'> = new Graph(); | ||
let bundleGraph: IdealBundleGraph = new Graph(); | ||
let stack: Array<[BundleRoot, NodeId]> = []; | ||
@@ -371,7 +381,5 @@ | ||
if ( | ||
(config.loadConditionalBundlesInParallel ?? | ||
!bundle.env.shouldScopeHoist) && | ||
getFeatureFlag('conditionalBundlingApi') && | ||
dependency.priority === 'conditional' | ||
) { | ||
// When configured (or serving code in development), serve conditional bundles in parallel so we don't get module not found errors | ||
let [referencingBundleRoot, bundleGroupNodeId] = nullthrows( | ||
@@ -385,4 +393,17 @@ stack[stack.length - 1], | ||
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]); | ||
bundleGraph.addEdge(referencingBundleId, bundleId); | ||
if ( | ||
config.loadConditionalBundlesInParallel ?? | ||
!bundle.env.shouldScopeHoist | ||
) { | ||
// When configured (or serving code in development), serve conditional bundles in parallel so we don't get module not found errors | ||
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]); | ||
bundleGraph.addEdge(referencingBundleId, bundleId); | ||
} | ||
// Add conditional edge to track which bundles request each other | ||
bundleGraph.addEdge( | ||
referencingBundleId, | ||
bundleId, | ||
idealBundleGraphEdges.conditional, | ||
); | ||
} | ||
@@ -1316,3 +1337,3 @@ } else if ( | ||
function removeBundle( | ||
bundleGraph: Graph<Bundle | 'root'>, | ||
bundleGraph: IdealBundleGraph, | ||
bundleId: NodeId, | ||
@@ -1319,0 +1340,0 @@ assetReference: DefaultMap<Asset, Array<[Dependency, Bundle]>>, |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
152630
3332