mirror of
https://github.com/zhigang1992/esbuild.git
synced 2026-05-04 21:28:46 +08:00
fix #1057: pass "metafile" to "onRebuild"
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
* Expose `metafile` to `onRebuild` in watch mode ([#1057](https://github.com/evanw/esbuild/issues/1057))
|
||||||
|
|
||||||
|
Previously the build results returned to the watch mode `onRebuild` callback was missing the `metafile` property when the `metafile: true` option was present. This bug has been fixed.
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
|
|
||||||
**This release contains backwards-incompatible changes.** Since esbuild is before version 1.0.0, these changes have been released as a new minor version to reflect this (as [recommended by npm](https://docs.npmjs.com/cli/v6/using-npm/semver/)). You should either be pinning the exact version of `esbuild` in your `package.json` file or be using a version range syntax that only accepts patch upgrades such as `~0.9.0`. See the documentation about [semver](https://docs.npmjs.com/cli/v6/using-npm/semver/) for more information.
|
**This release contains backwards-incompatible changes.** Since esbuild is before version 1.0.0, these changes have been released as a new minor version to reflect this (as [recommended by npm](https://docs.npmjs.com/cli/v6/using-npm/semver/)). You should either be pinning the exact version of `esbuild` in your `package.json` file or be using a version range syntax that only accepts patch upgrades such as `~0.9.0`. See the documentation about [semver](https://docs.npmjs.com/cli/v6/using-npm/semver/) for more information.
|
||||||
|
|||||||
@@ -863,6 +863,11 @@ export function createChannel(streamIn: StreamIn): StreamOut {
|
|||||||
// Factor out response handling so it can be reused for rebuilds
|
// Factor out response handling so it can be reused for rebuilds
|
||||||
let rebuild: types.BuildResult['rebuild'] | undefined;
|
let rebuild: types.BuildResult['rebuild'] | undefined;
|
||||||
let stop: types.BuildResult['stop'] | undefined;
|
let stop: types.BuildResult['stop'] | undefined;
|
||||||
|
let copyResponseToResult = (response: protocol.BuildResponse, result: types.BuildResult) => {
|
||||||
|
if (response.outputFiles) result.outputFiles = response!.outputFiles.map(convertOutputFiles);
|
||||||
|
if (response.metafile) result.metafile = JSON.parse(response!.metafile);
|
||||||
|
if (response.writeToStdout !== void 0) console.log(protocol.decodeUTF8(response!.writeToStdout).replace(/\n$/, ''));
|
||||||
|
};
|
||||||
let buildResponseToResult = (
|
let buildResponseToResult = (
|
||||||
response: protocol.BuildResponse | null,
|
response: protocol.BuildResponse | null,
|
||||||
callback: (error: Error | null, result: types.BuildResult | null) => void,
|
callback: (error: Error | null, result: types.BuildResult | null) => void,
|
||||||
@@ -871,9 +876,7 @@ export function createChannel(streamIn: StreamIn): StreamOut {
|
|||||||
let warnings = replaceDetailsInMessages(response!.warnings, details);
|
let warnings = replaceDetailsInMessages(response!.warnings, details);
|
||||||
if (errors.length > 0) return callback(failureErrorWithLog('Build failed', errors, warnings), null);
|
if (errors.length > 0) return callback(failureErrorWithLog('Build failed', errors, warnings), null);
|
||||||
let result: types.BuildResult = { warnings };
|
let result: types.BuildResult = { warnings };
|
||||||
if (response!.outputFiles) result.outputFiles = response!.outputFiles.map(convertOutputFiles);
|
copyResponseToResult(response!, result);
|
||||||
if (response!.metafile) result.metafile = JSON.parse(response!.metafile);
|
|
||||||
if (response!.writeToStdout !== void 0) console.log(protocol.decodeUTF8(response!.writeToStdout).replace(/\n$/, ''));
|
|
||||||
|
|
||||||
// Handle incremental rebuilds
|
// Handle incremental rebuilds
|
||||||
if (response!.rebuildID !== void 0) {
|
if (response!.rebuildID !== void 0) {
|
||||||
@@ -924,7 +927,7 @@ export function createChannel(streamIn: StreamIn): StreamOut {
|
|||||||
let warnings = replaceDetailsInMessages(watchResponse.warnings, details);
|
let warnings = replaceDetailsInMessages(watchResponse.warnings, details);
|
||||||
if (errors.length > 0) return watch!.onRebuild!(failureErrorWithLog('Build failed', errors, warnings), null);
|
if (errors.length > 0) return watch!.onRebuild!(failureErrorWithLog('Build failed', errors, warnings), null);
|
||||||
let result: types.BuildResult = { warnings };
|
let result: types.BuildResult = { warnings };
|
||||||
if (watchResponse.outputFiles) result.outputFiles = watchResponse.outputFiles.map(convertOutputFiles);
|
copyResponseToResult(watchResponse, result);
|
||||||
if (watchResponse.rebuildID !== void 0) result.rebuild = rebuild;
|
if (watchResponse.rebuildID !== void 0) result.rebuild = rebuild;
|
||||||
result.stop = stop;
|
result.stop = stop;
|
||||||
watch!.onRebuild!(null, result);
|
watch!.onRebuild!(null, result);
|
||||||
|
|||||||
Reference in New Issue
Block a user