A function that returns the normally hidden `AsyncFunction` constructor
by ljharbJavaScript
Last 12 weeks · 1 commit
4 of 6 standards met
ESM imports require a file extension. Also directory imports don’t resolve to . This goes for source code as well as type definitions. Modern module resolution settings validate this. The correct value for libraries that target Node.js 16 or lower is . For libraries that target Node.js 18 or greater should set it to or . For code that gets bundled, the correct option is . All other options are outdated. The config in sets this correctly, but it contains a syntax error.
Repository: ljharb/async-function. Description: A function that returns the normally hidden `AsyncFunction` constructor Stars: 6, Forks: 2. Primary language: JavaScript. Languages: JavaScript (96.4%), TypeScript (3.6%). License: MIT. Open PRs: 1, open issues: 0. Last activity: 2mo ago. Community health: 85%. Top contributors: ljharb, EduardoRFS.
Here’s a rough example of a basic import and call. When importing this library (using the code above) and attempting to execute the script via , the following fatal error occurs: This was done on Node.js and . Note that the error does NOT occur when the following is present in . I only realized that specifying the as fixes the issue when I tried to run the same code via . requires that the is set to for it to run and when set, it runs without an error. Perhaps this is not an issue with at all! I just wanted to mention the issue and my findings here from https://github.com/ljharb/get-intrinsic/issues/23 just in case. Please feel free to close this otherwise as it may be a simple and obvious misconfiguration. Thank you!
My project depends on async-function and use PKG to package all js files to exe. After package complete, run the exe, it will report could not find . Check the PKG log, PKG add into package, the file is not added. If I change the main in from to , this file will be added to PKG package and exe could run successfully. I'm curious why the main entry in package.json points to , can we change to ?