Skip to content

Transform TS path aliases to absolute paths for esbuild

License

Notifications You must be signed in to change notification settings

frankleng/esbuild-ts-paths

Repository files navigation

esbuild-ts-paths

Transform TS path alias to absolute paths for esbuild

Example

// tsconfig.json

"compilerOptions": {
  "outDir": "./dist",
    "baseUrl": ".",
    "paths": {
    "@common/*": ["../common/*"], // asterisks are important
    "@shared/*": ["./src/shared/*"]
  }
}
// esbuild
const tsPaths = require("esbuild-ts-paths") 
esbuild.build({
    //...
    plugins:[
        tsPaths(
            "./path/to/tsconfig.json" // optional, defaults to ./tsconfig.json
        )
    ]
})