Skip to content

Commit

Permalink
chore: test swc ast
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Dec 19, 2024
1 parent 5025fb5 commit 6703c14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
Logger,
clearScreen,
colors,
determineEnvironment,
isArray,
isEmptyObject,
isNodeEnv,
isObject,
isWindows,
normalizePath
Expand Down Expand Up @@ -392,9 +392,9 @@ export async function normalizeUserCompilationConfig(
resolvedCompilation.mode ??= mode;

setProcessEnv(resolvedCompilation.mode);
const targetEnv = determineEnvironment(resolvedCompilation.output.targetEnv);
const isNode = isNodeEnv(resolvedCompilation.output.targetEnv);
if (
targetEnv !== 'node' &&
!isNode &&
isArray(resolvedCompilation.runtime.plugins) &&
resolvedUserConfig.server?.hmr &&
!resolvedCompilation.runtime.plugins.includes(hmrClientPluginPath)
Expand Down Expand Up @@ -824,7 +824,7 @@ export async function checkCompilationInputValue(
const { compilation } = userConfig;
const targetEnv = compilation?.output?.targetEnv;
const inputValue = Object.values(compilation?.input).filter(Boolean);
const isTargetNode = determineEnvironment(targetEnv) === 'node';
const isTargetNode = isNodeEnv(targetEnv);
const defaultHtmlPath = './index.html';
let inputIndexConfig: {
index?: string;
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/utils/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,3 @@ export function arrayEqual(a: any[], b: any[]): boolean {
export function isNodeEnv(env: OutputConfig['targetEnv']): boolean {
return /^(node|library)(?!-browser)/.test(env);
}

export function determineEnvironment(targetEnv: string): 'node' | 'browser' {
if (
FARM_TARGET_LIBRARY_ENVS.includes(targetEnv) ||
FARM_TARGET_NODE_ENVS.includes(targetEnv)
) {
return 'node';
}
return 'browser';
}

0 comments on commit 6703c14

Please sign in to comment.