docs: add docs for module condition#10524
Closed
benmccann wants to merge 1 commit intovitejs:mainfrom
Closed
Conversation
bluwy
reviewed
Oct 19, 2022
| Here, `import` and `require` are "conditions". Conditions can be nested and should be specified from most specific to least specific. | ||
|
|
||
| Vite has a list of "allowed conditions" and will match the first condition that is in the allowed list. The default allowed conditions are: `import`, `module`, `browser`, `default`, and `production/development` based on current mode. The `resolve.conditions` config option allows specifying additional allowed conditions. | ||
| Vite has a list of "allowed conditions" and will match the first condition that is in the allowed list. The default allowed conditions are: `import`, [`module`](https://webpack.js.org/guides/package-exports/#providing-commonjs-and-esm-version-stateless), `browser`, `default`, and `production/development` based on current mode. The `resolve.conditions` config option allows specifying additional allowed conditions. |
Member
There was a problem hiding this comment.
It looks like Vite doesn't follow the logic from the link. Webpack uses module for require() to prevent code duplication, but Vite would skip module for require(), and only works for import. Maybe we should remove the link for now.
Collaborator
Author
There was a problem hiding this comment.
Hmm. I wonder if module is something we should support in that case then. Anyway, I'll go ahead and close this based on your feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
modulecondition is not discussed in the Node docs, so I had a very hard time understanding what it was for. It seems to be something invented by Webpack which we later adoptedAdditional context
Motivated by #10442 and #10495
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).