question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

augmentChunkHash with extract: true breaks hashing

See original GitHub issue

My configuration looks like this:

  postcss({
    extract: true,
    minimize: process.env.NODE_ENV === 'production'
  })

https://rollupjs.org/guide/en/#augmentchunkhash https://github.com/egoist/rollup-plugin-postcss/blob/master/src/index.js#L140 The augmentChunkHash hook is used to augment the hash of chunks (entry js file + its dependencies), not assets, so I don’t understand why this is used. It’s not even filtering which chunk gets its hash augmented. This is causing all my js files to have new a hash on every build, even when nothing has changed.

The extracted stylesheet’s hash should also not be based on the entry file’s hash, it should have its own independent hash.

Removing the augmentChunkHash hook completely fixes first problem. rollup-plugin-postcss will still need to hash the stylesheet based on its content.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rproserpiocommented, Jan 1, 2021

You can go relatively far using something like patch-package to amend specific things until the maintainers have the time to look at the submitted PRs. To emit an asset together with its sourcemap you can do somenthing like the following (stolen from now deleted code in rollup-plugin-svelte):

function emitFileWithSourcemap(bundle, name, code, map) {
	const ref = this.emitFile({
		type: 'asset',
		name: name,
		source: code
	});
	const filename = this.getFileName(ref);
	const mapFilename = `${filename}.map`;
        // TODO handle inline, hidden or disabled sourcemap options
	bundle[filename].source += `\n/*# sourceMappingURL=${path.basename(mapFilename)} */`;
	this.emitFile({
		fileName: mapFilename,
		type: 'asset',
		source: map
	});
}

This function lets Rollup handle the naming and the hashing, using its output.assetFileNames conf. You can then completely remove augmentChunkHash, since the hashing is consistent with the extracted file content. If you use js dynamic imports that import css you may want to also look at #317 to avoid non deterministic source concatenation.

0reactions
AlexGalayscommented, Jan 1, 2021

Did anyone find a fork that fixes these kind of big/completely breaking bugs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

rollup-plugin-postcss - Bountysource
augmentChunkHash with extract : true breaks hashing $ 0. Created 2 years ago in egoist/rollup-plugin-postcss with 4 comments. My configuration looks like this:...
Read more >
rollup.js
On the other hand, augmentChunkHash is now evaluated after renderChunk when the hash is created. As file hashes are now based on the...
Read more >
egoist/rollup-plugin-postcss (Raised $0.00) - Issuehunt
augmentChunkHash with extract : true breaks hashing. Unfunded#315created bynstepien. $0.00. Hot Module Replacement (HMR). Unfunded#314created bynstepien.
Read more >
rollup.js
You will only get a default export from CommonJS plugins ... Next Hook: augmentChunkHash for each chunk that would contain a hash in...
Read more >
rollup changelog
Pull Requests · #3722: Add import specifiers to bundle information (@lukastaegert) · #3724: Fix missing variables for UMD and IIFE builds (@ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found