stacktrace.js icon indicating copy to clipboard operation
stacktrace.js copied to clipboard

Angular 10 build warning - CommonJS or AMD dependencies

Open clabough opened this issue 4 years ago • 2 comments

Current Behavior

When using stacktrace-js in an Angular 10 project, the build process now displays the following errors:

WARNING in ...\Services\error-handler.service.ts depends on 'stacktrace-js'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in ...\node_modules\stacktrace-js\stacktrace.js depends on 'error-stack-parser'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in ...\node_modules\stacktrace-js\stacktrace.js depends on 'stacktrace-gps'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in ...\node_modules\stacktrace-js\stacktrace.js depends on 'stack-generator'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Steps to Reproduce (for bugs)

Import stacktrace-js like this in an Angular 10 project typescript file (e.g. service)

import * as StackTrace from "stacktrace-js";

Your Environment

  • stacktrace.js version: 2.0.2

clabough avatar Jul 06 '20 17:07 clabough

to supress this warning you could add an entry in your angular.json at path "projects/XXX/architect/build/options/allowedCommonJsDependencies"

"allowedCommonJsDependencies": [
    "stacktrace-js",
    "error-stack-parser",
    "stacktrace-gps",
    "stack-generator"
]

der-raist avatar Aug 11 '20 10:08 der-raist

@der-raist Thanks for the workaround. I saw that in the Angular docs in the links about the warning. I'm hoping that this package gets updated to ECMAScript modules.

clabough avatar Aug 19 '20 00:08 clabough