evanw / evanw/esbuild

code transformed string still retain paths which configred by tsconfig.json

Open
#935 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I use `rollup-plugin-esbuild` to build file, and i found it's use transform API internal. After build files, i found they are still retain path which configured in `tsconfig.json` in rootDir.

At first, i think it's maybe the bug from rollup-plugin, but after i used `cat path/to/file | esbuild --loader=tsx` try to review what esbuild output original, I found there's nothing changed:

```shell
~/workspace/neutron refactor/packages*
❯ cat src/components/easy-form/index.tsx | esbuild --loader=tsx
import React from "react";
import get from "lodash/get";
import isNil from "lodash/isNil";
import merge from "lodash/merge";
import isObjectLike from "lodash/isObjectLike";
import {Button, Form} from "zent";
import {EasyFormPreview} from "./components/preview";
import {useFormConfigs} from "./hooks/use-form-configs";
import useUpdateTimes from "@hooks/use-update-times";
import {group} from "./utils/get-group-config";
import {list} from "./utils/get-list-config";
import {invariant} from "./utils/invariant";
import {RenderField} from "./components/render-filed";
import {useFormWatches} from "./hooks/use-form-watches";
import {propWalker} from "./utils/props-walker";
const {useForm, ValidateOption} = Form;
```

And that my `tsconfig.json`:

```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["./src/components/*"],
"@utils/*": ["./src/utils/*"],
"@hooks/*": ["./src/hooks/*"]
},
"removeComments": false,
"strictNullChecks": true,
"moduleResolution": "Node",
"esModuleInterop": true,
"experimentalDecorators": true,
"jsx": "react",
"noUnusedParameters": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"target": "es6",
"lib": ["dom", "es2018"],
"skipLibCheck": true
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "lib", "es", "__test__"]
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the shown `esbuild --loader=tsx` command with the supplied `tsconfig.json`, focusing on the `baseUrl` and `paths` entries. Then trace the transform API entry point and its handling of TSX imports; done means the expected treatment of configured path aliases is documented by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
build-system, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.