@@ -10,6 +10,7 @@ import replace from '@rollup/plugin-replace'
1010import styles from 'rollup-plugin-styles'
1111import * as tslib from 'tslib'
1212import * as babylonParser from 'recast/parsers/babylon.js'
13+ import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'
1314import * as fs from 'fs'
1415import * as path from 'path'
1516import * as vm from 'vm'
@@ -50,6 +51,7 @@ const VSCODE_DIR = path.resolve(__dirname, '../vscode')
5051const NODE_MODULES_DIR = path . resolve ( __dirname , '../node_modules' )
5152const MONACO_EDITOR_DIR = path . resolve ( NODE_MODULES_DIR , './monaco-editor' )
5253const OVERRIDE_PATH = path . resolve ( __dirname , '../src/override' )
54+ const KEYBOARD_LAYOUT_DIR = path . resolve ( VSCODE_DIR , 'vs/workbench/services/keybinding/browser/keyboardLayouts' )
5355
5456function getMemberExpressionPath ( node : recast . types . namedTypes . MemberExpression | recast . types . namedTypes . Identifier ) : string | null {
5557 if ( node . type === 'MemberExpression' ) {
@@ -106,7 +108,7 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
106108 annotations : true ,
107109 preset : 'smallest' ,
108110 moduleSideEffects ( id ) {
109- return id . startsWith ( SRC_DIR ) || id . endsWith ( '.css' )
111+ return id . startsWith ( SRC_DIR ) || id . endsWith ( '.css' ) || id . startsWith ( KEYBOARD_LAYOUT_DIR )
110112 }
111113 } ,
112114 external,
@@ -148,7 +150,7 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
148150 return undefined
149151 } ,
150152 transform ( code ) {
151- return toggleEsmComments ( code ) . replaceAll ( "'vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.' + platform" , "'./keyboardLayouts/_ .contribution'" )
153+ return toggleEsmComments ( code ) . replaceAll ( "'vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.' + platform" , "'./keyboardLayouts/layout .contribution.' + platform + '.js '" )
152154 } ,
153155 load ( id ) {
154156 if ( id . startsWith ( VSCODE_DIR ) && id . endsWith ( '.css' ) ) {
@@ -276,8 +278,8 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
276278 }
277279 } else if ( node . callee . type === 'Identifier' && PURE_FUNCTIONS . has ( node . callee . name ) ) {
278280 path . replace ( addComment ( node ) )
279- } else if ( node . callee . type === 'FunctionExpression' ) {
280- // Mark IIFE as pure, because typescript compile enums as IIFE
281+ } else if ( node . callee . type === 'FunctionExpression' && node . arguments . length === 1 ) {
282+ // Mark IIFE with single parameter as pure, because typescript compile enums as IIFE
281283 path . replace ( addComment ( node ) )
282284 }
283285 this . traverse ( path )
@@ -309,7 +311,8 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
309311 right : ').then(module => module.default ?? module)'
310312 }
311313 }
312- }
314+ } ,
315+ dynamicImportVars ( )
313316 ]
314317 } , {
315318 // 2nd pass to improve treeshaking
@@ -358,8 +361,8 @@ export default (args: Record<string, string>): rollup.RollupOptions[] => {
358361 }
359362 } else if ( node . callee . type === 'Identifier' && PURE_FUNCTIONS . has ( node . callee . name ) ) {
360363 path . replace ( addComment ( node ) )
361- } else if ( node . callee . type === 'FunctionExpression' ) {
362- // Mark IIFE as pure, because typescript compile enums as IIFE
364+ } else if ( node . callee . type === 'FunctionExpression' && node . arguments . length === 1 ) {
365+ // Mark IIFE with single parameter as pure, because typescript compile enums as IIFE
363366 path . replace ( addComment ( node ) )
364367 }
365368 this . traverse ( path )
0 commit comments