angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

ng build environments do not work with absolute paths #5407

Closed chris13524 closed 7 years ago

chris13524 commented 7 years ago

I'm trying to externalize my production environment config. Currently, if I try to use an absolute path like below, I get an error. However, if I use relative paths, it works fine.

angular-cli.json:

....
"environmentSource": "environments/environment.ts",
"environments": {
    "source": "environments/environment.ts",
    "dev": "environments/environment.dev.ts",
    "prod": "/my/absolute/path/to/environment.prod.ts"
}
....

Error:

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:8980:109)
    at parseSourceFileWorker (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:8940:26)
    at Object.parseSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:8899:26)
    at Object.createSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:8727:29)
    at VirtualFileStats.getSourceFile (/home/chris13524/programming/coconut/client/node_modules/@ngtools/webpack/src/compiler_host.js:65:35)
    at WebpackCompilerHost.getSourceFile (/home/chris13524/programming/coconut/client/node_modules/@ngtools/webpack/src/compiler_host.js:212:38)
    at findSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45859:29)
    at processImportedModules (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45994:25)
    at findSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45888:17)
    at processSourceFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45790:27)
    at processRootFile (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45694:13)
    at /home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45151:60
    at Object.forEach (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:1115:30)
    at Object.createProgram (/home/chris13524/programming/coconut/client/node_modules/typescript/lib/typescript.js:45151:16)
    at AotPlugin._setupOptions (/home/chris13524/programming/coconut/client/node_modules/@ngtools/webpack/src/plugin.js:121:28)
    at new AotPlugin (/home/chris13524/programming/coconut/client/node_modules/@ngtools/webpack/src/plugin.js:22:14)
    at _createAotPlugin (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/models/webpack-configs/typescript.js:54:12)
    at Object.exports.getAotConfig (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/models/webpack-configs/typescript.js:102:13)
    at new NgCliWebpackConfig (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/models/webpack-config.js:23:37)
    at Class.run (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/tasks/build.js:24:31)
    at Class.run (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/commands/build.js:63:26)
    at Class.<anonymous> (/home/chris13524/programming/coconut/client/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

Verson:

$ ng --version

<ascii art removed>

@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.21]
node: 7.4.0
os: linux x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.9
filipesilva commented 7 years ago

This is working as intended, in the sense that paths in the CLI config are meant to be relative.

But I agree that it would be nice as an enhancement.

angular-automatic-lock-bot[bot] commented 5 years ago

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.