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
{{ message }}
Repository navigation
fix(esbuild): let inspection-only transforms yield to later loaders - #646
An esbuild transform that inspects a file and returns undefined or null currently hands the original source back to esbuild. That stops esbuild from calling the next loader. In the reported Vue setup, esbuild tries to parse the raw .vue file as JavaScript.
Only an actual transform result replaces the loaded source. If no hook provides contents, the adapter lets esbuild continue down the loader chain. Warnings from inspection hooks are still reported through onEnd when the adapter yields. A fatal error or explicit watchFiles registration still produces a loader result, as esbuild requires a result from onLoad to register those files.
The regression tests use esbuild with an inspection hook followed by a native loader. They check both undefined and null, verify that the downstream loader supplies the bundled code, and check that the inspection warning is retained.
No actionable comments were generated in the recent review.
Walkthrough
The esbuild adapter now preserves transform-hook errors, warnings, and watch files through load processing. It returns metadata for transforms without content, defers warning-only load results to onEnd, and allows later loaders to handle absent transform output.
Changes: esbuild result handling
Layer / File(s)
Summary
Transform result shape src/esbuild/index.ts
The transform hook returns metadata when content is absent or unsupported. String and object results produce contents, with source maps applied to object results.
Load metadata and warning handling src/esbuild/index.ts, test/unit-tests/esbuild/index.test.ts
Load processing aggregates transform errors, warnings, and watch files. Warning-only results are deferred to onEnd. Tests cover undefined and null transform results and later loader handling.
unjs/unplugin#634: Both PRs change esbuild result handling for transform and load outputs.
Suggested reviewers:antfubot, sxzz
Merge Risk: Minimal · up to 402ee
This change lets esbuild fall through to later loaders when a transform only inspects a file, which fixes the reported Vue parsing failure. No concrete merge-blocking risk was identified, and regression tests cover the new behavior.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title states the main change: inspection-only transforms that return undefined or null now let later esbuild loaders handle the file. The raw summary describes this change in src/esbuild/index.ts,…
Linked Issues check
Linked issue #517 reports that an unplugin inspection step breaks esbuild. Vue files are parsed as JavaScript/JSX. At the reviewed head, src/esbuild/index.ts changes the adapter's onLoad path. Loa…
Out of Scope Changes check
All reviewed changes relate to the esbuild loader chain for inspection-only transforms. The changes cover: returning undefined when no contents exist, deferring warnings-only results to onEnd, ret…
Full details: Title check
Explanation
The title states the main change: inspection-only transforms that return undefined or null now let later esbuild loaders handle the file. The raw summary describes this change in src/esbuild/index.ts, where the load pipeline yields when a transform has no content, and in a test that checks a later loader supplies the contents when a transform returns undefined or null. The conventional commit prefix 'fix(esbuild)' matches the esbuild integration and the bug fix described in the objectives (issue #517).
Full details: Linked Issues check
Explanation
Linked issue #517 reports that an unplugin inspection step breaks esbuild. Vue files are parsed as JavaScript/JSX. At the reviewed head, src/esbuild/index.ts changes the adapter's onLoad path. Loaders are still called in order. If no load hook returns contents, and there are no errors or watch files, the wrapper returns undefined. esbuild then continues to the next loader. Transform hooks that return undefined or null no longer replace the source. Their warnings are kept and reported through onEnd as deferred warnings. Fatal errors and watchFiles still return a loader result. This covers the behavior the PR describes for #517. I did not run the reproduction repository or the unit tests. The diff tool could not read changed blobs, so I checked the change from the reviewed head file and the PR summary only.
Full details: Out of Scope Changes check
Explanation
All reviewed changes relate to the esbuild loader chain for inspection-only transforms. The changes cover: returning undefined when no contents exist, deferring warnings-only results to onEnd, returning transform metadata when no contents exist, and the matching unit tests for undefined/null and downstream loader behavior. The getContents fallback for ENOENT and the processCodeWithSourceMap handling were already present and are not changed by this PR according to the summary. I did not find unrelated changes in the evidence. The base-to-head text diff was unavailable, so this result is based on the head file and the PR summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
src/esbuild/index.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
test/unit-tests/esbuild/index.test.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: f4019b23-321b-47f2-830f-33484d7ae627
Commits
Reviewing files that changed from the base of the PR and between 5daf6e6 and 402ee85.
Files selected for processing: 2
src/esbuild/index.ts
test/unit-tests/esbuild/index.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
An esbuild transform that inspects a file and returns
undefinedornullcurrently hands the original source back to esbuild. That stops esbuild from calling the next loader. In the reported Vue setup, esbuild tries to parse the raw.vuefile as JavaScript.Only an actual transform result replaces the loaded source. If no hook provides contents, the adapter lets esbuild continue down the loader chain. Warnings from inspection hooks are still reported through
onEndwhen the adapter yields. A fatal error or explicitwatchFilesregistration still produces a loader result, as esbuild requires a result fromonLoadto register those files.The regression tests use esbuild with an inspection hook followed by a native loader. They check both
undefinedandnull, verify that the downstream loader supplies the bundled code, and check that the inspection warning is retained.Fixes #517.
Summary by CodeRabbit