@atlaspack/reporter-conditional-manifest 2.12.1-dev.3502 → 2.12.1-dev.3520

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.
@@ -18,14 +18,6 @@ function _plugin() {
18
18
  };
19
19
  return data;
20
20
  }
21
- function _nullthrows() {
22
- const data = _interopRequireDefault(require("nullthrows"));
23
- _nullthrows = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
21
  var _default = exports.default = new (_plugin().Reporter)({
30
22
  async report({
31
23
  event,
@@ -46,23 +38,22 @@ var _default = exports.default = new (_plugin().Reporter)({
46
38
  ifFalseBundles: mapBundles(cond.ifFalseBundles).reverse()
47
39
  };
48
40
  }
49
- manifest[(0, _path().relative)(bundle.target.distDir, bundle.filePath)] = bundleInfo;
41
+ manifest[bundle.target.name] ??= {};
42
+ manifest[bundle.target.name][(0, _path().relative)(bundle.target.distDir, bundle.filePath)] = bundleInfo;
50
43
  }
51
- const conditionalManifest = JSON.stringify(manifest, null, 2);
52
44
 
53
45
  // Error if there are multiple targets in the build
54
46
  const targets = new Set(event.bundleGraph.getBundles().map(bundle => bundle.target));
55
- if (targets.size > 1) {
56
- throw new Error('Conditional bundling does not support multiple targets');
47
+ for (const target of targets) {
48
+ const conditionalManifestFilename = (0, _path().join)(target.distDir, 'conditional-manifest.json');
49
+ const conditionalManifest = JSON.stringify(manifest[target.name], null, 2);
50
+ await options.outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
51
+ mode: 0o666
52
+ });
53
+ logger.info({
54
+ message: 'Wrote conditional manifest to ' + conditionalManifestFilename
55
+ });
57
56
  }
58
- const target = targets.values().next().value;
59
- const conditionalManifestFilename = (0, _path().join)((0, _nullthrows().default)(target === null || target === void 0 ? void 0 : target.distDir, 'distDir not found in target'), 'conditional-manifest.json');
60
- await options.outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
61
- mode: 0o666
62
- });
63
- logger.info({
64
- message: 'Wrote conditional manifest to ' + conditionalManifestFilename
65
- });
66
57
  }
67
58
  }
68
59
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/reporter-conditional-manifest",
3
- "version": "2.12.1-dev.3502+c2daeab5a",
3
+ "version": "2.12.1-dev.3520+8a5346e28",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,11 +13,11 @@
13
13
  "source": "src/ConditionalManifestReporter.js",
14
14
  "engines": {
15
15
  "node": ">= 16.0.0",
16
- "parcel": "^2.12.1-dev.3502+c2daeab5a"
16
+ "parcel": "^2.12.1-dev.3520+8a5346e28"
17
17
  },
18
18
  "dependencies": {
19
- "@atlaspack/plugin": "2.12.1-dev.3502+c2daeab5a",
19
+ "@atlaspack/plugin": "2.12.1-dev.3520+8a5346e28",
20
20
  "nullthrows": "^1.1.1"
21
21
  },
22
- "gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
22
+ "gitHead": "8a5346e28c1bb3b9cd40f1c4e77c66dd6666f1e4"
23
23
  }
@@ -1,7 +1,6 @@
1
1
  // @flow strict-local
2
2
  import {relative, join} from 'path';
3
3
  import {Reporter} from '@atlaspack/plugin';
4
- import nullthrows from 'nullthrows';
5
4
 
6
5
  export default (new Reporter({
7
6
  async report({event, options, logger}) {
@@ -24,35 +23,40 @@ export default (new Reporter({
24
23
  };
25
24
  }
26
25
 
27
- manifest[relative(bundle.target.distDir, bundle.filePath)] = bundleInfo;
26
+ manifest[bundle.target.name] ??= {};
27
+ manifest[bundle.target.name][
28
+ relative(bundle.target.distDir, bundle.filePath)
29
+ ] = bundleInfo;
28
30
  }
29
31
 
30
- const conditionalManifest = JSON.stringify(manifest, null, 2);
31
-
32
32
  // Error if there are multiple targets in the build
33
33
  const targets = new Set(
34
34
  event.bundleGraph.getBundles().map((bundle) => bundle.target),
35
35
  );
36
- if (targets.size > 1) {
37
- throw new Error(
38
- 'Conditional bundling does not support multiple targets',
36
+
37
+ for (const target of targets) {
38
+ const conditionalManifestFilename = join(
39
+ target.distDir,
40
+ 'conditional-manifest.json',
39
41
  );
40
- }
41
42
 
42
- const target = targets.values().next().value;
43
- const conditionalManifestFilename = join(
44
- nullthrows(target?.distDir, 'distDir not found in target'),
45
- 'conditional-manifest.json',
46
- );
47
- await options.outputFS.writeFile(
48
- conditionalManifestFilename,
49
- conditionalManifest,
50
- {mode: 0o666},
51
- );
43
+ const conditionalManifest = JSON.stringify(
44
+ manifest[target.name],
45
+ null,
46
+ 2,
47
+ );
48
+
49
+ await options.outputFS.writeFile(
50
+ conditionalManifestFilename,
51
+ conditionalManifest,
52
+ {mode: 0o666},
53
+ );
52
54
 
53
- logger.info({
54
- message: 'Wrote conditional manifest to ' + conditionalManifestFilename,
55
- });
55
+ logger.info({
56
+ message:
57
+ 'Wrote conditional manifest to ' + conditionalManifestFilename,
58
+ });
59
+ }
56
60
  }
57
61
  },
58
62
  }): Reporter);