@@ -281,7 +281,6 @@ function treeShakeTransform({ types: t }: typeof Babel): PluginObj<State> {
281281
282282export function treeShake ( ) : Plugin {
283283 let config : ResolvedConfig ;
284- const cache : Record < string , any > = { } ;
285284 let server : ViteDevServer ;
286285
287286 async function transform ( id : string , code : string ) {
@@ -314,40 +313,6 @@ export function treeShake(): Plugin {
314313 configureServer ( s ) {
315314 server = s ;
316315 } ,
317- async handleHotUpdate ( ctx ) {
318- if ( cache [ ctx . file ] ) {
319- const mods = [ ] ;
320- const newCode = await ctx . read ( ) ;
321- for ( const [ id , code ] of Object . entries ( cache [ ctx . file ] ) ) {
322- const transformed = await transform ( id , newCode ) ;
323- if ( ! transformed ) continue ;
324-
325- const { code : transformedCode } = transformed ;
326-
327- if ( transformedCode !== code ) {
328- const mod = server . moduleGraph . getModuleById ( id ) ;
329- if ( mod ) mods . push ( mod ) ;
330- }
331-
332- cache [ ctx . file ] ??= { } ;
333- cache [ ctx . file ] [ id ] = transformedCode ;
334- // server.moduleGraph.setModuleSource(id, code);
335- }
336-
337- return mods ;
338- }
339- // const mods = [];
340- // [...server.moduleGraph.urlToModuleMap.entries()].forEach(([url, m]) => {
341- // if (m.file === ctx.file && m.id.includes("pick=")) {
342- // if (!m.id.includes("pick=loader")) {
343- // mods.push(m);
344- // }
345- // }
346- // });
347- // return mods;
348- // // this.router.updateRoute(ctx.path);
349- // }
350- } ,
351316 async transform ( code , id ) {
352317 const [ path , queryString ] = id . split ( "?" ) ;
353318 if ( ! path ) return ;
@@ -358,9 +323,6 @@ export function treeShake(): Plugin {
358323 const transformed = await transform ( id , code ) ;
359324 if ( ! transformed ?. code ) return ;
360325
361- cache [ path ] ??= { } ;
362- cache [ path ] [ id ] = transformed . code ;
363-
364326 return {
365327 code : transformed . code ,
366328 map : transformed . map ,
0 commit comments