Skip to content

Commit

Permalink
Merge pull request #280 from klarkc/master
Browse files Browse the repository at this point in the history
Add support for es6 modules in boot scripts
  • Loading branch information
bajtos authored Oct 11, 2018
2 parents b7a14e3 + bfa874d commit 0ace54c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/plugins/boot-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function runScripts(app, list, callback) {
debug('Requiring script %s', filepath);
try {
var exports = require(filepath);
if (exports.__esModule) exports = exports.default;
if (typeof exports === 'function') {
debug('Exported function detected %s', filepath);
functions.push({
Expand Down
1 change: 1 addition & 0 deletions test/bootstrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('Bootstrapper', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
done();
});
Expand Down
2 changes: 2 additions & 0 deletions test/executor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ describe('executor', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
});
});
Expand All @@ -337,6 +338,7 @@ describe('executor', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
done();
});
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/simple-app/boot/umd-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright IBM Corp. 2017. All Rights Reserved.
// Node module: loopback-boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

module.exports = {
default: function() {
process.bootFlags.push('umdLoaded');
},
};
Object.defineProperty(module.exports, '__esModule', {value: true});

0 comments on commit 0ace54c

Please sign in to comment.