Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp-bro doesn't seem to work on stream, but on files? #86

Open
FlyveHest opened this issue Sep 7, 2023 · 0 comments
Open

Gulp-bro doesn't seem to work on stream, but on files? #86

FlyveHest opened this issue Sep 7, 2023 · 0 comments

Comments

@FlyveHest
Copy link

FlyveHest commented Sep 7, 2023

My scenario is the following.

I have a token, @@imports@@, in my JS source, and I am trying to generate a list of import statements based on js files in a folder.

Gulp pipeline, componentImportString is a variable containing the import statements.

  return gulp.src('src/js/index.js')
    .pipe(through.obj(function (chunk, enc, callback) {
      if (chunk.isBuffer()) {
        chunk.contents = Buffer.from(chunk.contents.toString(enc).replace('// @@IMPORTS@@', componentImportString), enc);

        this.push(chunk);
      }

      callback();
    }))
    .pipe(bro(browserifySettings))
    .pipe(rename('bundle.js'))
    .pipe(gulp.dest('dist/js'))

Note: I started with a simpler gulp-replace, but the results have been the same all the way through.

If I comment gulp-bro from my pipeline, I can see that the list of files are generated correctly, and transformed / replaced into the source as excpected.

But, when I run this with gulp-bro enabled, my transformation is completely ignored, it seems like gulp-bro work directly on files on disk, and not on the vinyl-stream in the pipeline.

Note 2: I have tried doing this transformation in browserify itself, but I am also running the esmify plugin, and it looks like browserify processes plugins before transformations, so thats not a solution either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant