rvagg / through2

Tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise
MIT License
1.9k stars 106 forks source link

v2.0.4 breaking change for gulp packages when using Node 0.10 #95

Closed chris-green closed 6 years ago

chris-green commented 6 years ago

The release of v2.0.4 contained a breaking change for Node v0.10 & npm v1.4.28 (please don't laugh)

This has caused gulp-utils to fail due to using "through2": "^2.0.0" where it pulls in v2.0.4, where v2.03 built correct.

Gulp-utils installs fine, but then fails to run with the following error:

-----> Running run_gulp_build
12:18:47
/tmp/build_ba31c9b023b8ec485371690aba70d833/.heroku/python/lib/node_modules/gulp/node_modules/gulp-util/node_modules/through2/node_modules/readable-stream/errors.js:3
const codes = {};
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/tmp/build_ba31c9b023b8ec485371690aba70d833/.heroku/python/lib/node_modules/gulp/node_modules/gulp-util/node_modules/through2/node_modules/readable-stream/lib/internal/streams/state.js:3:29)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

We're currently working on figuring out the exact cause of this issue.

mfjordvald commented 6 years ago

We're facing the same issue. The new version used for readable-stream is causing a SyntaxError: Use of const in strict mode. error.

Recommend re-releasing v2.0.4 as v3.0.0 so that gulp-utils don't break for old setups.

steal9pro commented 6 years ago

+1 to this issue. node version - 0.12.0/npm - 2.5.1

rfischer20 commented 6 years ago

I am working on the same issue with node 0.10 on an older project that we cannot update node at this point.

If anyone has suggestions on how to override the version that gulp-util uses, it would be helpful. We unfortunately cannot edit node_modules due to how scripts are written.

steal9pro commented 6 years ago

@rfischer20 for a time, you can fork gulp-utils and change version for your project.

rfischer20 commented 6 years ago

Thanks @Myrkotyn - that did the trick.

In case anyone needs it, I had to fork gulp as well due to dependencies. Feel free to use the fork:

https://github.com/20spokes/gulp

benholtz commented 6 years ago

@rvagg Can you help us out here?

rvagg commented 6 years ago

Try this: npm install -S readable-stream@2 through2@2.

Because we're using "2 || 3" in the dependencies this should pin you to readable-stream@2.

I'll have a bit more of a think about this but yeah, this might be reason to roll back and do a major bump.

phated commented 6 years ago

Yeah, I think a rollback and major is necessary

rvagg commented 6 years ago

OK, this is done now. 2.0.5 has a rollback(ish):

diff --git a/package.json b/package.json
index 123bc4a..15960b6 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,10 @@
 {
   "name": "through2",
-  "version": "3.0.0",
-  "description": "A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise",
+  "version": "2.0.5",
+  "description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
   "main": "through2.js",
   "scripts": {
-    "test": "nyc node test/test.js | faucet && nyc report"
+    "test": "node test/test.js | faucet"
   },
   "repository": {
     "type": "git",
@@ -19,13 +19,14 @@
   "author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
   "license": "MIT",
   "dependencies": {
-    "readable-stream": "2 || 3",
+    "readable-stream": "~2.3.6",
     "xtend": "~4.0.1"
   },
   "devDependencies": {
     "bl": "~2.0.1",
     "faucet": "0.0.1",
     "nyc": "~13.1.0",
+    "safe-buffer": "~5.1.2",
     "stream-spigot": "~3.0.6",
     "tape": "~4.9.1"
   }
diff --git a/test/test.js b/test/test.js
index 1e9573d..474f090 100644
--- a/test/test.js
+++ b/test/test.js
@@ -3,6 +3,7 @@ const test     = require('tape')
     , crypto   = require('crypto')
     , bl       = require('bl')
     , spigot   = require('stream-spigot')
+    , Buffer   = require('safe-buffer').Buffer

 test('plain through', function (t) {
   var th2 = through2(function (chunk, enc, callback) {

So 2.0.5 is pinned to readable-stream@2. I also have a v2.x branch to maintain this as needed.

3.0.0 has the new stuff but still does 2||3, so you could still do the pinning yourself as per my comment above.

phated commented 6 years ago

thanks @rvagg!!

chris-green commented 6 years ago

Cheers @rvagg

billiegoose commented 6 years ago

I'd love to interview anyone who's still using node 0.10. Mostly out of fascinated horror but also to learn more about what keeps projects using old versions.

chris-green commented 6 years ago

@wmhilton we use it to build sass and run some dev tools, so we've never really had any need to.

billiegoose commented 6 years ago

@chris-green I still find that hard to believe! 😁 Node 0.10.x is more than 5 years old, and reached end-of-life more than 2 years ago. I'd think for security reasons alone it would make business sense to upgrade.

billiegoose commented 6 years ago

(I think part of it is the disconnect between using an ancient tool to download code released yesterday.)

phated commented 6 years ago

@wmhilton "end of life" and "security reasons" don't mean anything when you are literally building things on your local machine. If something works, why spend time changing it?

billiegoose commented 6 years ago

@phated Ahhhh, that makes sense. Thanks!