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

coyotte508 added a commit that referenced this issue Nov 14, 2024
Seems necessary for
#1025 - also handle
#1001 (only for
tasks at the moment) cc @martin-gorner

also so that https://arethetypeswrong.github.io/?p=@huggingface/tasks is
:heavy_check_mark: cc @Pierrci - in addition to the .cts exports

And finally export snippets types
(https://github.com/huggingface-internal/moon-landing/pull/10998/files#r1841375306)

Types pass:
https://arethetypeswrong.github.io/?p=%40huggingface%2Ftasks%400.13.0-test5
!
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