tsx icon indicating copy to clipboard operation
tsx copied to clipboard

test: failing test for #38

Open privatenumber opened this issue 2 years ago • 5 comments

Failing test for https://github.com/esbuild-kit/tsx/issues/38

privatenumber avatar Jun 21 '22 01:06 privatenumber

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

remorses avatar Jun 30 '22 14:06 remorses

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

remorses avatar Jun 30 '22 14:06 remorses

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.

privatenumber avatar Jun 30 '22 15:06 privatenumber

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

remorses avatar Jul 02 '22 07:07 remorses

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

privatenumber avatar Jul 02 '22 18:07 privatenumber