Skip to content
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

1.1.0-rc.0 regression: wrong library bundled #6351

Closed
achimha opened this issue May 17, 2017 · 6 comments
Closed

1.1.0-rc.0 regression: wrong library bundled #6351

achimha opened this issue May 17, 2017 · 6 comments

Comments

@achimha
Copy link

achimha commented May 17, 2017

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.1.0-rc.0
node: 6.10.2
os: linux x64
@angular/common: 4.1.2
@angular/compiler: 4.1.2
@angular/core: 4.1.2
@angular/forms: 4.1.2
@angular/http: 4.1.2
@angular/platform-browser: 4.1.2
@angular/platform-browser-dynamic: 4.1.2
@angular/router: 4.1.2
@angular/cli: 1.1.0-rc.0
@angular/compiler-cli: 4.1.2
-->

Repro steps.

My project bundles OpenLayers which is a monolithic JavaScript created by Closure compiler. With 1.1.0-rc.0 (but not any version before including up to 1.1.0-beta.1), it seems that incorrect code is emitted leading to a runtime error deep down in the library. From the looks of it, an identifier is not defined -- possibly incorrect tree-shaking?

I can reproduce it at will but given the complexity of the project, I am a bit at loss as to how to proceed the investigation.

@achimha
Copy link
Author

achimha commented May 17, 2017

It is both reproducible with ng serve and in an AOT production build.

@achimha
Copy link
Author

achimha commented May 17, 2017

I believe I found where the error is coming from. I captured the chunks emitted by the dev server for both beta 1 and rc 0 and compared them.

My usage of libraries as like this:

MyApp
  |-- angular2-openlayers
      |-- openlayers
  |-- openlayers

With beta 1 I see in my chunk:

var openlayers_1 = __webpack_require__("./node_modules/openlayers/dist/ol.js");

With rc 0, the same chunk only has one difference:

var openlayers_1 = __webpack_require__("./node_modules/angular2-openlayers/node_modules/openlayers/dist/ol.js");

It therefore takes the library openlayers from a subcomponent which has a different version than the one my app references.

@achimha achimha changed the title 1.1.0-rc.0 regression: incorrect bundling 1.1.0-rc.0 regression: wrong library bundled May 17, 2017
@achimha
Copy link
Author

achimha commented May 17, 2017

So it's this change causing the issue: #6276

@clydin
Copy link
Member

clydin commented May 17, 2017

What you are seeing is the correct behavior exposing a defect in either the dependency configuration of the project or one of the dependencies (in this case angular2-openlayers).
angular2-openlayers has a pinned dependency on version 4.0.1 of openlayers which means that package has a requirement on that specific version and if the project also uses the openlayers package directly than it would need to also use that exact version.
The angular2-openlayers package should probably use a more lenient versioning strategy; also, and most likely more ideally, it could use a peer dependency which would allow a project to use their preferred version of the package.

@achimha
Copy link
Author

achimha commented May 17, 2017

You are of course right. I've relaxed the openlayers dependency to

"openlayers": "4.0.x || 4.1.x"

Which is broad enough for users of the package and now rc 0 bundles the correction version of the library.

@achimha achimha closed this as completed May 17, 2017
@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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants