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

Unable to import .js files with matching .d.ts files using @swc-node/register #775

Closed
maxburs opened this issue May 16, 2024 · 2 comments · Fixed by #777
Closed

Unable to import .js files with matching .d.ts files using @swc-node/register #775

maxburs opened this issue May 16, 2024 · 2 comments · Fixed by #777

Comments

@maxburs
Copy link

maxburs commented May 16, 2024

image

Script

import { test } from "./test.js"; // from "./test"; also fails
test();

test.js

export function test() {
  console.log("foo");
}

test.d.ts

export declare function test(): void;

The package in this1 repro reproduces it with the "cantImportJsFile" npm script.

Footnotes

  1. https://github.com/maxburs/swc-node

@Brooooooklyn
Copy link
Member

@yeliex it seems the ts.resolveModuleName resolves x.d.ts rather than the x.js, can you please take a look?

My suggestion is replace the ts.resolveModuleName with the https://github.com/oxc-project/oxc-resolver

@yeliex
Copy link
Contributor

yeliex commented May 16, 2024

@Brooooooklyn I would take time to deal with it next week. Sorry for being so busy recently

I think it is better to rollback to 1.9.0 and bump 2.0.0 as a major with a better resolve solution later

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