function notPure() {
UnknownGlobalCouldHaveSideEffect.test('value');
}
console.log('test');
I expect an indentical file in the output, but Vite ignores no-treeshake and I get the following output file, keeping only code it thinks has side effects.
console.log('test');
When I use the same plugin with Rollup directly, I get the correct non-treeshaken output as desired. It's an issue with Vite.
[X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
[X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
I have created a simple plugin that prevents Vite from treeshaking a JavaScript file.
Given the input file:
I expect an indentical file in the output, but Vite ignores
no-treeshake
and I get the following output file, keeping only code it thinks has side effects.When I use the same plugin with Rollup directly, I get the correct non-treeshaken output as desired. It's an issue with Vite.
Reproduction
https://github.com/kwangure/no-treeshake-repro
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations