ym-project / gulp-esbuild

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

sourcemap is not working #23

Closed mohammadrafigh closed 3 months ago

mohammadrafigh commented 3 months ago

Enabling sourcemap doesn't output sourcemap and just returns the bundle, or maybe I missed something? For example:

export function buildScripts() {
    return src(paths.scripts.src)
        .pipe(esBuild({
            bundle: true,
            target: 'es2022',
            sourcemap: true,
            outfile: 'main.min.js',
            minify: true
        }))
        .pipe(dest(paths.scripts.dest));
}
ym-project commented 3 months ago

Hi! I can't reproduce the problem because sourcemaps are generated.

gulpfile.js

const { src, dest } = require('gulp')
const gulpEsbuild = require('gulp-esbuild')

function build() {
    return src('./src/*.js')
        .pipe(gulpEsbuild({
            bundle: true,
            target: 'es2022',
            sourcemap: true,
            outfile: 'main.min.js',
            minify: true
        }))
        .pipe(dest('./dist'))
}

exports.build = build;

src/a.js

function sum(a, b) {
    return a + b;
}

function printAll() {
    console.log('sum1', sum(5, 10));
}

printAll()

package.json

{
    "private": true,
    "scripts": {
      "build": "gulp build"
    },
    "devDependencies": {
      "gulp": "^4.0.2",
      "gulp-esbuild": "latest"
    }
}

command line

npm run build

I got dist/main.min.js, dist/main.min.js.map with correct content.

mohammadrafigh commented 3 months ago

Well, it seems it's not working on gulp 5.0.0.

mohammadrafigh commented 3 months ago

Oops, sorry it seems I had a misconfiguration somewhere else. Thanks for being responsible.