@atlaspack/bundler-default 2.13.2-dev.3689 → 2.14.1-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/lib/MonolithicBundler.js +31 -34
- package/lib/idealGraph.js +3 -3
- package/package.json +9 -9
- package/src/MonolithicBundler.js +38 -37
- package/src/idealGraph.js +3 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @atlaspack/bundler-default
|
|
2
2
|
|
|
3
|
+
## 2.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#405](https://github.com/atlassian-labs/atlaspack/pull/405) [`306246e`](https://github.com/atlassian-labs/atlaspack/commit/306246ee5a492583059b028ee5d0d1b49ce42223) Thanks [@benjervis](https://github.com/benjervis)! - Adds additional support for asset types when using the `singleFileOutput` option.
|
|
8
|
+
|
|
9
|
+
When the single file output option was first defined, it was a very quick and naive
|
|
10
|
+
implementation that only added JS assets to a single bundle, primarily to support
|
|
11
|
+
SSR runtimes that only allow a single file.
|
|
12
|
+
|
|
13
|
+
This falls apart when attempting to server render something like an SVG, because
|
|
14
|
+
the existing implementation would ignore them entirely.
|
|
15
|
+
|
|
16
|
+
This is fixed by adding support for "isolated" bundles, of which SVGs are one but
|
|
17
|
+
not the only use case.
|
|
18
|
+
The content itself is not included in the primary bundle, but the references between
|
|
19
|
+
them (like an SVG URL) will now be inserted.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#379](https://github.com/atlassian-labs/atlaspack/pull/379) [`8bc3db9`](https://github.com/atlassian-labs/atlaspack/commit/8bc3db94cc7382b22ca8207c92af8f6389c17e2e) Thanks [@JakeLane](https://github.com/JakeLane)! - Support nested conditional imports in runtime for dynamic import edges in graph. Introduces a new feature flag `conditionalBundlingNestedRuntime`
|
|
24
|
+
|
|
25
|
+
- [#414](https://github.com/atlassian-labs/atlaspack/pull/414) [`eff9809`](https://github.com/atlassian-labs/atlaspack/commit/eff98093703b9999a511b87a19562f5aaccfcb53) Thanks [@alshdavid](https://github.com/alshdavid)! - Added type:commonjs to package.json files
|
|
26
|
+
|
|
27
|
+
- [#408](https://github.com/atlassian-labs/atlaspack/pull/408) [`f6afae7`](https://github.com/atlassian-labs/atlaspack/commit/f6afae7a168c85341f9f41aa70c2cd2491a9ff17) Thanks [@benjervis](https://github.com/benjervis)! - In the first attempt to support isolated bundles, there was a check on the number of assets that wasn't really correct.
|
|
28
|
+
That check has been removed, so we can bundle even where there are special cases.
|
|
29
|
+
|
|
30
|
+
- [#381](https://github.com/atlassian-labs/atlaspack/pull/381) [`91ffa66`](https://github.com/atlassian-labs/atlaspack/commit/91ffa662ea3af48f1ca0c4f0d976db9c48995f4f) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Fix re-used bundles for async imports with circular dependencies
|
|
31
|
+
|
|
32
|
+
- [#411](https://github.com/atlassian-labs/atlaspack/pull/411) [`50265fd`](https://github.com/atlassian-labs/atlaspack/commit/50265fdf4024ec18439e85b472aa77a7952e2e08) Thanks [@benjervis](https://github.com/benjervis)! - Switches the isolated behaviour in single file output mode to be for inline bundles instead. Also makes isolated bundles an error.
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`bfe81e5`](https://github.com/atlassian-labs/atlaspack/commit/bfe81e551c4e4bb2cac7fc4745222e66962c1728), [`fa4fcf6`](https://github.com/atlassian-labs/atlaspack/commit/fa4fcf69a82b0a3727066ada6e93a149b259936e), [`cd964ee`](https://github.com/atlassian-labs/atlaspack/commit/cd964eed5a330ae63733656ded691d1ea3afe4e3), [`1953d1b`](https://github.com/atlassian-labs/atlaspack/commit/1953d1bec266a39dc4bfce5f6c7959e77e63411e), [`ce4ce95`](https://github.com/atlassian-labs/atlaspack/commit/ce4ce953914e08991cf58c70c98f758690e5ee21), [`28dee1d`](https://github.com/atlassian-labs/atlaspack/commit/28dee1db7d9a995161b45f76c1a03b80ccaeab4b), [`a317453`](https://github.com/atlassian-labs/atlaspack/commit/a317453432b7f30e98f2a4cbcafdaa5601bcde63), [`2055adb`](https://github.com/atlassian-labs/atlaspack/commit/2055adbe31de792e2a2a591b94d2f33f50735879), [`8bc3db9`](https://github.com/atlassian-labs/atlaspack/commit/8bc3db94cc7382b22ca8207c92af8f6389c17e2e), [`cfa1c63`](https://github.com/atlassian-labs/atlaspack/commit/cfa1c63d710c5f9c9abc55f34220b70fb517c3b8), [`17427a2`](https://github.com/atlassian-labs/atlaspack/commit/17427a2b2fc9c34ef0b941907c2868edef6d1507), [`e962cd7`](https://github.com/atlassian-labs/atlaspack/commit/e962cd735877f7f16163e60868d70d9c10054ebe), [`104a46a`](https://github.com/atlassian-labs/atlaspack/commit/104a46a5ee1fae176d29fcc6420d6bd9c01b35b1), [`9572aca`](https://github.com/atlassian-labs/atlaspack/commit/9572aca2a2313a3c05551f73e556128e77a37732), [`34b740d`](https://github.com/atlassian-labs/atlaspack/commit/34b740d4e2449fba7b50cb9708c56d8033dca5b9), [`4837b69`](https://github.com/atlassian-labs/atlaspack/commit/4837b6988e56ca842a24797b796160964d3696ce), [`e5fa92d`](https://github.com/atlassian-labs/atlaspack/commit/e5fa92de26c87fb5d4d681af1931451749ba970a), [`7e21377`](https://github.com/atlassian-labs/atlaspack/commit/7e21377914e8091d484f67cb11052a1efd2227e3), [`43113f8`](https://github.com/atlassian-labs/atlaspack/commit/43113f8f00232c5a52169a3f11f846d6e4d94b0a), [`3650f7c`](https://github.com/atlassian-labs/atlaspack/commit/3650f7c9ab803b5ae20b223e82b2268a1b614e43), [`eff9809`](https://github.com/atlassian-labs/atlaspack/commit/eff98093703b9999a511b87a19562f5aaccfcb53), [`c2ef915`](https://github.com/atlassian-labs/atlaspack/commit/c2ef915dc54784ce4b8180025ac1b2e13b375002), [`f635123`](https://github.com/atlassian-labs/atlaspack/commit/f635123f9a06961bc5e053e237f1023f10800ea3), [`4812d0f`](https://github.com/atlassian-labs/atlaspack/commit/4812d0f7400af0f8416f1b7175ecb87700860a68), [`80d963e`](https://github.com/atlassian-labs/atlaspack/commit/80d963ed950f5d742ebd78014cf74f3c65cd4474), [`8fae5f3`](https://github.com/atlassian-labs/atlaspack/commit/8fae5f3005bd7c806b175b4df1754abf58922591), [`cc66aaa`](https://github.com/atlassian-labs/atlaspack/commit/cc66aaa66d67dd0cb89e083f387a278e74aad3f0), [`67df3f1`](https://github.com/atlassian-labs/atlaspack/commit/67df3f1af1432d77ee6b8850010d976d3313693a), [`0c3ad7a`](https://github.com/atlassian-labs/atlaspack/commit/0c3ad7a302330da1d5e3c025963cc583eb5c28ed)]:
|
|
35
|
+
- @atlaspack/diagnostic@2.14.0
|
|
36
|
+
- @atlaspack/feature-flags@2.14.0
|
|
37
|
+
- @atlaspack/graph@3.4.0
|
|
38
|
+
- @atlaspack/plugin@2.14.0
|
|
39
|
+
- @atlaspack/rust@3.0.0
|
|
40
|
+
- @atlaspack/utils@2.14.0
|
|
41
|
+
|
|
3
42
|
## 2.13.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
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,41 @@ function addJSMonolithBundle(bundleGraph, entryAsset, entryDep) {
|
|
|
44
37
|
return;
|
|
45
38
|
}
|
|
46
39
|
let assets = bundleGraph.getDependencyAssets(dependency);
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
for (const asset of assets) {
|
|
41
|
+
if (asset.bundleBehavior === 'isolated') {
|
|
42
|
+
throw new Error('Isolated assets are not supported for single file output builds');
|
|
43
|
+
}
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
// For assets marked as inline, we create new bundles and let other
|
|
46
|
+
// plugins like optimizers include them in the primary bundle
|
|
47
|
+
if (asset.bundleBehavior === 'inline') {
|
|
48
|
+
// Create a new bundle to hold the isolated asset
|
|
49
|
+
let isolatedBundle = bundleGraph.createBundle({
|
|
50
|
+
entryAsset: asset,
|
|
51
|
+
target,
|
|
52
|
+
bundleBehavior: asset.bundleBehavior
|
|
53
|
+
});
|
|
54
|
+
bundleGraph.addAssetToBundle(asset, isolatedBundle);
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
// Add the new bundle to the bundle graph, in its own bundle group
|
|
57
|
+
bundleGraph.createBundleReference(bundle, isolatedBundle);
|
|
58
|
+
bundleGraph.addBundleToBundleGroup(isolatedBundle, bundleGraph.createBundleGroup(dependency, target));
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
// Nothing below the isolated asset needs to go in the main bundle, so
|
|
61
|
+
// we can stop traversal here
|
|
62
|
+
actions.skipChildren();
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
// To be properly isolated, all of this asset's dependencies need to go
|
|
65
|
+
// in this new bundle
|
|
66
|
+
bundleGraph.traverse(subNode => {
|
|
67
|
+
if (subNode.type === 'asset' && subNode.value.type === 'js') {
|
|
68
|
+
bundleGraph.addAssetToBundle(subNode.value, isolatedBundle);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}, asset, {
|
|
72
|
+
skipUnusedDependencies: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
78
75
|
}
|
|
79
76
|
}, entryAsset, {
|
|
80
77
|
skipUnusedDependencies: true
|
package/lib/idealGraph.js
CHANGED
|
@@ -274,8 +274,8 @@ function createIdealGraph(assetGraph, config, entries, logger) {
|
|
|
274
274
|
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && dependency.priority === 'conditional') {
|
|
275
275
|
let [referencingBundleRoot, bundleGroupNodeId] = (0, _nullthrows().default)(stack[stack.length - 1]);
|
|
276
276
|
let referencingBundleId = (0, _nullthrows().default)(bundleRoots.get(referencingBundleRoot))[0];
|
|
277
|
-
if (config.loadConditionalBundlesInParallel
|
|
278
|
-
// When configured
|
|
277
|
+
if (config.loadConditionalBundlesInParallel) {
|
|
278
|
+
// When configured, serve conditional bundles in parallel so we don't get module not found errors
|
|
279
279
|
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]);
|
|
280
280
|
bundleGraph.addEdge(referencingBundleId, bundleId);
|
|
281
281
|
}
|
|
@@ -438,7 +438,7 @@ function createIdealGraph(assetGraph, config, entries, logger) {
|
|
|
438
438
|
let bundleRoot = assets[0];
|
|
439
439
|
let bundle = (0, _nullthrows().default)(bundleGraph.getNode((0, _nullthrows().default)(bundles.get(bundleRoot.id))));
|
|
440
440
|
if (bundle !== 'root' && bundle.bundleBehavior == null && !bundle.env.isIsolated() && bundle.env.context === root.env.context) {
|
|
441
|
-
bundleRootGraph.addEdge(bundleRootId, (0, _nullthrows().default)(assetToBundleRootNodeId.get(bundleRoot)), dependency.priority === 'parallel' ||
|
|
441
|
+
bundleRootGraph.addEdge(bundleRootId, (0, _nullthrows().default)(assetToBundleRootNodeId.get(bundleRoot)), dependency.priority === 'parallel' || config.loadConditionalBundlesInParallel && dependency.priority === 'conditional' ? bundleRootEdgeTypes.parallel : bundleRootEdgeTypes.lazy);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
if (dependency.priority !== 'sync') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/bundler-default",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1-canary.10+3b66d6b4b",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
|
+
"type": "commonjs",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
@@ -12,17 +13,16 @@
|
|
|
12
13
|
"main": "lib/DefaultBundler.js",
|
|
13
14
|
"source": "src/DefaultBundler.js",
|
|
14
15
|
"engines": {
|
|
15
|
-
"atlaspack": "^2.13.2-dev.3689+7a2e6e783",
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.
|
|
20
|
-
"@atlaspack/feature-flags": "2.
|
|
21
|
-
"@atlaspack/graph": "3.
|
|
22
|
-
"@atlaspack/plugin": "2.
|
|
23
|
-
"@atlaspack/rust": "
|
|
24
|
-
"@atlaspack/utils": "2.
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.10+3b66d6b4b",
|
|
20
|
+
"@atlaspack/feature-flags": "2.14.1-canary.10+3b66d6b4b",
|
|
21
|
+
"@atlaspack/graph": "3.4.1-canary.10+3b66d6b4b",
|
|
22
|
+
"@atlaspack/plugin": "2.14.1-canary.10+3b66d6b4b",
|
|
23
|
+
"@atlaspack/rust": "3.0.1-canary.10+3b66d6b4b",
|
|
24
|
+
"@atlaspack/utils": "2.14.1-canary.10+3b66d6b4b",
|
|
25
25
|
"nullthrows": "^1.1.1"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "3b66d6b4bfd652ab3b41e86aacf3e47d39cd5a70"
|
|
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,50 @@ 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
|
+
if (asset.bundleBehavior === 'isolated') {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'Isolated assets are not supported for single file output builds',
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
// For assets marked as inline, we create new bundles and let other
|
|
49
|
+
// plugins like optimizers include them in the primary bundle
|
|
50
|
+
if (asset.bundleBehavior === 'inline') {
|
|
51
|
+
// Create a new bundle to hold the isolated asset
|
|
52
|
+
let isolatedBundle = bundleGraph.createBundle({
|
|
53
|
+
entryAsset: asset,
|
|
54
|
+
target,
|
|
55
|
+
bundleBehavior: asset.bundleBehavior,
|
|
56
|
+
});
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
bundleGraph.addAssetToBundle(asset, isolatedBundle);
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
// Add the new bundle to the bundle graph, in its own bundle group
|
|
61
|
+
bundleGraph.createBundleReference(bundle, isolatedBundle);
|
|
62
|
+
bundleGraph.addBundleToBundleGroup(
|
|
63
|
+
isolatedBundle,
|
|
64
|
+
bundleGraph.createBundleGroup(dependency, target),
|
|
65
|
+
);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// Nothing below the isolated asset needs to go in the main bundle, so
|
|
68
|
+
// we can stop traversal here
|
|
69
|
+
actions.skipChildren();
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
// To be properly isolated, all of this asset's dependencies need to go
|
|
72
|
+
// in this new bundle
|
|
73
|
+
bundleGraph.traverse(
|
|
74
|
+
(subNode) => {
|
|
75
|
+
if (subNode.type === 'asset' && subNode.value.type === 'js') {
|
|
76
|
+
bundleGraph.addAssetToBundle(subNode.value, isolatedBundle);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
asset,
|
|
81
|
+
{skipUnusedDependencies: true},
|
|
82
|
+
);
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
entryAsset,
|
package/src/idealGraph.js
CHANGED
|
@@ -385,11 +385,8 @@ export function createIdealGraph(
|
|
|
385
385
|
bundleRoots.get(referencingBundleRoot),
|
|
386
386
|
)[0];
|
|
387
387
|
|
|
388
|
-
if (
|
|
389
|
-
|
|
390
|
-
!bundle.env.shouldScopeHoist
|
|
391
|
-
) {
|
|
392
|
-
// When configured (or serving code in development), serve conditional bundles in parallel so we don't get module not found errors
|
|
388
|
+
if (config.loadConditionalBundlesInParallel) {
|
|
389
|
+
// When configured, serve conditional bundles in parallel so we don't get module not found errors
|
|
393
390
|
bundleRoots.set(childAsset, [bundleId, bundleGroupNodeId]);
|
|
394
391
|
bundleGraph.addEdge(referencingBundleId, bundleId);
|
|
395
392
|
}
|
|
@@ -622,8 +619,7 @@ export function createIdealGraph(
|
|
|
622
619
|
bundleRootId,
|
|
623
620
|
nullthrows(assetToBundleRootNodeId.get(bundleRoot)),
|
|
624
621
|
dependency.priority === 'parallel' ||
|
|
625
|
-
(
|
|
626
|
-
!bundle.env.shouldScopeHoist) &&
|
|
622
|
+
(config.loadConditionalBundlesInParallel &&
|
|
627
623
|
dependency.priority === 'conditional')
|
|
628
624
|
? bundleRootEdgeTypes.parallel
|
|
629
625
|
: bundleRootEdgeTypes.lazy,
|