-
Describe the bugI have written a Vue 3 package with a component and a composable, the component uses the composable for logic and is exposed outside the app to be used on other parts of the actual application. Vite DemoThe code of the implementation can be found here: https://github.com/mmeester/component-composable-demo Expected behaviour Actual local behaviour Build / Production behaviour Vue-CLII've also tried to run the same example with the vue CLI to see if this has anything to do with vue or particularly with vite. The code of the vue-cli can be found here: https://github.com/mmeester/component-composable-vue-demo Expected behaviour Actual local behaviour Build / Production behaviour Reproduction
System InfoSystem:
OS: macOS 12.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 3.05 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.15 - ~/.nvm/versions/node/v16.13.0/bin/yarn
npm: 8.1.4 - ~/.nvm/versions/node/v16.13.0/bin/npm
Browsers:
Chrome: 96.0.4664.55
Edge: 96.0.1054.43
Firefox: 94.0.2
Safari: 15.1
npmPackages:
@vitejs/plugin-vue: ^1.9.3 => 1.10.1
vite: ^2.6.4 => 2.6.14 Used Package Managernpm LogsNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Because your package depends on vue, rebuilding vue causes the two component states not to share. vite will pre-bundled packages, and the dependent packages do not declare dependent vue, so vite will rebuilding vue.
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: [
'component-composable'
]
}
}) |
Beta Was this translation helpful? Give feedback.
-
Thanks @poyoho this fixes the issue, wonder if this should be documented somewhere. |
Beta Was this translation helpful? Give feedback.
-
Possibly related to #26 and vitejs/vite#7454 (comment). I wonder if |
Beta Was this translation helpful? Give feedback.
Because your package depends on vue, rebuilding vue causes the two component states not to share.
vite will pre-bundled packages, and the dependent packages do not declare dependent vue, so vite will rebuilding vue.