Skip to content

Commit

Permalink
🚧 数据格式调整
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkioTomas committed Aug 26, 2024
1 parent 94d2246 commit afd1c1d
Show file tree
Hide file tree
Showing 173 changed files with 565 additions and 276 deletions.
8 changes: 4 additions & 4 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
"build": "jest && webpack --mode production"
},
"devDependencies": {
"@babel/core": "^7.24.9",
"@babel/preset-env": "^7.24.8",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.0.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/pluginutils": "^5.1.0",
"babel-jest": "^29.7.0",
"crypto": "^1.0.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"glob": "^11.0.0",
"jest": "^29.7.0",
"prettier": "3.2.5",
"rollup": "^4.18.1",
"rollup": "^4.21.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-terser": "^1.0.3"
},
Expand Down
47 changes: 43 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import fs from 'fs';
import { createFilter } from '@rollup/pluginutils';
import { terser } from 'rollup-terser';
import babel from '@rollup/plugin-babel';

// 递归地获取所有规则文件
function getRuleFiles(dirPath) {
Expand All @@ -21,6 +22,7 @@ function getRuleFiles(dirPath) {
return files;
}
const rulesFolder = path.join('src', 'rule');
const utilsFolder = path.join('src', 'utils');
const ruleFiles = getRuleFiles(rulesFolder);
const externalFilter = createFilter([], null, { resolve: false });
const rules = [];
Expand Down Expand Up @@ -48,13 +50,41 @@ const outputs = ruleFiles.map(file => {
// exports: 'none', // 禁止导出模块的方式
// banner: `let ${ruleName} = {};`,
// footer: `let ${ruleName} = ${ruleName};`, // 将变量暴露到全局对象 window 上
globals: {
'./src/utils/RuleObject': 'RuleObject',
'./src/utils/BillType': 'BillType',
'./src/utils/Currency': 'Currency',
'./src/utils/Time': 'Time',
'./src/utils/Number': 'Number',
},
},
plugins: [terser()],
external: id => externalFilter(id),
plugins: [
terser(),
// resolve('', ''), // 解析 node_modules 中的模块
// commonjs(), // 将 CommonJS 模块转换为 ES6 模块
babel({
babelHelpers: 'bundled', // Babel 帮助程序类型
exclude: 'node_modules/**', // 排除 node_modules 目录
presets: [
'@babel/preset-env', // 使用 Babel 预设
],
}),
],
external: [
'./src/utils/RuleObject',
'./src/utils/BillType',
'./src/utils/Currency',
'./src/utils/Time',
'./src/utils/Number',
],
};
});
// 删除dist文件夹
fs.rmdirSync(path.join('dist'), { recursive: true });
// 如果dist文件夹存在就删除文件夹
// TODO
try {
fs.rmSync(path.join('dist'), { recursive: true });
} catch (e) {}
// 创建dist文件夹
fs.mkdirSync(path.join('dist'), { recursive: true });
// 将规则信息写入rules.json文件
Expand Down Expand Up @@ -88,7 +118,16 @@ outputs.push({
};
`,
},
plugins: [terser()],
plugins: [
terser(),
babel({
babelHelpers: 'bundled', // Babel 帮助程序类型
exclude: 'node_modules/**', // 排除 node_modules 目录
presets: [
'@babel/preset-env', // 使用 Babel 预设
],
}),
],
});

outputs.push({
Expand Down
Loading

0 comments on commit afd1c1d

Please sign in to comment.