This addresses an issue where Meteor packages that come bundled with npm packages might be included twice if your client app also depends on the same npm package.
33
Instructing Vite to import from Meteor instead of node_modules
Per-import
// No changes here.
// This will import from your node_modules like you would expect
import MyPackage from 'some-npm-package'
// If you have a Meteor package that already comes bundled with an npm package, the following
// syntax can be used to tell Vite to externalize this import request.
import MyPackage from 'meteor:some-npm-package';
Both imports are safe to use together. Bearing in mind that both versions of the npm package will be included in your final client bundle.
[x] Add configuration option to globally externalize certain npm packages
[ ] Improve error messages when an externalized npm package cannot be found in the Meteor bundle
[ ] Hint to the user if we detect packages that may be provided by Meteor
[ ] Try to avoid parsing the Meteor modules file with every new npm package import. All imports use the same underlying file, so it should be cached only once.
[x] Update React example to use new externalization feature
This addresses an issue where Meteor packages that come bundled with npm packages might be included twice if your client app also depends on the same npm package.
33
Instructing Vite to import from Meteor instead of
node_modules
Per-import
Both imports are safe to use together. Bearing in mind that both versions of the npm package will be included in your final client bundle.
For all imports
Todo