@atlaspack/packager-html 2.14.5-canary.13 → 2.14.5-canary.130

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 CHANGED
@@ -1,5 +1,135 @@
1
1
  # @atlaspack/packager-html
2
2
 
3
+ ## 2.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#640](https://github.com/atlassian-labs/atlaspack/pull/640) [`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d) Thanks [@JakeLane](https://github.com/JakeLane)! - Clean up conditional bundling feature flags
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`c4415a4`](https://github.com/atlassian-labs/atlaspack/commit/c4415a455543d984ca28452c2cb87a794d22497c), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
12
+ - @atlaspack/feature-flags@2.19.0
13
+ - @atlaspack/utils@2.17.0
14
+ - @atlaspack/types@2.15.8
15
+ - @atlaspack/plugin@2.14.18
16
+
17
+ ## 2.14.17
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies []:
22
+ - @atlaspack/utils@2.16.1
23
+ - @atlaspack/types@2.15.7
24
+ - @atlaspack/plugin@2.14.17
25
+
26
+ ## 2.14.16
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c), [`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
31
+ - @atlaspack/feature-flags@2.18.4
32
+ - @atlaspack/utils@2.16.0
33
+ - @atlaspack/types@2.15.6
34
+ - @atlaspack/plugin@2.14.16
35
+
36
+ ## 2.14.15
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
41
+ - @atlaspack/feature-flags@2.18.3
42
+ - @atlaspack/utils@2.15.3
43
+ - @atlaspack/types@2.15.5
44
+ - @atlaspack/plugin@2.14.15
45
+
46
+ ## 2.14.14
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
51
+ - @atlaspack/feature-flags@2.18.2
52
+ - @atlaspack/utils@2.15.2
53
+ - @atlaspack/types@2.15.4
54
+ - @atlaspack/plugin@2.14.14
55
+
56
+ ## 2.14.13
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
61
+ - @atlaspack/feature-flags@2.18.1
62
+ - @atlaspack/types@2.15.3
63
+ - @atlaspack/utils@2.15.1
64
+ - @atlaspack/plugin@2.14.13
65
+
66
+ ## 2.14.12
67
+
68
+ ### Patch Changes
69
+
70
+ - 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)]:
71
+ - @atlaspack/feature-flags@2.18.0
72
+ - @atlaspack/utils@2.15.0
73
+ - @atlaspack/types@2.15.2
74
+ - @atlaspack/plugin@2.14.12
75
+
76
+ ## 2.14.11
77
+
78
+ ### Patch Changes
79
+
80
+ - [#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
81
+
82
+ - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
83
+ - @atlaspack/feature-flags@2.17.0
84
+ - @atlaspack/utils@2.14.11
85
+ - @atlaspack/types@2.15.1
86
+ - @atlaspack/plugin@2.14.11
87
+
88
+ ## 2.14.10
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
93
+ - @atlaspack/types@2.15.0
94
+ - @atlaspack/plugin@2.14.10
95
+ - @atlaspack/utils@2.14.10
96
+
97
+ ## 2.14.9
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies []:
102
+ - @atlaspack/utils@2.14.9
103
+ - @atlaspack/types@2.14.9
104
+ - @atlaspack/plugin@2.14.9
105
+
106
+ ## 2.14.8
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies []:
111
+ - @atlaspack/utils@2.14.8
112
+ - @atlaspack/types@2.14.8
113
+ - @atlaspack/plugin@2.14.8
114
+
115
+ ## 2.14.7
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies []:
120
+ - @atlaspack/utils@2.14.7
121
+ - @atlaspack/types@2.14.7
122
+ - @atlaspack/plugin@2.14.7
123
+
124
+ ## 2.14.6
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies []:
129
+ - @atlaspack/utils@2.14.6
130
+ - @atlaspack/types@2.14.6
131
+ - @atlaspack/plugin@2.14.6
132
+
3
133
  ## 2.14.5
4
134
 
5
135
  ### Patch Changes
@@ -88,7 +88,7 @@ var _default = exports.default = new (_plugin().Packager)({
88
88
  let referencedBundles = [...(0, _utils().setSymmetricDifference)(new Set(referencedBundlesRecursive), new Set(bundleGraph.getReferencedBundles(bundle, {
89
89
  recursive: false
90
90
  })))];
91
- let conditionalBundles = config.evaluateRootConditionalBundles ? (0, _utils().setDifference)(new Set([...referencedBundlesRecursive.flatMap(referencedBundle => bundleGraph.getReferencedConditionalBundles(referencedBundle))]), new Set(referencedBundles)) : new Set();
91
+ let conditionalBundles = config.evaluateRootConditionalBundles ? (0, _utils().setDifference)(getReferencedConditionalScripts(bundleGraph, referencedBundlesRecursive), new Set(referencedBundles)) : new Set();
92
92
  let renderConfig = config === null || config === void 0 ? void 0 : config.render;
93
93
  let {
94
94
  html
@@ -243,4 +243,20 @@ function findBundleInsertIndex(content) {
243
243
  }
244
244
  }
245
245
  return doctypeIndex ? doctypeIndex + 1 : 0;
246
+ }
247
+ function getReferencedConditionalScripts(bundleGraph, referencedBundles) {
248
+ const conditionalBundleMapping = bundleGraph.getConditionalBundleMapping();
249
+ const bundles = [];
250
+ for (const bundle of referencedBundles) {
251
+ const conditions = conditionalBundleMapping.get(bundle.id);
252
+ if (conditions) {
253
+ for (const [, cond] of conditions) {
254
+ // Reverse so dependent bundles are loaded first
255
+ const dependentBundles = [...cond.ifTrueBundles.reverse(), ...cond.ifFalseBundles.reverse()];
256
+ bundles.push(...dependentBundles);
257
+ referencedBundles.push(...dependentBundles);
258
+ }
259
+ }
260
+ }
261
+ return new Set(bundles);
246
262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-html",
3
- "version": "2.14.5-canary.13+e0f533757",
3
+ "version": "2.14.5-canary.130+13aef177e",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,12 +15,13 @@
15
15
  "node": ">= 16.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.13+e0f533757",
19
- "@atlaspack/types": "2.14.5-canary.13+e0f533757",
20
- "@atlaspack/utils": "2.14.5-canary.13+e0f533757",
18
+ "@atlaspack/feature-flags": "2.14.1-canary.198+13aef177e",
19
+ "@atlaspack/plugin": "2.14.5-canary.130+13aef177e",
20
+ "@atlaspack/types": "2.14.5-canary.130+13aef177e",
21
+ "@atlaspack/utils": "2.14.5-canary.130+13aef177e",
21
22
  "nullthrows": "^1.1.1",
22
23
  "posthtml": "^0.16.5"
23
24
  },
24
25
  "type": "commonjs",
25
- "gitHead": "e0f533757bd1019dbd108a04952c87da15286e09"
26
+ "gitHead": "13aef177eea289a6e40d2113b5ec1ac9be18a33d"
26
27
  }
@@ -77,15 +77,13 @@ export default (new Packager({
77
77
 
78
78
  let conditionalBundles = config.evaluateRootConditionalBundles
79
79
  ? setDifference(
80
- new Set([
81
- ...referencedBundlesRecursive.flatMap((referencedBundle) =>
82
- bundleGraph.getReferencedConditionalBundles(referencedBundle),
83
- ),
84
- ]),
80
+ getReferencedConditionalScripts(
81
+ bundleGraph,
82
+ referencedBundlesRecursive,
83
+ ),
85
84
  new Set(referencedBundles),
86
85
  )
87
86
  : new Set();
88
-
89
87
  let renderConfig = config?.render;
90
88
 
91
89
  let {html} = await posthtml([
@@ -284,3 +282,28 @@ function findBundleInsertIndex(content) {
284
282
 
285
283
  return doctypeIndex ? doctypeIndex + 1 : 0;
286
284
  }
285
+
286
+ function getReferencedConditionalScripts(
287
+ bundleGraph: BundleGraph<NamedBundle>,
288
+ referencedBundles: NamedBundle[],
289
+ ): Set<NamedBundle> {
290
+ const conditionalBundleMapping = bundleGraph.getConditionalBundleMapping();
291
+
292
+ const bundles = [];
293
+ for (const bundle of referencedBundles) {
294
+ const conditions = conditionalBundleMapping.get(bundle.id);
295
+ if (conditions) {
296
+ for (const [, cond] of conditions) {
297
+ // Reverse so dependent bundles are loaded first
298
+ const dependentBundles = [
299
+ ...cond.ifTrueBundles.reverse(),
300
+ ...cond.ifFalseBundles.reverse(),
301
+ ];
302
+ bundles.push(...dependentBundles);
303
+ referencedBundles.push(...dependentBundles);
304
+ }
305
+ }
306
+ }
307
+
308
+ return new Set(bundles);
309
+ }