Skip to content

BUG: option resolveFully does not work with transform, but works with transformFile #11064

@luas10c

Description

@luas10c

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

luas10c/tsnite@fb521ca

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions