Skip to content

Custom typescript transformer source file changes are not applied #16250

@JulianH

Description

@JulianH

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the custom transformer worked in angular 7

Description

We are using a custom typescript transformer which is replacing provider tokens in component decorators to enable custom implementations of services depending on the build configuration.

Example:

@Component({
    selector: 'booking-editor',
    template: '...',
    providers: [
        BookingUiService
    ]
})
export class BookingEditorComponent {
  constrcutor(uiService: BookingUiService){}
}

which will be transformed to the following:

@Component({
    selector: 'booking-editor',
    template: '...',
    providers: [
      { provide: BookingUiService, useClass: CustomBookingUiService }
    ]
})
export class BookingEditorComponent {
  constrcutor(uiService: BookingUiService){}
}

This custom transformer we add to the beginning of _transformers array of the AngularCompilerPlugin.

Until the upgrade from Angular 7 to Angular 8, this worked like a charm but now on runtime, the custom implementation is not present, when doing the build with AOT enabled, the JIT build does use the transformed version.

If i dump the modified ts.SourceFile, i can see the applied change as well as another already applied change, the importFactory transformer adds export { ɵ0 }; to the sourceFile, even if i add the custom transformer to the beginning of the _transformers list?

🌍 Your Environment


     _                      _                 ____ _     ___ 
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | | 
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | | 
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.17
Node: 10.13.0
OS: win32 x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms     
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------     
@angular-devkit/architect         0.803.17
@angular-devkit/build-angular     0.803.17
@angular-devkit/build-optimizer   0.803.17
@angular-devkit/build-webpack     0.803.17
@angular-devkit/core              8.3.17
@angular-devkit/schematics        8.3.17
@angular/cli                      8.3.17
@ngtools/webpack                  8.3.17
@schematics/angular               8.3.17
@schematics/update                0.803.17
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions