@atlaspack/reporter-conditional-manifest 2.14.5-canary.16 → 2.14.5-canary.161

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,163 @@
1
1
  # @atlaspack/reporter-conditional-manifest
2
2
 
3
+ ## 2.15.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1)]:
8
+ - @atlaspack/feature-flags@2.23.0
9
+ - @atlaspack/plugin@2.14.25
10
+
11
+ ## 2.15.6
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
16
+ - @atlaspack/feature-flags@2.22.0
17
+ - @atlaspack/plugin@2.14.24
18
+
19
+ ## 2.15.5
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
24
+ - @atlaspack/feature-flags@2.21.0
25
+ - @atlaspack/plugin@2.14.23
26
+
27
+ ## 2.15.4
28
+
29
+ ### Patch Changes
30
+
31
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
32
+
33
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`12bee0e`](https://github.com/atlassian-labs/atlaspack/commit/12bee0e23f0464d7f6bd3e24fbe0d19c126d587d)]:
34
+ - @atlaspack/feature-flags@2.20.1
35
+ - @atlaspack/plugin@2.14.22
36
+
37
+ ## 2.15.3
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
42
+ - @atlaspack/feature-flags@2.20.0
43
+ - @atlaspack/plugin@2.14.21
44
+
45
+ ## 2.15.2
46
+
47
+ ### Patch Changes
48
+
49
+ - 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)]:
50
+ - @atlaspack/plugin@2.14.20
51
+ - @atlaspack/feature-flags@2.19.2
52
+
53
+ ## 2.15.1
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [[`13aef17`](https://github.com/atlassian-labs/atlaspack/commit/13aef177eea289a6e40d2113b5ec1ac9be18a33d)]:
58
+ - @atlaspack/feature-flags@2.19.1
59
+ - @atlaspack/plugin@2.14.19
60
+
61
+ ## 2.15.0
62
+
63
+ ### Minor Changes
64
+
65
+ - [#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
66
+
67
+ ### Patch Changes
68
+
69
+ - 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)]:
70
+ - @atlaspack/feature-flags@2.19.0
71
+ - @atlaspack/plugin@2.14.18
72
+
73
+ ## 2.14.17
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies []:
78
+ - @atlaspack/plugin@2.14.17
79
+
80
+ ## 2.14.16
81
+
82
+ ### Patch Changes
83
+
84
+ - Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c)]:
85
+ - @atlaspack/feature-flags@2.18.4
86
+ - @atlaspack/plugin@2.14.16
87
+
88
+ ## 2.14.15
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
93
+ - @atlaspack/feature-flags@2.18.3
94
+ - @atlaspack/plugin@2.14.15
95
+
96
+ ## 2.14.14
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
101
+ - @atlaspack/feature-flags@2.18.2
102
+ - @atlaspack/plugin@2.14.14
103
+
104
+ ## 2.14.13
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
109
+ - @atlaspack/feature-flags@2.18.1
110
+ - @atlaspack/plugin@2.14.13
111
+
112
+ ## 2.14.12
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2)]:
117
+ - @atlaspack/feature-flags@2.18.0
118
+ - @atlaspack/plugin@2.14.12
119
+
120
+ ## 2.14.11
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
125
+ - @atlaspack/feature-flags@2.17.0
126
+ - @atlaspack/plugin@2.14.11
127
+
128
+ ## 2.14.10
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies []:
133
+ - @atlaspack/plugin@2.14.10
134
+
135
+ ## 2.14.9
136
+
137
+ ### Patch Changes
138
+
139
+ - [#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
140
+
141
+ - Updated dependencies [[`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b)]:
142
+ - @atlaspack/feature-flags@2.16.0
143
+ - @atlaspack/plugin@2.14.9
144
+
145
+ ## 2.14.8
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b)]:
150
+ - @atlaspack/feature-flags@2.15.1
151
+ - @atlaspack/plugin@2.14.8
152
+
153
+ ## 2.14.7
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929)]:
158
+ - @atlaspack/feature-flags@2.15.0
159
+ - @atlaspack/plugin@2.14.7
160
+
3
161
  ## 2.14.6
4
162
 
5
163
  ### Patch Changes
@@ -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,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;
@@ -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.16+4b2b575b9",
3
+ "version": "2.14.5-canary.161+ee040bb64",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,21 @@
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/types/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.84+4b2b575b9",
19
- "@atlaspack/plugin": "2.14.5-canary.16+4b2b575b9",
19
+ "@atlaspack/feature-flags": "2.14.1-canary.229+ee040bb64",
20
+ "@atlaspack/plugin": "2.14.5-canary.161+ee040bb64",
20
21
  "nullthrows": "^1.1.1"
21
22
  },
22
23
  "type": "commonjs",
23
- "gitHead": "4b2b575b98951f2dcf0c45ed8e94359b23b43815"
24
+ "scripts": {
25
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
26
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
27
+ },
28
+ "gitHead": "ee040bb6428f29b57d892ddd8107e29077d08ffd"
24
29
  }
@@ -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
+ }