You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The challenge is that we have multiple tsconfigs with slightly different (but mostly common) paths:
Example
// tsconfig.dev.json includes the `linaria` mock + externals + aliases{"extends": "../tsconfig.json","compilerOptions": {"paths": {// Mocks"linaria": ["../esbuild/mocks/linaria/index.ts"],// Externals"react": ["../esbuild/externals/react/index.js"],"react-dom": ["../esbuild/externals/react-dom/index.js"],"react-dom/unstable-native-dependencies": ["../esbuild/externals/react-dom/unstable-native-dependencies/index.js"],"react-dom/server": ["../esbuild/externals/react-dom/server/index.js"],// Aliases"library/*": ["../../../library/src/*"],"test/features": ["../test/features.ts"],// (10 more lines)}}}// tsconfig.prod.json includes externals + aliases{"extends": "../tsconfig.json","compilerOptions": {"paths": {// Externals"react": ["../esbuild/externals/react/index.js"],"react-dom": ["../esbuild/externals/react-dom/index.js"],"react-dom/unstable-native-dependencies": ["../esbuild/externals/react-dom/unstable-native-dependencies/index.js"],"react-dom/server": ["../esbuild/externals/react-dom/server/index.js"],// Aliases"library/*": ["../../../library/src/*"],"test/features": ["../test/features.ts"],// (10 more lines)}}}// The parent ../tsconfig.json only includes aliases{"compilerOptions": {"paths": {// Aliases"library/*": ["../../../library/src/*"],"test/features": ["../test/features.ts"],// (10 more lines)}}}
We have to duplicate all these paths across all files (because you can’t extend the compilerOptions.paths field – if doesn’t merge with the parent’s compilerOptions.paths field but overrides it). This is fairly inconvenient.
Having a tsconfigRaw field in the build API would allow us to generate a virtual tsconfig.json every time ESBuild runs – and add paths as needed.
The text was updated successfully, but these errors were encountered:
Thanks for describing your use case in detail. I understand why you might want a virtual file here. In case it helps, another approach is to write out the generated JSON to an actual file and use the tsconfig setting. I mention this because it doesn't sound like you tried this from your description. Does this work for you?
Yeah, that’d definitely work as well! Writing out temporary files is a bit less convenient than simply passing a string, but if you prefer to not implement tsconfigRaw, the temp file approach would be 100% suitable.
Hey,
Would it be possible to expose the
tsconfigRaw
option (from the transform API) in the build API as well?Rationale: We’re using
tsconfig.json
to provide aliases and overrides for import paths. Eg, one oftsconfig.json
s that ESBuild uses looks like this:The challenge is that we have multiple tsconfigs with slightly different (but mostly common) paths:
Example
We have to duplicate all these paths across all files (because you can’t extend the
compilerOptions.paths
field – if doesn’t merge with the parent’scompilerOptions.paths
field but overrides it). This is fairly inconvenient.Having a
tsconfigRaw
field in the build API would allow us to generate a virtualtsconfig.json
every time ESBuild runs – and add paths as needed.The text was updated successfully, but these errors were encountered: