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

Deduplicate assets when using Buffer content in emitFile #4711

Closed
patak-dev opened this issue Nov 9, 2022 · 1 comment · Fixed by #4712
Closed

Deduplicate assets when using Buffer content in emitFile #4711

patak-dev opened this issue Nov 9, 2022 · 1 comment · Fixed by #4712

Comments

@patak-dev
Copy link
Contributor

patak-dev commented Nov 9, 2022

Feature Use Case

Now that vite@4.0.0-alpha.0 is running on Rollup 3. We're checking if we could simplify our custom hashing of assets (we currently do hashing, deduplication, and filenames by hand) to use the standard Rollup asset handling. As an example, here we are hashing and deduplicating by hand before calling emitFile https://github.com/vitejs/vite/blob/cb84f37771fdc424b5656079a4765e7aee74cc25/packages/vite/src/node/plugins/asset.ts#L460.

We're running into an issue when refactoring this code to directly use emitFile because it doesn't deduplicate the file if a Buffer is passed instead of a string. But for Fonts we would also want to have deduplication.

Feature Proposal

In our case, by default we have [hash] in assetsFileNames, so if strings and Buffers would be deduplicated using hashes there wouldn't be a noticeable performance penalty.

I imagine this feature should be optional if a performance regression must be avoided for the case of assetsFileNames without [hash].

@rollup-bot
Copy link
Collaborator

This issue has been resolved via #4712 as part of rollup@3.3.0. You can test it via npm install rollup.

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