You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Real UseCase: a npm package need global data which initialize in main app.js(script module).
production build puts all npm package in vendor(modulepreload), which call stack is defferent from dev mode.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
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 https://github.com/vuejs/core instead.
dabuside
changed the title
[bud]Vite production build lose order of execution in js
[bug]Vite production build lose order of execution in js
Mar 11, 2022
You can configure how chunks are split using `build.rollupOptions.output.manualChunks` (see [Rollup docs](https://rollupjs.org/guide/en/#outputmanualchunks)). Until Vite 2.8, the default chunking strategy divided the chunks into `index` and `vendor`. It is a good strategy for some SPAs, but it is hard to provide a general solution for every Vite target use case. From Vite 2.9, `manualChunks` is no longer modified by default. You can continue to use the Split Vendor Chunk strategy by adding the `splitVendorChunkPlugin` in your config file:
```js
// vite.config.js
import { splitVendorChunkPlugin } from'vite'
module.exports=defineConfig({
plugins: [splitVendorChunkPlugin()]
})
```
This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkCache })` factory, in case composition with custom logic is needed. `cache.reset()` needs to be called at `buildStart` for build watch mode to work correctly in this case.
You can now bump the vite version to v2.9.0-beta.0 to fix this issue.
Describe the bug
Step to Reproduction
vite dev
console output is100
vite build && vite preview
console output isundefined
Real UseCase: a npm package need global data which initialize in main app.js(script module).
production build puts all npm package in vendor(modulepreload), which call stack is defferent from dev mode.
Reproduction
https://stackblitz.com/edit/vitejs-vite-mngeim?file=index.html
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: