Repository navigation
fix(esbuild,bun): keep empty results, filter by id before reading, normalize hooks once #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b11f7e4
5717955
286bc98
0dfad4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,7 +133,6 @@ export function combineSourcemaps( | |
| } | ||
|
|
||
| export function createBuildContext(build: PluginBuild): UnpluginBuildContext { | ||
| const watchFiles: string[] = [] | ||
| const { initialOptions } = build | ||
| return { | ||
| parse, | ||
|
|
@@ -152,7 +151,7 @@ export function createBuildContext(build: PluginBuild): UnpluginBuildContext { | |
| } | ||
| }, | ||
| getWatchFiles() { | ||
| return watchFiles | ||
| return [] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Retain the build-wide list for If a plugin calls
|
||
| }, | ||
| getNativeBuildContext() { | ||
| return { framework: 'esbuild', build } | ||
|
|
@@ -172,11 +171,16 @@ export function createPluginContext(context: UnpluginBuildContext): { | |
| warn(message) { warnings.push(normalizeMessage(message)) }, | ||
| } | ||
|
|
||
| // Each hook call reports only the files it added, so esbuild does not tie every module to every watched file | ||
| const watchFiles: string[] = [] | ||
| const mixedContext: UnpluginContext & UnpluginBuildContext = { | ||
| ...context, | ||
| ...pluginContext, | ||
| addWatchFile(id: string) { | ||
| context.getWatchFiles().push(id) | ||
| watchFiles.push(id) | ||
| }, | ||
| getWatchFiles() { | ||
| return watchFiles | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const dep = 'ORIGINAL_DEP' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { dep } from './dep.js' | ||
|
|
||
| console.log(dep) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { dep } from './dep.js' | ||
| import 'virtual:empty' | ||
|
|
||
| console.log(dep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve load-hook watch files when a transform returns code.
If
loadcallsaddWatchFile('config.json')andtransformreturns code,result = _resultreplaces the load result'swatchFileswith the transform context's separate list. Esbuild then cannot watchconfig.json, so edits to it do not trigger a rebuild. This also applies to the newly accepted empty-string transform result. Merge the watch-file lists when replacingresult, and test the load-plus-transform case. (raw.githubusercontent.com)