ng-packagr / ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build with --watch option produces an empty module

somq opened this issue · comments

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

Transpiled library module is empty when building the lib with the --watch option with the latest versions (16.x)

How To Reproduce

  1. Bootstrap an app and a lib
  2. Run the build with the --watch option (i.e. ng build ngx-mylib --configuration development --watch)
  3. Edit a lib file such as the generated service
  4. The transpiled module appears to be empty

Example

In dist/ngx-mylib/lib/ngx-mylib.module.d.ts

export declare class NgxMyLibModule {
}
//# sourceMappingURL=ngx-mylib.module.d.ts.map

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            16.2.0-next.1
@angular/compiler:     16.1.7
rollup:                3.26.2
typescript:            5.1.6

Additional

Tried all v16 versions and finally downgraded to v15 which actually works.
Not 100% sure this issue belongs here, apologies if it's not the case 🙏

Having the same issue compiling a library.

  • Using partial and full compilation triggers the same issue.
  • Enabling or disabling the cache triggers the same issue.

I do not have any circular dependencies in my code.
The error is not triggered every time, sometimes the emitted code will be fine.

The way i can reproduce the error the most easily is when :

  • i introduce an error in the code which makes the library recompile with an error,
  • i fix the error, making the library compile well in appearance, but the ɵfac, ɵmod and ɵinjare missing from the code.

angular/angular-cli#25706 has provided a repro:

  1. Get the project from https://github.com/t0m-4/lib-build-watch/tree/main
  2. Run 'ng build my-lib --watch --configuration development'.
  3. Check the file my-workspace\dist\my-lib\ui\form\form.module.d.ts
  4. Update the file my-workspace\projects\my-lib\ui\form\models\form-type.model.ts (for exemple set another value for the enum value 'Other'
  5. Check again the file my-workspace\dist\my-lib\ui\form\form.module.d.ts, some imports disappeared.
commented

Than you @JeanMeche i didn't find this ticket when I created mine

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.