Skip to content

When using webpack 5, cannot import this package. #12

Open
@leokolezhuk

Description

@leokolezhuk

Upgraded to webpack 5.7 from 4.x and VueCli 5 from 4.

In an es module using the js-graph-algorithms package.
const jsgraphs = require('js-graph-algorithms');
In this case jsgraphs is an empty object and errors are raised like
Cannot read property Graph of undefined when trying to access jsgraphs.Graph.

This is caused by the way jsgraphs object is exported in src/jsgraphs.js
The code var module = module || {}; if(module) { module.exports = jsgraphs; }
seems to confuse webpack.

If I change this code to a normal commonjs export:
module.exports = jsgraphs;
without any extra logic, everything works normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions