Fix package-relative paths for external sources #128
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: this unblocks migration of BuildBuddy to
rules_js
. We build our app externally likebazel build @com_github_buildbuddy_io_buildbuddy//enterprise/app:app_bundle
when deploying via our internal repo, and this is broken because the current logic in rules_swc results in files being written to the wrong path.Before, we'd get an error from esbuild like
app.tsx: ERROR: Could not resolve "./root/root"
, and inspecting the sandbox dir after building with--sandbox_debug
, the tree would look like this (filtering just toapp.tsx
androot.js
here which are the main relevant files):The problem is that
esbuild
can't locate./root/root.js
because it's nested under./external/com_github_buildbuddy_io_buildbuddy/enterprise/app/root/
relative toapp.tsx
, when it should just be under./root/root
.This PR fixes that issue. After the fix, the directory structure looks like this: