Merge pull request #280 from klarkc/master
Add support for es6 modules in boot scripts
This commit is contained in:
commit
0ace54cd9e
|
@ -66,6 +66,7 @@ function runScripts(app, list, callback) {
|
||||||
debug('Requiring script %s', filepath);
|
debug('Requiring script %s', filepath);
|
||||||
try {
|
try {
|
||||||
var exports = require(filepath);
|
var exports = require(filepath);
|
||||||
|
if (exports.__esModule) exports = exports.default;
|
||||||
if (typeof exports === 'function') {
|
if (typeof exports === 'function') {
|
||||||
debug('Exported function detected %s', filepath);
|
debug('Exported function detected %s', filepath);
|
||||||
functions.push({
|
functions.push({
|
||||||
|
|
|
@ -81,6 +81,7 @@ describe('Bootstrapper', function() {
|
||||||
'promiseFinished',
|
'promiseFinished',
|
||||||
'thenableStarted',
|
'thenableStarted',
|
||||||
'thenableFinished',
|
'thenableFinished',
|
||||||
|
'umdLoaded',
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -315,6 +315,7 @@ describe('executor', function() {
|
||||||
'promiseFinished',
|
'promiseFinished',
|
||||||
'thenableStarted',
|
'thenableStarted',
|
||||||
'thenableFinished',
|
'thenableFinished',
|
||||||
|
'umdLoaded',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -337,6 +338,7 @@ describe('executor', function() {
|
||||||
'promiseFinished',
|
'promiseFinished',
|
||||||
'thenableStarted',
|
'thenableStarted',
|
||||||
'thenableFinished',
|
'thenableFinished',
|
||||||
|
'umdLoaded',
|
||||||
]);
|
]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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});
|
Loading…
Reference in New Issue