Skip to content

1.7.0-beta.3 or higher breaks production build in existing application #9667

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

Closed
alfaproject opened this issue Feb 17, 2018 · 7 comments · Fixed by #9699
Closed

1.7.0-beta.3 or higher breaks production build in existing application #9667

alfaproject opened this issue Feb 17, 2018 · 7 comments · Fixed by #9699
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix

Comments

@alfaproject
Copy link

alfaproject commented Feb 17, 2018

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.

Versions

macOS 10.13.13 (High Sierra)

Angular CLI: 1.7.0
Node: 8.9.1
OS: darwin x64
Angular: 5.2.5
... common, compiler, compiler-cli, core, http, platform-browser
... platform-browser-dynamic

@angular/cli: 1.7.0
@angular-devkit/build-optimizer: 0.3.1
@angular-devkit/core: 0.3.1
@angular-devkit/schematics: 0.3.1
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.0
@schematics/angular: 0.3.1
@schematics/package-update: 0.3.1
typescript: 2.6.2
webpack: 3.11.0

Repro steps

Observed behavior

I've created a minimal repro closest to what I have in my applications. See the repro steps above.

Not quite sure how to explain, but it seems like Webpack or Rollup or something along those lines is not replacing imports/exports correctly in all cases.

Example source:

import { query } from './query';

@Component({ /* ... */ })
class BrokenComponent {
  q$ = this.apollo.query({ query });

  constructor(private apollo: Apollo) { }
}

Gets transpiled to something like:

// ...
, $s = tu(/* ... */), // `$s` is the query import
function() {
  function t(t) {
    this.apollo = t,
    this.q$ = this.apollo.query({ query: query }) // `query` instead of `$s`
  }
  // ...
}()

Browser stack trace:

main.e038a7c30f039f88a388.bundle.js:1 ERROR ReferenceError: query is not defined
    at new t (main.e038a7c30f039f88a388.bundle.js:1)
    at bo (main.e038a7c30f039f88a388.bundle.js:1)
    at go (main.e038a7c30f039f88a388.bundle.js:1)
    at Yo (main.e038a7c30f039f88a388.bundle.js:1)
    at ll (main.e038a7c30f039f88a388.bundle.js:1)
    at il (main.e038a7c30f039f88a388.bundle.js:1)
    at Yo (main.e038a7c30f039f88a388.bundle.js:1)
    at Ho (main.e038a7c30f039f88a388.bundle.js:1)
    at Object.dl [as createRootView] (main.e038a7c30f039f88a388.bundle.js:1)
    at e.create (main.e038a7c30f039f88a388.bundle.js:1)

If 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. ):

Desired behavior

Same behaviour as any version before 1.7.0-beta.3. The application gets transpiled correctly and everything works fine.

@alfaproject
Copy link
Author

I've updated the original description with a minimal repro that resembles what I have in my applications.

@dldavis
Copy link

dldavis commented Feb 19, 2018

I believe this is related to this issue

#9495

@alfaproject
Copy link
Author

I thought that as well, but I'm already using es5 as target as you can see in the repo I linked. ):

@dldavis
Copy link

dldavis commented Feb 19, 2018 via email

@alfaproject
Copy link
Author

As I said the target is already es5, but you gave me an idea. I changed the module to commonjs and now it seems to work in the repro app.

@clydin is it ok to use commonjs as module?

@clydin
Copy link
Member

clydin commented Feb 19, 2018

I’ve traced the root cause to an improper interaction in the import eliding transformer regarding the usage of a shorthand property assignment that also happens to be an import. A fix is incoming and should be available in the next patch release.

@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants