Adding exports
map and peerDependencies
to package.json
#138
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.
Adding
exports
map andpeerDependencies
topackage.json
Currently when we use
antd
from anycdn
provider likeskypack
orantd
we will run into 2 issues regarding the cdn you are using. I tried to resolve the issues in this PR.Missing peerDependencies
Currently i see the package is using
react
andreact-dom
but they are defined only indevDependencies
alone. This doesn't raise a issue when used local, because most of the time. It will be used in areact
based project and works. But when loaded viacdn
's like this. They miss out the package information and breaks instead.How
jspm
handles the issueRight now, if the package is missing in
package.json
it tries to redirect to the latest version of it.It's just as a fallback and here it is why it can't the solution always and the package need to be corrected, for example you are using
[email protected]
in development. But it might loadreact16.7
since it is the latest release.And that's the main reason why skypack throws error too.
How
skypack
handles itSkypack throws an error instead, currently it checks on
peerDependencies
anddependencies
alone for the version number.Missing export map
Both the
cdn
's highly rely onexports
field in thepackage.json
for resolving the modules which is anode
standard for handling. Sincemain
field is missing from thepackage.json
andexports
map too. It is causing issues when static analysis happens in the package.But the
exports
introduces the change in the way the package is being used. For example,rc-image
which uses this package for adding functionalities uses likehttps://github.com/react-component/image/blob/ac08b58b28a560ce2422ad43ac61a1f664f3c602/src/getFixScaleEleTransPosition.tsx#L1
should be changed to
Since the
cjs
oresm
resolution is taken care by export map itself.PS:
If the package doesn't want to introduce this change for imports, i can revert the change from the PR and add
peerDependency
change alone.