From 71116ffd2d0c1724b466af18743172a55ebdbd9a Mon Sep 17 00:00:00 2001 From: John McLaughlin Date: Thu, 24 Mar 2016 15:47:27 +0700 Subject: [PATCH] Fix for absolute external node_modules dependencies. --- gulpfile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4d7495d..ba5d223 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -130,10 +130,13 @@ function Webpack() { if(m) return callback(null, `../server/${m[1]}.json`); // externalise if the path begins with a node_modules name or if it's // an absolute path containing /node_modules/ (the latter results from - // loopback middleware dependencies). + // loopback component and middleware dependencies). const pathBase = request.split(/[\/\\]/)[0]; - if(nodeModules.has(pathBase) || /[\/\\]node_modules[\/\\]/.test(request)) + if(nodeModules.has(pathBase)) return callback(null, 'commonjs ' + request); + m = request.match(/[\/\\]node_modules[\/\\](.*)$/); + if(m) + return callback(null, 'commonjs ' + m[1].replace(/\\/g, '/')); // otherwise internalise (bundle) the request. callback(); };