Skip to content

Commit

Permalink
fix(utils): Update vanilla JS require loader to be fully ES5 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcovdb authored and brandonroberts committed Dec 8, 2017
1 parent 615d86a commit e6d9d88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spec/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ describe('Utils', function() {

it('should return an asynchronous require loadChildren statement with vanilla javascript', function() {
var result = [
'loadChildren: () => new Promise(function (resolve, reject) {',
'loadChildren: function () { return new Promise(function (resolve, reject) {',
' require.ensure([], function (require) {',
' resolve(' + getRequireString(path, name) + ');',
' }, function () {',
' reject({ loadChunkError: true });',
' }, \'name\');',
'})'
'})}'
];
getRequireLoader('path', 'name', 'name', true, true).should.eql(result.join(''));
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module.exports.getRequireLoader = function(filePath, chunkName, moduleName, inli
var requireString = module.exports.getRequireString(filePath, moduleName);

var result = [
'loadChildren: () => new Promise(function (resolve, reject) {',
'loadChildren: '+ (isJs ? 'function () { return' : '() =>') + ' new Promise(function (resolve, reject) {',
' ' + (isJs ? 'require' : '(require as any)') + '.ensure([], function (' + (isJs ? 'require' : 'require: any') + ') {',
' resolve(' + requireString + ');',
' }, function () {',
' reject({ loadChunkError: true });',
' }' + module.exports.getChunkName('require', chunkName) + ');',
'})'
'})' + (isJs ? '}' : '')
];

return inline ? result.join('') : result.join('\n');
Expand Down

0 comments on commit e6d9d88

Please sign in to comment.