Coder Social home page Coder Social logo

Comments (4)

mdaines avatar mdaines commented on June 8, 2024 1

In what environment and situation are you seeing this? I think the referenced commit should address it, but knowing that might help prevent similar mistakes in the future.

from viz-js.

mdaines avatar mdaines commented on June 8, 2024 1

v2.1.2-pre.1 (also on NPM) includes a fix for this.

It looks like you're importing the render script file. You can certainly do that, and I've added an example showing that technique. It fails to build with v2.1.1 (in the way you're seeing) and works with v2.1.2-pre.1.

However, if possible I would recommend something like this example, where file-loader imports just the URL of the render script file using the ".render.js" suffix and then passes that to the Viz constructor:

https://github.com/mdaines/viz-examples/blob/0a9f7100aa73ff6f4ec4b4e150a842033a058ade/webpack/index.js#L2-L4

This avoids having Webpack actually look at the contents of the render script file, which is pretty big and will slow down the build.

from viz-js.

zetaraku avatar zetaraku commented on June 8, 2024

I was using viz.js for my project with webpack, and it gave me the error message (shown below) when packing my project.

ERROR in ./node_modules/viz.js/full.render.js 68:10
Module parse failed: Identifier 'error' has already been declared (68:10)
You may need an appropriate loader to handle this file type.
|       postMessage({ id: id, result: result });
|     } catch (error) {
>       var error = error instanceof Error
|         ? { message: error.message, fileName: error.fileName, lineNumber: error.lineNumber }
|         : { message: error.toString() };
 @ ./src/js/main/index.js 30:0-52 46:22-28 46:30-36
 @ ./src/index.js

from viz-js.

zetaraku avatar zetaraku commented on June 8, 2024

Thanks for the quick fix and the suggestion and explanation of using file-loader! :D
My project now works fine!

Since the render script is a special case for the .js files, I use:
import vizjsWorkerURL from 'file-loader!viz.js/full.render.js';
to import it instead. :)

from viz-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.