我在用延迟加载的模块编译NS 6代码共享项目时遇到问题。
我以这种方式将其添加到路线中:
{ path: 'onboarding', loadChildren: './onboarding/onboarding.module#OnboardingModule' },
这在Angular CLI项目和非代码共享NS项目中一直有效。
但是,在这种情况下,我会遇到此错误:
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: /Users/denny/workspaceNW/gesso-app/src/app/onboarding/onboarding.module.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/denny/workspaceNW/gesso-app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:838:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/denny/workspaceNW/gesso-app/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.js:28:26)
at plugin.done.then (/Users/denny/workspaceNW/gesso-app/node_modules/@ngtools/webpack/src/loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ../$$_lazy_route_resource lazy namespace object ./onboarding/onboarding.module
@ ../node_modules/@angular/core/fesm5/core.js
@ ./main.tns.ts
我可以通过在tsconfig.tns.json
的“文件”部分添加模块文件来修复它,但是我想知道这是否是正确的方法:
"files": [
"src/main.tns.ts",
"src/app/onboarding/onboarding.module.ts"
]
有人遇到过同样的问题吗?我正在使用最新版本的Nativescript:
tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.0.3 version and is up to date.
✔ Component tns-core-modules has 6.0.7 version and is up to date.
✔ Component tns-android has 6.0.2 version and is up to date.
✔ Component tns-ios has 6.0.2 version and is up to date.
我还尝试将nativescript-dev-webpack
软件包更新为~1.1.1
,结果相同。