diff options
author | Benjamin Pasero <benjamin.pasero@microsoft.com> | 2021-09-02 12:14:16 +0300 |
---|---|---|
committer | Benjamin Pasero <benjamin.pasero@microsoft.com> | 2021-09-02 12:15:23 +0300 |
commit | ed5c561ff33cf0f29cc06726669225a338d4272d (patch) | |
tree | 5e3d87dab5e3c86623a6aa5eeea87e24d2f8432b /src/bootstrap-window.js | |
parent | 4ede35548b6c74922ce8d47a96a6d619a8e4f970 (diff) |
perf - ensure node modules are loaded via script tags and not node.js (#130302)
Diffstat (limited to 'src/bootstrap-window.js')
-rw-r--r-- | src/bootstrap-window.js | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index 0cc92ec15a3..149a66f5788 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -124,23 +124,24 @@ }); } - // Enable loading of node modules: - // - sandbox: we list paths of webpacked modules to help the loader - // - non-sandbox: we signal that any module that does not begin with - // `vs/` should be loaded using node.js require() - if (safeProcess.sandboxed) { - loaderConfig.paths = { - 'vscode-textmate': `../node_modules/vscode-textmate/release/main`, - 'vscode-oniguruma': `../node_modules/vscode-oniguruma/release/main`, - 'xterm': `../node_modules/xterm/lib/xterm.js`, - 'xterm-addon-search': `../node_modules/xterm-addon-search/lib/xterm-addon-search.js`, - 'xterm-addon-unicode11': `../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, - 'xterm-addon-webgl': `../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, - 'iconv-lite-umd': `../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`, - 'jschardet': `../node_modules/jschardet/dist/jschardet.min.js`, - }; - } else { - loaderConfig.amdModulesPattern = /^vs\//; + // Teach the loader the location of the node modules we use in renderers + // This will enable to load these modules via <script> tags instead of + // using a fallback such as node.js require which does not exist in sandbox + loaderConfig.paths = { + 'vscode-textmate': `../node_modules/vscode-textmate/release/main`, + 'vscode-oniguruma': `../node_modules/vscode-oniguruma/release/main`, + 'xterm': `../node_modules/xterm/lib/xterm.js`, + 'xterm-addon-search': `../node_modules/xterm-addon-search/lib/xterm-addon-search.js`, + 'xterm-addon-unicode11': `../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, + 'xterm-addon-webgl': `../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, + 'iconv-lite-umd': `../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`, + 'jschardet': `../node_modules/jschardet/dist/jschardet.min.js`, + }; + + // For priviledged renderers, allow to load built-in and other node.js + // modules via AMD which has a fallback to using node.js `require` + if (!safeProcess.sandboxed) { + loaderConfig.amdModulesPattern = /(^vs\/)|(^vscode-textmate$)|(^vscode-oniguruma$)|(^xterm$)|(^xterm-addon-search$)|(^xterm-addon-unicode11$)|(^xterm-addon-webgl$)|(^iconv-lite-umd$)|(^jschardet$)/; } // Signal before require.config() |