Add support for es6 modules for boot scripts

This commit is contained in:
Walker 2018-06-17 13:14:52 -03:00 committed by Miroslav Bajtoš
parent b7a14e30e1
commit bfa874de63
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
4 changed files with 17 additions and 0 deletions

View File

@ -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({

View File

@ -81,6 +81,7 @@ describe('Bootstrapper', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
done();
});

View File

@ -315,6 +315,7 @@ describe('executor', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
});
});
@ -337,6 +338,7 @@ describe('executor', function() {
'promiseFinished',
'thenableStarted',
'thenableFinished',
'umdLoaded',
]);
done();
});

View File

@ -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});