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

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,145 @@
1
1
  # @atlaspack/packager-html
2
2
 
3
+ ## 2.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`13aef17`](https://github.com/atlassian-labs/atlaspack/commit/13aef177eea289a6e40d2113b5ec1ac9be18a33d)]:
8
+ - @atlaspack/feature-flags@2.19.1
9
+ - @atlaspack/utils@2.17.1
10
+ - @atlaspack/types@2.15.9
11
+ - @atlaspack/plugin@2.14.19
12
+
13
+ ## 2.15.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#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
18
+
19
+ ### Patch Changes
20
+
21
+ - 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)]:
22
+ - @atlaspack/feature-flags@2.19.0
23
+ - @atlaspack/utils@2.17.0
24
+ - @atlaspack/types@2.15.8
25
+ - @atlaspack/plugin@2.14.18
26
+
27
+ ## 2.14.17
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies []:
32
+ - @atlaspack/utils@2.16.1
33
+ - @atlaspack/types@2.15.7
34
+ - @atlaspack/plugin@2.14.17
35
+
36
+ ## 2.14.16
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c), [`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
41
+ - @atlaspack/feature-flags@2.18.4
42
+ - @atlaspack/utils@2.16.0
43
+ - @atlaspack/types@2.15.6
44
+ - @atlaspack/plugin@2.14.16
45
+
46
+ ## 2.14.15
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
51
+ - @atlaspack/feature-flags@2.18.3
52
+ - @atlaspack/utils@2.15.3
53
+ - @atlaspack/types@2.15.5
54
+ - @atlaspack/plugin@2.14.15
55
+
56
+ ## 2.14.14
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
61
+ - @atlaspack/feature-flags@2.18.2
62
+ - @atlaspack/utils@2.15.2
63
+ - @atlaspack/types@2.15.4
64
+ - @atlaspack/plugin@2.14.14
65
+
66
+ ## 2.14.13
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
71
+ - @atlaspack/feature-flags@2.18.1
72
+ - @atlaspack/types@2.15.3
73
+ - @atlaspack/utils@2.15.1
74
+ - @atlaspack/plugin@2.14.13
75
+
76
+ ## 2.14.12
77
+
78
+ ### Patch Changes
79
+
80
+ - 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)]:
81
+ - @atlaspack/feature-flags@2.18.0
82
+ - @atlaspack/utils@2.15.0
83
+ - @atlaspack/types@2.15.2
84
+ - @atlaspack/plugin@2.14.12
85
+
86
+ ## 2.14.11
87
+
88
+ ### Patch Changes
89
+
90
+ - [#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
91
+
92
+ - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
93
+ - @atlaspack/feature-flags@2.17.0
94
+ - @atlaspack/utils@2.14.11
95
+ - @atlaspack/types@2.15.1
96
+ - @atlaspack/plugin@2.14.11
97
+
98
+ ## 2.14.10
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
103
+ - @atlaspack/types@2.15.0
104
+ - @atlaspack/plugin@2.14.10
105
+ - @atlaspack/utils@2.14.10
106
+
107
+ ## 2.14.9
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies []:
112
+ - @atlaspack/utils@2.14.9
113
+ - @atlaspack/types@2.14.9
114
+ - @atlaspack/plugin@2.14.9
115
+
116
+ ## 2.14.8
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies []:
121
+ - @atlaspack/utils@2.14.8
122
+ - @atlaspack/types@2.14.8
123
+ - @atlaspack/plugin@2.14.8
124
+
125
+ ## 2.14.7
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies []:
130
+ - @atlaspack/utils@2.14.7
131
+ - @atlaspack/types@2.14.7
132
+ - @atlaspack/plugin@2.14.7
133
+
134
+ ## 2.14.6
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies []:
139
+ - @atlaspack/utils@2.14.6
140
+ - @atlaspack/types@2.14.6
141
+ - @atlaspack/plugin@2.14.6
142
+
3
143
  ## 2.14.5
4
144
 
5
145
  ### 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.131+75286ffe8",
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.199+75286ffe8",
19
+ "@atlaspack/plugin": "2.14.5-canary.131+75286ffe8",
20
+ "@atlaspack/types": "2.14.5-canary.131+75286ffe8",
21
+ "@atlaspack/utils": "2.14.5-canary.131+75286ffe8",
21
22
  "nullthrows": "^1.1.1",
22
23
  "posthtml": "^0.16.5"
23
24
  },
24
25
  "type": "commonjs",
25
- "gitHead": "e0f533757bd1019dbd108a04952c87da15286e09"
26
+ "gitHead": "75286ffe8068fae73afa5954a6d2a0f53fbf5e0d"
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
+ }