| 143 | } |
| 144 | |
| 145 | async function ensureFixtureBundle() { |
| 146 | await mkdir(cacheDir, { recursive: true }) |
| 147 | |
| 148 | await esbuild.build({ |
| 149 | entryPoints: [fixtureEntryPath], |
| 150 | outfile: fixtureBundlePath, |
| 151 | bundle: true, |
| 152 | format: 'iife', |
| 153 | sourcemap: false, |
| 154 | platform: 'browser', |
| 155 | alias: { |
| 156 | react: rootReactPath, |
| 157 | 'react-dom': rootReactDomPath, |
| 158 | }, |
| 159 | jsx: 'transform', |
| 160 | jsxFactory: 'React.createElement', |
| 161 | jsxFragment: 'React.Fragment', |
| 162 | loader: { |
| 163 | '.js': 'jsx', |
| 164 | '.ts': 'ts', |
| 165 | '.tsx': 'tsx', |
| 166 | }, |
| 167 | }) |
| 168 | |
| 169 | const html = await readFile(fixtureHtmlPath, 'utf8') |
| 170 | await writeFile( |
| 171 | cacheHtmlPath, |
| 172 | html.replace('<script type="module" src="/app.js"></script>', ''), |
| 173 | 'utf8', |
| 174 | ) |
| 175 | } |
| 176 | |
| 177 | async function main() { |
| 178 | logProgress('Preparing benchmark bundle') |