Skip to content

Commit 0ace54c

Browse files
authored
Merge pull request #280 from klarkc/master
Add support for es6 modules in boot scripts
2 parents b7a14e3 + bfa874d commit 0ace54c

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

lib/plugins/boot-script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function runScripts(app, list, callback) {
6666
debug('Requiring script %s', filepath);
6767
try {
6868
var exports = require(filepath);
69+
if (exports.__esModule) exports = exports.default;
6970
if (typeof exports === 'function') {
7071
debug('Exported function detected %s', filepath);
7172
functions.push({

test/bootstrapper.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe('Bootstrapper', function() {
8181
'promiseFinished',
8282
'thenableStarted',
8383
'thenableFinished',
84+
'umdLoaded',
8485
]);
8586
done();
8687
});

test/executor.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ describe('executor', function() {
315315
'promiseFinished',
316316
'thenableStarted',
317317
'thenableFinished',
318+
'umdLoaded',
318319
]);
319320
});
320321
});
@@ -337,6 +338,7 @@ describe('executor', function() {
337338
'promiseFinished',
338339
'thenableStarted',
339340
'thenableFinished',
341+
'umdLoaded',
340342
]);
341343
done();
342344
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright IBM Corp. 2017. All Rights Reserved.
2+
// Node module: loopback-boot
3+
// This file is licensed under the MIT License.
4+
// License text available at https://opensource.org/licenses/MIT
5+
6+
'use strict';
7+
8+
module.exports = {
9+
default: function() {
10+
process.bootFlags.push('umdLoaded');
11+
},
12+
};
13+
Object.defineProperty(module.exports, '__esModule', {value: true});

0 commit comments

Comments
 (0)