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

Make sure the absolute path isn't contained in the cache #5900

Merged
merged 43 commits into from
Jul 7, 2021
Merged

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented Feb 20, 2021

Depends on #5802

Closes T-870

This should also always use / as path separators

Grepping the absolute path in .parcel-cache didn't yield any results after this change (for a simple test case).

  • I wasn't yet able to figure out why the the remaining few tests fail. Something with cache invalidation after file changes is wrong.
  • Move the new utils into utils.js in @parcel/core, no reason to put them into @parcel/utils if they're not used outside of core.
  • locs
  • still use micromatch 4?
  • throw an error if namers return an absolute path
  • Windows CI fails?

@height
Copy link

height bot commented Feb 20, 2021

This pull request has been linked to and will mark 1 task as "Done" when merged:

  • T-870 Ensure all paths are relative and use platform agnostic separators in graphs and cache keys (unlink task)

💡Tip: You can link multiple Height tasks to a pull request.

@parcel-benchmark
Copy link

parcel-benchmark commented Feb 20, 2021

Benchmark Results

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...

React HackerNews ✅

Timings

Description Time Difference
Cold 8.99s -202.00ms
Cached 447.00ms +20.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/logo.1e014c76.png 274.00b +0.00b 203.00ms -63.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/logo.1e014c76.png 274.00b +0.00b 225.00ms -75.00ms 🚀

AtlasKit 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...

Three.js ✅

Timings

Description Time Difference
Cold 6.74s -151.00ms
Cached 431.00ms +39.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

}
}

for (let id of this.globNodeIds) {
let globNode = this.getNode(id);
invariant(globNode && globNode.type === 'glob');

if (isGlobMatch(filePath, globNode.value)) {
if (isGlobMatch(filePath, fromProjectPathRelative(globNode.value))) {
Copy link
Member

Choose a reason for hiding this comment

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

So filePath here is absolute, but the glob is relative? Won't that not match except if the glob starts with **/? I was thinking about how to do this for the glob resolver. Should the glob in the invalidation be relative to the project root? If so, then I think we'd need to make it absolute here.

Copy link
Member Author

Choose a reason for hiding this comment

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

filePath is also relative here, further up there's

let filePath = fromProjectPathRelative(_filePath);

Copy link
Member Author

Choose a reason for hiding this comment

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

But I ran into #5483 (comment) again, so I guess I'll have to use the absolute paths anyway (to make micromatch happy).

As a workaround, I've downgraded to micromatch 3 for now 😬

Base automatically changed from dev-dep-invalidation to v2 March 1, 2021 16:15
@mischnic mischnic force-pushed the project-path branch 2 times, most recently from c3ba28f to c2dc0c0 Compare March 4, 2021 15:23
Comment on lines +20 to +21
) => ProjectPath) &
((projectRoot: FilePath, p: FilePath | void) => ProjectPath | void) &
// $FlowFixMe Not sure how to type properly
((projectRoot: FilePath, p: ?FilePath) => ?ProjectPath) = toProjectPath_;
Copy link
Member Author

Choose a reason for hiding this comment

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

🤷‍♂️

@elliottkember
Copy link

elliottkember commented Apr 13, 2021

Hi! Great work here. this PR would be a really big deal for CI / deployment environments where the build directory changes between builds. Several orders of magnitude difference. At the moment it seems the Parcel cache uses the absolute directory.

@@ -445,10 +445,9 @@ export type DependencyOptions = {|
+meta?: Meta,
+pipeline?: string,
+resolveFrom?: FilePath,
+target?: Target,
Copy link
Member Author

Choose a reason for hiding this comment

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

This was apparently neither used in the plugins nor inside addDependency

@devongovett devongovett marked this pull request as ready for review July 6, 2021 03:50
@devongovett
Copy link
Member

I think this is ready. I added a util that verifies that there are no references to the project root inside the cache folder after each cache test. After upgrading the source maps package to the latest release, all the tests pass.

Copy link
Contributor

@wbinnssmith wbinnssmith left a comment

Choose a reason for hiding this comment

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

It's a lot, but from what I can tell LGTM. cc @mischnic to review changes from @devongovett

let b = await runBundle(entries, options);

await assertNoFilePathInCache(
Copy link
Contributor

Choose a reason for hiding this comment

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

🤩

@devongovett devongovett merged commit 9176b98 into v2 Jul 7, 2021
@devongovett devongovett deleted the project-path branch July 7, 2021 19:34
lettertwo added a commit that referenced this pull request Jul 13, 2021
* v2: (34 commits)
  Wrap assets recursively when any incoming dependency is wrapped (#6572)
  Improvements for library targets (#6570)
  Diagnostic for undeclared external dependencies in library builds (#6564)
  More bugs (#6567)
  Don't require `url:` for image transformer (#6565)
  Remove 'Name already registered with serializer' error (#6566)
  Fix live bindings and `this` of external CommonJS modules (#6548)
  JS runtime improvements (#6531)
  Make sure the absolute path isn't contained in the cache (#5900)
  Adds '@parcel/diagnostic' to dependencies (#6563)
  Disable workers with string literals and improve diagnostics (#6536)
  Bug fixes (#6541)
  Don't attempt to resolve URLs starting with '#' (#6504)
  Correctly set worker's output format if not support by environment (#6534)
  Babel: Recognize peerDependencies in isJSX (#6497)
  fix setHeaders ordering on dev server (#6500)
  Graph: Remove Node interface (#6530)
  Fix TS build script for old Node versions (#6526)
  Improve library targets (#6517)
  Fix TypeScript and other sourcemaps by always creating an initial sourcemap (#6472)
  ...
lettertwo added a commit that referenced this pull request Jul 21, 2021
Seems micromatch 3 and 4 have undocumented behavior differences,
So we ignore the version mismatches for now, under the assumption
that the specified versions are exhibiting the expected behavior
for the packages they are used in.

See #5483 (comment)
and #5900 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants