@atlaspack/reporter-conditional-manifest 2.14.5-canary.14 → 2.14.5-canary.140

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,137 @@
1
1
  # @atlaspack/reporter-conditional-manifest
2
2
 
3
+ ## 2.15.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
8
+ - @atlaspack/feature-flags@2.20.0
9
+ - @atlaspack/plugin@2.14.21
10
+
11
+ ## 2.15.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa), [`1c7865a`](https://github.com/atlassian-labs/atlaspack/commit/1c7865a64451116d94015e248302435839d347c0), [`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a)]:
16
+ - @atlaspack/plugin@2.14.20
17
+ - @atlaspack/feature-flags@2.19.2
18
+
19
+ ## 2.15.1
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`13aef17`](https://github.com/atlassian-labs/atlaspack/commit/13aef177eea289a6e40d2113b5ec1ac9be18a33d)]:
24
+ - @atlaspack/feature-flags@2.19.1
25
+ - @atlaspack/plugin@2.14.19
26
+
27
+ ## 2.15.0
28
+
29
+ ### Minor Changes
30
+
31
+ - [#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
32
+
33
+ ### Patch Changes
34
+
35
+ - 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), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417)]:
36
+ - @atlaspack/feature-flags@2.19.0
37
+ - @atlaspack/plugin@2.14.18
38
+
39
+ ## 2.14.17
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies []:
44
+ - @atlaspack/plugin@2.14.17
45
+
46
+ ## 2.14.16
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c)]:
51
+ - @atlaspack/feature-flags@2.18.4
52
+ - @atlaspack/plugin@2.14.16
53
+
54
+ ## 2.14.15
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
59
+ - @atlaspack/feature-flags@2.18.3
60
+ - @atlaspack/plugin@2.14.15
61
+
62
+ ## 2.14.14
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
67
+ - @atlaspack/feature-flags@2.18.2
68
+ - @atlaspack/plugin@2.14.14
69
+
70
+ ## 2.14.13
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
75
+ - @atlaspack/feature-flags@2.18.1
76
+ - @atlaspack/plugin@2.14.13
77
+
78
+ ## 2.14.12
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2)]:
83
+ - @atlaspack/feature-flags@2.18.0
84
+ - @atlaspack/plugin@2.14.12
85
+
86
+ ## 2.14.11
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
91
+ - @atlaspack/feature-flags@2.17.0
92
+ - @atlaspack/plugin@2.14.11
93
+
94
+ ## 2.14.10
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies []:
99
+ - @atlaspack/plugin@2.14.10
100
+
101
+ ## 2.14.9
102
+
103
+ ### Patch Changes
104
+
105
+ - [#503](https://github.com/atlassian-labs/atlaspack/pull/503) [`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818) Thanks [@JakeLane](https://github.com/JakeLane)! - Fix conditional bundling reporter when condition is reused
106
+
107
+ - Updated dependencies [[`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b)]:
108
+ - @atlaspack/feature-flags@2.16.0
109
+ - @atlaspack/plugin@2.14.9
110
+
111
+ ## 2.14.8
112
+
113
+ ### Patch Changes
114
+
115
+ - Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b)]:
116
+ - @atlaspack/feature-flags@2.15.1
117
+ - @atlaspack/plugin@2.14.8
118
+
119
+ ## 2.14.7
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929)]:
124
+ - @atlaspack/feature-flags@2.15.0
125
+ - @atlaspack/plugin@2.14.7
126
+
127
+ ## 2.14.6
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
132
+ - @atlaspack/feature-flags@2.14.4
133
+ - @atlaspack/plugin@2.14.6
134
+
3
135
  ## 2.14.5
4
136
 
5
137
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ import { Reporter } from '@atlaspack/plugin';
2
+ import type { Async, PluginLogger, PluginOptions, PluginTracer, ReporterEvent, FileSystem, FilePath } from '@atlaspack/types-internal';
3
+ export declare const manifestHashes: Map<FilePath, string>;
4
+ export declare const updateManifest: (outputFS: FileSystem, logger: PluginLogger, conditionalManifestFilename: FilePath, conditionalManifest: string) => Promise<void>;
5
+ export declare function report({ event, options, logger, }: {
6
+ event: ReporterEvent;
7
+ options: PluginOptions;
8
+ logger: PluginLogger;
9
+ tracer: PluginTracer;
10
+ }): Promise<Async<void>>;
11
+ declare const _default: Reporter;
12
+ export default _default;
@@ -28,13 +28,6 @@ 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
- }
38
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
32
  const manifestHashes = exports.manifestHashes = new Map();
40
33
  const updateManifest = async (outputFS, logger, conditionalManifestFilename, conditionalManifest) => {
@@ -60,19 +53,21 @@ async function report({
60
53
  const bundles = event.bundleGraph.getConditionalBundleMapping();
61
54
 
62
55
  // Replace bundles with file paths
56
+ // @ts-expect-error TS2304
63
57
  const mapBundles = bundles => bundles.map(bundle => (0, _path().relative)(bundle.target.distDir, bundle.filePath));
64
58
  const manifest = {};
65
59
  for (const conditions of bundles.values()) {
66
- const bundleInfo = {};
67
60
  for (const [key, cond] of conditions) {
61
+ var _manifest$bundle$targ, _bundleInfo$key, _bundleInfo$key2;
68
62
  const bundle = cond.bundle;
63
+ const relativeBundlePath = (0, _path().relative)(bundle.target.distDir, bundle.filePath);
64
+ const bundleInfo = ((_manifest$bundle$targ = manifest[bundle.target.name]) === null || _manifest$bundle$targ === void 0 ? void 0 : _manifest$bundle$targ[relativeBundlePath]) ?? {};
69
65
  bundleInfo[key] = {
70
- // Reverse bundles so we load children bundles first
71
- ifTrueBundles: mapBundles(cond.ifTrueBundles).reverse(),
72
- ifFalseBundles: mapBundles(cond.ifFalseBundles).reverse()
66
+ ifTrueBundles: mapBundles(cond.ifTrueBundles).concat(((_bundleInfo$key = bundleInfo[key]) === null || _bundleInfo$key === void 0 ? void 0 : _bundleInfo$key.ifTrueBundles) ?? []).sort(),
67
+ ifFalseBundles: mapBundles(cond.ifFalseBundles).concat(((_bundleInfo$key2 = bundleInfo[key]) === null || _bundleInfo$key2 === void 0 ? void 0 : _bundleInfo$key2.ifFalseBundles) ?? []).sort()
73
68
  };
74
69
  manifest[bundle.target.name] ??= {};
75
- manifest[bundle.target.name][(0, _path().relative)(bundle.target.distDir, bundle.filePath)] = bundleInfo;
70
+ manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
76
71
  }
77
72
  }
78
73
  const targets = new Set(event.bundleGraph.getBundles().map(bundle => bundle.target));
@@ -84,20 +79,12 @@ async function report({
84
79
  const conditionalManifest = JSON.stringify(
85
80
  // If there's no content, send an empty manifest so we can still map from it safely
86
81
  manifest[target.name] ?? {}, null, 2);
87
- if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterDuplicateFix')) {
88
- await updateManifest(options.outputFS, logger, conditionalManifestFilename, conditionalManifest);
89
- } else {
90
- await options.outputFS.mkdirp((0, _path().dirname)(conditionalManifestFilename));
91
- await options.outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
92
- mode: 0o666
93
- });
94
- logger.info({
95
- message: 'Wrote conditional manifest to ' + conditionalManifestFilename
96
- });
97
- }
82
+ await updateManifest(options.outputFS, logger, conditionalManifestFilename, conditionalManifest);
98
83
  }
99
84
  }
100
85
  }
86
+
87
+ // @ts-expect-error TS2322
101
88
  var _default = exports.default = new (_plugin().Reporter)({
102
89
  report
103
90
  });
@@ -0,0 +1,6 @@
1
+ import type { PluginOptions } from '@atlaspack/types-internal';
2
+ type Config = {
3
+ filename: string;
4
+ };
5
+ export declare function getConfig({ env, inputFS, projectRoot, }: PluginOptions): Promise<Config>;
6
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/reporter-conditional-manifest",
3
- "version": "2.14.5-canary.14+267b0d591",
3
+ "version": "2.14.5-canary.140+43fdd2238",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,20 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/ConditionalManifestReporter.js",
13
- "source": "src/ConditionalManifestReporter.js",
12
+ "main": "./lib/ConditionalManifestReporter.js",
13
+ "source": "./src/ConditionalManifestReporter.ts",
14
+ "types": "./lib/ConditionalManifestReporter.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/feature-flags": "2.14.1-canary.82+267b0d591",
19
- "@atlaspack/plugin": "2.14.5-canary.14+267b0d591",
19
+ "@atlaspack/feature-flags": "2.14.1-canary.208+43fdd2238",
20
+ "@atlaspack/plugin": "2.14.5-canary.140+43fdd2238",
20
21
  "nullthrows": "^1.1.1"
21
22
  },
22
23
  "type": "commonjs",
23
- "gitHead": "267b0d59131c00e4cd1526bbf87aa84b9c8fd411"
24
- }
24
+ "scripts": {
25
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src"
26
+ },
27
+ "gitHead": "43fdd223860fbc97af17d68c65419b97412cb888"
28
+ }
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import {relative, join, dirname} from 'path';
3
2
  import crypto from 'crypto';
4
3
  import {Reporter} from '@atlaspack/plugin';
@@ -12,7 +11,6 @@ import type {
12
11
  FilePath,
13
12
  } from '@atlaspack/types-internal';
14
13
  import {getConfig} from './Config';
15
- import {getFeatureFlag} from '@atlaspack/feature-flags';
16
14
 
17
15
  export const manifestHashes: Map<FilePath, string> = new Map();
18
16
 
@@ -45,33 +43,43 @@ export async function report({
45
43
  event,
46
44
  options,
47
45
  logger,
48
- }: {|
49
- event: ReporterEvent,
50
- options: PluginOptions,
51
- logger: PluginLogger,
52
- tracer: PluginTracer,
53
- |}): Async<void> {
46
+ }: {
47
+ event: ReporterEvent;
48
+ options: PluginOptions;
49
+ logger: PluginLogger;
50
+ tracer: PluginTracer;
51
+ }): Promise<Async<void>> {
54
52
  if (event.type === 'buildSuccess') {
55
53
  const bundles = event.bundleGraph.getConditionalBundleMapping();
56
54
 
57
55
  // Replace bundles with file paths
58
- const mapBundles = (bundles) =>
56
+ // @ts-expect-error TS2304
57
+ const mapBundles = (bundles: Array<PackagedBundle>) =>
59
58
  bundles.map((bundle) => relative(bundle.target.distDir, bundle.filePath));
60
59
 
61
- const manifest = {};
60
+ const manifest: Record<string, any> = {};
62
61
  for (const conditions of bundles.values()) {
63
- const bundleInfo = {};
64
62
  for (const [key, cond] of conditions) {
65
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
+
66
72
  bundleInfo[key] = {
67
- // Reverse bundles so we load children bundles first
68
- ifTrueBundles: mapBundles(cond.ifTrueBundles).reverse(),
69
- ifFalseBundles: mapBundles(cond.ifFalseBundles).reverse(),
73
+ ifTrueBundles: mapBundles(cond.ifTrueBundles)
74
+ .concat(bundleInfo[key]?.ifTrueBundles ?? [])
75
+ .sort(),
76
+ ifFalseBundles: mapBundles(cond.ifFalseBundles)
77
+ .concat(bundleInfo[key]?.ifFalseBundles ?? [])
78
+ .sort(),
70
79
  };
80
+
71
81
  manifest[bundle.target.name] ??= {};
72
- manifest[bundle.target.name][
73
- relative(bundle.target.distDir, bundle.filePath)
74
- ] = bundleInfo;
82
+ manifest[bundle.target.name][relativeBundlePath] = bundleInfo;
75
83
  }
76
84
  }
77
85
 
@@ -90,28 +98,15 @@ export async function report({
90
98
  2,
91
99
  );
92
100
 
93
- if (getFeatureFlag('conditionalBundlingReporterDuplicateFix')) {
94
- await updateManifest(
95
- options.outputFS,
96
- logger,
97
- conditionalManifestFilename,
98
- conditionalManifest,
99
- );
100
- } else {
101
- await options.outputFS.mkdirp(dirname(conditionalManifestFilename));
102
- await options.outputFS.writeFile(
103
- conditionalManifestFilename,
104
- conditionalManifest,
105
- {mode: 0o666},
106
- );
107
-
108
- logger.info({
109
- message:
110
- 'Wrote conditional manifest to ' + conditionalManifestFilename,
111
- });
112
- }
101
+ await updateManifest(
102
+ options.outputFS,
103
+ logger,
104
+ conditionalManifestFilename,
105
+ conditionalManifest,
106
+ );
113
107
  }
114
108
  }
115
109
  }
116
110
 
117
- export default (new Reporter({report}): Reporter);
111
+ // @ts-expect-error TS2322
112
+ export default new Reporter({report}) as Reporter;
@@ -1,10 +1,9 @@
1
- // @flow strict-local
2
1
  import {join} from 'path';
3
2
  import type {PluginOptions} from '@atlaspack/types-internal';
4
3
 
5
- type Config = {|
6
- filename: string,
7
- |};
4
+ type Config = {
5
+ filename: string;
6
+ };
8
7
 
9
8
  export async function getConfig({
10
9
  env,
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import {
3
2
  manifestHashes,
4
3
  updateManifest,
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import type {PluginOptions, EnvMap} from '@atlaspack/types-internal';
3
2
 
4
3
  import {NodePackageManager} from '@atlaspack/package-manager';
@@ -7,7 +6,7 @@ import {overlayFS, fsFixture} from '@atlaspack/test-utils';
7
6
  import assert from 'assert';
8
7
  import {DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
9
8
 
10
- function getPluginOptions({env}: {env?: EnvMap, ...}): PluginOptions {
9
+ function getPluginOptions({env}: {env?: EnvMap}): PluginOptions {
11
10
  return {
12
11
  mode: 'development',
13
12
  parcelVersion: 'version',
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }