ES6 module import support #8555
katjuncker
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
This is something we are open to implementing in LoopBack 4's booter.
This is a concern; Is there any reason why we can't just call |
Beta Was this translation helpful? Give feedback.
4 replies
-
Hi, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been using LoopBack4 from a project that is setup as an ES6 module. The issue is that the lb4 bootloader is unable to scan and import my classes because it is using require() and this is not supported in ES6 context.
I have a fork with a fix for this that allows the bootloader to detect the support for ES6 imports and use them, falling back to require() otherwise. I have tested this on node versions from 10 to 16 and it works fine with all unit tests passing.
Before I go ahead and submit a PR, is there anything I should be aware of? I'm a bit concerned because my solution for detection of the feature uses the "new Function()" which relies upon eval(). This feels a bit hacky, but as far as I can tell is the only valid way to perform this kind of feature detection.
Any feedback would be appreciated.
Forked branch with the fix: https://github.com/sheldonjuncker/loopback-next/tree/es6-bootloading
The primary affected code is in /packages/boot/src/booters/booter-utils.ts
Beta Was this translation helpful? Give feedback.
All reactions