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

tsx should have option to not do extra things #228

Closed
1 task
loynoir opened this issue Apr 26, 2023 · 6 comments
Closed
1 task

tsx should have option to not do extra things #228

loynoir opened this issue Apr 26, 2023 · 6 comments

Comments

@loynoir
Copy link

loynoir commented Apr 26, 2023

Bug description

tsx should have option to not do extra things.

Reproduction

Prepare

reproduce1.mjs

// @ts-check
import playwright from 'playwright-core'
const browser = await playwright.firefox.launch()
const browserContext = await browser.newContext()
const page = await browserContext.newPage()
await page.goto('http://127.0.0.1:1234/')
await page.waitForFunction('() => true')
await page.close()
await browserContext.close()
await browser.close()
$ cp reproduce1.mjs reproduce2.mts

Actual

$ npm exec -- tsx reproduce1.mjs
node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

page.waitForFunction: __name is not defined
@debugger eval code line 195 > eval:1:95
evaluate@debugger eval code:197:17
@debugger eval code:1:44

    at file:///path/to/reproduce1.mjs:7:12 {
  name: 'Error'
}

Node.js v18.15.0
$ npm exec -- tsx reproduce2.mts
node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

page.waitForFunction: __name is not defined
@debugger eval code line 195 > eval:1:95
evaluate@debugger eval code:197:17
@debugger eval code:1:44

    at <anonymous> (/path/to/reproduce2.mts:7:12) {
  name: 'Error'
}

Node.js v18.15.0

Expected

$  node --loader @esbuild-kit/esm-loader reproduce1.mjs && echo OK
(node:615388) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
OK
$ node --loader @esbuild-kit/esm-loader reproduce2.mts && echo OK
(node:615873) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
OK

Environment

Binaries:
    Node: 18.15.0 - /usr/sbin/node
    Yarn: 1.22.19 - /usr/sbin/yarn
    npm: 8.19.2 - /usr/sbin/npm

Can you work on a fix?

  • I’m interested in opening a pull request to address this issue.

Related

#113

@loynoir loynoir added bug Something isn't working pending triage labels Apr 26, 2023
@privatenumber
Copy link
Owner

tsx should have option to not do extra things.

Not sure what you're talking about. Can you elaborate?

Seems like a duplicate of #113?

@loynoir
Copy link
Author

loynoir commented Apr 26, 2023

@privatenumber

Seems like a duplicate of #113?

No.

https://github.com/esbuild-kit/esno/blob/v0.14.1/esmo.mjs

For example, esmo@0.14.1 just means node --loader esbuild-node-loader.

tsx does not mean node --loader @esbuild-kit/esm-loader, they have different output.

node --loader @esbuild-kit/esm-loader works fine.

But tsx works unexpected.

@privatenumber
Copy link
Owner

I see.

node --loader @esbuild-kit/esm-loader works for your input because playwight-core is a CommonJS package, and @esbuild-kit/esm-loader only transforms ESM files.

tsx does node --loader @esbuild-kit/esm-loader --require @esbuild-kit/cjs-loader which adds support for transforming CommonJS too (transforming playwright-core). But currently, it transforms more than it needs to (it doesn't need to transform playwright-core).

@loynoir loynoir changed the title tsx should have option to not do extra things split tsx to mtsx and ctsx, like esmo Apr 27, 2023
@loynoir loynoir changed the title split tsx to mtsx and ctsx, like esmo tsx should have option to not do extra things Apr 27, 2023
@saonan90077

This comment was marked as spam.

@privatenumber privatenumber mentioned this issue Jul 15, 2023
21 tasks
@lxy951101

This comment was marked as spam.

@privatenumber
Copy link
Owner

playwright-core should work expectedly now with https://github.com/privatenumber/tsx/releases/tag/v4.0.0

Hope it works well for you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants