@@ -13,11 +13,10 @@ import * as fs from 'fs';
1313import replace from 'rollup-plugin-replace' ;
1414import { rollup } from 'rollup' ;
1515
16+ const rollupCache : Map < string , string | null > = new Map ( ) ;
17+
1618// Utility function to read and bundle a standalone browser script
17- async function getRollupResult (
18- scriptSrc : string ,
19- rollupCache : Map < string , string | null > ,
20- ) : Promise < string | null > {
19+ async function getRollupResult ( scriptSrc : string ) : Promise < string | null > {
2120 const cachedResult = rollupCache . get ( scriptSrc ) ;
2221 if ( cachedResult !== undefined ) {
2322 return cachedResult ;
@@ -71,7 +70,6 @@ async function getRollupResult(
7170// 2. Resolving scripts with sources
7271async function replaceScriptsAndMove (
7372 window : any ,
74- rollupCache : Map < string , string | null > ,
7573 CSPnonce : string | null ,
7674 node : Node ,
7775 parent : Node | null ,
@@ -85,7 +83,7 @@ async function replaceScriptsAndMove(
8583 const script = window . document . createElement ( 'SCRIPT' ) ;
8684 const scriptSrc = element . getAttribute ( 'src' ) ;
8785 if ( scriptSrc ) {
88- const rollupOutput = await getRollupResult ( scriptSrc , rollupCache ) ;
86+ const rollupOutput = await getRollupResult ( scriptSrc ) ;
8987 if ( rollupOutput ) {
9088 // Manually call eval(...) here, since changing the HTML text content
9189 // may interfere with hydration
@@ -107,7 +105,7 @@ async function replaceScriptsAndMove(
107105 } else {
108106 for ( let i = 0 ; i < node . childNodes . length ; i ++ ) {
109107 const inner = node . childNodes [ i ] ;
110- await replaceScriptsAndMove ( window , rollupCache , CSPnonce , inner , null ) ;
108+ await replaceScriptsAndMove ( window , CSPnonce , inner , null ) ;
111109 }
112110 if ( parent != null ) {
113111 parent . appendChild ( node ) ;
0 commit comments