tsx
tsx copied to clipboard
[yarn] `[ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected array buffer, or typed array to be returned for the "source" from the "transformSource" function but got undefined.`
Problem
yarn tsx ./src/reproduce.ts
throw error
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected array buffer, or typed array to be returned for the "source" from the "transformSource" function but got undefined.
at __node_internal_captureLargerStackTrace (node:internal/errors:497:5)
at new NodeError (node:internal/errors:406:5)
at assertBufferSource (node:internal/modules/esm/translators:84:9)
at stringify (node:internal/modules/esm/translators:94:3)
at createCJSModuleWrap (node:internal/modules/esm/translators:219:12)
at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:297:10) {
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}
Node.js v20.8.0
Expected behavior
No error.
Minimal reproduction URL
https://github.com/loynoir/reproduce-tsx-338
Version
3.13.0
Node.js version
v20.8.0
Package manager
yarn
Operating system
Linux
Contributions
- [ ] I plan to open a pull request for this issue
- [ ] I plan to make a financial contribution to this project
Would you try with node 19? If you're using yarn PnP, the version should be 19.6.0 and up.
Would you try with node 19? If you're using yarn PnP, the version should be 19.6.0 and up.
works with nodejs 19.
Is there possibility tsx will work with Yarn PnP and node 20+ in the future?
Latest working version for me is v20.5.1
Not working with Node v20.9.0 but does work in v19.9.0
Personally, I dont use yarn so this wont be a priority for me to work on.
If its a priority for you, feel free to submit a PR with tests and Id be happy to review.
FYI, yarn combine with a very simple loader would work.
https://github.com/esbuild-kit/esm-loader/issues/81
const source2 = esbuild_transform_fallback_to_ts_transpile(...transpileOptions)
try {
await nextLoad(url, context)
return { format, responseURL: url, source: source2 }
} catch {
return { format, responseURL: url, source: source2, shortCircuit: true }
}
Possible upstream fix https://github.com/nodejs/node/issues/50435