Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/core/core/src/AssetGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import nullthrows from 'nullthrows';
import {ContentGraph} from '@atlaspack/graph';
import {createDependency} from './Dependency';
import {type ProjectPath, fromProjectPathRelative} from './projectPath';
import {fromEnvironmentId, toEnvironmentId} from './EnvironmentManager';
import {
fromEnvironmentId,
toEnvironmentId,
toEnvironmentRef,
} from './EnvironmentManager';
import {getFeatureFlag} from '@atlaspack/feature-flags';

type InitOpts = {|
Expand Down Expand Up @@ -160,7 +164,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {

let env = this.envCache.get(idAndContext);
if (env) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes behind a flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is a flag in that function

input.env = env;
input.env = toEnvironmentRef(env);
} else {
this.envCache.set(idAndContext, fromEnvironmentId(input.env));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function mergeEnvironments(
});
}

function getEnvironmentHash(env: Environment): string {
export function getEnvironmentHash(env: Environment): string {
const data = {
context: env.context,
engines: env.engines,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/EnvironmentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export opaque type EnvironmentId = string;
/**
* When deduplication is cleaned-up this will always be a string.
*/
export type EnvironmentRef = EnvironmentId | CoreEnvironment;
export opaque type EnvironmentRef = EnvironmentId | CoreEnvironment;

/**
* Convert environment to a ref.
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/public/MutableBundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
} from '@atlaspack/types';
import type {
AtlaspackOptions,
BundleGraphNode,
BundleGroup as InternalBundleGroup,
BundleNode,
} from '../types';
Expand Down Expand Up @@ -207,7 +208,8 @@ export default class MutableBundleGraph
bundleBehavior: opts.bundleBehavior ?? null,
});

let existing = this.#graph._graph.getNodeByContentKey(bundleId);
let existing: ?BundleGraphNode =
this.#graph._graph.getNodeByContentKey(bundleId);
if (existing != null) {
invariant(existing.type === 'bundle');
return Bundle.get(existing.value, this.#graph, this.#options);
Expand Down
16 changes: 14 additions & 2 deletions packages/core/core/src/requests/AssetGraphRequestRust.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import invariant from 'assert';
import ThrowableDiagnostic from '@atlaspack/diagnostic';
import type {Async} from '@atlaspack/types';
import {instrument} from '@atlaspack/logger';
import {getFeatureFlag} from '@atlaspack/feature-flags';

import AssetGraph, {nodeFromAssetGroup} from '../AssetGraph';
import type {AtlaspackV3} from '../atlaspack-v3';
Expand All @@ -16,6 +17,8 @@ import type {
AssetGraphRequestInput,
AssetGraphRequestResult,
} from './AssetGraphRequest';
import {toEnvironmentRef} from '../EnvironmentManager';
import {getEnvironmentHash} from '../Environment';

type RunInput = {|
input: AssetGraphRequestInput,
Expand Down Expand Up @@ -166,9 +169,14 @@ export function getAssetGraph(serializedGraph: any): {

asset.committed = true;
asset.contentKey = id;
asset.env.id = getEnvId(asset.env);
asset.env.id = getFeatureFlag('environmentDeduplication')
? // TODO: Rust can do this and avoid copying a significant amount of data over
getEnvironmentHash(asset.env)
: getEnvId(asset.env);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a number which is wrong

asset.mapKey = `map:${asset.id}`;

asset.env = toEnvironmentRef(asset.env);

// This is populated later when we map the edges between assets and dependencies
asset.dependencies = new Map();

Expand All @@ -195,7 +203,11 @@ export function getAssetGraph(serializedGraph: any): {
let dependency = node.value.dependency;

dependency.id = id;
dependency.env.id = getEnvId(dependency.env);
dependency.env.id = getFeatureFlag('environmentDeduplication')
? // TODO: Rust can do this and avoid copying a significant amount of data over
getEnvironmentHash(dependency.env)
: getEnvId(dependency.env);
dependency.env = toEnvironmentRef(dependency.env);

if (dependency.symbols != null) {
dependency.symbols = new Map(dependency.symbols?.map(mapSymbols));
Expand Down
Loading