v8/web-tooling-benchmark

No longer working in node?

ofrobots opened this issue · 5 comments

After a fresh clone and npm install:

~/src/web-tooling-benchmark master
❯ node dist/cli.js
/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:52067
/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof self !== "undefined" && self) || window;
                                                                                                   ^

ReferenceError: window is not defined
    at Object.<anonymous> (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:52067:100)
    at Object.<anonymous> (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:52129:30)
    at __webpack_require__ (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:25:30)
    at Object.module.exports (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:90860:69)
    at __webpack_require__ (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:25:30)
    at Object.toString (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:164851:20)
    at __webpack_require__ (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:25:30)
    at Object.<anonymous> (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:160010:74)
    at __webpack_require__ (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:25:30)
    at Object.<anonymous> (/Users/ofrobots/src/web-tooling-benchmark/dist/cli.js:7374:19)

I can reproduce the issue with Node.js v9.8.0.

The offending code is in node_modules/timers-browserify/main.js. timers-browserify was recently changed: browserify/timers-browserify@v2.0.6...v2.0.9 We might be able to work around it by defining window = global.

(This would have been avoided with package-lock.json!)

Unfortunately, that workaround won’t fly. window = global breaks Coffeescript, which then uses window.attachEvent.

I’ll submit a PR to timers-browserify to use this instead of window.

@ofrobots As a workaround for the time being:

npm install https://github.com/mathiasbynens/timers-browserify#patch-1
npm run build
node dist/cli.js

Hopefully my patch gets accepted soon.

Thanks for the fast investigation on this! A package-lock.json in this repo would be great indeed. I'll try the work-around in the meanwhile.

This is now fixed upstream.