Replies: 1 comment
-
UPDATE To make things more clear I created a demo project. In that way it is really easy and fast for you to reproduce my issues. Since I want to use cytoscape inside a webcomponent I use the Lit (as Polymer is deprecated). For that I just adopted the LIT javascript starter Kit. Please download my adopted demo code: lit-element-starter-js-main-cytoscape.zip Changes I made in the starter kit
How to use
ISSUE 1: import problem
ISSUE 2: CSS problem
ISSUE 3: Drag&Drop offset problem
So, is it impossible to use cytoscape inside a webcomponent? I had the same behaviour with Polymer. Any help would be very much apprechiated. Please let me know if I can make things even more clear. |
Beta Was this translation helpful? Give feedback.
-
see UPDATE below in second post
How can I import cytoscape.js into my Lit npm ESM project?
actually this is a repost from Stackoverflow, but I did not get any response there :-(
Of course, if you can help me you'll get the credits also on Stackoverflow.
Versions I use are: npm: '8.1.4', node: '14.15.3' and current cytoscape.js npm package (3.20.0)
My package.json defines that I want to do ESM:
"type": "module"
,The cytoscape.js documentation states the following:
I followed the instructions. However, the import results in the error:
Uncaught SyntaxError: The requested module './../../node_modules/cytoscape/dist/cytoscape.cjs.js' does not provide an export named 'default'
Well, that is correct since the commonjs version was loaded. But in an ESM environment
cytoscape.esm.js
should be loaded instead ofcytoscape.cjs.js
. However,node_modules/cytoscape/package.json
says to use the commonjs version:"main": "dist/cytoscape.cjs.js"
,So I tried to import the ESM version directly in my code:
import cytoscape from './../../node_modules/cytoscape/dist/cytoscape.esm.js';
Cytoscape.js is now imported. However, I get the followup error in an dependent package:
Uncaught SyntaxError: The requested module './../../heap/index.js' does not provide an export named 'default' in line cytoscape.esm.js:24
I'm kind of stuck now. Other related questions did not help so far. I'll be happy for any suggestion or even solution. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions