-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: correct main
field in package.json for CDN support
#51
Conversation
I still can't get it to run in VSCode. Is there a magic trick to re-install the local version? |
E.g., same issue as before. But then again, I don't know if VSCode requires some explicit magic to happen. Screen.Recording.2022-12-12.at.8.00.45.PM.mp4 |
Did you release a new version to npm? I believe VSCode relies on loading from CDN, and the package.json must be updated there |
Okay. Let's hope things work :D |
hmmmm, it might actually be related to the how the amd module is defined? I see a 200 and request for |
for reference:
|
Oh boy haha |
looking at the jupyter-scatter includes an additional |
Should fix #37
Google Colab and VSCode rely on loading the bundled extension (
dist/index.js
) from a CDN. I believe Colab uses unpkg, but others may use jsdelivr, etc.CDNs generally defer to the
main
field of thepackage.json
(since this is how Node's resolution algorithm works), but there are unofficial fields likeunpkg
,jsdelivr
,module
,browser
, etc. It would be simple enough to make themain
fielddist/index.js
to support most CDNs, but then that breaksjupyterlab extension build
(which requires themain
to besrc/index.js
). Fix one leak and another opens 🙃This PR uses
publishConfig
– an formal field used bynpm
(and other package managers) to override properties in thepackage.json
at publish-time (e.g., when runningnpm publish
). This meansmain
remainssrc/index.js
during development and when running all build commands, and then is changed todist/index.js
only when publish to npm.In my experience, this is the easiest fix - especially since the source code (
js/src/index.js
) isn't useable in any JS runtime nor would be used by others with a bundler since it's so specific for the Jupyter-like clients.