facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.72k stars 26.85k forks source link

Different Hash Names in AWS CodePipeline #6737

Open whatadewitt opened 5 years ago

whatadewitt commented 5 years ago

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Deployment, static files, hosting

Environment

 System:
 OS: Linux 4.14 Ubuntu 14.04.5 LTS, Trusty Tahr
 CPU: x64 Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz
 Binaries:
 Node: 10.14.0 - /usr/bin/node
 npm: 6.4.1 - /usr/bin/npm
 npmPackages:
 react: 16.8.4 => 16.8.4
 react-dom: 16.8.4 => 16.8.4
 react-scripts: 2.1.8 => 2.1.8
 npmGlobalPackages:
 create-react-app: Not Found

Steps to Reproduce

  1. Make changes to my CRA App
  2. Commit those changes to github
  3. Codepipeline sees changes and kicks off the build process in 2 different regions (us-east-1 and us-east-2)

Expected Behavior

Based on the docs, I would expect the "contenthash" values on both of my builds to be the same for my main.js, main.css and chunk.js files.

Actual Behavior

On the 2 different boxes, my app builds successfully, but the hashnames are totally different.

I know this is happening because CodePipeline is bringing my code into a directory that they are creating dynamically. The "hash" is based on the directory that the code is built in.

Reproducible Demo

Clone the CRA base into a local working directory (./cra1 as an example). Clone it again into another local working directory (./cra2 as an example).

Run npm run build on both folders.

Note the "compiled" filenames are different but their content is the same.

heyimalex commented 5 years ago

Reproduced just like you said; renaming the directory causes the hashes to change.

ianschmitz commented 5 years ago

Related: https://github.com/webpack/webpack/issues/8419.

Sounds like they are reworking their hashing system for webpack 5.0 that could possibly fix this.

iansu commented 3 years ago

It looks like this has been fixed in webpack 5. We're currently working on upgrading to webpack 5 so this will be fixed then. See #9994.