-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Support external in dev #6582
Comments
As noted in #6583 (comment), it would be great if you can explain how you encountered the issue and what error it gives. That would help us evaluate the correct fix for it. |
I created an example repo to demonstrate the error: |
Thanks for the example @hasangenc0. I tried implementing this at https://github.com/bluwy/vite/tree/rollup-options-external. Turns out there's a lot more to be done to fully support externalizing deps. I think I got it nearly done, except that we can't just leave If you'd like you can build on top of my changes, or update #6583 with it. I think #6583 at its current state isn't sufficient. |
A workaround mentioned in #6393 (comment) might help for now. |
Any updates? dev |
Besides the implementation not being done yet, in a recent team meeting we discussed to have the new option at |
@bluwy do you have a good example of this one? I think |
I'm not sure if this is related or not but I see the exported interface for the ESBuild plugin references I could not find an |
I implemented the stuff before I was familiar about importmaps, so yeah I think importmaps could be a good reason that we can leave that as-is for now. Supporting @Djfaucette I don't have any plans for now so I added the "contributions welcome" label. Maybe one day I'll revisit if I can get the motivation 😬 This shouldn't meddle with esbuild at all, except for Vite's optimizer that uses esbuild, which we need to pass the |
hello, I am trying to create a lib, that externalize Firebase, but it does not works. |
I have created a plugin to solve this issue during development, until official support is implemented: https://github.com/MilanKovacic/vite-plugin-externalize-dependencies |
Another use case here: we have a custom browser-like JS runtime that provides built-in modules similar to Node's |
plz notice me once the issue is resolved. |
Hi @thjjames please use the Subscribe button instead of leaving a comment in the future: https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/viewing-and-triaging-notifications/triaging-a-single-notification#customizing-when-to-receive-future-updates-for-an-issue-or-pull-request |
As it took me some time to figure out a simple workaround without needing some plugin, I want to share my solution here. As it is possible to ignore dynamic imports with const moduleName = '@code/some-module';
const module = await import(/* @vite-ignore */ moduleName);
module.someExportedFunction() Using the string directly in the |
The error load( id ) {
if ( dependencies.includes( id ) ) {
return '';
}
} Alternatively, you can disable pre-transformation like so: // vite.config.js
export default {
server: {
preTransformRequests: false
}
}; |
In addition to the fix in #6582 (comment), the linked code also doesn't handle base url, so here's a fix:
escapeRegExp if from lodash |
FWIW, I was able to get vite to load from CDN in debug mode without any plugins by using the Once the proper alias is defined vite seems to load the bundles from the url specified in the alias rathe then Hope this helps someone! |
With the environment API here, there's now the Moving this off the milestone, but this maybe something we'd investigate more post v6. |
Clear and concise description of the problem
When I have external dependencies that are not a npm package, vite dev server throws an error in
vite:import-analysis
stage.vite build
command just works fine butvite
command tries to resolve all of the external dependencies in the import-analysis stage.Suggested solution
Skip resolving the external dependencies in import-analysis.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: