diff --git a/packages/perspective-workspace/build.js b/packages/perspective-workspace/build.js index a2f571a2c4..4b161d9ebf 100644 --- a/packages/perspective-workspace/build.js +++ b/packages/perspective-workspace/build.js @@ -29,7 +29,9 @@ const BUILD = [ InlineCSSPlugin(), IgnoreCSSPlugin(), IgnoreFontsPlugin(), - NodeModulesExternal(), + + // Inlining `lumino` and importing the `.ts` source saves _50kb_ + NodeModulesExternal("@lumino"), ], loader: { ".html": "text", diff --git a/tools/perspective-build/external.js b/tools/perspective-build/external.js index f2946e384f..2ed8494544 100644 --- a/tools/perspective-build/external.js +++ b/tools/perspective-build/external.js @@ -1,11 +1,13 @@ -exports.NodeModulesExternal = function NodeModulesExternal() { +exports.NodeModulesExternal = function NodeModulesExternal(whitelist) { function setup(build) { build.onResolve({filter: /^[A-Za-z0-9\@]/}, (args) => { - return { - path: args.path, - external: true, - namespace: "skip-node-modules", - }; + if (!whitelist || !args.path.startsWith(whitelist)) { + return { + path: args.path, + external: true, + namespace: "skip-node-modules", + }; + } }); }