ym-project / gulp-esbuild

gulp plugin for esbuild bundler
MIT License
43 stars 7 forks source link

Support incremental builds #1

Closed tompazourek closed 3 years ago

tompazourek commented 3 years ago

esbuild v0.8.12 added support for incremental builds via the incremental: true option.

What's your opinion on adding support for this to gulp-esbuild? I think it would be nice to have.

ym-project commented 3 years ago

Hi @tompazourek! I saw this feature. This feature would be suit to gulp watch mode perfectly.

I made a new branch and an example. You can check it (instructions in README).

It works such way:

const {createGulpEsbuild} = require('gulp-esbuild')
const gulpEsbuild = createGulpEsbuild()

function gulpTask() {
    return src()
        .pipe(gulpEsbuild())
        .pipe(dest())
}

watch('', gulpTask)

Wrapper createGulpEsbuild needs to remember is is the first build or more than first build.

If you like it I will release new version. If you have a notice I will be glad to read it.

ym-project commented 3 years ago

I tested it and got results:

[14:38:42] Using gulpfile ~.../gulp-esbuild/examples/watch/gulpfile.js
[14:38:42] Starting 'watch'...
[14:38:50] Starting 'build'...
[14:38:50] Finished 'build' after 156 ms
[14:38:54] Starting 'build'...
[14:38:54] Finished 'build' after 60 ms
[14:39:17] Starting 'build'...
[14:39:17] Finished 'build' after 62 ms

Rebuild is faster 2.5x than the first build.

tompazourek commented 3 years ago

@ym-project Looks really good, thank you for sharing! 👍 I'm just experimenting at this point, I'll have to try this out.

ym-project commented 3 years ago

I released a new version with incremental build (0.3.0 version). I think this issue is resolved. If you will find any problems, just create a new issue.