Consider using babel-plugin-remove-webpack
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.
Same solution :- ) https://github.com/morlay/babel-plugin-transform-ensure-ignore
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.
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.