{"action":"opened","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/9667","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/9667/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/9667/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/9667/events","html_url":"https://github.com/angular/angular-cli/issues/9667","id":298024234,"number":9667,"title":"1.7.0-beta.3 or higher breaks production build in existing application","user":{"login":"alfaproject","id":60164,"avatar_url":"https://avatars1.githubusercontent.com/u/60164?v=4","gravatar_id":"","url":"https://api.github.com/users/alfaproject","html_url":"https://github.com/alfaproject","followers_url":"https://api.github.com/users/alfaproject/followers","following_url":"https://api.github.com/users/alfaproject/following{/other_user}","gists_url":"https://api.github.com/users/alfaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/alfaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfaproject/subscriptions","organizations_url":"https://api.github.com/users/alfaproject/orgs","repos_url":"https://api.github.com/users/alfaproject/repos","events_url":"https://api.github.com/users/alfaproject/events{/privacy}","received_events_url":"https://api.github.com/users/alfaproject/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-17T18:09:50Z","updated_at":"2018-02-17T18:09:50Z","closed_at":null,"author_association":"NONE","body":"I'm going to report on the latest version because that's what we want to be fixed but the issue being reported started on `1.7.0-beta.3` and manifests in all versions after.\r\n\r\n### Versions\r\n```\r\nAngular CLI: 1.7.0\r\nNode: 8.9.1\r\nOS: darwin x64\r\nAngular: 5.2.5\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, router, service-worker\r\n\r\n@angular/cdk: 5.2.1\r\n@angular/cli: 1.7.0\r\n@angular/flex-layout: 2.0.0-beta.12\r\n@angular/material: 5.2.1\r\n@angular-devkit/build-optimizer: 0.3.1\r\n@angular-devkit/core: 0.3.1\r\n@angular-devkit/schematics: 0.3.1\r\n@ngtools/json-schema: 1.2.0\r\n@ngtools/webpack: 1.10.0\r\n@schematics/angular: 0.3.1\r\n@schematics/package-update: 0.3.1\r\ntypescript: 2.6.2\r\nwebpack: 3.11.0\r\n```\r\nmacOS 10.13.13 (High Sierra)\r\n\r\n### Repro steps\r\n* Update an existing application to CLI 1.7.0-beta.3 or higher\r\n* `ng serve --prod` (it works fine if it's not production)\r\n\r\n### Observed behavior\r\nIt's really difficult to give something concrete and I'm trying to work out a minimal repro without success so far. Been at it for a few hours, and I'll try to find some more time today or tomorrow to see if I can.\r\n\r\nBasically, it seems like Webpack or Rollup or something along those lines is not replacing imports/exports correctly in all cases.\r\n\r\nExample:\r\n```ts\r\nimport { query } from './query';\r\n\r\n@Component({ /* ... */ })\r\nclass BrokenComponent {\r\n  q$ = this.apollo.query({ query });\r\n\r\n  constructor(private apollo: Apollo) { }\r\n}\r\n```\r\n\r\nGets transpiled to something like:\r\n```js\r\n// ...\r\n, $s = tu(/* ... */), // `$s` is the query import\r\nfunction() {\r\n  function t(t) {\r\n    this.apollo = t,\r\n    this.q$ = this.apollo.query({ query: query }) // `query` instead of `$s`\r\n  }\r\n  // ...\r\n}()\r\n```\r\n\r\nBrowser stack trace:\r\n```\r\nmain.e038a7c30f039f88a388.bundle.js:1 ERROR ReferenceError: query is not defined\r\n    at new t (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at bo (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at go (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at Yo (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at ll (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at il (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at Yo (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at Ho (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at Object.dl [as createRootView] (main.e038a7c30f039f88a388.bundle.js:1)\r\n    at e.create (main.e038a7c30f039f88a388.bundle.js:1)\r\n```\r\n\r\nIf I rename that `query` on the import, for example: `import { query as BrokenQuery } from './query';` then the import is correctly used and this error will go away, but another one appears in something unrelated, which I try to work around until an error in some vendor module appears which I can't work around. ):\r\n\r\n### Desired behavior\r\nSame behaviour as any version before `1.7.0-beta.3`. The application gets transpiled correctly and everything works fine."}}
{"actor":{"display_login":"alfaproject"}}