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

[Bug]: source code content was incorrectly replaced by file hash name. #8474

Open
bigbossx opened this issue Nov 19, 2024 · 5 comments
Open
Assignees
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.

Comments

@bigbossx
Copy link

bigbossx commented Nov 19, 2024

System Info

rsbuild version: 1.0.19

// use in project
export const lazyLoadDateHolidays = () => {
  return import(
    /* webpackChunkName: "date-holidays"*/
    /* webpackPrefetch: true */
    'date-holidays'
  );
};

break down in production build

Image

Details

  • is it stable reproduce ? No, i can't provider a mini reproduce

  • webpack has some problem?No, only happen with rsbuild

maybe rspack need a better way to replace hash content in chunk, not global replace

please cc @chenjiahan btw, thanks for your quick answer in wechat. help me a lot

Reproduce link

No response

Reproduce Steps

source code was break down in

Image

@bigbossx bigbossx added bug Something isn't working pending triage The issue/PR is currently untouched. labels Nov 19, 2024
@bigbossx
Copy link
Author

workaround:

// rsbuild.config.ts

export default defineConfig({
   output:{
     filenameHash: 'contenthash:16' // long hash name to reduce the probability of conflict
   }
})

@chenjiahan
Copy link
Member

Yes, we have discussed this issue. Using a content hash of 10 characters or more should avoid this problem, but it will also increase the bundle size slightly.

If Rspack can implement a more secure hash replacement, that will be the best approach.

@inottn
Copy link
Collaborator

inottn commented Nov 19, 2024

It might be similar to webpack/webpack#14058.

@chenjiahan
Copy link
Member

Duplicate with: #5339

@bigbossx
Copy link
Author

bigbossx commented Nov 19, 2024

just a suggestion:

  1. maybe we can change the default config in rsbuild to
const getHash = () => {
    if (typeof filenameHash === 'string') {
      return filenameHash ? `.[${filenameHash}]` : '';
    }
    return filenameHash ? '.[contenthash:12]' : '';
};
  1. and note this warning or tips in rspack docs

in next release

because it seems like it will take some time to really fix it(webpack too), but before that, we can reduce the probability of bugs happening(we was report by user in production env🥹)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

4 participants