@atlaspack/reporter-conditional-manifest 2.14.18-noselfbuild-63bde801d.0 → 2.14.18-typescript-e769947a5.0

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.
@@ -28,6 +28,13 @@ function _plugin() {
28
28
  return data;
29
29
  }
30
30
  var _Config = require("./Config");
31
+ function _featureFlags() {
32
+ const data = require("@atlaspack/feature-flags");
33
+ _featureFlags = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
31
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
39
  const manifestHashes = exports.manifestHashes = new Map();
33
40
  const updateManifest = async (outputFS, logger, conditionalManifestFilename, conditionalManifest) => {
@@ -56,17 +63,29 @@ async function report({
56
63
  const mapBundles = bundles => bundles.map(bundle => (0, _path().relative)(bundle.target.distDir, bundle.filePath));
57
64
  const manifest = {};
58
65
  for (const conditions of bundles.values()) {
66
+ const oldBundleInfo = {};
59
67
  for (const [key, cond] of conditions) {
60
- var _manifest$bundle$targ, _bundleInfo$key, _bundleInfo$key2;
61
- const bundle = cond.bundle;
62
- const relativeBundlePath = (0, _path().relative)(bundle.target.distDir, bundle.filePath);
63
- const bundleInfo = ((_manifest$bundle$targ = manifest[bundle.target.name]) === null || _manifest$bundle$targ === void 0 ? void 0 : _manifest$bundle$targ[relativeBundlePath]) ?? {};
64
- bundleInfo[key] = {
65
- ifTrueBundles: mapBundles(cond.ifTrueBundles).concat(((_bundleInfo$key = bundleInfo[key]) === null || _bundleInfo$key === void 0 ? void 0 : _bundleInfo$key.ifTrueBundles) ?? []).sort(),
66
- ifFalseBundles: mapBundles(cond.ifFalseBundles).concat(((_bundleInfo$key2 = bundleInfo[key]) === null || _bundleInfo$key2 === void 0 ? void 0 : _bundleInfo$key2.ifFalseBundles) ?? []).sort()
67
- };
68
- manifest[bundle.target.name] ??= {};
69
- manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
68
+ if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterSameConditionFix')) {
69
+ var _manifest$bundle$targ, _bundleInfo$key, _bundleInfo$key2;
70
+ const bundle = cond.bundle;
71
+ const relativeBundlePath = (0, _path().relative)(bundle.target.distDir, bundle.filePath);
72
+ const bundleInfo = ((_manifest$bundle$targ = manifest[bundle.target.name]) === null || _manifest$bundle$targ === void 0 ? void 0 : _manifest$bundle$targ[relativeBundlePath]) ?? {};
73
+ bundleInfo[key] = {
74
+ ifTrueBundles: mapBundles(cond.ifTrueBundles).concat(((_bundleInfo$key = bundleInfo[key]) === null || _bundleInfo$key === void 0 ? void 0 : _bundleInfo$key.ifTrueBundles) ?? []).sort(),
75
+ ifFalseBundles: mapBundles(cond.ifFalseBundles).concat(((_bundleInfo$key2 = bundleInfo[key]) === null || _bundleInfo$key2 === void 0 ? void 0 : _bundleInfo$key2.ifFalseBundles) ?? []).sort()
76
+ };
77
+ manifest[bundle.target.name] ??= {};
78
+ manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
79
+ } else {
80
+ const bundle = cond.bundle;
81
+ oldBundleInfo[key] = {
82
+ // Reverse bundles so we load children bundles first
83
+ ifTrueBundles: mapBundles(cond.ifTrueBundles).reverse(),
84
+ ifFalseBundles: mapBundles(cond.ifFalseBundles).reverse()
85
+ };
86
+ manifest[bundle.target.name] ??= {};
87
+ manifest[bundle.target.name][(0, _path().relative)(bundle.target.distDir, bundle.filePath)] = oldBundleInfo;
88
+ }
70
89
  }
71
90
  }
72
91
  const targets = new Set(event.bundleGraph.getBundles().map(bundle => bundle.target));
@@ -78,7 +97,17 @@ async function report({
78
97
  const conditionalManifest = JSON.stringify(
79
98
  // If there's no content, send an empty manifest so we can still map from it safely
80
99
  manifest[target.name] ?? {}, null, 2);
81
- await updateManifest(options.outputFS, logger, conditionalManifestFilename, conditionalManifest);
100
+ if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterDuplicateFix')) {
101
+ await updateManifest(options.outputFS, logger, conditionalManifestFilename, conditionalManifest);
102
+ } else {
103
+ await options.outputFS.mkdirp((0, _path().dirname)(conditionalManifestFilename));
104
+ await options.outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
105
+ mode: 0o666
106
+ });
107
+ logger.info({
108
+ message: 'Wrote conditional manifest to ' + conditionalManifestFilename
109
+ });
110
+ }
82
111
  }
83
112
  }
84
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/reporter-conditional-manifest",
3
- "version": "2.14.18-noselfbuild-63bde801d.0",
3
+ "version": "2.14.18-typescript-e769947a5.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,10 +15,10 @@
15
15
  "node": ">= 16.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "@atlaspack/feature-flags": "2.18.5-noselfbuild-63bde801d.0",
19
- "@atlaspack/plugin": "2.14.18-noselfbuild-63bde801d.0",
18
+ "@atlaspack/feature-flags": "2.18.5-typescript-e769947a5.0",
19
+ "@atlaspack/plugin": "2.14.18-typescript-e769947a5.0",
20
20
  "nullthrows": "^1.1.1"
21
21
  },
22
22
  "type": "commonjs",
23
- "gitHead": "63bde801db96c5cb339ea9360cbcd0172a26cbba"
23
+ "gitHead": "e769947a5b0c22d9477211ac1ce6614e6bf9def3"
24
24
  }
@@ -12,6 +12,7 @@ import type {
12
12
  FilePath,
13
13
  } from '@atlaspack/types-internal';
14
14
  import {getConfig} from './Config';
15
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
15
16
 
16
17
  export const manifestHashes: Map<FilePath, string> = new Map();
17
18
 
@@ -59,27 +60,41 @@ export async function report({
59
60
 
60
61
  const manifest = {};
61
62
  for (const conditions of bundles.values()) {
63
+ const oldBundleInfo = {};
62
64
  for (const [key, cond] of conditions) {
63
- const bundle = cond.bundle;
64
- const relativeBundlePath = relative(
65
- bundle.target.distDir,
66
- bundle.filePath,
67
- );
68
-
69
- const bundleInfo =
70
- manifest[bundle.target.name]?.[relativeBundlePath] ?? {};
71
-
72
- bundleInfo[key] = {
73
- ifTrueBundles: mapBundles(cond.ifTrueBundles)
74
- .concat(bundleInfo[key]?.ifTrueBundles ?? [])
75
- .sort(),
76
- ifFalseBundles: mapBundles(cond.ifFalseBundles)
77
- .concat(bundleInfo[key]?.ifFalseBundles ?? [])
78
- .sort(),
79
- };
80
-
81
- manifest[bundle.target.name] ??= {};
82
- manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
65
+ if (getFeatureFlag('conditionalBundlingReporterSameConditionFix')) {
66
+ const bundle = cond.bundle;
67
+ const relativeBundlePath = relative(
68
+ bundle.target.distDir,
69
+ bundle.filePath,
70
+ );
71
+
72
+ const bundleInfo =
73
+ manifest[bundle.target.name]?.[relativeBundlePath] ?? {};
74
+
75
+ bundleInfo[key] = {
76
+ ifTrueBundles: mapBundles(cond.ifTrueBundles)
77
+ .concat(bundleInfo[key]?.ifTrueBundles ?? [])
78
+ .sort(),
79
+ ifFalseBundles: mapBundles(cond.ifFalseBundles)
80
+ .concat(bundleInfo[key]?.ifFalseBundles ?? [])
81
+ .sort(),
82
+ };
83
+
84
+ manifest[bundle.target.name] ??= {};
85
+ manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
86
+ } else {
87
+ const bundle = cond.bundle;
88
+ oldBundleInfo[key] = {
89
+ // Reverse bundles so we load children bundles first
90
+ ifTrueBundles: mapBundles(cond.ifTrueBundles).reverse(),
91
+ ifFalseBundles: mapBundles(cond.ifFalseBundles).reverse(),
92
+ };
93
+ manifest[bundle.target.name] ??= {};
94
+ manifest[bundle.target.name][
95
+ relative(bundle.target.distDir, bundle.filePath)
96
+ ] = oldBundleInfo;
97
+ }
83
98
  }
84
99
  }
85
100
 
@@ -98,12 +113,26 @@ export async function report({
98
113
  2,
99
114
  );
100
115
 
101
- await updateManifest(
102
- options.outputFS,
103
- logger,
104
- conditionalManifestFilename,
105
- conditionalManifest,
106
- );
116
+ if (getFeatureFlag('conditionalBundlingReporterDuplicateFix')) {
117
+ await updateManifest(
118
+ options.outputFS,
119
+ logger,
120
+ conditionalManifestFilename,
121
+ conditionalManifest,
122
+ );
123
+ } else {
124
+ await options.outputFS.mkdirp(dirname(conditionalManifestFilename));
125
+ await options.outputFS.writeFile(
126
+ conditionalManifestFilename,
127
+ conditionalManifest,
128
+ {mode: 0o666},
129
+ );
130
+
131
+ logger.info({
132
+ message:
133
+ 'Wrote conditional manifest to ' + conditionalManifestFilename,
134
+ });
135
+ }
107
136
  }
108
137
  }
109
138
  }