mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2026-07-06 16:21:09 +08:00
Compare commits
No commits in common. "ed26dfb39b753f7d28ab1e3d6bd43fb90c972427" and "8448e38c379bee2db71abb77fcc3db7488fc689a" have entirely different histories.
ed26dfb39b
...
8448e38c37
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -35,7 +34,5 @@ export default defineConfig({
|
||||
dts: true,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/plugins/commands/index-default.html', 'dist/plugins/commands/index-default.html');
|
||||
},
|
||||
onSuccess: 'cp -r src/plugins/commands/index-default.html dist/plugins/commands/index-default.html',
|
||||
});
|
||||
|
||||
@ -3,7 +3,6 @@ import assert from 'node:assert';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { extname, join } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { chalk, chokidar, compatESModuleRequire, deepmerge, lodash, winPath } from '@fesjs/utils';
|
||||
import joi from 'joi';
|
||||
import { ServiceStage } from '../service/enums';
|
||||
@ -142,11 +141,7 @@ export default class Config {
|
||||
}
|
||||
|
||||
async requireConfigs(configFiles: string[]): Promise<any[]> {
|
||||
const models = await Promise.all(configFiles.map(f => {
|
||||
// 使用 pathToFileURL 确保在 Windows 下路径格式正确
|
||||
const fileUrl = pathToFileURL(f).href;
|
||||
return import(fileUrl);
|
||||
}));
|
||||
const models = await Promise.all(configFiles.map(f => import(f)));
|
||||
return models.map(m => compatESModuleRequire(m));
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import type { Plugin } from '../../types';
|
||||
import { basename, dirname, extname, join, relative } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { chalk, compatESModuleRequire, lodash, resolve, winPath } from '@fesjs/utils';
|
||||
import { readJSONSync } from 'fs-extra/esm';
|
||||
import { packageUp } from 'package-up';
|
||||
@ -159,9 +158,7 @@ export async function pathToObj({ path, type, cwd }: PathToObjOptions): Promise<
|
||||
path: winPath(path),
|
||||
async apply() {
|
||||
try {
|
||||
// 使用 pathToFileURL 确保在 Windows 下路径格式正确
|
||||
const fileUrl = pathToFileURL(path).href;
|
||||
const ret = await import(fileUrl);
|
||||
const ret = await import(path);
|
||||
// use the default member for es modules
|
||||
return compatESModuleRequire(ret);
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,8 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess() {
|
||||
copySync('public', 'dist');
|
||||
},
|
||||
onSuccess: 'cp public/* dist/',
|
||||
format: ['esm'],
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -10,7 +9,5 @@ export default defineConfig({
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>Fes4.x webpack - micro - index</div>
|
||||
<div>webpack - micro - index</div>
|
||||
</template>
|
||||
|
||||
<config>
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -14,8 +13,5 @@ export default defineConfig({
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess() {
|
||||
copySync('src/main/runtime', 'dist/main/runtime');
|
||||
copySync('src/micro/runtime', 'dist/micro/runtime');
|
||||
},
|
||||
onSuccess: 'cp -r src/main/runtime dist/main && cp -r src/micro/runtime dist/micro',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/template', 'dist/template');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/template dist',
|
||||
});
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,7 +8,6 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { chokidar, lodash } from '@fesjs/utils';
|
||||
|
||||
export default (api) => {
|
||||
@ -101,7 +100,7 @@ export default (api) => {
|
||||
// require最新的 mock.js 文件
|
||||
try {
|
||||
// register babel
|
||||
const _initFunction = await import(pathToFileURL(mockFile).href);
|
||||
const _initFunction = await import(mockFile);
|
||||
const initFunction = _initFunction.default || _initFunction;
|
||||
if (!lodash.isFunction(initFunction)) {
|
||||
api.logger.info('mock.js should export Function');
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
import { copyFileSync, mkdirSync, readdirSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { defineConfig } from 'tsup';
|
||||
import { copyTplFiles } from '../../scripts/shared.mjs';
|
||||
|
||||
function copyTplFiles(srcDir: string, dstDir: string) {
|
||||
function walk(currentSrc: string, currentDst: string) {
|
||||
readdirSync(currentSrc, { withFileTypes: true }).forEach((dirent) => {
|
||||
const srcPath = join(currentSrc, dirent.name);
|
||||
const dstPath = join(currentDst, dirent.name);
|
||||
|
||||
if (dirent.isDirectory()) {
|
||||
walk(srcPath, dstPath);
|
||||
}
|
||||
else if (dirent.isFile() && dirent.name.endsWith('.tpl')) {
|
||||
mkdirSync(dirname(dstPath), { recursive: true });
|
||||
copyFileSync(srcPath, dstPath);
|
||||
console.log(`Copied: ${srcPath} -> ${dstPath}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
walk(srcDir, dstDir);
|
||||
}
|
||||
export default defineConfig({
|
||||
entry: [
|
||||
'src/index.ts',
|
||||
@ -38,6 +57,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: () => {
|
||||
copyTplFiles('src', 'dist');
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user