From 732a70c466d07946926a095049ba24dedf013001 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Sat, 12 Aug 2017 16:17:56 -0400 Subject: [PATCH] Speed up `bin/webpack*` executables by dropping `yarn run` overhead (#638) --- lib/install/bin/webpack-dev-server.tt | 21 ++++++++++----------- lib/install/bin/webpack.tt | 11 +++-------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index ac15988f2..7428a040b 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -51,20 +51,19 @@ end ARGV.delete(arg) end -newenv = { +env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape, "ASSET_HOST" => DEV_SERVER_ADDR.shellescape -}.freeze +} -options = ["--progress", "--color", "--config", WEBPACK_CONFIG, "--host", LISTEN_HOST_ADDR, "--public", "#{HOSTNAME}:#{PORT}", "--port", PORT.to_s] - -if Gem.win_platform? - # Workaround for yarn not playing nicely with path separators - cmdline = ["#{NODE_MODULES_PATH}/.bin/webpack-dev-server", *options] + ARGV -else - cmdline = ["yarn", "run", "webpack-dev-server", "--", *options] + ARGV -end +cmd = [ + "#{NODE_MODULES_PATH}/.bin/webpack-dev-server", "--progress", "--color", + "--config", WEBPACK_CONFIG, + "--host", LISTEN_HOST_ADDR, + "--public", "#{HOSTNAME}:#{PORT}", + "--port", PORT.to_s +] + ARGV Dir.chdir(APP_PATH) do - exec newenv, *cmdline + exec env, *cmd end diff --git a/lib/install/bin/webpack.tt b/lib/install/bin/webpack.tt index 6a3248aa8..ddce50b3e 100644 --- a/lib/install/bin/webpack.tt +++ b/lib/install/bin/webpack.tt @@ -19,14 +19,9 @@ unless File.exist?(WEBPACK_CONFIG) exit! end -newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } -if Gem.win_platform? - # Workaround for yarn not playing nicely with path separators - cmdline = ["#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG] + ARGV -else - cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV -end +env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } +cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV Dir.chdir(APP_PATH) do - exec newenv, *cmdline + exec env, *cmd end