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

ESM syntax in REPL doesn't work #52

Closed
1 task
segevfiner opened this issue Jun 30, 2022 · 1 comment · Fixed by #56
Closed
1 task

ESM syntax in REPL doesn't work #52

segevfiner opened this issue Jun 30, 2022 · 1 comment · Fixed by #56
Labels
bug Something isn't working outdated

Comments

@segevfiner
Copy link

segevfiner commented Jun 30, 2022

Bug description

Have some .ts file and try to import it using ESM syntax in the REPL. The variable will be left undefined.

Reproduction

index.ts:

export default "Hello, World!";
❯ tsx
Welcome to tsx v3.6.0 (Node.js v16.15.1).
Type ".help" for more information.
> import hello from './index'
undefined
> hello
Uncaught ReferenceError: hello is not defined
>

Environment

  System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 440.86 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.13.1 - ~/.nvm/versions/node/v16.15.1/bin/npm

tsx is version 3.6.0, envinfo fails to list it for some reason.

Can you contribute a fix?

  • I’m interested in opening a pull request for this issue.
@segevfiner segevfiner added bug Something isn't working pending triage labels Jun 30, 2022
@privatenumber
Copy link
Owner

Import statements are not supposed to work in the REPL, but you can use a dynamic import expression instead.

I'll keep this open because there should be an error/warning emitted.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working outdated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants