Skip to content

fix: Update vanilla JS require loader te be fully ES5 #98

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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