From 196bec0ede6cc5412c71830a293c0062d7599534 Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Wed, 20 Sep 2023 17:56:36 +0800 Subject: [PATCH] fix: build bug (#2685) --- packages/core/build/src/buildPlugin.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/build/src/buildPlugin.ts b/packages/core/build/src/buildPlugin.ts index 1e10ed4159..5833554764 100644 --- a/packages/core/build/src/buildPlugin.ts +++ b/packages/core/build/src/buildPlugin.ts @@ -21,8 +21,9 @@ import { getDepPkgPath, getDepsConfig } from './utils/getDepsConfig'; import { EsbuildSupportExts, globExcludeFiles } from './constant'; import { PkgLog, UserConfig, getPackageJson } from './utils'; -const serverGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/client/**', ...globExcludeFiles]; -const clientGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/server/**', ...globExcludeFiles]; +const validExts = ['.ts', '.tsx', '.js', '.jsx', '.mjs']; +const serverGlobalFiles: string[] = ['src/**', '!src/client/**', ...globExcludeFiles]; +const clientGlobalFiles: string[] = ['src/**', '!src/server/**', ...globExcludeFiles]; const sourceGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/**/__tests__']; const external = [ @@ -155,7 +156,7 @@ export function writeExternalPackageVersion(cwd: string, log: PkgLog) { export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) { log('build plugin server dependencies'); const outDir = path.join(cwd, target_dir, 'node_modules'); - const serverFileSource = serverFiles.map((item) => fs.readFileSync(item, 'utf-8')); + const serverFileSource = serverFiles.filter(item => validExts.includes(path.extname(item))).map((item) => fs.readFileSync(item, 'utf-8')); const sourcePackages = getSourcePackages(serverFileSource); const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix); const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix);