question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
clydincommented, 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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Production build breaks code that works in development #126
Works with npm start. Breaks with npm build , giving Element type is invalid error. If you rearrange the code so that AppItem...
Read more >
npm install issue : 27 vulnerabilities (16 moderate, 9 high, 2 ...
27 vulnerabilities (16 moderate, 9 high, 2 critical) To address all issues (including breaking changes), run: npm audit fix --force Run `npm ...
Read more >
Meteor 1.8 erases the debts of 1.7 | by Ben Newman
It's no secret that rebuild times increased with Meteor 1.7. Building an entirely new client bundle for legacy browsers takes time, ...
Read more >
6 high severity vulnerabilities to address all issues ... - You.com
However, npm audit is designed for Node apps so it flags issues that can occur when you run actual Node code in production....
Read more >
What's new in Kotlin 1.7.0
It is available only for the JVM, and none of the compiler plugins, ... applied when you build your Kotlin/JS application in production...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found