-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Context
For some projects I would like to use rollup to benefit from tree-shaking and url hashing without generating chunks (disable concatenation of files). From my understanding preserveModules is the option to use for that situation. According to my tests preserveModules behaviour is not what I expected.
The following code illustrates what I have in mind.
import { rollup } from "rollup"
import { fileURLToPath } from "url"
const start = async () => {
const projectDirectoryUrl = new URL("./", import.meta.url)
const fileContents = {
"./main.js": `import { value } from "./dep.js"
console.log(value)`,
"./dep.js": `export const value = 42`,
}
const rollupBundle = await rollup({
input: ["./main.js"],
plugins: [
{
resolveId: (id) => {
return id
},
load: (id) => {
return fileContents[id]
},
},
],
})
await rollupBundle.write({
dir: fileURLToPath(`${projectDirectoryUrl}dist`),
preserveModules: true,
chunkFileNames: `[name]-[hash].js`,
})
}
start()Expected Behavior / Situation
Rollup write files with hash in their names such as
dist/main-25e95a00.js
dist/dep-5dd85f23.js
Actual Behavior / Situation
Rollup write files without hash under _virtual directory.
dist/_virtual/main.js
dist/_virtual/dep.js
Modification Proposal
Allow to disable chunks using preserveModules options or something else and update import paths to get hash in urls.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels