Open deecewan opened 1 year ago
I've the same issue with p-limit
.
file:///<folder>/imports-repro/node_modules/p-limit/index.js#async_hooks.mts:2
import { AsyncResource } from "#async_hooks";
^^^^^^^^^^^^^
SyntaxError: The requested module '#async_hooks' does not provide an export named 'AsyncResource'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
the
chalk
usesimports
in the package.json. these start with a#
. I'm not sure of the full semantics of how this "should" work. It might be as simple as switching this:but that might be too naive to work in every case.
It seems to be because the
check
function callsfileURLToPath
fromurl
, which strips the#
and following text, meaning that thecheck
function ends up just checking if theparentURL
exists.I think the full solution to this would be to, if there's a
#
at the start of the import, callfallback
and then process the result offallback
, as it might resolve to a typescript file. It might be enough to just ignore any#
files and assume that the package exposing them is not using typescript?Repro Steps
mkdir imports-report && cd imports-repro
npm init -y
npm add chalk tsm
echo "import chalk from 'chalk';" > index.mjs
node --loader tsm index.mjs
you'll see