微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NativeScript-升级Angular 9后无法使用nativescript-ui-sidedrawer插件进行编译

如何解决NativeScript-升级Angular 9后无法使用nativescript-ui-sidedrawer插件进行编译

我有一个使用Angular 8.2.0和NS 6.4.1制作的NativeScript应用程序。我的项目中包含此插件https://github.com/ProgressNS/nativescript-ui-feedback nativescript-ui-sidedrawer ,它运行良好,可以编译该项目。

在这里遵循了这些指示:https://github.com/NativeScript/nativescript-angular/wiki/Updating-and-developing-for-@nativescript-angular-v9-with-Ivy-or-without 要将我的项目更新为Angular 9。

运行此命令时出现错误 tns build android --env.aot

错误

tns build android --env.aot 
Preparing project...
Compiling nativescript-ui-sidedrawer-angular : module as esm5
Warning: Invalid constructor parameter decorator in /Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/nativescript-ui-sidedrawer/angular/fesm2015/nativescript-ui-sidedrawer-angular.js:
 () => [
    { type: ElementRef,decorators: [{ type: Inject,args: [ElementRef,] }] },{ type: ViewContainerRef,args: [ViewContainerRef,] }] }
]
Error: Error on worker #1: Error: The given rootPath undefined is not a file of the program.
    at getRootFileOrFail (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:2103:19)
    at Esm5ReflectionHost.Esm2015ReflectionHost.computePublicDtsDeclarationMap (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:1500:27)
    at Esm5ReflectionHost.Esm2015ReflectionHost.getDtsDeclaration (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:523:53)
    at DelegatingReflectionHost.getDtsDeclaration (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/host/delegating_host.js:60:34)
    at Object.wrapTypeReference (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/util.js:462:34)
    at Object.extractDirectiveMetadata (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/directive.js:236:27)
    at ComponentDecoratorHandler.analyze (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:143:47)
    at NgccTraitCompiler.TraitCompiler.analyzeTrait (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:345:40)
    at analyze (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:297:58)
    at _loop_1 (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:319:21)
    at ClusterMaster.onWorkerMessage (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:194:27)
    at /Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:54:95
    at ClusterMaster.<anonymous> (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:292:57)
    at step (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tslib/tslib.js:122:57)
    at /Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tslib/tslib.js:115:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tslib/tslib.js:111:16)
    at EventEmitter.<anonymous> (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:286:32)
    at EventEmitter.emit (events.js:198:13)
/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/bin/cli.js:453
                throw err;
                ^

Error: NGCC Failed.
    at NgccProcessor.process (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@ngtools/webpack/src/ngcc_processor.js:76:19)
    at compiler.hooks.environment.tap (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:579:31)
    at SyncHook.eval [as call] (eval at create (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tapable/lib/HookCodeFactory.js:19:10),<anonymous>:9:1)
    at SyncHook.lazyCompileHook (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/tapable/lib/Hook.js:154:20)
    at webpack (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack/lib/webpack.js:55:30)
    at processOptions (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/bin/cli.js:441:16)
    at yargs.parse (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/bin/cli.js:536:3)
    at Object.parse (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/node_modules/yargs/yargs.js:567:18)
    at /Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/bin/cli.js:219:8
    at Object.<anonymous> (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack-cli/bin/cli.js:538:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/aubrey/Documents/Repos/SelfServiceApp2/node_modules/webpack/bin/webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJscore (internal/bootstrap/node.js:623:3)
Executing webpack Failed with exit code 1.

这是我的环境信息:

package.json

{
    "nativescript": {
        "id": "org.nativescript.MyApp","tns-ios": {
            "version": "6.5.2"
        },"tns-android": {
            "version": "6.5.3"
        }
    },"description": "NativeScript Application","license": "SEE LICENSE IN <your-license-filename>","repository": "<fill-your-repository-here>","dependencies": {
        "@angular/animations": "~9.1.12","@angular/common": "~9.1.12","@angular/compiler": "~9.1.12","@angular/compiler-cli": "~9.1.12","@angular/core": "~9.1.12","@angular/forms": "~9.1.12","@angular/platform-browser": "~9.1.12","@angular/platform-browser-dynamic": "~9.1.12","@angular/router": "~9.1.12","@danvick/ngx-translate-nativescript-loader": "^2.0.0","@nativescript/angular": "^9.0.0","@nativescript/core": "^6.5.18","@nativescript/theme": "^2.2.1","@ngx-translate/core": "^12.1.2","@ngx-translate/http-loader": "^4.0.0","@nstudio/nativescript-loading-indicator": "^3.0.3","@schematics/angular": "^8.3.18","autobind-decorator": "^2.4.0","moment": "^2.24.0","nativescript-appversion": "^1.4.4","nativescript-Feedback": "^1.3.12","nativescript-inappbrowser": "^2.2.0","nativescript-iqkeyboardmanager": "^1.5.1","nativescript-store-update": "^1.0.2","nativescript-theme-core": "~1.0.6","nativescript-ui-dataform": "^6.1.0","nativescript-ui-sidedrawer": "^9.0.3","nativescript-unit-test-runner": "^0.7.0","nativescript-urlhandler": "^1.3.0","reflect-Metadata": "~0.1.12","rxjs": "^6.5.5","tns-core-modules": "^6.4.1","zone.js": "~0.10.3"
    },"devDependencies": {
        "@angular/cli": "^9.0.5","@nativescript/schematics": "^1.0.0","@ngtools/webpack": "^9.1.12","@types/jasmine": "3.5.6","@types/jest": "^24.0.20","@types/mocha": "^5.2.7","jasmine-marbles": "^0.6.0","karma": "4.4.1","karma-jasmine": "3.1.1","karma-nativescript-launcher": "0.4.0","karma-typescript": "^4.1.1","karma-typescript-angular2-transform": "^4.1.1","karma-webpack": "3.0.5","nativescript-dev-webpack": "^1.5.1","node-sass": "^4.12.0","sass": "^1.23.7","sass-loader": "^8.0.0","terser-webpack-plugin": "^4.2.1","tns-platform-declarations": "^6.4.1","typescript": "~3.8.3","webpack": "^4.44.1"
    },"peerDependencies": {
        "tslib": "1.10.0"
    },"gitHead": "1964ea9e8ca1a0518e0d6370781eedcf6c23db42","readme": "NativeScript Application","scripts": {
        "ngcc": "ngcc --properties es2015 module main --first-only","postinstall": "npm run ngcc"
    }
}

ngcc.config.js

module.exports = {
    "packages": {
        "@nativescript/angular": {
            entryPoints: {
                ".": {
                    override: {
                        main: "./index.js",typings: "./index.d.ts",},ignoreMissingDependencies: true,}
            },ignorableDeepImportMatchers: [
                /zone.js\//,/tns-core-modules\//,/@nativescript\/core\//
            ]
        },"nativescript-localize": {
            entryPoints: {
                ".": {
                    override: {
                        main: "./angular.js",typings: "./angular.d.ts",ignorableDeepImportMatchers: [
                /@nativescript\/core\//
            ]
        },"nativescript-datetimepicker": {
            entryPoints: {
                ".": {
                    override: {
                        main: "./index.js","angular": {
                    override: {
                        main: "./index.js",ignorableDeepImportMatchers: [
                /tns-core-modules\//,/@nativescript\/core\//,/@nativescript\/angular\//
            ]
        },"nativescript-ui-sidedrawer": {
            entryPoints: {
                "angular": {
                    override: {
                        main: "./side-drawer-directives.js",typings: "./side-drawer-directives.d.ts","nativescript-ui-listview": {
            entryPoints: {
                "angular": {
                    override: {
                        main: "./listview-directives.js",typings: "./listview-directives.d.ts",/@nativescript\/angular\//
            ]
        }
    }
}

tsconfig

{
    "compilerOptions": {
        "module": "commonjs","target": "es5","experimentalDecorators": true,"emitDecoratorMetadata": true,"noEmitHelpers": true,"noEmitOnError": true,"skipLibCheck": true,"lib": [
            "es2017","es6","dom","es2018.promise"
        ],"baseUrl": ".","paths": {
            "~/*": [
                "src/*"
            ]
        }
    },"angularCompilerOptions": {
        "enableIvy": true
    },"include": [
        "reference.d.ts"
    ],"files": [
        "./src/main.ts"
    ],"exclude": [
        "node_modules","platforms","**/*.aot","e2e"
    ]
}

tsconfig.tns.json

{
    "extends": "./tsconfig","compilerOptions": {
        "module": "ESNext","moduleResolution": "node"
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。