Skip to content

Commit

Permalink
wip: integrate core plugin (vite:define)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 11, 2024
1 parent d716a08 commit 8d5f500
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ export async function resolveConfig(
process.env.NODE_ENV = defaultNodeEnv
}

// TODO: should we make `command == "build"` on rolldown dev?
const configEnv: ConfigEnv = {
mode,
command,
Expand Down
16 changes: 10 additions & 6 deletions packages/vite/src/node/server/environments/rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ export function rolldownDevHandleConfig(config: UserConfig): UserConfig {
noDiscovery: true,
include: [],
},
define: {
// TODO: use vite:define plugin
'process.env.NODE_ENV': "'development'",
experimental: {
enableNativePlugin: true,
},
environments: {
client: {
Expand Down Expand Up @@ -224,8 +223,14 @@ class RolldownEnvironment extends DevEnvironment {
// all plugins are shared like Vite 6 `sharedConfigBuild`.
let plugins = this._plugins!
plugins = plugins.filter(
// TODO: reuse core plugins
(p) => !(p.name?.startsWith('vite:') || p.name === 'alias'),
(p) =>
!(
typeof p.name === 'number' ||
p.name?.startsWith('vite:') ||
p.name === 'alias'
) ||
// enable some core plugins
p.name === 'vite:define',
)
plugins = plugins.map((p) => injectEnvironmentToHooks(this as any, p))

Expand All @@ -240,7 +245,6 @@ class RolldownEnvironment extends DevEnvironment {
mainFields: this.config.resolve.mainFields,
symlinks: !this.config.resolve.preserveSymlinks,
},
define: this.config.define,
plugins: [
viterollEntryPlugin(this.config, this.rolldownDevOptions),
// TODO: how to use jsx-dev-runtime?
Expand Down
1 change: 1 addition & 0 deletions playground/rolldown-dev-ssr/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineConfig({
},
experimental: {
rolldownDev: { hmr: true, reactRefresh: true },
enableNativePlugin: true,
},
plugins: [
{
Expand Down

0 comments on commit 8d5f500

Please sign in to comment.