Giter Site home page Giter Site logo

Comments (9)

weltraumpirat avatar weltraumpirat commented on July 16, 2024 1

As @h4l said:

If so the reason is that 0.3.1 changed the arguments of the algorithm function. See #25. You need to change the signature to function(buf, options, cb)

So 0.3.1 of compression-webpack-plugin changed the API that the angular2-webpack-starter package relies on. The thing is, there's already an open issue that requests the change to be reversed, or at least optional (sic). I probably wouldn't go nuts changing that call on all your machines, if you can postpone it.

from compression-webpack-plugin.

h4l avatar h4l commented on July 16, 2024

Which version of compression-webpack-plugin are you using and which options are you passing?

from compression-webpack-plugin.

abilng avatar abilng commented on July 16, 2024

version: "0.3.1"

from compression-webpack-plugin.

h4l avatar h4l commented on July 16, 2024

Are you providing your own function with the algorithm option like this?:

module.exports = {
    context: __dirname + "/app",
    entry: "./entry",
    output: {
        path: __dirname + "/dist",
        filename: "bundle.js"
    },
    plugins: [
        new CompressionPlugin({
            algorithm: function(buf, cb) {
                zlib.gzip(buf, {}, cb);
            }
        })
    ]
};

// Results in:
$ webpack
zlib.js:227
    callback(null, buf);
    ^
TypeError: object is not a function
    at Gzip.onEnd (zlib.js:227:5)
    at Gzip.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

If so the reason is that 0.3.1 changed the arguments of the algorithm function. See #25. You need to change the signature to function(buf, options, cb)

from compression-webpack-plugin.

smitchell avatar smitchell commented on July 16, 2024

I get this error too, on my home machine, but not at work with the same project. It must some version that is different between environments.

"If you do, this is most likely a problem with the angular2-webpack-starter package,"

`zlib.js:227
callback(err, buf);
^

TypeError: callback is not a function
at Gzip.onEnd (zlib.js:227:5)
at emitNone (events.js:85:20)
at Gzip.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (node.js:383:13)
at process._tickCallback (node.js:407:11)

$ npm -v compression-webpack-plugin
3.8.3
$ node --version
v5.9.0
$ npm -version
3.8.3

from compression-webpack-plugin.

weltraumpirat avatar weltraumpirat commented on July 16, 2024

I can confirm a signature change will fix the problem with angular2-webpack-starter package. You need to edit helper.js from this:

function gzipMaxLevel(buffer, callback) {
  return zlib['gzip'](buffer, {level: 9}, callback)
}

to this:

function gzipMaxLevel(buffer, option, callback) {
  return zlib['gzip'](buffer, {level: 9}, callback)
}

from compression-webpack-plugin.

smitchell avatar smitchell commented on July 16, 2024

Thanks, I made this change on the machine where "build:prod" was failing and verified it was fixed. What library version caused the need for this change? Is this a breaking change for the machines that were working? I assuming I'll need to bring all our machines to some minimum version of that library.

from compression-webpack-plugin.

tbrisker avatar tbrisker commented on July 16, 2024

This error also occurs when using compression-webpack-plugin with node 0.10, which doesn't support the options parameter for gzip.
As a workaround I used the following code:

plugins: [
    new CompressionPlugin({
      algorithm: function(buffer, options, callback){
                   zlib.gzip(buffer, callback);
                 }
    })
]

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on July 16, 2024

Will be fixed by either #26 , #27 discussion moved to the respective PR's, feedback highly welcome 😛 . Vote with 👍 / 👎 on the opening post of the PR you prefer

from compression-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.