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

Content hash changes if working directory changes #4894

Closed
christophgysin opened this issue Jul 15, 2020 · 1 comment · Fixed by #4940
Closed

Content hash changes if working directory changes #4894

christophgysin opened this issue Jul 15, 2020 · 1 comment · Fixed by #4940

Comments

@christophgysin
Copy link

🐛 bug report

The content hash seems to include the absolute path of the file. So for the same content, but built in a different directory, a different hash is created.

This causes a problem in e.g. CI build environments where the build directory is different for every build. Since all files get new hashes on every build, the cache is always invalidated.

🎛 Configuration (.babelrc, package.json, cli command)

Default configuration.

🤔 Expected Behavior

The hash should be the same for the same file content, no matter what directory it is built in.

😯 Current Behavior

The hash changes when built in a different directory.

💁 Possible Solution

Don't include the current directory when calculating the hash.

🔦 Context

When bundling in CI where the build directory is different for every build, all bundles will always get a new hash.

💻 Code Sample

$ cd a
$ cat index.html
<html>
  <head>
    <script src="app.js"></script>
  </head>
</html>
$ cat app.js
console.log('test')
$ npx parcel build index.html
✨ Built in 1.38s

dist/index.html         66 B    227ms
dist/app.3ccb8354.js    62 B    294ms
$ cp index.html app.js ../b
$ npx parcel build index.html
✨ Built in 1.41s

dist/index.html         66 B    225ms
dist/app.b818d20c.js    62 B    293ms

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-beta.1
Node v14.5.0
npm/Yarn 6.14.6 / 1.22.4
Operating System arch linux
@mischnic
Copy link
Member

mischnic commented Jul 27, 2020

This is somehow caused by the sourcemap file, the hash is identical with --no-source-maps...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants