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

Warn on build when bundling code that uses nodejs built in module #12074

Closed
4 tasks done
yoonminsang opened this issue Feb 16, 2023 · 2 comments · Fixed by #12616
Closed
4 tasks done

Warn on build when bundling code that uses nodejs built in module #12074

yoonminsang opened this issue Feb 16, 2023 · 2 comments · Fixed by #12616
Labels
enhancement New feature or request

Comments

@yoonminsang
Copy link

Description

I understand that vite does not provide nodejs polyfill by default.

Suggested solution

So, what if we make the build fail if we use nodejs modules? In cra, the build fails when using the fs module. But it doesn't fail with vite.
Some people apply polyfills, so how about giving an option like this: vite build no-polyfill

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented Feb 16, 2023

I think maybe a warning is enough instead of failing the build. Vite currently implements a mocked module for the builtin modules so that it emits a warning in runtime, maybe it make sense to surface it during build too.

@yoonminsang
Copy link
Author

Thanks for the reply. Thanks to vite, the development environment has improved.
I have introduced vite to an existing project that is quite large. And I'm not sure all the libraries I installed don't use nodejs built in modules. As explained in the official documentation, do not use nodejs built in modules in libraries. But like you said, I'd like to know if at least some library has this problem or not. @bluwy

@bluwy bluwy added enhancement New feature or request and removed enhancement: pending triage labels Feb 18, 2023
@bluwy bluwy changed the title Let build fail when using nodejs built in module Warn on build when bundling code that uses nodejs built in module Feb 18, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants