-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Describe the bug
import { transform } from '@swc/core' does not work resolveFully
import { transformFile } from '@swc/core' resolveFully works
I made a cli that uses swc to transpile typescript code
Input code
import { transform } from '@swc/core'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
const data = await readFile(join(import.meta.dirname, 'bootstrap.ts'), 'utf-8')
const { code } = await transform(data, {
jsc: {
baseUrl: join(process.cwd(), '.'),
parser: {
syntax: 'typescript',
decorators: true
},
target: 'es2022',
keepClassNames: true,
transform: {
treatConstEnumAsEnum: true,
decoratorMetadata: true,
legacyDecorator: true
},
experimental: {
keepImportAssertions: true
},
paths
},
module: {
type: 'es6',
strict: true,
outFileExtension: 'js',
resolveFully: true
},
sourceMaps: true
})
// the code that is exported does not resolve the imports with .js at the end
// when I use transformFile it works as expected
Config
Link to the code that reproduces this issue
SWC Info output
No response
Expected behavior
I hope it resolves imports with, for example,
./common/config.js , it returns ./common/config for esm builds.
Actual behavior
No response
Version
1.13.5
Additional context
No response