mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2026-07-04 23:21:09 +08:00
Compare commits
3 Commits
8448e38c37
...
ed26dfb39b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed26dfb39b | ||
|
|
2c69c96642 | ||
|
|
7c33e3e3ab |
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -34,5 +35,7 @@ export default defineConfig({
|
||||
dts: true,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
onSuccess: 'cp -r src/plugins/commands/index-default.html dist/plugins/commands/index-default.html',
|
||||
onSuccess() {
|
||||
copySync('src/plugins/commands/index-default.html', 'dist/plugins/commands/index-default.html');
|
||||
},
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@ 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';
|
||||
@ -141,7 +142,11 @@ export default class Config {
|
||||
}
|
||||
|
||||
async requireConfigs(configFiles: string[]): Promise<any[]> {
|
||||
const models = await Promise.all(configFiles.map(f => import(f)));
|
||||
const models = await Promise.all(configFiles.map(f => {
|
||||
// 使用 pathToFileURL 确保在 Windows 下路径格式正确
|
||||
const fileUrl = pathToFileURL(f).href;
|
||||
return import(fileUrl);
|
||||
}));
|
||||
return models.map(m => compatESModuleRequire(m));
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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';
|
||||
@ -158,7 +159,9 @@ export async function pathToObj({ path, type, cwd }: PathToObjOptions): Promise<
|
||||
path: winPath(path),
|
||||
async apply() {
|
||||
try {
|
||||
const ret = await import(path);
|
||||
// 使用 pathToFileURL 确保在 Windows 下路径格式正确
|
||||
const fileUrl = pathToFileURL(path).href;
|
||||
const ret = await import(fileUrl);
|
||||
// use the default member for es modules
|
||||
return compatESModuleRequire(ret);
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,8 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp public/* dist/',
|
||||
onSuccess() {
|
||||
copySync('public', 'dist');
|
||||
},
|
||||
format: ['esm'],
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -9,5 +10,7 @@ export default defineConfig({
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>webpack - micro - index</div>
|
||||
<div>Fes4.x webpack - micro - index</div>
|
||||
</template>
|
||||
|
||||
<config>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -13,5 +14,8 @@ export default defineConfig({
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/main/runtime dist/main && cp -r src/micro/runtime dist/micro',
|
||||
onSuccess() {
|
||||
copySync('src/main/runtime', 'dist/main/runtime');
|
||||
copySync('src/micro/runtime', 'dist/micro/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/template dist',
|
||||
onSuccess() {
|
||||
copySync('src/template', 'dist/template');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
@ -8,6 +9,7 @@ export default defineConfig({
|
||||
dts: false,
|
||||
shims: true,
|
||||
format: ['esm'],
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
onSuccess: 'cp -r src/runtime dist',
|
||||
onSuccess() {
|
||||
copySync('src/runtime', 'dist/runtime');
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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) => {
|
||||
@ -100,7 +101,7 @@ export default (api) => {
|
||||
// require最新的 mock.js 文件
|
||||
try {
|
||||
// register babel
|
||||
const _initFunction = await import(mockFile);
|
||||
const _initFunction = await import(pathToFileURL(mockFile).href);
|
||||
const initFunction = _initFunction.default || _initFunction;
|
||||
if (!lodash.isFunction(initFunction)) {
|
||||
api.logger.info('mock.js should export Function');
|
||||
|
||||
@ -1,25 +1,6 @@
|
||||
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',
|
||||
@ -57,7 +38,6 @@ 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