1- import url from 'node:url'
21import aliasPlugin , { type ResolverFunction } from '@rollup/plugin-alias'
32import type { ObjectHook } from 'rolldown'
4- import type { TransformOptions as OxcTransformOptions } from 'rolldown/experimental'
5- import {
6- aliasPlugin as nativeAliasPlugin ,
7- dynamicImportVarsPlugin as nativeDynamicImportVarsPlugin ,
8- importGlobPlugin as nativeImportGlobPlugin ,
9- jsonPlugin as nativeJsonPlugin ,
10- modulePreloadPolyfillPlugin as nativeModulePreloadPolyfillPlugin ,
11- transformPlugin as nativeTransformPlugin ,
12- wasmFallbackPlugin as nativeWasmFallbackPlugin ,
13- wasmHelperPlugin as nativeWasmHelperPlugin ,
14- } from 'rolldown/experimental'
3+ import { aliasPlugin as nativeAliasPlugin } from 'rolldown/experimental'
154import type { PluginHookUtils , ResolvedConfig } from '../config'
165import {
176 type HookHandler ,
187 type Plugin ,
198 type PluginWithRequiredHook ,
20- perEnvironmentPlugin ,
219} from '../plugin'
2210import { watchPackageDataPlugin } from '../packages'
23- import { normalizePath } from '../utils'
2411import { jsonPlugin } from './json'
2512import { oxcResolvePlugin , resolvePlugin } from './resolve'
2613import { optimizedDepsPlugin } from './optimizedDeps'
@@ -44,7 +31,7 @@ import {
4431 createFilterForTransform ,
4532 createIdFilter ,
4633} from './pluginFilter'
47- import { type OxcOptions , oxcPlugin } from './oxc'
34+ import { oxcPlugin } from './oxc'
4835import { esbuildBannerFooterCompatPlugin } from './esbuildBannerFooterCompatPlugin'
4936
5037export async function resolvePlugins (
@@ -83,19 +70,7 @@ export async function resolvePlugins(
8370 ...prePlugins ,
8471
8572 modulePreload !== false && modulePreload . polyfill
86- ? enableNativePlugin === true
87- ? perEnvironmentPlugin (
88- 'native:modulepreload-polyfill' ,
89- ( environment ) => {
90- if (
91- config . command !== 'build' ||
92- environment . config . consumer !== 'client'
93- )
94- return false
95- return nativeModulePreloadPolyfillPlugin ( )
96- } ,
97- )
98- : modulePreloadPolyfillPlugin ( config )
73+ ? modulePreloadPolyfillPlugin ( config )
9974 : null ,
10075 ...( enableNativePlugin
10176 ? oxcResolvePlugin (
@@ -126,65 +101,23 @@ export async function resolvePlugins(
126101 htmlInlineProxyPlugin ( config ) ,
127102 cssPlugin ( config ) ,
128103 esbuildBannerFooterCompatPlugin ( config ) ,
129- config . oxc !== false
130- ? enableNativePlugin === true
131- ? perEnvironmentPlugin ( 'native:transform' , ( environment ) => {
132- const {
133- jsxInject,
134- include = / \. ( m ? t s | [ j t ] s x ) $ / ,
135- exclude = / \. j s $ / ,
136- jsxRefreshInclude,
137- jsxRefreshExclude,
138- ..._transformOptions
139- } = config . oxc as Exclude < OxcOptions , false | undefined >
140-
141- const transformOptions : OxcTransformOptions = _transformOptions
142- transformOptions . sourcemap =
143- environment . config . mode !== 'build' ||
144- ! ! environment . config . build . sourcemap
145-
146- return nativeTransformPlugin ( {
147- include,
148- exclude,
149- jsxRefreshInclude,
150- jsxRefreshExclude,
151- isServerConsumer : environment . config . consumer === 'server' ,
152- runtimeResolveBase : normalizePath (
153- url . fileURLToPath ( import . meta. url ) ,
154- ) ,
155- jsxInject,
156- transformOptions,
157- } )
158- } )
159- : oxcPlugin ( config )
160- : null ,
161- enableNativePlugin === true
162- ? nativeJsonPlugin ( { ...config . json , minify : isBuild } )
163- : jsonPlugin ( config . json , isBuild ) ,
164- enableNativePlugin === true ? nativeWasmHelperPlugin ( ) : wasmHelperPlugin ( ) ,
104+ config . oxc !== false ? oxcPlugin ( config ) : null ,
105+ jsonPlugin ( config . json , isBuild , enableNativePlugin === true ) ,
106+ wasmHelperPlugin ( config ) ,
165107 webWorkerPlugin ( config ) ,
166108 assetPlugin ( config ) ,
167109
168110 ...normalPlugins ,
169111
170- enableNativePlugin === true
171- ? nativeWasmFallbackPlugin ( )
172- : wasmFallbackPlugin ( ) ,
112+ wasmFallbackPlugin ( config ) ,
173113 definePlugin ( config ) ,
174114 cssPostPlugin ( config ) ,
175115 isBuild && buildHtmlPlugin ( config ) ,
176116 workerImportMetaUrlPlugin ( config ) ,
177117 assetImportMetaUrlPlugin ( config ) ,
178118 ...buildPlugins . pre ,
179- enableNativePlugin === true
180- ? nativeDynamicImportVarsPlugin ( )
181- : dynamicImportVarsPlugin ( config ) ,
182- enableNativePlugin === true
183- ? nativeImportGlobPlugin ( {
184- root : config . root ,
185- restoreQueryExtension : config . experimental . importGlobRestoreExtension ,
186- } )
187- : importGlobPlugin ( config ) ,
119+ dynamicImportVarsPlugin ( config ) ,
120+ importGlobPlugin ( config ) ,
188121
189122 ...postPlugins ,
190123
0 commit comments