question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

canvg optionalDependency is installed on npm install

See original GitHub issue

Because it’s declared as dependency in package.json, canvg is installed and loads core-js from babel.

My project uses angular and angular-cli throws warnings about those, because angular-cli@>=v8.0.0 already handles core-js imports automatically.

WARNING in /Users/.../Desktop/Projects/.../.../node_modules/canvg/lib/index.es.js depends on '@babel/runtime-corejs3/regenerator'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

I’ve already opened an issue in canvg repo, but the problem is in fact in jspdf repo. https://github.com/canvg/canvg/issues/1253

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

20reactions
Fred723commented, Apr 28, 2021

For me I include this lines to my angular.json file :

"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    "allowedCommonJsDependencies": [
              "raf",
              "@babel/runtime-corejs3"
    ]
    // ...
  }
  // ...
},

It work for me and remove warnings

0reactions
HackbrettXXXcommented, Mar 4, 2021

@pete-mcwilliams what kind of dependency it is does AKAIK not matter for the build tools. They will create a chunk for the optional dependencies no matter what. However, since the optional dependencies are imported with dynamic imports, they will end up in separate chunks. These chunks will only be loaded when the respective code paths are executed.

Currently, the optional dependencies are declared as “optionalDependencies”. Making them “peerDependencies” will not really make a difference with npm 7+ (See e.g. https://github.blog/2021-02-02-npm-7-is-now-generally-available/#peer-dependencies), as they will get installed automatically, too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

canvg - npm
Start using canvg in your project by running `npm i canvg`. There are 193 other projects in the npm registry using canvg.
Read more >
A brand new website interface for an even better experience!
canvg optionalDependency is installed on npm install.
Read more >
npm install cannot find package.json from dependencies of ...
Installed n and tried different versions of nodejs/npm. I run the npm command inside the virtual machine Homestead which runs : Homestead 9.4.0 ......
Read more >
What are Optional Dependencies and when should we use them
Does npm install optional dependencies: The npm will automatically ... Installing Colors package as an optional dependency: As an example, ...
Read more >
What's the difference between `dependencies ... - Sentry
You can add dependencies to the optionalDependencies object by manually modifying the package.json file. Further Reading. Find the Installed Version of an npm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found