From 19e8c68f37b2280c1709b8d3d6dd424064abaace Mon Sep 17 00:00:00 2001 From: patak Date: Mon, 22 May 2023 09:11:04 +0200 Subject: [PATCH] test: respect commonjs options in playgrounds (#13273) --- packages/vite/src/node/config.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 1933a5484b7565..72dc882973fa30 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -457,7 +457,12 @@ export async function resolveConfig( const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins] config = await runConfigHook(config, userPlugins, configEnv) - if (process.env.VITE_TEST_WITHOUT_PLUGIN_COMMONJS) { + // If there are custom commonjsOptions, don't force optimized deps for this test + // even if the env var is set as it would interfere with the playground specs. + if ( + !config.build?.commonjsOptions && + process.env.VITE_TEST_WITHOUT_PLUGIN_COMMONJS + ) { config = mergeConfig(config, { optimizeDeps: { disabled: false }, ssr: { optimizeDeps: { disabled: false } },