summarylogtreecommitdiffstats
path: root/exclude-scoped-modules.diff
blob: 372ceb26c0bd00394cfe04f396c614d459b8f25b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff --git a/webpack.config.js b/webpack.config.js
index a03e8ed..7714f7a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -8,13 +8,24 @@ var nodeModules = {};
 
 // This is to filter out node_modules as we don't want them
 // to be made part of any bundles.
-fs.readdirSync('node_modules')
-  .filter(function(x) {
-    return ['.bin'].indexOf(x) === -1;
-  })
-  .forEach(function(mod) {
-    nodeModules[mod] = 'commonjs ' + mod;
-  });
+
+function addToNodeModulesMap(modName) {
+  if (modName.indexOf('bin') !== -1) {
+    return;
+  }
+  nodeModules[modName] = 'commonjs ' + modName;
+}
+
+for (const dirname of fs.readdirSync('node_modules')) {
+  if (dirname[0] === '@') {
+    const inner_dirs = fs.readdirSync(path.join('node_modules', dirname));
+    for (const inner_dirname of inner_dirs) {
+      addToNodeModulesMap(path.join(dirname, inner_dirname));
+    }
+  } else {
+    addToNodeModulesMap(dirname);
+  }
+}
 
 var rules = [
   {