@atlaspack/packager-html 2.14.10 → 2.14.12
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 +22 -0
- package/lib/HTMLPackager.js +24 -1
- package/package.json +5 -4
- package/src/HTMLPackager.js +41 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaspack/packager-html
|
|
2
2
|
|
|
3
|
+
## 2.14.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.18.0
|
|
9
|
+
- @atlaspack/utils@2.15.0
|
|
10
|
+
- @atlaspack/types@2.15.2
|
|
11
|
+
- @atlaspack/plugin@2.14.12
|
|
12
|
+
|
|
13
|
+
## 2.14.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#623](https://github.com/atlassian-labs/atlaspack/pull/623) [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef) Thanks [@JakeLane](https://github.com/JakeLane)! - Load same conditional bundles as conditional manifest in HTML
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
|
|
20
|
+
- @atlaspack/feature-flags@2.17.0
|
|
21
|
+
- @atlaspack/utils@2.14.11
|
|
22
|
+
- @atlaspack/types@2.15.1
|
|
23
|
+
- @atlaspack/plugin@2.14.11
|
|
24
|
+
|
|
3
25
|
## 2.14.10
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/lib/HTMLPackager.js
CHANGED
|
@@ -46,6 +46,13 @@ function _nullthrows() {
|
|
|
46
46
|
};
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
|
+
function _featureFlags() {
|
|
50
|
+
const data = require("@atlaspack/feature-flags");
|
|
51
|
+
_featureFlags = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
49
56
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
57
|
// https://www.w3.org/TR/html5/dom.html#metadata-content-2
|
|
51
58
|
const metadataContent = new Set(['base', 'link', 'meta', 'noscript',
|
|
@@ -88,7 +95,7 @@ var _default = exports.default = new (_plugin().Packager)({
|
|
|
88
95
|
let referencedBundles = [...(0, _utils().setSymmetricDifference)(new Set(referencedBundlesRecursive), new Set(bundleGraph.getReferencedBundles(bundle, {
|
|
89
96
|
recursive: false
|
|
90
97
|
})))];
|
|
91
|
-
let conditionalBundles = config.evaluateRootConditionalBundles ? (0, _utils().setDifference)(new Set([...referencedBundlesRecursive.flatMap(referencedBundle => bundleGraph.getReferencedConditionalBundles(referencedBundle))]), new Set(referencedBundles)) : new Set();
|
|
98
|
+
let conditionalBundles = config.evaluateRootConditionalBundles ? (0, _featureFlags().getFeatureFlag)('condbHtmlPackagerChange') ? (0, _utils().setDifference)(getReferencedConditionalScripts(bundleGraph, referencedBundlesRecursive), new Set(referencedBundles)) : (0, _utils().setDifference)(new Set([...referencedBundlesRecursive.flatMap(referencedBundle => bundleGraph.getReferencedConditionalBundles(referencedBundle))]), new Set(referencedBundles)) : new Set();
|
|
92
99
|
let renderConfig = config === null || config === void 0 ? void 0 : config.render;
|
|
93
100
|
let {
|
|
94
101
|
html
|
|
@@ -243,4 +250,20 @@ function findBundleInsertIndex(content) {
|
|
|
243
250
|
}
|
|
244
251
|
}
|
|
245
252
|
return doctypeIndex ? doctypeIndex + 1 : 0;
|
|
253
|
+
}
|
|
254
|
+
function getReferencedConditionalScripts(bundleGraph, referencedBundles) {
|
|
255
|
+
const conditionalBundleMapping = bundleGraph.getConditionalBundleMapping();
|
|
256
|
+
const bundles = [];
|
|
257
|
+
for (const bundle of referencedBundles) {
|
|
258
|
+
const conditions = conditionalBundleMapping.get(bundle.id);
|
|
259
|
+
if (conditions) {
|
|
260
|
+
for (const [, cond] of conditions) {
|
|
261
|
+
// Reverse so dependent bundles are loaded first
|
|
262
|
+
const dependentBundles = [...cond.ifTrueBundles.reverse(), ...cond.ifFalseBundles.reverse()];
|
|
263
|
+
bundles.push(...dependentBundles);
|
|
264
|
+
referencedBundles.push(...dependentBundles);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return new Set(bundles);
|
|
246
269
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-html",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.12",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"node": ">= 16.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atlaspack/plugin": "2.14.
|
|
19
|
-
"@atlaspack/types": "2.15.
|
|
20
|
-
"@atlaspack/utils": "2.
|
|
18
|
+
"@atlaspack/plugin": "2.14.12",
|
|
19
|
+
"@atlaspack/types": "2.15.2",
|
|
20
|
+
"@atlaspack/utils": "2.15.0",
|
|
21
|
+
"@atlaspack/feature-flags": "2.18.0",
|
|
21
22
|
"nullthrows": "^1.1.1",
|
|
22
23
|
"posthtml": "^0.16.5"
|
|
23
24
|
},
|
package/src/HTMLPackager.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
urlJoin,
|
|
14
14
|
} from '@atlaspack/utils';
|
|
15
15
|
import nullthrows from 'nullthrows';
|
|
16
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
16
17
|
|
|
17
18
|
// https://www.w3.org/TR/html5/dom.html#metadata-content-2
|
|
18
19
|
const metadataContent = new Set([
|
|
@@ -76,16 +77,23 @@ export default (new Packager({
|
|
|
76
77
|
];
|
|
77
78
|
|
|
78
79
|
let conditionalBundles = config.evaluateRootConditionalBundles
|
|
79
|
-
?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
bundleGraph
|
|
80
|
+
? getFeatureFlag('condbHtmlPackagerChange')
|
|
81
|
+
? setDifference(
|
|
82
|
+
getReferencedConditionalScripts(
|
|
83
|
+
bundleGraph,
|
|
84
|
+
referencedBundlesRecursive,
|
|
83
85
|
),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
new Set(referencedBundles),
|
|
87
|
+
)
|
|
88
|
+
: setDifference(
|
|
89
|
+
new Set([
|
|
90
|
+
...referencedBundlesRecursive.flatMap((referencedBundle) =>
|
|
91
|
+
bundleGraph.getReferencedConditionalBundles(referencedBundle),
|
|
92
|
+
),
|
|
93
|
+
]),
|
|
94
|
+
new Set(referencedBundles),
|
|
95
|
+
)
|
|
87
96
|
: new Set();
|
|
88
|
-
|
|
89
97
|
let renderConfig = config?.render;
|
|
90
98
|
|
|
91
99
|
let {html} = await posthtml([
|
|
@@ -284,3 +292,28 @@ function findBundleInsertIndex(content) {
|
|
|
284
292
|
|
|
285
293
|
return doctypeIndex ? doctypeIndex + 1 : 0;
|
|
286
294
|
}
|
|
295
|
+
|
|
296
|
+
function getReferencedConditionalScripts(
|
|
297
|
+
bundleGraph: BundleGraph<NamedBundle>,
|
|
298
|
+
referencedBundles: NamedBundle[],
|
|
299
|
+
): Set<NamedBundle> {
|
|
300
|
+
const conditionalBundleMapping = bundleGraph.getConditionalBundleMapping();
|
|
301
|
+
|
|
302
|
+
const bundles = [];
|
|
303
|
+
for (const bundle of referencedBundles) {
|
|
304
|
+
const conditions = conditionalBundleMapping.get(bundle.id);
|
|
305
|
+
if (conditions) {
|
|
306
|
+
for (const [, cond] of conditions) {
|
|
307
|
+
// Reverse so dependent bundles are loaded first
|
|
308
|
+
const dependentBundles = [
|
|
309
|
+
...cond.ifTrueBundles.reverse(),
|
|
310
|
+
...cond.ifFalseBundles.reverse(),
|
|
311
|
+
];
|
|
312
|
+
bundles.push(...dependentBundles);
|
|
313
|
+
referencedBundles.push(...dependentBundles);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return new Set(bundles);
|
|
319
|
+
}
|