fix: build bug (#2685)

This commit is contained in:
jack zhang 2023-09-20 17:56:36 +08:00 committed by GitHub
parent 56d1d1b85f
commit 196bec0ede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,8 +21,9 @@ import { getDepPkgPath, getDepsConfig } from './utils/getDepsConfig';
import { EsbuildSupportExts, globExcludeFiles } from './constant'; import { EsbuildSupportExts, globExcludeFiles } from './constant';
import { PkgLog, UserConfig, getPackageJson } from './utils'; import { PkgLog, UserConfig, getPackageJson } from './utils';
const serverGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/client/**', ...globExcludeFiles]; const validExts = ['.ts', '.tsx', '.js', '.jsx', '.mjs'];
const clientGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/server/**', ...globExcludeFiles]; 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 sourceGlobalFiles: string[] = ['src/**/*.{ts,js,tsx,jsx,mjs}', '!src/**/__tests__'];
const external = [ const external = [
@ -155,7 +156,7 @@ export function writeExternalPackageVersion(cwd: string, log: PkgLog) {
export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) { export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) {
log('build plugin server dependencies'); log('build plugin server dependencies');
const outDir = path.join(cwd, target_dir, 'node_modules'); 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 sourcePackages = getSourcePackages(serverFileSource);
const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix); const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix);
const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix);