fix: 修复 amis-editor 校验面板没有翻译的问题 (#10974)

This commit is contained in:
liaoxuezhi 2024-09-27 15:22:41 +08:00 committed by GitHub
parent 8ac45be9ec
commit 4372a8330c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 182 additions and 113 deletions

View File

@ -15,6 +15,7 @@ import {
dependencies
} from './package.json';
import path from 'path';
import fs from 'fs';
const isDev = process.env.NODE_ENV !== 'production';
@ -22,38 +23,30 @@ const settings = {
globals: {}
};
const external = id => {
const result = new RegExp(
`^(?:${Object.keys(dependencies)
.concat([
'react',
'react-dom',
'react-overlays',
'warning',
'tslib',
'dom-helpers',
'@restart/hooks',
'entities',
'linkify-it',
'markdown-it',
'prop-types',
'markdown-it-html5-media',
'mdurl',
'uc.micro',
'@babel/runtime'
])
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (!result && ~id.indexOf('node_modules')) {
console.log(id);
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
return result;
};
});
const external = id =>
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
const input = './src/index.tsx';
/** 获取子包编译后的入口路径,需要使用相对路径 */
@ -200,7 +193,8 @@ function getPlugins(format = 'esm') {
}),
replace({
preventAssignment: true,
__buildVersion: version
__buildVersion: version,
__buildTime: () => new Date().toISOString()
}),
typescript(typeScriptOptions),
commonjs({

View File

@ -125,6 +125,10 @@ import {StatusScoped} from './StatusScoped';
// @ts-ignore
export const version = '__buildVersion';
(window as any).amisVersionInfo = {
version: '__buildVersion',
buildTime: '__buildTime'
};
export {
clearStoresCache,

View File

@ -14,8 +14,8 @@ import {
dependencies
} from './package.json';
import path from 'path';
import svgr from '@svgr/rollup';
import fs from 'fs';
import svgr from '@svgr/rollup';
import i18nPlugin from 'plugin-react-i18n';
import postcssImport from 'postcss-import';
import minify from 'postcss-minify';
@ -30,15 +30,30 @@ const settings = {
globals: {}
};
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
new RegExp(
`^(?:${Object.keys(dependencies)
.concat(fs.readdirSync(path.join(__dirname, '../../node_modules')))
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
const input = './src/index.ts';
export default [
@ -152,7 +167,8 @@ function getPlugins(format = 'esm') {
}),
replace({
preventAssignment: true,
__buildVersion: version
__buildVersion: version,
__buildTime: () => new Date().toISOString()
}),
commonjs({
sourceMap: false

View File

@ -44,6 +44,10 @@ import WidthDraggableContainer from './component/base/WidthDraggableContainer';
import {SchemaFrom} from './component/base/SchemaForm';
export const version = '__buildVersion';
(window as any).amisEditorVersionInfo = {
version: '__buildVersion',
buildTime: '__buildTime'
};
export default Editor;

View File

@ -14,8 +14,8 @@ import {
dependencies
} from './package.json';
import path from 'path';
import svgr from '@svgr/rollup';
import fs from 'fs';
import svgr from '@svgr/rollup';
import i18nPlugin from 'plugin-react-i18n';
import moment from 'moment';
@ -23,22 +23,33 @@ const i18nConfig = require('./i18nConfig');
const settings = {
globals: {},
commonConfig: {
footer: `window.amisEditorVersionInfo={version:'${version}',buildTime:'${moment().format(
'YYYY-MM-DD'
)}'};`
}
commonConfig: {}
};
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
new RegExp(
`^(?:${Object.keys(dependencies)
.concat(fs.readdirSync(path.join(__dirname, '../../node_modules')))
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
const input = './src/index.tsx';
export default [

View File

@ -1,5 +1,5 @@
import 'amis';
import './locale/index';
export * from './locale/index';
export * from 'amis-editor-core';
export * from './builder';
import './tpl/index';

View File

@ -1,3 +1,4 @@
import './locale/index';
/**
* @file
*/

View File

@ -13,20 +13,36 @@ import {
dependencies
} from './package.json';
import path from 'path';
import fs from 'fs';
const settings = {
globals: {}
};
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
new RegExp(
`^(?:${Object.keys(dependencies)
.concat([])
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
export default [
{

View File

@ -15,6 +15,7 @@ import {
dependencies
} from './package.json';
import path from 'path';
import fs from 'fs';
import svgr from '@svgr/rollup';
import fs from 'fs';
import i18nPlugin from 'plugin-react-i18n';
@ -25,15 +26,30 @@ const settings = {
globals: {}
};
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
new RegExp(
`^(?:${Object.keys(dependencies ?? {})
.concat(fs.readdirSync(path.join(__dirname, '../../node_modules')))
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
const input = ['./src/index.ts'];
export default [

View File

@ -19,29 +19,37 @@ import {
dependencies
} from './package.json';
import path from 'path';
import fs from 'fs';
import svgr from '@svgr/rollup';
const settings = {
globals: {}
};
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
new RegExp(
`^(?:${Object.keys(dependencies)
.concat([
'linkify-it',
'react-is',
'markdown-it',
'markdown-it-html5-media',
'mdurl',
'uc.micro',
'entities'
])
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
const input = [
'./src/index.tsx',
'./src/components/ColorPicker.tsx', // 默认不加载的需要手动维护列表,否则不会编译

View File

@ -14,42 +14,41 @@ import {
dependencies
} from './package.json';
import path from 'path';
import fs from 'fs';
import svgr from '@svgr/rollup';
import moment from 'moment';
import babel from 'rollup-plugin-babel';
const settings = {
globals: {},
commonConfig: {
footer: `window.amisVersionInfo={version:'${version}',buildTime:'${moment().format(
'YYYY-MM-DD'
)}'};`
}
commonConfig: {}
};
const external = id => {
const result = new RegExp(
`^(?:${Object.keys(dependencies)
.concat([
'monaco-editor',
'react',
'react-dom',
'rc-input-number',
'@rc-component/mini-decimal',
'@babel/runtime'
])
.map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
)
.join('|')})`
).test(id);
const pkgs = [];
// 读取所有的node_modules目录获取所有的包名
[
path.join(__dirname, './node_modules'),
path.join(__dirname, '../../node_modules')
].forEach(dir => {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach(item => {
if (item.startsWith('.')) {
return;
}
if (!result && ~id.indexOf('node_modules')) {
console.log(id);
if (item.startsWith('@')) {
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
pkgs.push(item + '/' + subItem);
});
}
return pkgs.push(item);
});
}
});
const external = id =>
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
return result;
};
const input = './src/index.tsx';
/** 获取子包编译后的入口路径,需要使用相对路径 */