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

Warning In angular 10 #92

Open
yeshwanthmn opened this issue Aug 21, 2020 · 13 comments · May be fixed by apexcharts/apexcharts.js#4691
Open

Warning In angular 10 #92

yeshwanthmn opened this issue Aug 21, 2020 · 13 comments · May be fixed by apexcharts/apexcharts.js#4691

Comments

@yeshwanthmn
Copy link

When I start the angular 10 app I am getting below mentioned warning
ng-apexcharts__ivy_ngcc__fesm2015 g-apexcharts.js depends on 'apexcharts'. CommonJS or AMD dependencies can cause optimization bailouts.

@IsaacSomething
Copy link

This issue can be removed by adding "apexcharts" to the allowedCommonJsDependencies in your angular.json file

"architect": {
        "build": {
             "options": {
                  "allowedCommonJsDependencies":

@j-a-h-i-r
Copy link

@IsaacSomething, this will only suppress the warning and not actually fix the issue causing this warning.

@stefanolsenn
Copy link

That's because this lib is depending on the CommonJS module instead of the ESM (surprise)

I see that they changed the import from the ESM to the min version, and later removed the deep import to get rid of the ivy warning. See #79
@junedchhipa Maybe you could clarify a bit on that decision? I would rather silence the deep import warning, than my bundle size increases.

@junedchhipa
Copy link
Contributor

@stefanolsenn The ESM module caused issues in all libraries (react/vue/angular) because of the way it was generated.
I haven't found a fix for that and hence it was removed.

@stefanolsenn
Copy link

What issues are we talking about here?

@junedchhipa
Copy link
Contributor

junedchhipa commented Dec 28, 2020

There is a 3rd party library called svg.js being bundled inside.
Instead of the main ApexCharts being exposed, SVG was exposed from the ESM module.

@stashaway
Copy link

Any news on this? Seems like the svg.js being exposed is an issue that could be solved. As Angular moves pretty fast, it would be great to not have optimization bailouts in the current versions.

@MNorgren
Copy link

Any updates on this? apexcharts is 25% of my apps bundle size.

@AmirSavand
Copy link

Any update on this? Is this a time-consuming bug to fix?

@AmirSavand
Copy link

AmirSavand commented Jul 26, 2022

@VitorBarleta
Copy link

Any update on this issue? I just updated from Angular 13 (everything was ok) to Angular 14 and this warning started to appear.

@rtpHarry
Copy link

rtpHarry commented Dec 3, 2023

Seeing this as well with Angular 16 :/

@jeroen1602
Copy link

jeroen1602 commented Sep 4, 2024

I found that manually adding:

"es2020": "dist/apexcharts.esm.js",

to the package.json of the apexchart package makes it so that the Angular compiler can find the correct ESM version.

So to get this fixed we would need to get this field added to the apexcharts library.

Here is the order that Angular uses to find the entry point in a package:
https://github.com/angular/angular-cli/blob/d6a34034d7489c09753090642ade4c606cd98ece/packages/angular/build/src/tools/esbuild/application-code-bundle.ts#L50

EDIT: It does come with this warning if you run ng build --verbose. But I did a quick test and everything seems to work just fine, so I think it can be ignored.

● [DEBUG] The CommonJS "module" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm]

    node_modules/apexcharts/dist/apexcharts.esm.js:16997:111:
      16997 │ }) : "object" === ("undefined" == typeof exports ? "undefined" : i(exports)) && "undefined" != typeof module ? module.exports = Rt.document ? Ht(Rt, Rt.document) : function (t) {
            ╵                                                                                                                ~~~~~~

  This file is considered to be an ECMAScript module because of the "export" keyword here:

    node_modules/apexcharts/dist/apexcharts.esm.js:18423:0:
      18423 │ export { _t as default };
            ╵ ~~~~~~
``

@jeroen1602 jeroen1602 linked a pull request Sep 9, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.