| 113 | |
| 114 | const cachedBuilds = new Map(); |
| 115 | const incrementalEsbuild = async (/** @type {esbuild.BuildOptions} */ options) => { |
| 116 | const key = JSON.stringify(options); |
| 117 | if (cachedBuilds.has(key)) { |
| 118 | return cachedBuilds.get(key).rebuild(); |
| 119 | } |
| 120 | |
| 121 | if (!isWatch) { |
| 122 | const r = await esbuild.build(options); |
| 123 | if (r.metafile) { |
| 124 | console.log(await esbuild.analyzeMetafile(r.metafile)); |
| 125 | } |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | const ctx = await esbuild.context(options); |
| 130 | cachedBuilds.set(key, ctx); |
| 131 | |
| 132 | await ctx.rebuild(); |
| 133 | }; |
| 134 | |
| 135 | gulp.task('compile:build-scripts', async () => |
| 136 | incrementalEsbuild({ |