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

build: assetfiles-without-hash #1760

Merged
merged 3 commits into from
Jun 7, 2022
Merged

Conversation

eitjuh
Copy link
Contributor

@eitjuh eitjuh commented May 9, 2022

Caution:

I assume this hash is implemented to ensure a new file is loaded. It's important to check if caching is handled correctly with this fix. It might lead to new problems with caching, and needing hard refreshes and things like that.

Problem:

The current build is causing this error:
It is because we are loading https://app.emeris.com/assets/Asset.4782f5bd.js
which has this hash 4782f5bd inside the url
image

Solution:

As described in vitejs/vite#378
There is an easy way to remove this hash by adding:

      rollupOptions: {
        output: {
          entryFileNames: `assets/[name].js`,
          chunkFileNames: `assets/[name].js`,
          assetFileNames: `assets/[name].[ext]`,
        },
      },

which cleans up the hash from the files, and you can see my dist folder, with a clean Asset.js:
image

This means it won't fail to dynamically import these modules anymore.

@github-actions
Copy link

github-actions bot commented May 9, 2022

Visit the preview URL for this PR (updated for commit d15bffc):

https://emeris-app--pr1760-build-assetfiles-wit-8sj8dt1y.web.app

(expires Tue, 14 Jun 2022 12:10:56 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Contributor

@fl-y fl-y left a comment

Choose a reason for hiding this comment

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

LGTM until Sentry error logs are tidied up.
Long thread here https://allinbits.slack.com/archives/C02TBMVAJDN/p1652087614472409

@Dawntraoz
Copy link
Contributor

The hashes are important for the user to have the latest changes: https://stackoverflow.com/questions/59194365/webpack-4-hash-and-contenthash-and-chunkhash-when-to-use-which, otherwise the user will always see an old version if we have cache in place, and I think is a huge problem for us

@eitjuh eitjuh marked this pull request as draft May 9, 2022 10:08
@eitjuh
Copy link
Contributor Author

eitjuh commented May 9, 2022

The hashes are important for the user to have the latest changes: stackoverflow.com/questions/59194365/webpack-4-hash-and-contenthash-and-chunkhash-when-to-use-which, otherwise the user will always see an old version if we have cache in place, and I think is a huge problem for us

would this create a temporary solution?
instead of
https://app.emeris.com/assets/Asset.4782f5bd.js
we use
https://app.emeris.com/assets/Asset.js?v=4782f5bd

@Dawntraoz would this solve your concern? This way we could still have the import resolve well, and also update it with the new hash

@Dawntraoz
Copy link
Contributor

would this create a temporary solution? instead of https://app.emeris.com/assets/Asset.4782f5bd.js we use https://app.emeris.com/assets/Asset.js?v=4782f5bd

@Dawntraoz would this solve your concern? This way we could still have the import resolve well, and also update it with the new hash

Of course, but guessing that the version should be one for build and not one for file (as it was wtih the chunkHash).

@eitjuh eitjuh closed this May 12, 2022
@eitjuh eitjuh deleted the build/assetfiles-without-hash branch May 12, 2022 11:20
@eitjuh eitjuh restored the build/assetfiles-without-hash branch May 14, 2022 19:16
@eitjuh eitjuh reopened this May 14, 2022
@eitjuh eitjuh closed this May 16, 2022
@eitjuh eitjuh deleted the build/assetfiles-without-hash branch May 16, 2022 12:54
@eitjuh eitjuh restored the build/assetfiles-without-hash branch June 7, 2022 12:07
@eitjuh eitjuh reopened this Jun 7, 2022
@eitjuh eitjuh marked this pull request as ready for review June 7, 2022 12:08
@eitjuh eitjuh merged commit 2286d64 into production Jun 7, 2022
@eitjuh eitjuh deleted the build/assetfiles-without-hash branch June 7, 2022 12:14
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.

3 participants