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

Migrating Angular 9 to 11 #579

Open
jakeleveroni opened this issue Mar 31, 2021 · 0 comments
Open

Migrating Angular 9 to 11 #579

jakeleveroni opened this issue Mar 31, 2021 · 0 comments

Comments

@jakeleveroni
Copy link

jakeleveroni commented Mar 31, 2021

Environment: (ng version)

@angular-devkit/architect 0.1002.3
@angular-devkit/build-angular 0.1002.3
@angular-devkit/core 10.2.3
@angular-devkit/schematics 10.2.3
@angular/cdk 10.2.7
@angular/cli 10.2.3
@angular/fire 6.1.4
@angular/flex-layout 11.0.0-beta.33
@angular/material 9.0.0
@schematics/angular 10.2.3
@schematics/update 0.1002.3
rxjs 6.6.7
typescript 4.0.7

@dagonmetric/ng-cache 2.1.2

I am migrating an angular 9 project to angular 11 and in the process, I am seeing the following error while running ngcc in the package.json postinstall script.

Error: Error on worker #1: Error: Attempted to get members of a non-class: "class CacheLocalStorage {
        /**
         * @param {?=} cacheKeyPrefix
         */
        constructor(cacheKeyPrefix) {
            this.cacheKeyPrefix = cacheKeyPrefix || DEFAULT_STORAGE_CACHE_KEY_PREFIX;
        }
        /**
         * @return {?}
         */
        get enabled() {
            if (typeof this.enabledInternal === 'boolean') {
                return this.enabledInternal;
            }
            if (!localStorage) {
                this.enabledInternal = false;
                return this.enabledInternal;
            }
            try {
                /** @type {?} */
                let testKey = '__test__';
                /** @type {?} */
                let i = 1;
                while (localStorage.getItem(testKey)) {
                    testKey = `${testKey}${i}`;
                    i = i + 1;
                }
                localStorage.setItem(testKey, 'test');
                localStorage.removeItem(testKey);
                this.enabledInternal = true;
                return this.enabledInternal;
            }
            catch (e) {
                this.enabledInternal = false;
                return this.enabledInternal;
            }
        }
        /**
         * @return {?}
         */
        get name() {
            return 'localStorage';
        }
        /**
         * @return {?}
         */
        get keys() {
            if (!this.enabled) {
                return [];
            }
            return Object.keys(localStorage)
                .filter((/**
             * @param {?} key
             * @return {?}
             */
            (key) => !this.cacheKeyPrefix || key.startsWith(this.cacheKeyPrefix)))
                .map((/**
             * @param {?} key
             * @return {?}
             */
            (key) => {
                if (this.cacheKeyPrefix && key.length > this.cacheKeyPrefix.length) {
                    return key.substr(this.cacheKeyPrefix.length);
                }
                else {
                    return key;
                }
            }));
        }
        /**
         * @param {?} key
         * @param {?} value
         * @return {?}
         */
        setItem(key, value) {
            if (!this.enabled) {
                return false;
            }
            try {
                localStorage.setItem(`${this.cacheKeyPrefix}${key}`, JSON.stringify(value));
                return true;
            }
            catch (e) {
                return false;
            }
        }
        /**
         * @param {?} key
         * @return {?}
         */
        getItem(key) {
            if (!this.enabled) {
                return undefined;
            }
            /** @type {?} */
            const value = localStorage.getItem(`${this.cacheKeyPrefix}${key}`);
            if (value == null) {
                return undefined;
            }
            // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
            /** @type {?} */
            const obj = JSON.parse(value);
            if (typeof obj === 'object') {
                return (/** @type {?} */ (obj));
            }
            return undefined;
        }
        /**
         * @param {?} key
         * @return {?}
         */
        removeItem(key) {
            if (!this.enabled) {
                return;
            }
            localStorage.removeItem(`${this.cacheKeyPrefix}${key}`);
        }
        /**
         * @return {?}
         */
        clear() {
            if (!this.enabled) {
                return;
            }
            if (this.cacheKeyPrefix) {
                this.keys.forEach((/**
                 * @param {?} key
                 * @return {?}
                 */
                (key) => {
                    localStorage.removeItem(`${this.cacheKeyPrefix}${key}`);
                }));
            }
            else {
                localStorage.clear();
            }
        }
        /**
         * @return {?}
         */
        _getNgCacheVersion() {
            if (!this.enabled) {
                return undefined;
            }
            return localStorage.getItem(STORED_VERSION_KEY);
        }
        /**
         * @param {?} ver
         * @return {?}
         */
        _setNgCacheVersion(ver) {
            if (!this.enabled) {
                return;
            }
            localStorage.setItem(STORED_VERSION_KEY, ver);
        }
    }"
    at UmdReflectionHost.Esm2015ReflectionHost.getMembersOfClass (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:178:23)
    at DelegatingReflectionHost.getMembersOfClass (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/host/delegating_host.js:103:34)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/analysis/module_with_providers_analyzer.js:77:32
    at Map.forEach (<anonymous>)
    at ModuleWithProvidersAnalyzer.getModuleWithProvidersFunctions (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/analysis/module_with_providers_analyzer.js:72:21)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/analysis/module_with_providers_analyzer.js:39:33
    at Array.forEach (<anonymous>)
    at ModuleWithProvidersAnalyzer.analyzeProgram (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/analysis/module_with_providers_analyzer.js:38:23)
    at Transformer.analyzeProgram (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/packages/transformer.js:133:45)
    at Transformer.transform (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/packages/transformer.js:76:27)
    at ClusterMaster.onWorkerMessage (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:195:27)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:55:95
    at ClusterMaster.<anonymous> (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:293:57)
    at step (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:143:27)
    at Object.next (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:124:57)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:113:16)
    at EventEmitter.<anonymous> (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:287:32)
    at EventEmitter.emit (events.js:210:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
jacobleveroni@Jacobs-MacBook-Pro Elektrowhip-Web % (node:23435) UnhandledPromiseRejectionWarning: Error: write EPIPE
    at process.target._send (internal/child_process.js:806:20)
    at process.target.send (internal/child_process.js:676:19)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/utils.js:51:21
    at new Promise (<anonymous>)
    at Object.exports.sendMessageToMaster (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/utils.js:46:16)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/worker.js:104:66
    at step (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:143:27)
    at Object.throw (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:124:57)
    at rejected (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:115:69)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:23435) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23435) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:23436) UnhandledPromiseRejectionWarning: Error: write EPIPE
    at process.target._send (internal/child_process.js:806:20)
    at process.target.send (internal/child_process.js:676:19)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/utils.js:51:21
    at new Promise (<anonymous>)
    at Object.exports.sendMessageToMaster (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/utils.js:46:16)
    at /Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/worker.js:104:66
    at step (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:143:27)
    at Object.throw (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:124:57)
    at rejected (/Users/jacobleveroni/Projects/personal/Elektrowhip-Web/node_modules/@angular/compiler-cli/node_modules/tslib/tslib.js:115:69)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Really not sure if it's something in the library or if I have a bad configuration. I've spent the last 3 hours looking around for answers and it seems like this has happened with other libs but I don't see any search results with this error for this package. I think the error happens when the npm package isn't an es2015 module but on checking the node_modules folder I see /@dagonmetric/fesm2015 which I thought would be interchangeable with es2015 modules. Please let me know if this is something on my end, ill happily close the issue.

Not sure if this has anything to do with it but I was looking to upgrade the zone.js version as well and I saw this on their npm page:

Starting with v0.11.1, Zone.js follows the Angular Package Format. Therefore the new Zone.js file layout is:

bundles: ES5 bundle in UMD format.
fesm2015: ES5 bundle in ESM format.
dist: ES5 bundle in UMD format. This directory is present to keep backward compatibility.

I see the bundles and fesm2015 directories in the @dagonmetric/ng-cache directory but I don't see a dist directory. Is /dist a required property? Seems like the /bundles and /fesm2015 should be enough but I'm unsure.

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