samgoody / require-esm-in-cjs Goto Github PK
View Code? Open in Web Editor NEWrequire( ESM modules) within your CommonJS scripts.
License: GNU Affero General Public License v3.0
require( ESM modules) within your CommonJS scripts.
License: GNU Affero General Public License v3.0
It doesn't work when there is no default exported
Tried on multiple versions of Node.js from 16 to 20. None of them worked. Did some debugging. Looks like the promise of the dynamic import never resolves. The process just hangs up there. But in fairness there are a lot of hang up issues reported for deasync
, so probably it's the fault of that one.
But I've also tried the solution with execSync('sleep 1')
, got very similar result. As long as Node.js was stuck in the loop, the code could never get into the .then(...)
part of the import()
. Looks like execSync
is really sync after all, meaning the promise hasn't got a chance to ever resolve. Removing the while
loop lets the promise to fulfil. Only issue is that in that case by the time the promise resolves everything else is completed, even the code that wanted to use the imported module.
I just cannot understand how you managed to get that one to work...?
I guess all is in the title :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.