Skip to content

angular-compiler: Cannot read properties of undefined (reading 'startName') #52540

Closed

Description

@zip-fa

Command

build, serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Hi.
After updating to rc3 my project is not going to compile/build. Also my build process in dev server is never-ending and doesn't give me error.
Also i see these errors, which are not true, because they are persist in my tsconfig and everything seems to be building on rc2:

File 'server.ts' is missing from the TypeScript compilation
File 'src\main.server.ts' is missing from the TypeScript compilation.

I ran schematics to migrate to new control flow, maybe this is related.
Still need to review 400 components and will give you repro.

Minimal Reproduction

ng serve / ng build

Exception or Error

X [ERROR] Cannot read properties of undefined (reading 'startName') [plugin angular-compiler]

  This error came from the "onStart" callback registered here:

    node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:89:18:
      89 │             build.onStart(async () => {
         ╵                   ~~~~~~~

    at setup (C:\node_modules\@angular-devkit\build-angular\src\tools\esbuild\angular\compiler-plugin.js:89:19)
    at async handlePlugins (C:\node_modules\esbuild\lib\main.js:1340:9)


X [ERROR] File 'src\main.ts' is missing from the TypeScript compilation. [plugin angular-compiler]

  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.


X [ERROR] File 'src\main.server.ts' is missing from the TypeScript compilation. [plugin angular-compiler]

  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.


X [ERROR] File 'server.ts' is missing from the TypeScript compilation. [plugin angular-compiler]

  Ensure the file is part of the TypeScript program via the 'files' or 'include' property.


Application bundle generation failed. [17.522 seconds]

Your Environment

Angular CLI: 17.0.0-rc.3
Node: 18.18.1
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 17.0.0-rc.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-rc.3
@angular-devkit/build-angular   17.0.0-rc.3
@angular-devkit/core            17.0.0-rc.3
@angular-devkit/schematics      17.0.0-rc.3
@angular/cli                    17.0.0-rc.3
@angular/ssr                    17.0.0-rc.3
@schematics/angular             17.0.0-rc.3
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.0

Anything else relevant?

No response

Activity

  1. alan-agius4 commented on Nov 6, 2023

    @alan-agius4
    Contributor

    This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

    You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

    This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

  2. zip-fa commented on Nov 6, 2023

    @zip-fa
    Author

    @alan-agius4 i can confirm that this exists on rc2, rc1 and rc2.
    Also i don't have any output on esbuild-builder/application builder, but i receive bunch of errors on good-old browser builder.
    I will need more time to investigate what exactly caused this, because i tried to migrate my whole project, which consists of ~400 components

  3. zip-fa commented on Nov 6, 2023

    @zip-fa
    Author
  4. clydin commented on Nov 6, 2023

    @clydin
    Member

    That appears to be a defect in Web Containers (used inside StackBlitz).
    You should be able to workaround the bug by changing the package.json start script to:

    "start": "NG_BUILD_PARALLEL_TS=0 ng serve",
    

    EDIT: This comment was related to the previous comment's issue (#52540) and not the issue reported originally.

  5. zip-fa commented on Nov 6, 2023

    @zip-fa
    Author

    I receive same error on my Windows PC. Will try to reproduce.

  6. zip-fa commented on Nov 6, 2023

    @zip-fa
    Author

    I managed to reproduce what caused this behavior.

    Take a look at this:
    https://github.com/zip-fa/ng17-i18n-control-flow-bug

    control flow inside i18n block leads to never-ending build with esbuild-based builders on Windows system, while with browser builder it throws this error:

    ./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
    Error: Cannot read properties of undefined (reading 'startName')
    
  7. zip-fa commented on Nov 6, 2023

    @zip-fa
    Author

    @alan-agius4 that happened after automatic migration from *ngIf to control flow. This is the code, which was working before:

    <button class="button button_block button_submit" type="button">
            <div class="button__text" i18n="@@payment.crypto.charge">Пополнить<span class="button__currency" *ngIf="cryptoAmount && cryptoAmount > 0"> на {{ cryptoAmount }} {{ currentMethod.currencyCode | uppercase }}</span></div>
          </button>
    
  8. alan-agius4 commented on Nov 6, 2023

    @alan-agius4
    Contributor

    Transfer to the FW repo since this is not caused by the CLI.

  9. zip-fa commented on Nov 7, 2023

    @zip-fa
    Author

    Transfer to the FW repo since this is not caused by the CLI.

    But with esbuild-builders there is no visible errors on Windows PC, it just shows “Building…” text in console indefinitely. On other hand, webpack gives trace to what caused this

  10. alan-agius4 commented on Nov 7, 2023

    @alan-agius4
    Contributor

    That solved the solved in the latest RC

  11. added
    area: core
    on Nov 8, 2023
  12. added this to the needsTriage milestone on Nov 8, 2023
  13. self-assigned this
    on Nov 12, 2023
  14. vpallathu commented on Nov 13, 2023

    @vpallathu

    I still see the error with version v17.0.0. I don't see any new npm version than v17.0.0. Should I use the interim version v17.0.2?

  15. added a commit that references this issue on Nov 20, 2023
    291deac
  16. angular-automatic-lock-bot commented on Dec 21, 2023

    @angular-automatic-lock-bot

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

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  17. locked and limited conversation to collaborators on Dec 21, 2023
  18. added a commit that references this issue on Jan 23, 2024
    22d8da4
  19. added 2 commits that reference this issue on Jan 26, 2024
    406049b
    1a86095
  20. added a commit that references this issue on Jan 26, 2024
    9485b93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: corestate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions