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

Suffix all imports with .js #1001

Open
coyotte508 opened this issue Oct 30, 2024 · 2 comments
Open

Suffix all imports with .js #1001

coyotte508 opened this issue Oct 30, 2024 · 2 comments

Comments

@coyotte508
Copy link
Member

coyotte508 commented Oct 30, 2024

So that we can run code in node after a basic npx tsc, without module compatibility problems

cc @martin-gorner for viz

Later we can investigate other steps needed to debug a local file, until we reduce it to the minimal amount

@martin-gorner
Copy link
Contributor

source: Node v18+ docs: https://nodejs.org/api/esm.html#mandatory-file-extensions

"Mandatory file extensions
A file extension must be provided when using the import keyword to resolve relative or absolute specifiers. Directory indexes (e.g. './startup/index.js') must also be fully specified."

@martin-gorner
Copy link
Contributor

I also noticed we use import statements without an extension throughout the codebase, in huggingface.js and internal projects as well. Maybe there is a rationale for that. If so, node can be made to work with extensionless imports using the "extensionless" package:
npm install extensionless and then node --import=extensionless/register test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants