Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split InternalAsset into UncommittedAsset and CommittedAsset (Cache ASTs followup) #4378

Merged
merged 6 commits into from
Mar 27, 2020

Conversation

wbinnssmith
Copy link
Contributor

This is a followup based on my experience implementing parts of #3695, and also integrates some feedback from that PR.

This splits InternalAsset into UncommittedAsset and CommittedAsset. The former implements a mutable interface for transformers, only holding into values in memory (with the exception of generation), and the latter implements an immutable interface that loads content from disk and caches it in memory.

Previously, InternalAsset implemented both, in some situations branching on the state. This also allows for simpler implementations in each case. Common code was extracted into assetUtils.js in the same directory.

This also cleans up babel7.js to safely use getAST() and moves it to use the Async methods as we don't require synchronous behavior.

Test Plan: yarn test

@wbinnssmith wbinnssmith added this to In progress in Parcel 2 via automation Mar 25, 2020
@height
Copy link

height bot commented Mar 25, 2020

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

parcel-benchmark commented Mar 25, 2020

Benchmark Results

packages/benchmarks/three 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/kitchen-sink 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/react-hn 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/ak-editor 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

Click here to view a detailed benchmark overview.

@@ -24,6 +24,7 @@
"@babel/plugin-transform-typescript": "^7.4.5",
"@babel/preset-env": "^7.0.0",
"@babel/traverse": "^7.0.0",
"@parcel/babel-ast-utils": "^2.0.0-alpha.3.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the import/no-extraneous-dependencies lint rule didn't catch this. It seems to only be missed with packages in the monorepo?

packages/core/core/src/CommittedAsset.js Outdated Show resolved Hide resolved
};
}

export async function getConfig(
Copy link
Member

Choose a reason for hiding this comment

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

We should only expose this in transformers IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getPackage is probably useful everywhere though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validators receive an Asset (not a MutableAsset unlike transformers), and use .getConfig() 😕


const generateResults: WeakMap<Asset, Promise<GenerateOutput>> = new WeakMap();

export function generateFromAST(
Copy link
Member

Choose a reason for hiding this comment

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

Is this only needed in CommittedAsset? Should we make this and the below function methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now we generate early in Transformation.js if we're not scope hoisting, which has an UncommittedAsset.

@wbinnssmith wbinnssmith force-pushed the wbinnssmith/cache-asts-cleanup branch from fcc3d52 to 53b94d2 Compare March 25, 2020 19:16
@wbinnssmith wbinnssmith force-pushed the wbinnssmith/cache-asts-cleanup branch from 53b94d2 to 9d4cf94 Compare March 25, 2020 19:16
@wbinnssmith wbinnssmith changed the title Cache ASTs followup (Split InternalAsset into UncommittedAsset and CommittedAsset) Split InternalAsset into UncommittedAsset and CommittedAsset (Cache ASTs followup) Mar 25, 2020
Parcel 2 automation moved this from In progress to Reviewer approved Mar 25, 2020
@wbinnssmith wbinnssmith merged commit c690f91 into v2 Mar 27, 2020
Parcel 2 automation moved this from Reviewer approved to Done Mar 27, 2020
@DeMoorJasper DeMoorJasper deleted the wbinnssmith/cache-asts-cleanup branch April 5, 2020 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Parcel 2
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants