Having trouble setting up Cytoscape using TypeScript and Rollup

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',
    }),
  ],
};

Answer №1

In the unlikely event that someone comes across this information, the reason for this crashing incident is due to Cytoscape.js modifying Array.prototype. The recent update in Obsidian altered Array.prototype and set it to read-only. A resolution is on the way to rectify this issue, enabling smooth importing of Cytoscape once again.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue arose when attempting to save a nested list of schema types in Typegoose and Mongoose, resulting in a failed Cast to

Encountering this issue: Error: Competition validation failed: results.0: Cast to ObjectId failed for value "{ name: 'David'}" The main model is as follows: class Competition { @prop() compName: string @prop({ ref: () => C ...

Is it possible to establish a limit on a field's value in MongoDB?

Just a quick query - I'm curious if there's a feature in mongodb that allows for fields to have a set maximum value. For instance, let's say the field "cards" is restricted to a maximum value of 100. If an increment would exceed this limit, ...

Displaying Bootstrap alert after a successful jQuery AJAX call

I have been attempting to display an alert on a form once the submission action is completed. Here is my JavaScript function: function submitForm(){ // Initialize Variables With Form Content var nomeCompleto = $("#nomeCompleto").val(); v ...

Encountering issues with Codeigniter and ajax: Success function failure

I'm currently facing an issue with the success function in my jQuery $.ajax call in a JavaScript file: $("#country select").change(function () { var country_value = $(this).val(); $.ajax({ url:base_url + "Sea ...

Is there a way to retrieve data from a sealed JSON object using JavaScript?

The data is being fetched from the API and here is the response object: { "abc": [{ "xyz": "INFO 1", "pqr": "INFO 2" }, { "xyz": "INFO 3", "pqr": "INFO 4" } ] } We are lookin ...

What are the security benefits of using Res.cookie compared to document.cookie?

When it comes to setting cookies to save data of signed in members, I faced a dilemma between two options. On one hand, there's res.cookie which utilizes the Express framework to set/read cookies on the server-side. On the other hand, there's d ...

Loop through an array that holds another array in javascript

After making a post request, I am receiving the following object: "{\"Success\":false,\"Errors\":{\"Name\":[\"The Name field is required.\"],\"Id\":[&b ...

Using AngularJS instead of jQuery to delete items from the DOM or View

Curious about handling DOM elements in AngularJS, I came across a specific scenario in my View / Webpage <div> <p>I am some text or a comment or something</p> <a href="" ng-click="deleteThisDiv()">X</a> </div> & ...

Tips for adding a delay in between iterations of a for-loop

I'm working on a project where I need to display a series of slides, each with a specified display duration. My idea is to store these slides in an array and loop through them, showing each slide for the correct amount of time before moving on to the ...

Switching React Icons when Clicked

I'm struggling to understand this. I want the React icons below to be filled and remain filled when clicked, changing back to outlined when another is clicked. Here's the code: import { useState } from "react"; import { Link } from "react-router- ...

Having trouble loading Bootstrap styles in a dynamically generated table using javascript

I'm currently developing a trivia game that fetches questions from an API. To enhance the look of the game, I decided to utilize Bootstrap. The game itself is constructed as an HTML table using jQuery in JavaScript. However, upon calling the function, ...

Unlocking the power of JSONB column filtering in KNEX with Typescript/Javascript: A comprehensive guide

Could someone please assist me with this query issue? I have a table with a jsonb column that stores stringified data in the following format: entry: { 1: "data1", 2: "data2" } I am trying to retrieve entries where the key is 1 ...

React.Children does not reveal the presence of any offspring

I am looking to implement react-native-maps-clustering in my project. However, this library only accepts markers that are direct children of the maps component. An example of how it should be structured: <MapView> <Marker/> <Marker/> ...

Error in sending data to the server via the specified URL: "Http failure response for http://localhost/post.php: 0 Unknown Error" and POST request to http://localhost/post.php failed with error code

Feeling a bit stuck trying to add data to my database. As a junior with PHP and Angular, I am using PHP via XAMPP and Angular 8. Is it possible to create separate files for the post and get methods in the PHP file? app.component.ts import { Component, O ...

Limiting client requests on the Azure Translation API

I have a client who needs to limit the number of requests made to my Azure Translation API service. I found information from Microsoft on how to implement request throttling, but it's unclear where exactly in the request this throttling data should be ...

I am on a quest to locate a specific key within an array of objects and then validate it using Regex

I've been struggling with this for over 3 days and still haven't found a solution. It feels like trying to find a needle in a haystack, but I'm determined to figure it out. My goal is to search for a specific key in an array of objects and ...

Implementing the fetch API with radio buttons in a React Native application

I found a useful package for radio buttons called react-native-flexi-radio-button. Currently, I'm working on displaying API results within radio buttons. The API response provides 4 options, and my goal is to render text alongside the corresponding ra ...

What causes the 'cannot read properties of null' error when using dot notation in React, and what are the possible solutions to resolve it?

When I employ the conventional method of accessing objects using dot notation {quote.text} {quote.author}, I encounter a "cannot read properties of null" error message. import { useState, useEffect } from 'react'; import "./React.css"; ...

What is the best way to choose an element within a component's template?

Is there a way to access an element that is defined in a component template? While Polymer has the $ and $$ to make this task simple, I am curious about how it can be done in Angular. Consider the example provided in the tutorial: import {Component} from ...

What are the types used for req and res in the Express framework?

Here in this demonstration I am trying to implement the DefinitelyTyped Response and Request types for the req, res parameters. However, I encounter a compilation error: const express = require('express'); const app = express(); app.get('/& ...