-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
I'm not sure if this is intended, but the .rebuild() method from the BuildResult interface, accordingly to the snippet below, can also be undefined:
Line 88 in 2fa473e
| rebuild?: (() => Promise<BuildResult>) & { dispose(): void }; // Only when "incremental" is true |
Because of this, is necessary to adhere to some hacky solutions like this:
const buildResult = await esbuildService.build({ ...esbuildConfig, incremental: true })
buildResult.rebuild!() // non-null assertions defeats the purpose of using "strict: true" on tsconfig.jsonor also:
const buildResult = await esbuildService.build({ ...esbuildConfig, incremental: true })
buildResult.rebuild && buildResult.rebuild()or even this:
const buildResult = await esbuildService.build({ ...esbuildConfig, incremental: true })
buildResult.rebuild?.call(this)Is there anything that i'm missing? as shown in the example from 0.8.12 release https://github.com/evanw/esbuild/blob/master/CHANGELOG.md), there were no need for any checking to use the .rebuild() method
require('esbuild').build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
incremental: true,
}).then(result => {
// The "rebuild" method is present if "incremental" is true. It returns a
// promise that resolves to the same kind of object that "build" returns.
// You can call "rebuild" as many times as you like.
result.rebuild().then(result2 => {
// Call "dispose" when you're done to free up resources.
result.rebuild.dispose()
})
})Metadata
Metadata
Assignees
Labels
No labels