-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adding exports map in package.json #3218
Comments
In the export map, using the ESM version ( |
Should be superseded by: |
See: @sidharthv96, would you follow the steps in #3217 (comment) to confirm that the exports map works in your project? |
@maxkfranz, sadly that didn't work.
This is what worked in mermaid. diff --git a/package.json b/package.json
index f2f77fa79c99382b079f4051ed51eafe8d2379c8..0bfddf55394e86f3a386eb7ab681369d410bae07 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,15 @@
"engines": {
"node": ">=0.10"
},
+ "exports": {
+ ".": {
+ "import": "./dist/cytoscape.umd.js",
+ "default": "./dist/cytoscape.cjs.js"
+ },
+ "./*": "./*"
+ },
"main": "dist/cytoscape.cjs.js",
+ "module": "dist/cytoscape.umd.js",
"unpkg": "dist/cytoscape.min.js",
"jsdelivr": "dist/cytoscape.min.js",
"scripts": { |
You need to make a build of Cytoscape. UMD really shouldn’t be used for import. |
I've updated the That should make your testing a bit simpler. You can verify that the ESM file linked above doesn't use any Steps:
|
@maxkfranz tried it. Didn't work. I forgot to update here then. Will rerun and add the logs. |
Parts of lodash are used: - lodash/get - lodash/set - lodash/toPath - lodash/debounce `heap` is used, but it hasn't been updated in a long time. It probably never needs to be updated unless there's a serious bug. Doubtful. Ref: - Improving ESM support and documentation, esp. for browsers #3217 - Adding exports map in package.json #3218
All of the builds on unstable currently have no external dependencies, including CJS now. There is nothing listed under You'll need to delete your patch file in Mermaid to test the steps. |
@maxkfranz it's working perfectly now! Thank you! We also moved to using esbuild as well. Now, one of our major concern is the size. I'll try to see if there are any low hanging fruits related to tree shaking available in cytoscape. |
Great
Also great
Cytoscape does a lot. It has a CSS parser, a renderer, several layouts, etc. There's a lot there. This probably couldn't be changed that much in the current v3 line in the main builds. Possibly in v4. It would probably require some significant API changes re. extensions. For your case, you're welcome to add a Rollup build config to the Cytoscape repo that's smaller, if you like. It could exclude things like the canvas renderer if you're just using it headlessly for the model and layouts. Something like 'cytoscape.headless.esm.js'. Note you'd have to do the following in Mermaid, if you use a custom build: import cytoscape from 'cytoscape/dist/cytoscape.headless.esm.js' |
This issue has been automatically marked as stale, because it has not had activity within the past 14 days. It will be closed if no further activity occurs within the next 7 days. If a feature request is important to you, please consider making a pull request. Thank you for your contributions. |
Environment info
Current (buggy) behaviour
When using
import cytoscape from 'cytoscape';
and bundling the code in a library, an regarding importing lodash is thrown during build.Desired behaviour
It should import the right bundle. This can be facilitated by adding an exports map.
https://github.com/mermaid-js/mermaid/pull/5247/files#diff-f0ed092719ff4df1eac0ddfe6e5cf61e979cbd3bae566ed14cb579290735faa8
Minimum steps to reproduce
(I can create the STR if mandatory, I can raise the PR directly with the fix, as the patch provided above is working for us)
What do you need to do to reproduce the issue?
Fork/clone this JSBin demo and reproduce your issue so that your issue can be addressed quickly and effectively:
http://jsbin.com/fiqugiq
For reviewers
Reviewers should ensure that the following tasks are carried out for incorporated issues:
master
,unstable
, and1.1.x
if the current release is 1.2).bug
, if necessary.The text was updated successfully, but these errors were encountered: