-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
tsconfig for single-file transforms #366
Comments
// index.js
const esbuild = require("esbuild");
const codeContent = `
const name: string = '111';
const render = () => {
return <div>Hello</div>;
};
`;
console.log(esbuild.transformSync(codeContent, { loader: 'tsx', tsconfig: '../tsconfig.json' })); // tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "ESNext",
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"]
} Please have a try. The esbuild.transformSync result no respect to |
@Akimyou sorry I didn't specify this, I meant reading the tsconfig of the user implicitly. There are rules around which files are affected by a tsconfig, and you need to crawl the file system to find the nearest config. I'd rather not re-implement that in my tools. |
@LarsDenBakker , But the |
Being able to use tsconfig in the For example: transforming a file that is part of a project which uses |
This is correct, and is by design. The intent of the transform API call is to do an isolated transformation without touching the file system. If you need to touch the file system, you should use the build API call without bundling enabled. Part of the reason for this is that the transform API works in places without a file system, such as in the web browser, while the build API requires a file system to work. |
@evanw , I understand. But is possible the build api accept code content and return result content as transform api? |
Yes. The build API has a |
I'll close this issue since the question was answered. Thanks! |
From what I can tell, the single file transforms don't pick up the user's tsconfig. Is this correct? I'm just double checking so that I know what to document for people using our tools which use esbuild.
Perhaps it would be useful to document the tsconfig logic in the readme.
The text was updated successfully, but these errors were encountered: