Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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. #338

Open
2 tasks
loynoir opened this issue Oct 16, 2023 · 7 comments
Labels
bug Something isn't working pending triage pr welcome

Comments

@loynoir
Copy link

loynoir commented Oct 16, 2023

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
@loynoir loynoir added bug Something isn't working pending triage labels Oct 16, 2023
@SnowMarble
Copy link

SnowMarble commented Oct 17, 2023

Would you try with node 19? If you're using yarn PnP, the version should be 19.6.0 and up.

@idchlife
Copy link

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?

@MarZab
Copy link

MarZab commented Oct 26, 2023

Latest working version for me is v20.5.1

@robinelvin
Copy link

Not working with Node v20.9.0 but does work in v19.9.0

@privatenumber
Copy link
Owner

privatenumber commented Nov 7, 2023

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.

@loynoir
Copy link
Author

loynoir commented Nov 7, 2023

FYI, yarn combine with a very simple loader would work.

esbuild-kit/esm-loader#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 }
      }

@MarZab
Copy link

MarZab commented Nov 29, 2023

Possible upstream fix nodejs/node#50435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage pr welcome
Projects
None yet
Development

No branches or pull requests

6 participants