Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 90846e1

Browse files
author
Dimitar Tachev
authored
Merge pull request #959 from NativeScript/tachev/fix-ng-lazy-exception
fix: the Lazy transformer is not crashing the TypeScript program anymore
2 parents b00fcdd + 7d18cc1 commit 90846e1

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

‎demo/TypeScriptApp/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"mochawesome": "~3.1.2",
2929
"nativescript-dev-appium": "next",
3030
"nativescript-dev-webpack": "next",
31-
"typescript": "~3.2.2",
31+
"typescript": "~3.4.1",
3232
"node-sass": "^4.12.0"
3333
},
3434
"scripts": {

‎transformers/ns-replace-lazy-loader.spec.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,43 @@ describe("@ngtools/webpack transformers", () => {
4343
AppModule);
4444
export { AppModule };`
4545
},
46+
{
47+
name: "should add providers and NgModuleFactoryLoader when providers is missing and decomposition is used",
48+
rawAppModule: `
49+
import { NgModule } from "@angular/core";
50+
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
51+
import { AppComponent } from "./app.component";
52+
53+
const declarationsArray = [AppComponent];
54+
@NgModule({
55+
bootstrap: [
56+
AppComponent
57+
],
58+
imports: [
59+
NativeScriptModule
60+
],
61+
declarations: [
62+
...declarationsArray
63+
]
64+
})
65+
export class AppModule { }
66+
`,
67+
transformedAppModule: `
68+
import * as tslib_1 from "tslib"; import { NgModule } from "@angular/core";
69+
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
70+
import { AppComponent } from "./app.component";
71+
${NgLazyLoaderCode}
72+
const declarationsArray = [AppComponent];
73+
let AppModule = class AppModule { };
74+
AppModule = tslib_1.__decorate([ NgModule({
75+
bootstrap: [ AppComponent ],
76+
imports: [ NativeScriptModule ],
77+
declarations: [ ...declarationsArray ],
78+
providers: [{ provide: nsNgCoreImport_Generated.NgModuleFactoryLoader, useClass: NSLazyModulesLoader_Generated }] })
79+
],
80+
AppModule);
81+
export { AppModule };`
82+
},
4683
{
4784
name: "should add NgModuleFactoryLoader when the providers array is empty",
4885
rawAppModule: `

‎transformers/ns-replace-lazy-loader.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export function addArrayPropertyValueToNgModule(
9393

9494
// the target field is missing, we will insert it @NgModule({ otherProps })
9595
const lastConfigObjPropertyNode = ngModuleConfigObjectNode.properties[ngModuleConfigObjectNode.properties.length - 1];
96-
const newTargetPropertyNode = ts.createIdentifier(`${targetPropertyName}: [${newPropertyValue}]`);
96+
97+
const newTargetPropertyNode = ts.createPropertyAssignment(targetPropertyName, ts.createIdentifier(`[${newPropertyValue}]`));
9798

9899
return [
99100
new AddNodeOperation(sourceFile, lastConfigObjPropertyNode, undefined, newTargetPropertyNode),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /