Skip to content

Suffix all imports with .js #1001

Open
@coyotte508

Description

@coyotte508

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

Activity

martin-gorner

martin-gorner commented on Oct 30, 2024

@martin-gorner
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

martin-gorner commented on Oct 30, 2024

@martin-gorner
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

added a commit that references this issue on Nov 14, 2024
julien-c

julien-c commented on Feb 5, 2025

@julien-c
Member

can close?

coyotte508

coyotte508 commented on Feb 6, 2025

@coyotte508
MemberAuthor

We only did it for tasks, ideally we do it for all modules I think

julien-c

julien-c commented on May 23, 2025

@julien-c
Member

Ok, lets go copilot

linked a pull request that will close this issue on May 23, 2025
coyotte508

coyotte508 commented on May 24, 2025

@coyotte508
MemberAuthor
added a commit that references this issue on May 26, 2025
ae2f381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Suffix all imports with `.js` · Issue #1001 · huggingface/huggingface.js