aspect-build / aspect-build/rules_esbuild
esbuild rule is incompatible with bundling from .ts sources
- Dominant language
- Starlark
- Stars
- 35
- Forks
- 45
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
Throughout the code base of rules_esbuild there are multiple places which make it impractical if not impossible to use a typescript entry point and have esbuild resolve depedencies using a tsconfig.json file.
To start this is this line which explictly removes the ability to pass esbuild a tsconfig file: https://github.com/aspect-build/rules_esbuild/blob/f3def5493814845ad1f7863dde5ba21c12f424b8/esbuild/private/launcher.js#L60
Secondly, when gathering transitive input sources, only files from js_providers are considered and the rest are thrown out: https://github.com/aspect-build/rules_esbuild/blob/main/esbuild/private/esbuild.bzl#L301
This is problematic since it leaves no way for targets to specify runtime dependencies they want to make available to esbuild during bundling. A common use case for this is to have a css import in a .ts or .js file `import ./index.css`. One would make `index.css` a data dependency of their `ts_project` or `js_library` target, expecting that this would make it so that the esbuild bundler would make the file available during bundling. However, this is not the case.
The only way to include non .js files is to specify the entire transitive closure of targets you need available within the `srcs` attribute. This is not sufficient for builds with many transitive dependencies. Each transitive dep should be able to declare what it needs to have available during bundling.
Contributor guide
Research direction
Start with esbuild/private/launcher.js around line 60 and esbuild/private/esbuild.bzl around line 301, then trace how tsconfig.json and transitive input sources are handled. Done means TypeScript entry points can use tsconfig.json during bundling and declared non-JavaScript runtime dependencies such as index.css are available without listing the entire transitive closure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100