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
SyntaxError: Named export 'graphviz' not found. #120
Comments
You may need to manually specify the esm module:
|
My package.json must not be 100% correct here: https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/package.json#L18-L33 If you can spot anything let me know... |
I should say that it worked fine also with hpcc-js/wasm version 1.15.5 or later before I adopted
That didn't work:
This is mostly black magic to me. I don't know what any of this means. The change I've made to my |
Also also tried this patch: diff --git a/src/dot.js b/src/dot.js
index 4b14ae7..fbdb4fd 100644
--- a/src/dot.js
+++ b/src/dot.js
@@ -1,5 +1,4 @@
-import { graphviz } from "@hpcc-js/wasm";
-import { graphvizSync } from "@hpcc-js/wasm";
+import * as hpccWasm from "@hpcc-js/wasm";
import * as d3 from "d3-selection";
import {extractAllElementsData, extractElementData, createElementWithAttributes} from "./element.js";
import {convertToPathData} from "./svg.js";
@@ -12,8 +11,8 @@ export function initViz() {
// force JIT compilation of @hpcc-js/wasm
try {
- graphviz.layout("", "svg", "dot").then(() => {
- graphvizSync().then((graphviz1) => {
+ hpccWasm.graphviz.layout("", "svg", "dot").then(() => {
+ hpccWasm.graphvizSync().then((graphviz1) => {
this.layoutSync = graphviz1.layout.bind(graphviz1);
if (this._worker == null) {
this._dispatch.call("initEnd", this);
diff --git a/src/graphviz.js b/src/graphviz.js
index 97650ec..bc3b68f 100644
--- a/src/graphviz.js
+++ b/src/graphviz.js
@@ -49,7 +49,7 @@ import {drawnNodeSelection} from "./drawNode.js";
import {workerCode} from "./workerCode.js";
import {sharedWorkerCode} from "./workerCode.js";
import {workerCodeBody} from "./workerCode.js";
-import {graphvizVersion as hpccWasmGraphvizVersion} from "@hpcc-js/wasm";
+import * as hpccWasm from "@hpcc-js/wasm";
export function Graphviz(selection, options) {
this._options = {
@@ -120,7 +120,7 @@ export function Graphviz(selection, options) {
this._workerPortClose = this._worker.terminate.bind(this._worker);
this._workerCallbacks = [];
} else {
- hpccWasmGraphvizVersion().then(((version) => {
+ hpccWasm.graphvizVersion().then(((version) => {
this._graphvizVersion = version;
}).bind(this));
} but got:
|
The above log is showing you pulling in the "node" version, which would be bad... Your using plain js so try this: |
You should also bump your rollup and plugins versions to latest and retest... |
Same problem:
I tried that and also upgraded all the babel dependencies, but it didn't help. |
As a temp workaround (as I have this same exercise ahead of me soon) - you could use the "alias" rollup plugin to resolve the correct source file:
|
I tried that with this patch: diff --git a/rollup.config.js b/rollup.config.js
index 44c950b..b143612 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,5 +1,6 @@
import resolve from '@rollup/plugin-node-resolve';
import babel from 'rollup-plugin-babel';
+import alias from '@rollup/plugin-alias';
export default [
{
@@ -37,6 +38,11 @@ export default [
(process.env.NODE_ENV === 'production' && babel({
exclude: ['node_modules/**'],
})),
+ alias({
+ entries: [
+ { find: '@hpcc-js/wasm', replacement: '@hpcc-js/wasm/dist/index.es6.js' },
+ ]
+ }),
],
}
]; but still got:
|
This is my full
|
I can reproduce this locally - but the only quick workaround I would have is to bundle my lib into yours (i.e. don't make it external). |
I tried |
My two cents:
|
@EAlexRojas thanks for the deep dive! FYI I am in the process of bumping versions to latest GraphViz and will revisit. FWIW dist/index.node.es6.js has other "esm" issues (it still referenced __dirname for example). |
@magjac, @EAlexRojas - I have just pushed a release and believe I have a clearer idea of this whole exports issue. In this release I have made minimal changes to the exports (and hope it will work for you), It is still a CommonJS by default package, but in the future I will switch to a esm by default package and clean up the naming conventions - but that will require a major version bump. |
@magjac did @GordonSmith change anything that helped ? |
I tested again by checking out the magjac/d3-graphviz#242 PR and using the newly released version of |
Sorry for the late reply. Yes, this problem is now gone. Thanks a lot. I have some other problems that I need to investigate further, but they might very well be my own. |
After having adopted type=module for d3-graphviz like D3 version 7 has, I get the following error when trying to
npm run test
for d3-graphviz using hpcc-js/wasm version 1.15.5 or later:Am I importing this incorrectly?
It works fine with version 1.15.4.
For background and details of the D3 change, see d3/d3#3469 and d3/d3#3501.
npm run build
works without problems.My system:
See magjac/d3-graphviz#242 for details.
The text was updated successfully, but these errors were encountered: