Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng update wrote wrong path of main.ts and polyfill.ts in tsconfig.app.json #16800

Closed
SachinShekhar opened this issue Jan 30, 2020 · 9 comments 路 Fixed by #16807 or nrwl/nx#2413
Closed

Comments

@SachinShekhar
Copy link

馃悶 bug report

Affected Package

N/A

Is this a regression?

Yes, the previous version in which this bug was not present was: v8

Description

After upgrading to v9, I found that path of main.ts and polyfill.ts are wrongly written in tsconfig.app.json which makes the app unusable.

馃敩 Minimal Reproduction

Checkout this commit SachinShekhar/angular-ssr-prerendering-bug@593f599 and run ng update @angular/core @angular/cli --next

The result will be SachinShekhar/angular-ssr-prerendering-bug@5528e5f#diff-d090b1ccd7cff3dfff369e150143bb09

馃敟 Exception or Error




ERROR in error TS6053: File 'x:/Bugs/angular-ssr-prerendering-bug/apps/angular-ssr-prerendering-bug/apps/angular-ssr-prerendering-bug/src/main.ts' not found.
error TS6053: File 'x:/Bugs/angular-ssr-prerendering-bug/apps/angular-ssr-prerendering-bug/apps/angular-ssr-prerendering-bug/src/polyfills.ts' not found.

This error is thrown when I run ng serve.

馃實 Your Environment

Angular Version:




Angular CLI: 9.0.0-rc.11
Node: 12.6.0
OS: win32 x64

Angular: 9.0.0-rc.11
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.11
@angular-devkit/build-angular     0.900.0-rc.11
@angular-devkit/build-optimizer   0.900.0-rc.11
@angular-devkit/build-webpack     0.900.0-rc.11
@angular-devkit/core              9.0.0-rc.11
@angular-devkit/schematics        9.0.0-rc.11
@ngtools/webpack                  9.0.0-rc.11
@nguniversal/builders             9.0.0-rc.1
@nguniversal/common               9.0.0-rc.1
@nguniversal/express-engine       9.0.0-rc.1
@schematics/angular               9.0.0-rc.11
@schematics/update                0.900.0-rc.11
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?

This project uses NX schematics. I've a feeling that it is the culprit.

@gkalpak gkalpak transferred this issue from angular/angular Jan 30, 2020
@IgorMinar IgorMinar added this to the v9-candidates milestone Jan 30, 2020
@ngbot ngbot bot removed this from the v9-candidates milestone Jan 30, 2020
@filipesilva
Copy link
Contributor

Heya, thanks for the detailed repro! This happens because of the windows-style path separators in your angular.json:

 "projects": {
    "angular-ssr-prerendering-bug": {
      "projectType": "application",
      "schematics": {},
      "root": "apps\\angular-ssr-prerendering-bug",
      "sourceRoot": "apps\\angular-ssr-prerendering-bug\\src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist\\apps\\angular-ssr-prerendering-bug",
            "index": "apps/angular-ssr-prerendering-bug/src/index.html",
            "main": "apps/angular-ssr-prerendering-bug/src/main.ts",
            "polyfills": "apps/angular-ssr-prerendering-bug/src/polyfills.ts",
            "tsConfig": "apps\\angular-ssr-prerendering-bug\\tsconfig.app.json",

Technically the config file only supports unix-style paths. But we don't enforce it, and in most places just silently accept the windows-style paths.

@filipesilva
Copy link
Contributor

@SachinShekhar by the way, how did you get those paths? Did you add them yourself, or were they generated automatically by CLI, or even by Nx?

@filipesilva filipesilva self-assigned this Jan 30, 2020
@SachinShekhar
Copy link
Author

@filipesilva Those paths were generated automatically by CLI.
ng new angular-ssr-prerendering-bug
(global @angular/cli is latest v9)

@filipesilva
Copy link
Contributor

@SachinShekhar do you remember what the commands were that generated the paths with \\? We really shouldn't be doing those.

I see them in the SachinShekhar/angular-ssr-prerendering-bug@593f599 commit but don't know what made them. I don't think we have a command that would change the paths for an existing app after ng new.

@SachinShekhar
Copy link
Author

SachinShekhar commented Jan 31, 2020

@filipesilva Oh, I see it was updated later.

I strongly believe ng add @nrwl/workspace is culprit then. NX brings the main app from src directory to apps/{project-name}, so it has to update the path.

@filipesilva
Copy link
Contributor

filipesilva commented Jan 31, 2020

@SachinShekhar ah I see! @FrozenPandaz heya, if Nx is writing windows paths in angular.json, can you switch that over to always writing unix paths please?

@FrozenPandaz
Copy link
Contributor

FrozenPandaz commented Jan 31, 2020

I made the fix :) ^

@filipesilva
Copy link
Contributor

Awesome, thanks @FrozenPandaz! Also have a fix of our own for the migrations incoming.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.