-
|
Hello, I'd like to test maxgraph and I haven't succeeded. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
How about deleting |
Beta Was this translation helpful? Give feedback.
-
|
Hi @bochatay , Error reproductionI have reproduced your error. Firefox 126.0.1 (French language) Chrome 126.0.6478.55 Quick explanationsImports using "@maxgraph/core" are intended to be interpreted by bundlers, TypeScript, .... but don't work in the browser, which requires relative references (see the Chrome error) or absolute references. The maxGraph npm package is intended to be used with a package manager and bundlers which will bundle maxGraph with the rest of your application (as explicitly states in the README). Possible workaround/hackThat being said, I have tried to directly import the package entry point directly in the page. It is a ES module so it could be possible to load it. In the page, I changed the import directive like this: // use jsdelivr
import {Graph, InternalEvent} from 'https://cdn.jsdelivr.net/npm/@maxgraph/core@0.11.0/dist/index.js';
// or locally if the page is in the same folder as the 'node_modules' folder
// import {Graph, InternalEvent} from './node_modules/@maxgraph/core/dist/index.js';The dist/index.js file imports elements without extension, so the browser tries to load https://cdn.jsdelivr.net/npm/@maxgraph/core@0.11.0/dist/view/mixins/ConnectionsMixin instead. And so, it fails to load the resources. I finally found a workaround by locally patching the js files to ensure that all imports use the js extension to match the path of the file. The JavaScript code is the same as in the README of the maxGraph repo (after adaptation from TypeScript). Here is what I then see in the browser 👇🏿 Mini how-to patch the npm package
About the missing .js extensionThis may be fixed in the future as it impacts some webpack configuration. For example, see https://github.com/maxGraph/maxGraph/blob/v0.11.0/packages/js-example/webpack.config.js#L21-L30. |
Beta Was this translation helpful? Give feedback.
-
|
Hello, |
Beta Was this translation helpful? Give feedback.

Hi @bochatay ,
As mentioned by @reuse-ay, you should remove the "type" directive, but the error is not coming from that.
Error reproduction
I have reproduced your error.
Firefox 126.0.1 (French language)
Chrome 126.0.6478.55
Uncaught TypeError: Failed to resolve module specifier "@maxgraph/core". Relative references must start with either "/", "./", or "../".Quick explanations
Imports using "@maxgraph/core" are intended to be interpreted by bundlers, TypeScript, .... but don't work in the b…