Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,13 @@ export interface ExperimentalOptions {
*
* - 'resolver' (deprecated, will be removed in v8 stable): Enable only the native resolver plugin.
* - 'v1' (will be deprecated, will be removed in v8 stable): Enable the first stable set of native plugins (including resolver).
* - true: Enable all native plugins (currently an alias of 'v1', it will map to a newer one in the future versions).
* - 'v2' (will be deprecated, will be removed in v8 stable): Enable the improved dynamicImportVarsPlugin and importGlobPlugin.
* - true: Enable all native plugins (currently an alias of 'v2', it will map to a newer one in the future versions).
*
* @experimental
* @default 'v1'
* @default 'v2'
*/
enableNativePlugin?: boolean | 'resolver' | 'v1'
enableNativePlugin?: boolean | 'resolver' | 'v1' | 'v2'
/**
* Enable full bundle mode.
*
Expand Down Expand Up @@ -787,7 +788,7 @@ const configDefaults = Object.freeze({
importGlobRestoreExtension: false,
renderBuiltUrl: undefined,
hmrPartialAccept: false,
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : 'v1',
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : 'v2',
bundledDev: false,
},
future: {
Expand Down Expand Up @@ -2092,8 +2093,10 @@ function resolveNativePluginEnabledLevel(
case 'resolver':
return 0
case 'v1':
case true:
return 1
case 'v2':
case true:
return 2
case false:
return -1
default:
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/node/plugins/dynamicImportVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ export function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin {
resolver(id, importer) {
return resolve(environment, id, importer)
},
isV2:
config.nativePluginEnabledLevel >= 2
? {
sourcemap: !!environment.config.build.sourcemap,
}
: undefined,
})
})
}
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/node/plugins/importMetaGlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
return nativeImportGlobPlugin({
root: config.root,
restoreQueryExtension: config.experimental.importGlobRestoreExtension,
isV2:
config.nativePluginEnabledLevel >= 2
? {
sourcemap: !!config.build.sourcemap,
}
: undefined,
})
}

Expand Down
Loading