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

Consider using babel-plugin-remove-webpack #3

Open
knpwrs opened this issue Jan 8, 2016 · 3 comments
Open

Consider using babel-plugin-remove-webpack #3

knpwrs opened this issue Jan 8, 2016 · 3 comments

Comments

@knpwrs
Copy link

knpwrs commented Jan 8, 2016

I just published my first babel plugin, babel-plugin-remove-webpack. It automatically rewrites calls to require.ensure and require.include so the developer doesn't have to worry about them. A suggestion came up over at reddit that I talk with you guys about using it over here.

I'm open to your thoughts and suggestions.

@morlay
Copy link

morlay commented Jan 18, 2016

@sergeylukin
Copy link

Only both solutions don't work with how require.ensure is used in this repo's RootRoute.js:11

Regardless, I think maybe it's better to avoid hiding such tricky transformations but rather keep them in code to prevent errors in case babel will be replaced/deprecated in the future? Just a thought.

@knpwrs
Copy link
Author

knpwrs commented Mar 28, 2016

Just ran babel --presets es2015 --plugins remove-webpack RootRoute.js and got the following:

'use strict';

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

var _App = require('../components/App');

var _App2 = _interopRequireDefault(_App);

var _Index = require('../components/Index');

var _Index2 = _interopRequireDefault(_Index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// polyfill webpack require.ensure
if (typeof require.ensure !== 'function') require.ensure = function (d, c) {
  return c(require);
};

exports.default = {
  path: '/',
  component: _App2.default,
  getChildRoutes: function getChildRoutes(location, cb) {
    (function () {
      cb(null, [require('./AboutRoute')]);
    })();
  },

  indexRoute: {
    component: _Index2.default
  }
};

Am I missing something? Why wouldn't that work? The only thing I see about this repo off-hand is that it uses Babel 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants