Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]);
ops.push(
// Insert an import of the {N} Angular static bootstrap module in the beginning of the file:
// import * as __NgCli_bootstrap_2 from "nativescript-angular/platform-static";
...insertStarImport(
sourceFile,
idPlatformNativeScript,
'nativescript-angular/platform-static',
firstNode,
true,
),
// Insert an import of the module factory in the beginning of the file:
// import * as __NgCli_bootstrap_1 from "./app.module.ngfactory";
...insertStarImport(
sourceFile,
idNgFactory,
factoryModulePath,
firstNode,
true,
),
// Replace the bootstrap call expression. For example:
// from: platformNativeScriptDynamic().bootstrapModule(AppModule);
// to: platformNativeScript().bootstrapModuleFactory(__NgCli_bootstrap_2.AppModuleNgFactory);
new ReplaceNodeOperation(sourceFile, bootstrapCallExpr, newBootstrapCallExpr),
);
});
newNsPlatformCallExpr.expression = ts.createPropertyAccess(idPlatformNativeScript, 'platformNativeScript');
newBootstrapPropAccessExpr.expression = newNsPlatformCallExpr;
// TODO: if (ivy)
// newBootstrapPropAccessExpr.name = ts.createIdentifier("bootstrapModuleFactory");
newBootstrapPropAccessExpr.name = ts.createIdentifier("bootstrapModule");
const newBootstrapCallExpr = ts.getMutableClone(bootstrapCallExpr);
newBootstrapCallExpr.expression = newBootstrapPropAccessExpr;
newBootstrapCallExpr.arguments = ts.createNodeArray([
ts.createPropertyAccess(idNgFactory, ts.createIdentifier(factoryClassName))
]);
ops.push(
// Insert an import of the {N} Angular static bootstrap module in the beginning of the file:
// import * as __NgCli_bootstrap_2 from "nativescript-angular/platform-static";
...insertStarImport(
sourceFile,
idPlatformNativeScript,
'nativescript-angular/platform-static',
firstNode,
true,
),
// Insert an import of the module factory in the beginning of the file:
// import * as __NgCli_bootstrap_1 from "./app.module.ngfactory";
...insertStarImport(
sourceFile,
idNgFactory,
factoryModulePath,
firstNode,
true,
),
const optionsStatement = ts.createVariableStatement(undefined, optionsDeclarationList);
const setHmrOptionsNode = ts.createIdentifier(getHmrOptionsCode(appModuleName, appModulePath));
const acceptHmrNode = ts.createIdentifier(getAcceptMainModuleCode(appModulePath));
const objectAssignNode = ts.createPropertyAccess(ts.createIdentifier("Object"), ts.createIdentifier("assign"));
const extendAppOptionsNode = ts.createCall(objectAssignNode, undefined, [currentAppOptionsInitializationNode, ts.createIdentifier(GeneratedDynamicAppOptions)]);
const newNsDynamicCallArgs = ts.createNodeArray([extendAppOptionsNode, ...nativeScriptPlatformCallNode.arguments.slice(1)]);
const nsPlatformPath = findNativeScriptPlatformPathInSource(mainFile);
const nsPlatformText = getExpressionName(nativeScriptPlatformCallNode.expression);
const newNsDynamicCallNode = ts.createCall(ts.createPropertyAccess(ts.createIdentifier(NsNgPlatformStarImport), ts.createIdentifier(nsPlatformText)), [], newNsDynamicCallArgs);
return [
...insertStarImport(mainFile, ts.createIdentifier(NsNgPlatformStarImport), nsPlatformPath, firstImportNode, true),
new AddNodeOperation(mainFile, lastImportNode, undefined, optionsStatement),
new AddNodeOperation(mainFile, lastImportNode, undefined, setHmrOptionsNode),
new AddNodeOperation(mainFile, lastImportNode, undefined, acceptHmrNode),
new ReplaceNodeOperation(mainFile, nativeScriptPlatformCallNode, newNsDynamicCallNode)
];
}