Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create Pinia outside development #678

Merged
merged 1 commit into from
Dec 6, 2022
Merged

Don't create Pinia outside development #678

merged 1 commit into from
Dec 6, 2022

Conversation

matthew-white
Copy link
Member

See the commit message for notes.

We already don't create Pinia stores outside development. By not
creating Pinia at all, Pinia will no longer be included in the bundle.
We only use Pinia in development.
@@ -45,7 +48,7 @@ export default ({
logger = console
} = {}) => {
const container = {
pinia: createPinia(),
pinia: process.env.NODE_ENV === 'development' ? createPinia() : piniaMock,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, my strategy was going to be to use webpack to alias the pinia package to src/util/pinia.js. That way, only our webpack config would change, not this file. However, at the end of the day, I think this approach is clearer: there's less webpack magic involved. Plus, now that we're planning to move to Vite (#671), it seems good to have as little webpack-specific code as possible. I checked the build, and even though this file still imports Pinia, if it doesn't use Pinia at all, which it won't outside development, the import is removed from the bundle.

Since we won't use it after all, I've removed src/util/pinia.js.

@matthew-white matthew-white merged commit 20a4390 into master Dec 6, 2022
@matthew-white matthew-white deleted the no-pinia branch December 6, 2022 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants