Repository navigation
Use exports for the default path when main is missing - #404
Merged
Merged
Conversation
Without `path` in the config, Size Limit took `main` from package.json and otherwise `index.js`. An ESM-only package with only `exports`, like the one in ai#285, crashed with ENOENT on the missing `index.js`. Take the root entry of `exports` before falling back to `index.js`, preferring the `import` condition.
Owner
|
If nobody needs it ASAP I will release it with next feature. Size Limit releases are a little bit painful. |
Owner
|
Released in 14.2.0. |
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.
Fixes #285.
Without
pathin a check, Size Limit takes the file frommainin package.json and falls back toindex.js. A package that only hasexports, as in #285, has neither:{ "type": "module", "exports": { ".": { "import": "./lib/index.js" } } }With Size Limit 14.1.0 this crashes with
ENOENT: no such file or directory, open '.../index.js'.Now, when there is no
main, the root entry ofexportsis used before falling back toindex.js: the field itself when it is a string, otherwise the.entry, with conditions resolved inimport,default,requireorder (nested conditions likeimport: { types, default }included).mainstill wins when it is set, so existing configs keep their files.The new test uses the package.json from #285 as a fixture and fails without the change.
oxlintpasses. Locally on Windows, 6 other tests inpackages/size-limitfail with and without this change (the same 6, for example the path separator in "takes config from CLI config argument").