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

Consuming rxjs-es using webpack and babel causes invalid code while resolving imports #1992

Closed
jh3141 opened this issue Sep 30, 2016 · 3 comments

Comments

@jh3141
Copy link

jh3141 commented Sep 30, 2016

RxJS version: 5.0.0 beta 12

Code to reproduce:
In a project using webpack and babel to translate ES6 to traditional javascript:

  • Add an 'include' directive to the babel loader to allow babel to translate the rxjs-es module
  • Add import Rx from 'rxjs-es'; to the main source file of the project

Expected behavior:
rxjs-es is transpiled down to standard javascript and can be used in the project

Actual behavior:
The transpiled code contains the following chunk of invalid javascript that causes a runtime error during initialisation:

/*!***********************************!*\
  !*** ../~/rxjs-es/util/assign.js ***!
  \***********************************/
/***/ function(module, exports, __webpack_require__) {

    'use strict';

    Object.defineProperty(exports, "__esModule", {
        value: true
    });
    exports.assign = undefined;

    var _root = __webpack_require__(/*! ./root */ 417);

    var Object = _root.root.Object;

This does not work because the existence of the variable Object shadows the standard variable Object which the import code expects to be able to access, but because the definition is later in the file its value is not available at the time the import code needs it. As Object is not exported from this module, renaming it to something else would be a suitable workaround for this issue.

Additional information:

See also this bug filed against webpack: webpack/webpack#2618

While it does seem the problem is essentially webpacks, it doesn't seem they're making much progresss on solving a potentially difficult issue, whereas it would be trivial to work around it here.

@kwonoj
Copy link
Member

kwonoj commented Sep 30, 2016

Related to #1671 . Actually there's discussion to not publish sole ES2015 package, which will remove these problems eventually (I hope).

@jayphelps
Copy link
Member

We've decided to stop publishing rxjs-es for now per #2019 because it's caused more problems than it solved. We'll continue considering similar solutions for the future!

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
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

3 participants