Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
// 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),
);
});
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)
];
}