Skip to content

Commit 5a51f96

Browse files
authored
feat: use rolldown effectively for the optimizer (#70)
* feat: use oxc for the scanner and pass non-js files directly to rolldown * feat: use builtin transform for optimizer rolldown * feat: use filter for the plugins for optimizer
1 parent 48f59ce commit 5a51f96

File tree

3 files changed

+220
-191
lines changed

3 files changed

+220
-191
lines changed

packages/vite/src/node/optimizer/index.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { transformWithEsbuild } from '../plugins/esbuild'
3232
import { METADATA_FILENAME } from '../constants'
3333
import { isWindows } from '../../shared/utils'
3434
import type { Environment } from '../environment'
35-
import { transformWithOxc } from '../plugins/oxc'
3635
import { ScanEnvironment, scanImports } from './scan'
3736
import { createOptimizeDepsIncludeResolver, expandGlobIds } from './resolve'
3837
import {
@@ -767,22 +766,7 @@ async function prepareRolldownOptimizerRun(
767766
if (external.length) {
768767
plugins.push(rolldownCjsExternalPlugin(external, platform))
769768
}
770-
plugins.push(rolldownDepPlugin(environment, flatIdDeps, external))
771-
plugins.push({
772-
name: 'optimizer-transform',
773-
async transform(code, id) {
774-
if (/\.(?:m?[jt]s|[jt]sx)$/.test(id)) {
775-
const result = await transformWithOxc(this, code, id, {
776-
sourcemap: true,
777-
lang: jsxLoader && /\.js$/.test(id) ? 'jsx' : undefined,
778-
})
779-
return {
780-
code: result.code,
781-
map: result.map,
782-
}
783-
}
784-
},
785-
})
769+
plugins.push(...rolldownDepPlugin(environment, flatIdDeps, external))
786770

787771
let canceled = false
788772
async function build() {
@@ -804,6 +788,7 @@ async function prepareRolldownOptimizerRun(
804788
moduleTypes: {
805789
'.css': 'js',
806790
...rollupOptions.moduleTypes,
791+
...(jsxLoader ? { '.js': 'jsx' } : {}),
807792
},
808793
})
809794
if (canceled) {

0 commit comments

Comments
 (0)