-
Notifications
You must be signed in to change notification settings - Fork 12k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using paths inside tsconfig causing error on JIT: field 'browser' doesn't contain a valid alias configuration #7341
Comments
My guess is that this is related to this commit: |
I'm getting the same errors in my application. I followed the recreate steps and and I get the error without the aot flag so that confirms for me that it is not my app setup but something that changed in 1.3 |
@PierreDuc et al: Fix the |
My project does not build anymore after upgrading to 1.3.0 with this same error: https://travis-ci.org/ngx-plus/ngx-forms/builds/263376710#L3634 |
Is this something that can be fixed quickly? It's a show-stopper for us. |
@tacman for me downgrading the local cli version is the workaround |
@hansl just bringing this to your attention, since you are the author of the commit that may be related to this issue. See: #7341 (comment) |
I get the same error: Field 'browser' doesn't contain a valid alias configuration with v1.3.0 but I do not use AOT or paths in tsconfig.json! |
@bastienJS check if you have an import from |
For me |
I get the same error,
|
I can no longer confirm this bug. What I thought was related to the If you are seeing the bug described in this issue, check to see whether you are including the |
I have the same problem as @PierreDuc described. I have tried v1.3.1 and 1.4.0-beta.2, both resulted the same error message. Thanks. |
The same error (project https://github.com/ngrx/platform.git works with another version cli) |
Having the same issue with version 1.3.1: and
where |
@hansl can you take a look? |
@hansl @filipesilva @PierreDuc I had the same issue with the library repo and managed to find a workaround. Not sure what is causing this and didn't have much time to look into it. Maybe my workaround helps you out. I have updated @PierreDuc repo ( there are pending pull requests ) with the solution. Now ng serve and aot works properly. My main changes were to change tsconfig.json to: {
"compileOnSave": false,
"compilerOptions": {
"paths":{
"@app/*": ["src/app/*"]
},
"baseUrl": ".",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
and tsconfig.app.json to:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"paths":{
"@app/*": ["app/*"]
},
"outDir": "../out-tsc/app",
"baseUrl": ".",
"module": "es2015",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
} |
Some path mappings (see issue) were not resolving properly when they were used in deep paths. Fixes #7341
I have this error too. cli 1.3.2 |
I'm still getting this error in 1.4.0-rc.2. Will this be fixed soon? |
Same errors after upgraded to 1.4.0... it's failing for "ng build -prod", it's not seeing any of my share modules. ERROR in /Users/angular/proj/src/$$_gendir/app/app.module.ngfactory.ts (38,22): Cannot find module 'module-one'. |
Same here - 1.4.0 |
Was working until 1.3.0-rc.5.
|
Guys, I confirm this have been fixed and merged to 1.3.2 and 1.4.0. Please update & double-check your @angular/cli version with |
@hieuxlu It is not. There are use cases where the paths mapping is not resolved correctly. |
@dherges Try to create a repo where the mapping still doesn't work. Like I mentioned before, an import like |
I don't have a public repo but example where it was working but is broken now is
we could alias some-module in paths like
which was working until 1.3.0-rc.5. This now resolves the original some-module instead of the alias defined. |
Repro: https://github.com/dherges/ng-packaged/tree/146323597324337e435ad0f6d6a0fdad876603da Commit history: https://github.com/dherges/ng-packaged/commits/146323597324337e435ad0f6d6a0fdad876603da Started breaking in 1.3.0 It never turned back green again even w/ 1.3.2 as seen in Circle CI build 79: https://circleci.com/gh/dherges/ng-packaged/79?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link Neither did it in Curcle CI build 92, when upgrading to 1.4.2-rc.2: https://circleci.com/gh/dherges/ng-packaged/93?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link Eventually, I changed my configuration. By changing my configuration, the build no works again. Considering that it stopped working in the way it was being used before, there were regressions / breaking changes introduced to tsconfig paths mapping in Angular CLI. |
Essentially the same matter from 14 days ago |
@dherges You're correct. It seems like the fix did not cover resolving paths for commonjs module. For the mean time, you should either change reference to |
After fighting some days to put an "emulated" type monorepo, i got working and compiling in AOT mode with paths mappings in the current version (1.4.1) of the CLI. So my approach have some config time. First, i'm using multi app support and let's start on angular-cli.json. For the test project, called playground and you can see on the screenshot bellow i've use two configs for the same project, this only to have different tsconfig.app.json for resolving ts path maps. I've a shared code on lib, and want to share between the multiple apps. On tsconfig.json in the root my config is like this: tsconfig.json
Then inside the playground project i have two tsconfig for dev mode and for aot compilation. tsconfig.dev.json (DEV)
tsconfig.play.json (AOT)
And for this to work package.json scripts have to done some things before compile it, special on AOT mode. For this i copy folder lib to inside the playground app and that's the action that is needed for resolve paths in path mapping. package.json
As you can see on With this configs, i have multi apps like website, b2b app, mobile and so on emulating monorepo, sharing code, components and styles on my company. An extensive temporary fix to use path maps of ts. Main value copy my shared lib to the project that i'm compiling. The only problem that i'm facing is on run test, but i think it's a different thing from this thread. Current error on karma: Help on this. Cheers.!! |
@miguelramos Hey, I noticed you have followed a similar path with me. I have an open source repo https://github.com/nekkon/angular-cli-library which follows a similar logic with yours. |
@nekkon Nice! Thanks for the tip. |
Related to the test error on karma i was able to fix it putting on tsconfig app related the lib as : Bam! Everything rolling. |
I fixed this by removing By the way, i added the |
I had this issue which was caused by the following in tsconfig.json:
Not sure why it was added or what changed that caused this to break everything, our project had been building fine up until 22/02/18 with this in that file. I've removed it and now it's working. |
Some path mappings (see issue) were not resolving properly when they were used in deep paths. Fixes angular#7341
Similar to @miguelramos, in my case in tsconfig I had compilerOptions -> "target": "es2015", but compilerOptions -> lib: ["dom", "es2018"] |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)While using the
paths
object insidetsconfig.json
, module resolution doesn't seem to work anymore since the latest release. It did work on1.3.0-rc.5
. Ahead of Time does work. This seems to happen when you reference thesrc
folder or anything lower down the treeVersions.
@angular/cli: 1.3.0
node: 8.2.1
os: win32 x64
@angular/animations: 4.3.3
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.3
@angular/language-service: 4.3.3
Repro steps.
1.3.0
, this used to work in1.3.0-rc.5
and before"@root/*": ["./*"]
insidetsconfig.app..json
AppComponent
insideAppModule
toimport { AppComponent } from '@root/app/app.component';
ng serve
ng serve --aot
to see that this does workThe log given by the failure.
Desired functionality.
I would like to see no errors, obviously ;)
Mention any other details that might be useful.
Created a repo showing this issue
The text was updated successfully, but these errors were encountered: