Skip to content

Commit

Permalink
Add babel helpers necessary for es2015 imports
Browse files Browse the repository at this point in the history
Summary: public

Adding the babel helpers that are necessary to support ES2015 imports.

Fixes: https://gist.github.com/ehd/49cb2465df9da6b39710

Reviewed By: mkonicek

Differential Revision: D2690772

fb-gh-sync-id: b1b6c0c048bad809a5c58cdd0a2cbeaa11c72ea7
  • Loading branch information
davidaurelio authored and facebook-github-bot-4 committed Nov 24, 2015
1 parent 55f72c4 commit ffea779
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packager/react-packager/src/Resolver/polyfills/babelHelpers.js
Expand Up @@ -11,8 +11,10 @@
/* eslint-disable strict */

// Created by running:
// require('babel-core').buildExternalHelpers('_extends classCallCheck createClass createRawReactElement defineProperty get inherits objectWithoutProperties possibleConstructorReturn slicedToArray toConsumableArray'.split(' '))
// require('babel-core').buildExternalHelpers('_extends classCallCheck createClass createRawReactElement defineProperty get inherits interopRequireDefault interopRequireWildcard objectWithoutProperties possibleConstructorReturn slicedToArray toConsumableArray'.split(' '))
// then replacing the `global` reference in the last line to also use `this`.
//
// actually, that's a lie, because babel6 omits _extends and createRawReactElement

(function (global) {
var babelHelpers = global.babelHelpers = {};
Expand Down Expand Up @@ -125,6 +127,29 @@
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};

babelHelpers.interopRequireDefault = function (obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
};

babelHelpers.interopRequireWildcard = function (obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};

if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
}
}

newObj.default = obj;
return newObj;
}
};

babelHelpers.objectWithoutProperties = function (obj, keys) {
var target = {};

Expand Down

5 comments on commit ffea779

@mkonicek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

@seidtgeist
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻

@satya164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was struggling with Babel 6 today. This seems like it'll fix the issue for me ;)

Thanks @davidaurelio

@davidaurelio
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

@machnicki
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎸

Please sign in to comment.