feat: file extensions opt-in and lookup #4303
Draft
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.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
resolves #4301
Todo:
string
option? (can also be given as single array value instead ['.js']Initially I thought to implement a
requireFileExtensions
(boolean) option, but I thought it might be better to re-use the same option for the extension lookup , which can also be specified now. similar to webpack resolve extensionsfalse (default)
currently an
opt-in
, and therefore non-breaking. in that case theinternal default extensions
would be used, which are currently['.mjs', '.js']
.true
all given file paths are expected to have a file extension. they are required.
string[] e.g. ['.js'], ['.js', '.mjs']
replaces the
default extensions
, which also include the order of file lookups, for example ['.js', '.mjs] would first look for.js
files, then for.mjs
files. it also means that file extensions are not required, but still allowed.personally I would strongly suggest to make this option an
opt-out
(default: true) for v3, as node.js, the web, and other engines (nginx, moddable etc.) work the same way (including I believe webpack). rollup seems to be the only one standing out.