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.

ivy-ngcc doesn't transform UMD bundles correctly

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by ivy-ngcc tool

Is this a regression?

no

Description

ivy-ngcc transforms UMD bundles incorrectly. In particular, the symbol Injectable ends up as undefined in the transformed UMD bundle.

    AriaDescriber.decorators = [
        { type: core.Injectable, args: [{ providedIn: 'root' },] },
    ];
    /** @nocollapse */
    AriaDescriber.ctorParameters = function () { return [
        { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
    ]; };
    /** @nocollapse */ AriaDescriber.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function AriaDescriber_Factory() { return new AriaDescriber(core.ɵɵinject(common.DOCUMENT)); }, token: AriaDescriber, providedIn: "root" });
    return AriaDescriber;

in node_modules/@angular/cdk/bundles/cdk-a11y.umd.js.__ivy_ngcc_bak gets transformed to

/*@__PURE__*/ ɵngcc0.ɵsetClassMetadata(AriaDescriber, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: undefined, decorators: [{
                type: Inject,
                args: [common.DOCUMENT]
            }] }]; }, { _document: [], describe: [], removeDescription: [], ngOnDestroy: [], _createMessageElement: [], _deleteMessageElement: [], _createMessagesContainer: [], _deleteMessagesContainer: [], _removeCdkDescribedByReferenceIds: [], _addMessageReference: [], _removeMessageReference: [], _isElementDescribedByMessage: [], _canBeDescribed: [], _isElementNode: [] });
    return AriaDescriber;

in node_modules/@angular/cdk/bundles/cdk-a11y.umd.js where type: Injectable, is undefined when run in the browser:

Uncaught ReferenceError: Injectable is not defined

I would guess it should be type: core.Injectable since core is the @angular/core UMD dependency.

@angular/cdk/bundles/cdk-a11y.umd.js is just an example but same thing happens in other bundles transformed.

🔬 Reproduction

Clone the wassim/ivy branch of my fork of angular-bazel-example (https://github.com/gregmagolan/angular-bazel-example/tree/wassim/ivy) and run yarn install. ivy-ngcc is run in the postinstall step and you can inspect the resulting transofmed bundles under node_modules.

https://stackblitz.com/...

🔥 Exception or Error





🌍 Your Environment

Angular Version:





Anything else relevant?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
petebacondarwincommented, Jul 3, 2019

I’ll take a look.

2reactions
gregmagolancommented, Aug 15, 2019

Confirmed that all the UMD bundles used by angular-bazel-example (including @ngrx which was using core.Injectable()) are correctly transformed now with ivy-ngcc from angular 9.0.0-next.2. Tested in https://github.com/angular/angular-bazel-example/pull/505. Thanks @petebacondarwin @JoostK!

@alexeagle @CaerusKaru ^^

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to generate Ivy enabled umd bundles - Stack Overflow
We we copy these bundles from the bundles folder within the npm package (e.g. node_modules/@angular/core/bundles/core. umd. js). We would like ...
Read more >
ng-packagr | Yarn - Package Manager
Compilation of libraries using VIew Engine is no longer supported. · We no longer generate UMD bundles. The below options which were used...
Read more >
Angular 12 in Depth - Sébastien Dubois
The Angular team has been working on Ivy (the new compilation ... What ngcc does is compile libraries that rely on View Engine...
Read more >
Guide Leading Up to Angular 9.0.0 Release - HUSPI
ivy : host-styling doesn't throw assert exception inside *ngFor. ngcc: cache correctly invalidated when moving/removing files/directories ...
Read more >
Leafletmodule Could Not Be Resolved to An Ngmodule Class In Ivy
If you're seeing errors first temporarily turn off Ivy in your tsconfig.json ... has not been processed correctly by ngcc or is not...
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