kmagiera / babel-watch

Reload your babel-node app on JS source file changes. And do it fast.
MIT License
529 stars 70 forks source link

Buffer.from should initialize from empty array without sourcemap #100

Closed iiroj closed 5 years ago

iiroj commented 5 years ago

I get an error like this when trying to run the latest HEAD version of babel-watch:

throw new TypeError('"value" argument must not be a number');
^

TypeError: "value" argument must not be a number
    at new Buffer.from (buffer.js:186:11)
    at handleFileLoad ([REDACTED]/babel-watch.js:391:22)
    at handleFileLoad ([REDACTED]/babel-watch.js:214:5)
    at ChildProcess.app.on ([REDACTED]/babel-watch.js:389:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
STRML commented 5 years ago

I don't think this is meant to actually store 0 (thus making it a Buffer of length 1), it is meant to be empty. So undefined should be the right argument here.

iiroj commented 5 years ago

With undefined it also throws:

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
  at new Buffer.from (buffer.js:183:11)
  at handleFileLoad ([REDACTED]/babel-watch.js:391:22)
  at handleFileLoad ([REDACTED]/babel-watch.js:214:5)
  at ChildProcess.app.on ([REDACTED]/babel-watch.js:389:5)
  at emitTwo (events.js:126:13)
  at ChildProcess.emit (events.js:214:7)
  at emit (internal/child_process.js:772:12)
  at _combinedTickCallback (internal/process/next_tick.js:141:11)
  at process._tickCallback (internal/process/next_tick.js:180:9)

So maybe an empty array is the way to go?

STRML commented 5 years ago

Thanks, lgtm