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

Consider throwing errors instead of warnings if modules are not resolved (externalized by Rollup) #459

Closed
AlexandreBonaventure opened this issue Jun 25, 2020 · 2 comments

Comments

@AlexandreBonaventure
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When building with vite, if a module is not resolved (because of an oversight for instance) it will be externalized by Rollup with a warning. A module being externalized will most likely fail in the browser. However, warnings are hard to catch especially if you use a CI/CD setup, and we can safely assume it is most likely an error. If you do want a module to be external, it should be up to the user to explicitly configure it with rollupInputOptions: { external }

Describe the solution you'd like
The idea is to use onwarn hook to throw a hard error.
https://rollupjs.org/guide/en/#onwarn

@yyx990803
Copy link
Member

Open to PR for that. Although shouldn't that fail during dev already?

@AlexandreBonaventure
Copy link
Contributor Author

Yes it will [vite] Failed to resolve module import "xxxx". But it is still "easy" to miss.

There is another thing as well which could be another feature:
When using monorepo, let's say you require lodash in two packages but forgot to add it to package.json in one of them. Currently it is going to work in dev because modules are resolved to the optimized lodash, but fail when building (if you use a strict pkg manager). This could be addressed by always trying to resolve the module before routing to the optimized version in dev mode

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants