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
Enable proper tree-shaking of Vue's ESM bundler #3382
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/7zMtK3KicWkdMy4kRiU7tQMvWHt9 |
// Enable proper tree-shaking for Vue's ESM bundler | ||
// See http://link.vuejs.org/feature-flags | ||
const packageOptions = snowpackConfig.packageOptions || snowpackConfig.installOptions; | ||
if (packageOptions && packageOptions.source === 'local') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natemoo-re made a small change:
- if (packageOptions.source === 'local') {
+ if (packageOptions && packageOptions.source === 'local') {
The plugin-vue
test which doesn’t fully load Snowpack was throwing because the default wasn’t set. While that’s probably more the test’s concern than the plugin, I still think it’s easier to keep plugin tests writing not loading the entire Snowpack runtime, and also not mocking Snowpack’s normalization, either (which may change). Hence the change here in the plugin rather than the test.
I wasn’t really sure what gets normalized IRT the Snowpack config, so I just played it safe here. But if you‘d prefer throwing an error if packageOptions
doesn’t exist instead, I could do that, too.
Changes
Updates
@snowpack/plugin-vue
to automatically replace Vue's Feature Flags with boolean literals. This improves the treeshaking of Vue's ESM bundler (and removes a very persistentconsole.warn
).Testing
yarn link
locally and run in Astro. The warning is gone!Docs
Yes the docs were updated!