-
Notifications
You must be signed in to change notification settings - Fork 88
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
Added "./package.json"
to "exports"
field
#273
Conversation
Thanks for you contribution! I can merge this for you, but beforehand we'd need to update |
@@ -20,7 +20,8 @@ | |||
"react-native": "./dist/react-native/index.native.js", | |||
"exports": { | |||
"import": "./dist/es/index.mjs", | |||
"require": "./dist/cjs/index.js" | |||
"require": "./dist/cjs/index.js", | |||
"./package.json": "./package.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a linter warning coming from VSCode's package.json
schema-checker. Not sure if this is actually an issue in practice. Do you have any context @bmeeder22?
The warning disappears when conditional "exports"
are not in use. I'm not sure if this is a limitation of the spec, or of the schema reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The place that I am seeing warnings is while attempting to use this package in react-native
:
yarn run v1.22.17
$ react-native start
warn Package @magic-ext/solana has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /Users/.../mobile/node_modules/@magic-ext/solana/package.json
This appears to be unique to react native >= Node V14 as per this issue: react-native-community/cli#1168
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the warning is in the VS Code linter and not eslint. My guess is that your seeing that error only as part of the VS Code built in linter which might not have the most updated spec.
It appears that this only matters when there are defined exports. In packages without explicitly defined exports everything works just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another good thing to note that the warning appears to just be a warning initializing the extension is working just fine in the RN application. Hopefully that doesn't change in some later version.
"./package.json"
to "exports"
field
Unfortunately our build system complains about this change with the following warning: Which leads me to think this is a limitation of the {
"exports": {
"import": {
".": "./dist/es/index.mjs",
"./package.json": "./package.json"
},
"require": {
".": "./dist/cjs/index.js",
"./package.json": "./package.json"
}
},
} The problem is that this would require some tinkering with the conventions of our build system, which is pretty risky. We've had issues every single time we've overhauled something in the build system because we have to support so many different platforms, bundlers, and runtimes. Most recently this happened yesterday! (#270). I'd feel more comfortable about approaching a change like this once the Magic team has more cycles. It would be even better if we had some acceptance tests in place beforehand (which is something I'm anticipating for the future). VSCode complains either way... My personal experience with the If someone wanted to consume a Magic JS |
Closed as |
📦 Pull Request
When importing to react native an error message is appearing:
Not sure if this is causing any issues but it is best practices to export the package.json if exports are defined.
✅ Fixed Issues
Fixes #272
🚨 Test instructions
Add to a react native android app and make sure the warning doesn't appear.
patch
: Bug Fix