Skip to content
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

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #191

Open
Markus-x64 opened this issue Jul 26, 2024 · 0 comments

Comments

@Markus-x64
Copy link

Issue

I recently updated web-ifc-three to the latest version hoping to resolve this critical dependency warning without luck:

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
 @ ./node_modules/web-ifc-three/IFCLoader.js 1:0-34 2:0-233 112:7-15 113:7-24 188:68-93 661:10-26 667:10-43 673:10-35 679:10-34 685:10-29 812:70-80 883:62-72 1099:74-85 1964:7-15 1965:7-24 2386:15-28 2462:27-40 2598:27-40

Delving deeper, I discovered that the issue originates from web-ifc. There are already two issues on the web-ifc repository discussing this problem, and it was resolved in May 2023 with version 0.0.41.

  • Issue #376 where the critical dependency was addressed.
  • Issue #493 discussing the warning in the context of web-ifc-three, pointing out that it still uses an old version of web-ifc.

After some investigation, I found that both [email protected] and [email protected] from the Node Package Manager still rely on web-ifc@^0.0.39, which causes the critical dependency warning.

Here on the web-ifc-three GitHub repository, the package-lock.json for the main branch (version 0.0.125) specifies:

"node_modules/web-ifc": {
  "version": "0.0.41",
  "resolved": "https://registry.npmjs.org/web-ifc/-/web-ifc-0.0.41.tgz",
  "integrity": "sha512-rSucJcwWDw6jrfxPu77jVcpCU6otMd3qWYsH+6L3nr5jJVr4S1O5rAZfkKNlpBM5m0mDvSHU3DzXm9SXfGqBkw=="
}

Steps Taken to Resolve the Issue:

I tried various tricks with npm, but I wasn't able to override web-ifc version 0.0.39.

Finally, I resolved the critical dependency warnings by forcing web-ifc version 0.0.41 through modifying my package-lock.json. Here are the steps I took:

  1. Start with a clean package.json:
    {
      "name": "your-project-name",
      "version": "1.0.0",
      "dependencies": {
        "web-ifc-three": "0.0.125"
      }
    }
  2. Remove existing node_modules and package-lock.json:
    rm -rf node_modules package-lock.json
  3. Run npm install:
    npm install
  4. Install [email protected] to obtain the "resolved" and "integrity" values. Then uninstall it and repeated steps 2 and 3:
    npm install [email protected] --save
    npm uninstall web-ifc
  5. Open package-lock.json and manually update all occurrences of web-ifc to version 0.0.41:
    "web-ifc": {
      "version": "0.0.41",
      "resolved": "https://registry.npmjs.org/web-ifc/-/web-ifc-0.0.41.tgz",
      "integrity": "sha512-..."
    }
  6. Reinstall dependencies:
    npm install

Request

Could you update the web-ifc dependency in web-ifc-three to ^0.0.41 in the npm package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant