Skip to content

Commit

Permalink
wip: integrate core transform plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 11, 2024
1 parent 658f0da commit 01dba7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function resolvePlugins(
(environment) => !isDepOptimizationDisabled(environment.optimizeDeps),
)
const enableNativePlugin = config.experimental.enableNativePlugin
const rolldownDev = config.experimental.rolldownDev

return [
depOptimizationEnabled ? optimizedDepsPlugin() : null,
Expand Down Expand Up @@ -125,7 +126,10 @@ export async function resolvePlugins(
cssPlugin(config),
config.oxc !== false
? enableNativePlugin
? nativeTransformPlugin()
? nativeTransformPlugin({
// TODO: how to jsx dev?
reactRefresh: rolldownDev?.reactRefresh,
})
: oxcPlugin(config)
: null,
enableNativePlugin
Expand Down
9 changes: 2 additions & 7 deletions packages/vite/src/node/server/environments/rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import path from 'node:path'
import { pathToFileURL } from 'node:url'
import MagicString from 'magic-string'
import * as rolldown from 'rolldown'
import * as rolldownExperimental from 'rolldown/experimental'
import sirv from 'sirv'
import { createLogger } from '../../publicUtils'
import { DevEnvironment } from '../environment'
Expand Down Expand Up @@ -228,7 +227,7 @@ class RolldownEnvironment extends DevEnvironment {
(p) =>
!(typeof p.name === 'number' || p.name?.startsWith('vite:')) ||
['vite:define'].includes(p.name) ||
['AliasPlugin'].includes(p.constructor.name),
['AliasPlugin', 'TransformPlugin'].includes(p.constructor.name),
)
plugins = plugins.map((p) => injectEnvironmentToHooks(this as any, p))

Expand All @@ -244,13 +243,9 @@ class RolldownEnvironment extends DevEnvironment {
symlinks: !this.config.resolve.preserveSymlinks,
},
plugins: [
...plugins,
viterollEntryPlugin(this.config, this.rolldownDevOptions),
// TODO: how to use jsx-dev-runtime?
rolldownExperimental.transformPlugin({
reactRefresh: this.rolldownDevOptions?.reactRefresh,
}),
reactRefreshPlugin(this.rolldownDevOptions),
...plugins,
],
}
this.instance = await rolldown.rolldown(inputOptions)
Expand Down

0 comments on commit 01dba7d

Please sign in to comment.