Skip to content

Commit ae1c2c7

Browse files
committed
chore: skip sideeffects set for HTML scripts for now
1 parent 61be385 commit ae1c2c7

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

packages/vite/src/node/plugins/html.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,25 @@ export function buildHtmlPlugin(config: ResolvedConfig): RolldownPlugin {
488488
if (isModule) {
489489
inlineModuleIndex++
490490
if (url && !isExcludedUrl(url) && !isPublicFile) {
491-
setModuleSideEffectPromises.push(
492-
this.resolve(url, id).then((resolved) => {
493-
if (!resolved) {
494-
return Promise.reject(
495-
new Error(`Failed to resolve ${url} from ${id}`),
496-
)
497-
}
498-
// set moduleSideEffects to keep the module even if `treeshake.moduleSideEffects=false` is set
499-
const moduleInfo = this.getModuleInfo(resolved.id)
500-
if (moduleInfo) {
501-
moduleInfo.moduleSideEffects = true
502-
} else if (!resolved.external) {
503-
return this.load(resolved).then((mod) => {
504-
mod.moduleSideEffects = true
505-
})
506-
}
507-
}),
508-
)
491+
// FIXME: rolldown does not support `this.load`: https://github.com/rolldown/rolldown/issues/2355
492+
// setModuleSideEffectPromises.push(
493+
// this.resolve(url, id).then((resolved) => {
494+
// if (!resolved) {
495+
// return Promise.reject(
496+
// new Error(`Failed to resolve ${url} from ${id}`),
497+
// )
498+
// }
499+
// // set moduleSideEffects to keep the module even if `treeshake.moduleSideEffects=false` is set
500+
// const moduleInfo = this.getModuleInfo(resolved.id)
501+
// if (moduleInfo) {
502+
// moduleInfo.moduleSideEffects = true
503+
// } else if (!resolved.external) {
504+
// return this.load(resolved).then((mod) => {
505+
// mod.moduleSideEffects = true
506+
// })
507+
// }
508+
// }),
509+
// )
509510
// <script type="module" src="..."/>
510511
// add it as an import
511512
js += `\nimport ${JSON.stringify(url)}`

playground/html/__tests__/html.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ describe('side-effects', () => {
398398
await page.goto(viteTestUrl + '/side-effects/')
399399
})
400400

401-
test('console.log is not tree-shaken', async () => {
401+
test.skip('console.log is not tree-shaken', async () => {
402402
expect(browserLogs).toContain('message from sideEffects script')
403403
})
404404
})

0 commit comments

Comments
 (0)