swc
swc copied to clipboard
Package imports are rewritten incorrectly if they have 3 or more segments separated by dots
Describe the bug
If there are three dots (e.g. foo.bar.baz) in a package request, then the last segment is being treated as the file extension.
If its just foo.bar then it works fine.
Input code
import 'foo.bar.baz'
Config
{
"jsc": {
"target": "es2021",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": true
},
"baseUrl": "/Users/Vaughan/dev-mono/thirtyfive/repos/vjpr/packages/fun/app",
"paths": {
"#src/*": [
"/Users/Vaughan/dev-mono/thirtyfive/repos/vjpr/packages/fun/app/src/*"
]
},
"transform": {
"react": {
"development": true,
"refresh": true
}
}
},
"filename": "/Users/Vaughan/dev-mono/thirtyfive/repos/vjpr/packages/fun/app/src/bootstrap.ts",
"sourceMaps": true,
"sourceFileName": "/Users/Vaughan/dev-mono/thirtyfive/repos/vjpr/packages/fun/app/src/bootstrap.ts"
}
Playground link
No response
Expected behavior
/some/file.tsx
import 'foo.bar.baz'
foo.bar.baz/package.json
"exports": {
".": {
"types": "./src/index.jsx",
"browser": "./src/index.tsx",
"transpile": "./src/index.tsx",
"node": "./lib/index.jsx"
}
},
"browser": "./src/index.tsx",
Actual behavior
import "../../foo.bar/index.baz";
Version
1.2.215
Additional context
No response