Support for Typescript/Babel emitted ES2015 modules#250
Support for Typescript/Babel emitted ES2015 modules#250bajtos merged 1 commit intostrongloop:2.xfrom
Conversation
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
Can one of the admins verify this patch? |
2 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
bajtos
left a comment
There was a problem hiding this comment.
Thank you for the pull request. The changes look mostly good, please take a look at my comments below.
| { | ||
| "name": "loopback-boot", | ||
| "version": "2.24.1", | ||
| "version": "2.24.2", |
There was a problem hiding this comment.
Please revert. We are incrementing package version as part of our release process.
| // function | ||
| var m = require(sourceFile); | ||
| var exports = require(sourceFile); | ||
| var m = exports && exports.__esModule ? exports.default : exports; |
There was a problem hiding this comment.
This logic is duplicated on too many places. Could you please extract a shared helper function? Something along the following lines:
// lib/require.js
module.exports = function requireNodeOrEsModule(sourceFile) {
var exports = require(sourceFile);
return exports && exports.__esModule ? exports.default : exports;
}| @@ -0,0 +1,11 @@ | |||
| // Copyright IBM Corp. 2015. All Rights Reserved. | |||
There was a problem hiding this comment.
// Copyright IBM Corp. 2015,2017. All Rights Reserved.| @@ -0,0 +1,11 @@ | |||
| // Copyright IBM Corp. 2014. All Rights Reserved. | |||
There was a problem hiding this comment.
// Copyright IBM Corp. 2014,2017. All Rights Reserved.
| @@ -0,0 +1,11 @@ | |||
| // Copyright IBM Corp. 2014. All Rights Reserved. | |||
There was a problem hiding this comment.
// Copyright IBM Corp. 2014,2017. All Rights Reserved.
| @@ -0,0 +1,11 @@ | |||
| // Copyright IBM Corp. 2014. All Rights Reserved. | |||
There was a problem hiding this comment.
// Copyright IBM Corp. 2014,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 | ||
| // GENERATED CODE |
There was a problem hiding this comment.
How is this code generated? I am proposing to remove this comment.
|
@slnode ok to test |
|
Great, I've made all those changes. Thanks. |
Detect when a script file is an es2015 module created by a transpiler like Babel or TypeScript and use the `default` export instead of `module.exports` in such case. The following artefacts support the new syntax now: - boot scripts - components - middleware - model scripts
bajtos
left a comment
There was a problem hiding this comment.
Thanks. I fixed the copyright years to 2014,2017 and squashed all changes in to a single commit. Let's wait for CI results before landing the patch.
|
Landed 🎉 Thank you for the contribution! |
Description
Both Typescript and Babel (when run with
modules: false) emit modules that can be identified as ES2015 by the__esModuleflag. This PR updates loopback-boot to handle these modules in the following scenarios.Related issues
Checklist
guide