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

static import not support in repl #471

Open
5 of 6 tasks
liudonghua123 opened this issue Feb 6, 2024 · 0 comments
Open
5 of 6 tasks

static import not support in repl #471

liudonghua123 opened this issue Feb 6, 2024 · 0 comments
Labels
enhancement New feature or request pending triage

Comments

@liudonghua123
Copy link

liudonghua123 commented Feb 6, 2024

Precheck

  • I searched existing issues before opening this one to avoid duplicates
  • I understand tsx aims for TypeScript parity and will not support arbitrary Node.js enhancements
  • This request cannot be made to Node.js directly, and is specific to tsx
  • I understand this form is not for addressing a bug or seeking help

Feature request

I tried to test some pieces of code copied from other source in the repl. But it seems does not support static import. I also tested with ts-node, it works for this scenario.

> tsx
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> import {parse} from 'path';
import { parse } from "path";
^^^^^^

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import: const { parse } = await import("path");
>

> ts-node
> import {parse} from 'path'
undefined
> parse
[Function: parse]
>

I tested with non-repl environment, it works.

image

Motivations

For testing some code snippets without modification easier in the repl mode.

Alternatives

n.a.

Additional context

See also nodejs/node#48084 (comment).

No response

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@liudonghua123 liudonghua123 added enhancement New feature or request pending triage labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pending triage
Projects
None yet
Development

No branches or pull requests

1 participant