tools: Bundler causes rejoining of original streams instead of modified ones

Description

When the build stream is passed through the bundler, the result contains the original split streams instead of the modified ones (e.g., processed by uglify or other minifiers).

Versions & Environment

  • polymer-build: 0.6.0
  • node: 7.4.0
  • Operating System: macOS Sierra 10.12

Steps to Reproduce

  1. Generate project from generator-polymer-init-custom-build 2.0.0.

  2. Install gulp-uglify:

    yarn add -D gulp-uglify
    
  3. Edit the project’s gulpfile.js to use gulp-uglify, and uncomment gulpfile.js:46, which runs uglify:

    const uglify = require('gulp-uglify');
    ...
    
    function build() {
      ...
      let sourcesStream = polymerProject.sources()
        .pipe(gulpif(/\.js$/, uglify()))
    
  4. Run gulp build.

  5. Observe the output of build/src/my-view1.html does not contain minified JS.

  6. Comment out gulpfile.js:69, which pipes the build through the bundler:

    buildStream = buildStream.pipe(polymerProject.bundler);
    
  7. Run gulp build.

  8. Observe the output of build/src/my-view1.html contains minified JS.

Expected Results

Output files contain modified streams.

For example, minified JS like this:

<script>Polymer({is:"my-view1"});let foo=1;console.log(foo++);</script>

Actual Results

Output files contain original/unmodified streams from HTMLSplitter.

For example:

<script>
  Polymer({
    is: 'my-view1',
  });

  let foo = 1;
  console.log(foo++);
</script>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (14 by maintainers)

Most upvoted comments

Optimizing before bundle lets you process your source files and dependencies separately. So if you wanted to use something like babel to compile your sources only, you can.

If you aren’t handling your sources and dependencies separately, optimizing after bundling will probably give you a performance boost.