@atlaspack/bundler-default 2.13.2-canary.3689 → 2.13.2-canary.3691
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/MonolithicBundler.js +28 -35
- package/package.json +9 -9
- package/src/MonolithicBundler.js +33 -38
package/lib/MonolithicBundler.js
CHANGED
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addJSMonolithBundle = addJSMonolithBundle;
|
|
7
|
-
function _assert() {
|
|
8
|
-
const data = _interopRequireDefault(require("assert"));
|
|
9
|
-
_assert = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _nullthrows() {
|
|
15
8
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
16
9
|
_nullthrows = function () {
|
|
@@ -44,37 +37,37 @@ function addJSMonolithBundle(bundleGraph, entryAsset, entryDep) {
|
|
|
44
37
|
return;
|
|
45
38
|
}
|
|
46
39
|
let assets = bundleGraph.getDependencyAssets(dependency);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
bundleGraph.addAssetToBundle(asset, isolatedBundle);
|
|
40
|
+
for (const asset of assets) {
|
|
41
|
+
// For assets marked as isolated, we create new bundles and let other
|
|
42
|
+
// plugins like optimizers include them in the primary bundle
|
|
43
|
+
if (asset.bundleBehavior === 'isolated') {
|
|
44
|
+
// Create a new bundle to hold the isolated asset
|
|
45
|
+
let isolatedBundle = bundleGraph.createBundle({
|
|
46
|
+
entryAsset: asset,
|
|
47
|
+
target,
|
|
48
|
+
bundleBehavior: 'isolated'
|
|
49
|
+
});
|
|
50
|
+
bundleGraph.addAssetToBundle(asset, isolatedBundle);
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
// Add the new bundle to the bundle graph, in its own bundle group
|
|
53
|
+
bundleGraph.createBundleReference(bundle, isolatedBundle);
|
|
54
|
+
bundleGraph.addBundleToBundleGroup(isolatedBundle, bundleGraph.createBundleGroup(dependency, target));
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
// Nothing below the isolated asset needs to go in the main bundle, so
|
|
57
|
+
// we can stop traversal here
|
|
58
|
+
actions.skipChildren();
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
// To be properly isolated, all of this asset's dependencies need to go
|
|
61
|
+
// in this new bundle
|
|
62
|
+
bundleGraph.traverse(subNode => {
|
|
63
|
+
if (subNode.type === 'asset' && subNode.value.type === 'js') {
|
|
64
|
+
bundleGraph.addAssetToBundle(subNode.value, isolatedBundle);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}, asset, {
|
|
68
|
+
skipUnusedDependencies: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
78
71
|
}
|
|
79
72
|
}, entryAsset, {
|
|
80
73
|
skipUnusedDependencies: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/bundler-default",
|
|
3
|
-
"version": "2.13.2-canary.
|
|
3
|
+
"version": "2.13.2-canary.3691+67df3f1af",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"main": "lib/DefaultBundler.js",
|
|
13
13
|
"source": "src/DefaultBundler.js",
|
|
14
14
|
"engines": {
|
|
15
|
-
"atlaspack": "2.13.2-canary.
|
|
15
|
+
"atlaspack": "2.13.2-canary.3691+67df3f1af",
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.13.2-canary.
|
|
20
|
-
"@atlaspack/feature-flags": "2.13.2-canary.
|
|
21
|
-
"@atlaspack/graph": "3.3.2-canary.
|
|
22
|
-
"@atlaspack/plugin": "2.13.2-canary.
|
|
23
|
-
"@atlaspack/rust": "2.13.2-canary.
|
|
24
|
-
"@atlaspack/utils": "2.13.2-canary.
|
|
19
|
+
"@atlaspack/diagnostic": "2.13.2-canary.3691+67df3f1af",
|
|
20
|
+
"@atlaspack/feature-flags": "2.13.2-canary.3691+67df3f1af",
|
|
21
|
+
"@atlaspack/graph": "3.3.2-canary.3691+67df3f1af",
|
|
22
|
+
"@atlaspack/plugin": "2.13.2-canary.3691+67df3f1af",
|
|
23
|
+
"@atlaspack/rust": "2.13.2-canary.3691+67df3f1af",
|
|
24
|
+
"@atlaspack/utils": "2.13.2-canary.3691+67df3f1af",
|
|
25
25
|
"nullthrows": "^1.1.1"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "67df3f1af1432d77ee6b8850010d976d3313693a"
|
|
28
28
|
}
|
package/src/MonolithicBundler.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
import type {Asset, Dependency, MutableBundleGraph} from '@atlaspack/types';
|
|
3
|
-
import invariant from 'assert';
|
|
4
3
|
import nullthrows from 'nullthrows';
|
|
5
4
|
|
|
6
5
|
export function addJSMonolithBundle(
|
|
@@ -38,48 +37,44 @@ export function addJSMonolithBundle(
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
let assets = bundleGraph.getDependencyAssets(dependency);
|
|
41
|
-
invariant(
|
|
42
|
-
assets.length === 1,
|
|
43
|
-
'Expected dependency to have exactly one asset',
|
|
44
|
-
);
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
for (const asset of assets) {
|
|
42
|
+
// For assets marked as isolated, we create new bundles and let other
|
|
43
|
+
// plugins like optimizers include them in the primary bundle
|
|
44
|
+
if (asset.bundleBehavior === 'isolated') {
|
|
45
|
+
// Create a new bundle to hold the isolated asset
|
|
46
|
+
let isolatedBundle = bundleGraph.createBundle({
|
|
47
|
+
entryAsset: asset,
|
|
48
|
+
target,
|
|
49
|
+
bundleBehavior: 'isolated',
|
|
50
|
+
});
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
// plugins like optimizers include them in the primary bundle
|
|
50
|
-
if (asset.bundleBehavior === 'isolated') {
|
|
51
|
-
// Create a new bundle to hold the isolated asset
|
|
52
|
-
let isolatedBundle = bundleGraph.createBundle({
|
|
53
|
-
entryAsset: asset,
|
|
54
|
-
target,
|
|
55
|
-
bundleBehavior: 'isolated',
|
|
56
|
-
});
|
|
52
|
+
bundleGraph.addAssetToBundle(asset, isolatedBundle);
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
// Add the new bundle to the bundle graph, in its own bundle group
|
|
55
|
+
bundleGraph.createBundleReference(bundle, isolatedBundle);
|
|
56
|
+
bundleGraph.addBundleToBundleGroup(
|
|
57
|
+
isolatedBundle,
|
|
58
|
+
bundleGraph.createBundleGroup(dependency, target),
|
|
59
|
+
);
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
isolatedBundle,
|
|
64
|
-
bundleGraph.createBundleGroup(dependency, target),
|
|
65
|
-
);
|
|
61
|
+
// Nothing below the isolated asset needs to go in the main bundle, so
|
|
62
|
+
// we can stop traversal here
|
|
63
|
+
actions.skipChildren();
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
asset,
|
|
81
|
-
{skipUnusedDependencies: true},
|
|
82
|
-
);
|
|
65
|
+
// To be properly isolated, all of this asset's dependencies need to go
|
|
66
|
+
// in this new bundle
|
|
67
|
+
bundleGraph.traverse(
|
|
68
|
+
(subNode) => {
|
|
69
|
+
if (subNode.type === 'asset' && subNode.value.type === 'js') {
|
|
70
|
+
bundleGraph.addAssetToBundle(subNode.value, isolatedBundle);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
asset,
|
|
75
|
+
{skipUnusedDependencies: true},
|
|
76
|
+
);
|
|
77
|
+
}
|
|
83
78
|
}
|
|
84
79
|
},
|
|
85
80
|
entryAsset,
|