@atlaspack/core 2.16.2-dev.95 → 2.16.2-dev.97

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/lib/AssetGraph.js CHANGED
@@ -148,7 +148,7 @@ class AssetGraph extends _graph().ContentGraph {
148
148
  let idAndContext = `${id}-${context}`;
149
149
  let env = this.envCache.get(idAndContext);
150
150
  if (env) {
151
- input.env = env;
151
+ input.env = (0, _EnvironmentManager.toEnvironmentRef)(env);
152
152
  } else {
153
153
  this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
154
154
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createEnvironment = createEnvironment;
7
+ exports.getEnvironmentHash = getEnvironmentHash;
7
8
  exports.mergeEnvironments = mergeEnvironments;
8
9
  function _rust() {
9
10
  const data = require("@atlaspack/rust");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- if (process.env.ATLASPACK_BUILD_ENV !== 'production' || process.env.ATLASPACK_SELF_BUILD) {
3
+ if (process.env.ATLASPACK_DEV === 'true' || process.env.ATLASPACK_BUILD_ENV === 'test' || process.env.ATLASPACK_SELF_BUILD) {
4
4
  require('@atlaspack/babel-register');
5
5
  }
6
6
  require('./worker');
@@ -26,9 +26,18 @@ function _logger() {
26
26
  };
27
27
  return data;
28
28
  }
29
+ function _featureFlags() {
30
+ const data = require("@atlaspack/feature-flags");
31
+ _featureFlags = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
29
36
  var _AssetGraph = _interopRequireWildcard(require("../AssetGraph"));
30
37
  var _RequestTracker = require("../RequestTracker");
31
38
  var _SymbolPropagation = require("../SymbolPropagation");
39
+ var _EnvironmentManager = require("../EnvironmentManager");
40
+ var _Environment = require("../Environment");
32
41
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
33
42
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
34
43
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -137,8 +146,11 @@ function getAssetGraph(serializedGraph) {
137
146
  let id = asset.id;
138
147
  asset.committed = true;
139
148
  asset.contentKey = id;
140
- asset.env.id = getEnvId(asset.env);
149
+ asset.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
150
+ // TODO: Rust can do this and avoid copying a significant amount of data over
151
+ (0, _Environment.getEnvironmentHash)(asset.env) : getEnvId(asset.env);
141
152
  asset.mapKey = `map:${asset.id}`;
153
+ asset.env = (0, _EnvironmentManager.toEnvironmentRef)(asset.env);
142
154
 
143
155
  // This is populated later when we map the edges between assets and dependencies
144
156
  asset.dependencies = new Map();
@@ -162,7 +174,10 @@ function getAssetGraph(serializedGraph) {
162
174
  let id = node.value.id;
163
175
  let dependency = node.value.dependency;
164
176
  dependency.id = id;
165
- dependency.env.id = getEnvId(dependency.env);
177
+ dependency.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
178
+ // TODO: Rust can do this and avoid copying a significant amount of data over
179
+ (0, _Environment.getEnvironmentHash)(dependency.env) : getEnvId(dependency.env);
180
+ dependency.env = (0, _EnvironmentManager.toEnvironmentRef)(dependency.env);
166
181
  if (dependency.symbols != null) {
167
182
  var _dependency$symbols;
168
183
  dependency.symbols = new Map((_dependency$symbols = dependency.symbols) === null || _dependency$symbols === void 0 ? void 0 : _dependency$symbols.map(mapSymbols));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-dev.95+d8e35a83e",
3
+ "version": "2.16.2-dev.97+70270d69e",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,21 +21,21 @@
21
21
  "check-ts": "tsc --noEmit index.d.ts"
22
22
  },
23
23
  "dependencies": {
24
- "@atlaspack/build-cache": "2.13.3-dev.163+d8e35a83e",
25
- "@atlaspack/cache": "3.1.1-dev.95+d8e35a83e",
26
- "@atlaspack/diagnostic": "2.14.1-dev.163+d8e35a83e",
27
- "@atlaspack/events": "2.14.1-dev.163+d8e35a83e",
28
- "@atlaspack/feature-flags": "2.14.1-dev.163+d8e35a83e",
29
- "@atlaspack/fs": "2.14.5-dev.95+d8e35a83e",
30
- "@atlaspack/graph": "3.4.1-dev.163+d8e35a83e",
31
- "@atlaspack/logger": "2.14.5-dev.95+d8e35a83e",
32
- "@atlaspack/package-manager": "2.14.5-dev.95+d8e35a83e",
33
- "@atlaspack/plugin": "2.14.5-dev.95+d8e35a83e",
34
- "@atlaspack/profiler": "2.14.1-dev.163+d8e35a83e",
35
- "@atlaspack/rust": "3.2.1-dev.95+d8e35a83e",
36
- "@atlaspack/types": "2.14.5-dev.95+d8e35a83e",
37
- "@atlaspack/utils": "2.14.5-dev.95+d8e35a83e",
38
- "@atlaspack/workers": "2.14.5-dev.95+d8e35a83e",
24
+ "@atlaspack/build-cache": "2.13.3-dev.165+70270d69e",
25
+ "@atlaspack/cache": "3.1.1-dev.97+70270d69e",
26
+ "@atlaspack/diagnostic": "2.14.1-dev.165+70270d69e",
27
+ "@atlaspack/events": "2.14.1-dev.165+70270d69e",
28
+ "@atlaspack/feature-flags": "2.14.1-dev.165+70270d69e",
29
+ "@atlaspack/fs": "2.14.5-dev.97+70270d69e",
30
+ "@atlaspack/graph": "3.4.1-dev.165+70270d69e",
31
+ "@atlaspack/logger": "2.14.5-dev.97+70270d69e",
32
+ "@atlaspack/package-manager": "2.14.5-dev.97+70270d69e",
33
+ "@atlaspack/plugin": "2.14.5-dev.97+70270d69e",
34
+ "@atlaspack/profiler": "2.14.1-dev.165+70270d69e",
35
+ "@atlaspack/rust": "3.2.1-dev.97+70270d69e",
36
+ "@atlaspack/types": "2.14.5-dev.97+70270d69e",
37
+ "@atlaspack/utils": "2.14.5-dev.97+70270d69e",
38
+ "@atlaspack/workers": "2.14.5-dev.97+70270d69e",
39
39
  "@mischnic/json-sourcemap": "^0.1.0",
40
40
  "@parcel/source-map": "^2.1.1",
41
41
  "base-x": "^3.0.8",
@@ -60,5 +60,5 @@
60
60
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
61
61
  },
62
62
  "type": "commonjs",
63
- "gitHead": "d8e35a83e480e0811b63a319e88ffe9a2cd509e6"
63
+ "gitHead": "70270d69e3144a59f39970e1bcaa61c779342b11"
64
64
  }
package/src/AssetGraph.js CHANGED
@@ -29,7 +29,11 @@ import nullthrows from 'nullthrows';
29
29
  import {ContentGraph} from '@atlaspack/graph';
30
30
  import {createDependency} from './Dependency';
31
31
  import {type ProjectPath, fromProjectPathRelative} from './projectPath';
32
- import {fromEnvironmentId, toEnvironmentId} from './EnvironmentManager';
32
+ import {
33
+ fromEnvironmentId,
34
+ toEnvironmentId,
35
+ toEnvironmentRef,
36
+ } from './EnvironmentManager';
33
37
  import {getFeatureFlag} from '@atlaspack/feature-flags';
34
38
 
35
39
  type InitOpts = {|
@@ -160,7 +164,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
160
164
 
161
165
  let env = this.envCache.get(idAndContext);
162
166
  if (env) {
163
- input.env = env;
167
+ input.env = toEnvironmentRef(env);
164
168
  } else {
165
169
  this.envCache.set(idAndContext, fromEnvironmentId(input.env));
166
170
  }
@@ -140,7 +140,7 @@ export function mergeEnvironments(
140
140
  });
141
141
  }
142
142
 
143
- function getEnvironmentHash(env: Environment): string {
143
+ export function getEnvironmentHash(env: Environment): string {
144
144
  const data = {
145
145
  context: env.context,
146
146
  engines: env.engines,
@@ -21,7 +21,7 @@ export opaque type EnvironmentId = string;
21
21
  /**
22
22
  * When deduplication is cleaned-up this will always be a string.
23
23
  */
24
- export type EnvironmentRef = EnvironmentId | CoreEnvironment;
24
+ export opaque type EnvironmentRef = EnvironmentId | CoreEnvironment;
25
25
 
26
26
  /**
27
27
  * Convert environment to a ref.
@@ -1,5 +1,6 @@
1
1
  if (
2
- process.env.ATLASPACK_BUILD_ENV !== 'production' ||
2
+ process.env.ATLASPACK_DEV === 'true' ||
3
+ process.env.ATLASPACK_BUILD_ENV === 'test' ||
3
4
  process.env.ATLASPACK_SELF_BUILD
4
5
  ) {
5
6
  require('@atlaspack/babel-register');
@@ -11,6 +11,7 @@ import type {
11
11
  } from '@atlaspack/types';
12
12
  import type {
13
13
  AtlaspackOptions,
14
+ BundleGraphNode,
14
15
  BundleGroup as InternalBundleGroup,
15
16
  BundleNode,
16
17
  } from '../types';
@@ -207,7 +208,8 @@ export default class MutableBundleGraph
207
208
  bundleBehavior: opts.bundleBehavior ?? null,
208
209
  });
209
210
 
210
- let existing = this.#graph._graph.getNodeByContentKey(bundleId);
211
+ let existing: ?BundleGraphNode =
212
+ this.#graph._graph.getNodeByContentKey(bundleId);
211
213
  if (existing != null) {
212
214
  invariant(existing.type === 'bundle');
213
215
  return Bundle.get(existing.value, this.#graph, this.#options);
@@ -5,6 +5,7 @@ import invariant from 'assert';
5
5
  import ThrowableDiagnostic from '@atlaspack/diagnostic';
6
6
  import type {Async} from '@atlaspack/types';
7
7
  import {instrument} from '@atlaspack/logger';
8
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
8
9
 
9
10
  import AssetGraph, {nodeFromAssetGroup} from '../AssetGraph';
10
11
  import type {AtlaspackV3} from '../atlaspack-v3';
@@ -16,6 +17,8 @@ import type {
16
17
  AssetGraphRequestInput,
17
18
  AssetGraphRequestResult,
18
19
  } from './AssetGraphRequest';
20
+ import {toEnvironmentRef} from '../EnvironmentManager';
21
+ import {getEnvironmentHash} from '../Environment';
19
22
 
20
23
  type RunInput = {|
21
24
  input: AssetGraphRequestInput,
@@ -166,9 +169,14 @@ export function getAssetGraph(serializedGraph: any): {
166
169
 
167
170
  asset.committed = true;
168
171
  asset.contentKey = id;
169
- asset.env.id = getEnvId(asset.env);
172
+ asset.env.id = getFeatureFlag('environmentDeduplication')
173
+ ? // TODO: Rust can do this and avoid copying a significant amount of data over
174
+ getEnvironmentHash(asset.env)
175
+ : getEnvId(asset.env);
170
176
  asset.mapKey = `map:${asset.id}`;
171
177
 
178
+ asset.env = toEnvironmentRef(asset.env);
179
+
172
180
  // This is populated later when we map the edges between assets and dependencies
173
181
  asset.dependencies = new Map();
174
182
 
@@ -195,7 +203,11 @@ export function getAssetGraph(serializedGraph: any): {
195
203
  let dependency = node.value.dependency;
196
204
 
197
205
  dependency.id = id;
198
- dependency.env.id = getEnvId(dependency.env);
206
+ dependency.env.id = getFeatureFlag('environmentDeduplication')
207
+ ? // TODO: Rust can do this and avoid copying a significant amount of data over
208
+ getEnvironmentHash(dependency.env)
209
+ : getEnvId(dependency.env);
210
+ dependency.env = toEnvironmentRef(dependency.env);
199
211
 
200
212
  if (dependency.symbols != null) {
201
213
  dependency.symbols = new Map(dependency.symbols?.map(mapSymbols));