How to use the @ngtools/webpack/src/transformers.AddNodeOperation function in @ngtools/webpack

To help you get started, we’ve selected a few @ngtools/webpack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / nativescript-dev-webpack / transformers / ns-support-hmr-ng.ts View on Github external
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)
    ];
}
github NativeScript / nativescript-dev-webpack / transformers / ns-support-hmr-ng.ts View on Github external
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)
    ];
}
github NativeScript / nativescript-dev-webpack / transformers / ns-support-hmr-ng.ts View on Github external
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)
    ];
}