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

SWC transpiles node_module import to root TS file of the same name #9854

Open
NullScope opened this issue Jan 8, 2025 · 0 comments
Open
Labels
Milestone

Comments

@NullScope
Copy link

NullScope commented Jan 8, 2025

Describe the bug

Similar to #9121, however in this case it happens whenever there is a .ts file in the root directory with the same name as a node_module package.

Here is a codesandbox example, where just by changing the tsoa.ts file to something else the build will start to correctly import the package.

I believe this current behaviour is incorrect because the import is an absolute path instead of relative path and there are no path maps being applied here

Input code

No response

Config

{
    "$schema": "https://swc.rs/schema.json",
    "module": {
        "type": "commonjs"
    },
    "sourceMaps": true,
    "jsc": {
        "target": "es2022",
        "baseUrl": "./src",
        "parser": {
            "syntax": "typescript",
            "tsx": false,
            "decorators": true,
            "dynamicImport": false,
            "privateMethod": false,
            "functionBind": false,
            "exportDefaultFrom": false,
            "exportNamespaceFrom": false,
            "decoratorsBeforeExport": false,
            "topLevelAwait": false,
            "importMeta": false
        }
    }
}

Playground link (or link to the minimal reproduction)

https://github.com/NullScope/swc-ts-node_module-clash

SWC Info output

No response

Expected behavior

Whenever SWC encounters an import that matches both a node_module and a TS file, the node_module should take precedence IF the import is an absolute path and there are no corresponding path maps

Actual behavior

No response

Version

1.10.6

Additional context

No response

@NullScope NullScope added the C-bug label Jan 8, 2025
@kdy1 kdy1 added this to the Planned milestone Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants