Currently, I am attempting to set up Cytoscape.js for an Obsidian plugin. To import Cytoscape, I have used the following code:
import cytoscape from 'cytoscape';
. Later on, I invoke it with const viz = cytoscape();
.
Although this setup compiles successfully using rollup, when attempting to load the code, it crashes and displays the error below. It is important to note that cytoscape()
is never directly called in my code. Any insights on how to troubleshoot this import error would be greatly appreciated.
app.js:1 Plugin failure: neo4j-graph-view TypeError: Cannot assign to read only property 'remove' of object '[object Object]'
at eval (eval at <anonymous> (app.js:1), <anonymous>:13973:17)
at e.<anonymous> (app.js:1)
at app.js:1
at Object.next (app.js:1)
at a (app.js:1)
Below are snippets of my tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "es2015",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"lib": [
"dom",
"es5",
"scripthost",
"es2015"
],
"allowSyntheticDefaultImports": true,
// "esModuleInterop": true,
"typeRoots": [
"./node_modules/@types/"
]
},
"include": [
"**/*.ts"
]
}
Also, here is my rollup.config.js content:
import typescript from '@rollup/plugin-typescript';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
export default {
input: 'main.ts',
output: {
dir: '.',
sourcemap: 'inline',
format: 'cjs',
exports: 'default',
},
external: ['obsidian'],
plugins: [
typescript(),
nodeResolve({browser: true}),
commonjs({
include: 'node_modules/**',
}),
copy({
targets: [
{src: 'main.js', dest: '../../semantic-obsidian/Semantic Obsidian/.obsidian/plugins/neo4j-graph-view'},
],
hook: 'writeBundle',
}),
],
};