mxmul / closure-loader

Webpack loader for Google Closure modules ✨
MIT License
29 stars 22 forks source link

Webpack 4 support #40

Closed mxmul closed 6 years ago

mxmul commented 6 years ago

Fixes #39.

Followed the Webpack 4 migration guide – seems like the only issue was that we referenced this.options, which is removed in Webpack 4.

I also switched the Jest testing environment to 'node', because I was getting errors relating to the jsdom impementation of setTimeout (see facebook/jest#1909):

 FAIL  tests/common-js-closure-lib.test.js (14.778s)
  ● Console

    console.warn node_modules/bluebird/js/release/debuggability.js:873
      Unhandled rejection TypeError: setTimeout(...).unref is not a function
          at Farm.Object.<anonymous>.Farm.stopChild (/Users/mulder/closure-loader/node_modules/worker-farm/lib/farm.js:135:37)
          at Farm.<anonymous> (/Users/mulder/closure-loader/node_modules/worker-farm/lib/farm.js:324:12)
          at Array.forEach (<anonymous>)
          at Farm.Object.<anonymous>.Farm.end (/Users/mulder/closure-loader/node_modules/worker-farm/lib/farm.js:320:30)
          at Function.end (/Users/mulder/closure-loader/node_modules/worker-farm/lib/index.js:28:28)
          at _class.exit (/Users/mulder/closure-loader/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:124:30)
          at /Users/mulder/closure-loader/node_modules/uglifyjs-webpack-plugin/dist/index.js:264:18
          at step (/Users/mulder/closure-loader/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:90:11)
          at done (/Users/mulder/closure-loader/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:99:22)
          at tryCatcher (/Users/mulder/closure-loader/node_modules/bluebird/js/release/util.js:16:23)
          at Promise._settlePromiseFromHandler (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:512:31)
          at Promise._settlePromise (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:569:18)
          at Promise._settlePromise0 (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:614:10)
          at Promise._settlePromises (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:693:18)
          at Promise._fulfill (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:638:18)
          at Promise._resolveCallback (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:432:57)
          at Promise._settlePromiseFromHandler (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:524:17)
          at Promise._settlePromise (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:569:18)
          at Promise._settlePromise0 (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:614:10)
          at Promise._settlePromises (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:693:18)
          at Promise._fulfill (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:638:18)
          at Promise._resolveCallback (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:432:57)
          at Promise._settlePromiseFromHandler (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:524:17)
          at Promise._settlePromise (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:569:18)
          at Promise._settlePromise0 (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:614:10)
          at Promise._settlePromises (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:693:18)
          at Promise._fulfill (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:638:18)
          at Promise._settlePromise (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:582:21)
          at Promise._settlePromise0 (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:614:10)
          at Promise._settlePromises (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:693:18)
          at Promise._fulfill (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:638:18)
          at Promise._resolveCallback (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:454:14)
          at Promise._settlePromiseFromHandler (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:524:17)
          at Promise._settlePromise (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:569:18)
          at Promise._settlePromise0 (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:614:10)
          at Promise._settlePromises (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:693:18)
          at Promise._fulfill (/Users/mulder/closure-loader/node_modules/bluebird/js/release/promise.js:638:18)
          at /Users/mulder/closure-loader/node_modules/bluebird/js/release/nodeback.js:42:21
          at /Users/mulder/closure-loader/node_modules/graceful-fs/graceful-fs.js:121:16
          at /Users/mulder/closure-loader/node_modules/graceful-fs/graceful-fs.js:43:10
          at /Users/mulder/closure-loader/node_modules/graceful-fs/graceful-fs.js:43:10
          at /Users/mulder/closure-loader/node_modules/graceful-fs/graceful-fs.js:43:10
          at /Users/mulder/closure-loader/node_modules/graceful-fs/graceful-fs.js:43:10
          at FSReqWrap.oncomplete (fs.js:136:15)

    console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
      Error: Uncaught [TypeError: setTimeout(...).unref is not a function]
          at reportException (/Users/mulder/closure-loader/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:66:24)
          at Timeout.callback [as _onTimeout] (/Users/mulder/closure-loader/node_modules/jsdom/lib/jsdom/browser/Window.js:635:7)
          at ontimeout (timers.js:469:11)
          at tryOnTimeout (timers.js:304:5)
          at Timer.listOnTimeout (timers.js:264:5) TypeError: setTimeout(...).unref is not a function
          at Farm.Object.<anonymous>.Farm.stopChild (/Users/mulder/closure-loader/node_modules/worker-farm/lib/farm.js:135:37)
          at Farm.<anonymous> (/Users/mulder/closure-loader/node_modules/worker-farm/lib/farm.js:96:10)
          at Timeout.callback [as _onTimeout] (/Users/mulder/closure-loader/node_modules/jsdom/lib/jsdom/browser/Window.js:633:19)
          at ontimeout (timers.js:469:11)
          at tryOnTimeout (timers.js:304:5)
          at Timer.listOnTimeout (timers.js:264:5)