tsx
tsx copied to clipboard
test: failing test for #38
Failing test for https://github.com/esbuild-kit/tsx/issues/38
I think this can be fixed by passing platform: 'node'
to esbuild, this will emit cjs annotation like these
0 && (module.exports = {
x
});
Here is its documentation: https://esbuild.github.io/api/#platform
i just noticed transform is missing that option, i opened an issue for that https://github.com/evanw/esbuild/issues/2362
Otherwise we could use the build api and mark everything as external
I commented this in https://github.com/esbuild-kit/tsx/issues/38#issuecomment-1161175824, but I already went down that path via https://github.com/evanw/esbuild/issues/2248.
Sorry but what you said in #2362 about directly reading from disk does not apply to #38, because in that case the cjs file is a typescript file, so it will be transformed anyway
Do you have any research to back that up?
To me, it looks like a pretty straight forward fs.readFileSync
without any consideration for the possibility of transformation: https://github.com/nodejs/node/blob/bde889bd4ed68d33163897b4175557fbc669b66f/lib/internal/modules/esm/translators.js#L211