This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/angular/angular-cli/blob/bd040bd4d6d2f69b49cf7e343829027e5dbfc73d/packages/ngtools/webpack/src/ivy/transformation.ts#L14-L34 | |
| export function createAotTransformers( | |
| builder: ts.BuilderProgram, | |
| options: { emitClassMetadata?: boolean; emitNgModuleScope?: boolean }, | |
| ): ts.CustomTransformers { | |
| const getTypeChecker = () => builder.getProgram().getTypeChecker(); | |
| const transformers: ts.CustomTransformers = { | |
| before: [replaceBootstrap(getTypeChecker)], | |
| after: [], | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default (config: webpack.Configuration) => { | |
| if (config.mode === 'production') { | |
| const transformation = require('@ngtools/webpack/src/ivy/transformation'); | |
| const createAotTransformers = transformation.createAotTransformers; | |
| transformation.createAotTransformers = function () { | |
| const transformers: ts.CustomTransformers = createAotTransformers(...arguments); | |
| transformers.before!.push(replaceIsPlatformCallsTransformerFactory); | |
| return transformers; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArticleComponent { | |
| constructor(t, e) { | |
| this.article$ = t.params.pipe( | |
| Object(i.a)(t => { | |
| const o = Object(c.d)(`article:${t.id}`); | |
| return e.get(o, null); | |
| }), | |
| ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ɵɵdirectiveInject as directiveInject } from '@angular/core'; | |
| export class ArticleComponent { | |
| article$: Observable<Article>; | |
| constructor(route: ActivatedRoute, transferState: TransferState) { | |
| if (isPlatformServer(directiveInject(PLATFORM_ID))) { | |
| const meta = directiveInject(Meta); | |
| const http = directiveInject(HttpClient); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArticleComponent { | |
| constructor(t, e, o, n, r) { | |
| this.article$ = e.params.pipe( | |
| Object(l.a)(t => { | |
| const e = Object(i.e)(`article:${t.id}`); | |
| return r.get(e, null); | |
| }), | |
| ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as ts from 'typescript'; | |
| const replaceIsPlatformCallsTransformerFactory: ts.TransformerFactory<ts.SourceFile> = ( | |
| context: ts.TransformationContext, | |
| ) => (sourceFile: ts.SourceFile) => { | |
| const visitCallExpression: ts.Visitor = (node: ts.Node) => { | |
| if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) { | |
| // If it's a call expression like `isPlatformServer(platformId)`. | |
| if (node.expression.escapedText === 'isPlatformServer') { | |
| return ts.factory.createFalse(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as ts from 'typescript'; | |
| import * as webpack from 'webpack'; | |
| import { AngularCompilerPlugin, PLATFORM } from '@ngtools/webpack'; | |
| const replaceIsPlatformCallsTransformerFactory: ts.TransformerFactory<ts.SourceFile> = ( | |
| context: ts.TransformationContext, | |
| ) => (sourceFile: ts.SourceFile) => { | |
| const visitCallExpression: ts.Visitor = (node: ts.Node) => { | |
| if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) { | |
| // If it's a call expression like `isPlatformServer(platformId)`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as ts from 'typescript'; | |
| import { PLATFORM } from '@ngtools/webpack'; | |
| const replaceIsPlatformCallsTransformerFactory: ts.TransformerFactory<ts.SourceFile> = ( | |
| context: ts.TransformationContext, | |
| ) => (sourceFile: ts.SourceFile) => { | |
| const visitCallExpression: ts.Visitor = (node: ts.Node) => { | |
| if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) { | |
| // If it's a call expression like `isPlatformServer(platformId)`. | |
| if (node.expression.escapedText === 'isPlatformServer') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as ts from 'typescript'; | |
| const transformerFactory: ts.TransformerFactory<ts.SourceFile> = ( | |
| context: ts.TransformationContext, | |
| ) => { | |
| return (sourceFile: ts.SourceFile) => { | |
| const someVisitFunction: ts.Visitor = (node: ts.Node) => { | |
| if (ts.isFunctionDeclaration(node)) { | |
| console.log('Whooah, it is a function declaration!'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as webpack from 'webpack'; | |
| export default (config: webpack.Configuration) => { | |
| return config; | |
| }; |
NewerOlder