akfun 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/build2esm.js +5 -5
- package/src/build2node.js +3 -3
- package/src/rollup/build.js +2 -2
- package/src/rollup/rollup.node.config.js +1 -1
package/package.json
CHANGED
package/src/build2esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const getProjectConfig = require('./config/index'); // 用于获取当前项目配置文件
|
|
2
|
-
const rollupConfig = require('./config/rollup.config'); // rollup的配置文件
|
|
3
2
|
const { curConsoleTag } = require('./utils/akfunParams');
|
|
4
3
|
const rollupBuild = require('./rollup/build');
|
|
4
|
+
const rollupConfig = require('./rollup/rollup.config'); // rollup的配置文件
|
|
5
5
|
/**
|
|
6
6
|
* 用于构建 esm 模块
|
|
7
7
|
* @param {*} akfunConfig akfun 配置文件
|
|
@@ -26,12 +26,12 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
26
26
|
const consoleTag = _consoleTag || curConsoleTag;
|
|
27
27
|
// 获取项目配置文件
|
|
28
28
|
let config = getProjectConfig(akfunConfig);
|
|
29
|
-
|
|
30
|
-
const curRollupConfig = rollupConfig(fileName, config); // 默认配置
|
|
31
29
|
const build2esm = config.build2esm; // 用户的项目配置
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const curRollupConfig = rollupConfig(config, build2esm); // 默认配置
|
|
32
|
+
|
|
33
|
+
if (build2esm && !build2esm.format) {
|
|
34
|
+
build2esm.format = 'esm'; // 默认构建格式为 esm
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
rollupBuild(config, build2esm, curRollupConfig, consoleTag);
|
package/src/build2node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const getProjectConfig = require('./config/index'); // 用于获取当前项目配置文件
|
|
2
|
-
const rollupConfig = require('./config/rollup.node.config'); // rollup的配置文件
|
|
3
2
|
const { curConsoleTag } = require('./utils/akfunParams');
|
|
4
3
|
const rollupBuild = require('./rollup/build');
|
|
4
|
+
const rollupConfig = require('./rollup/rollup.node.config'); // rollup的配置文件
|
|
5
5
|
/**
|
|
6
6
|
* 用于构建 esm 模块
|
|
7
7
|
* @param {*} akfunConfig akfun 配置文件
|
|
@@ -22,10 +22,10 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
22
22
|
const consoleTag = _consoleTag || curConsoleTag;
|
|
23
23
|
// 获取项目配置文件
|
|
24
24
|
let config = getProjectConfig(akfunConfig);
|
|
25
|
-
|
|
26
|
-
const curRollupConfig = rollupConfig(fileName, config); // 默认配置
|
|
27
25
|
const build2node = config.build2node; // 用户的项目配置
|
|
28
26
|
|
|
27
|
+
const curRollupConfig = rollupConfig(config, build2node); // 默认配置
|
|
28
|
+
|
|
29
29
|
build2node.format = 'cjs'; // 构建格式固定为 cjs,无需用户配置
|
|
30
30
|
|
|
31
31
|
rollupBuild(config, build2node, curRollupConfig, consoleTag);
|
package/src/rollup/build.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const ora = require('ora');
|
|
2
2
|
const rollup = require('rollup');
|
|
3
3
|
const terser = require('@rollup/plugin-terser'); // 压缩
|
|
4
|
-
const { isArray, isObject } = require('
|
|
5
|
-
const { curConsoleTag } = require('
|
|
4
|
+
const { isArray, isObject } = require('../utils/typeof');
|
|
5
|
+
const { curConsoleTag } = require('../utils/akfunParams');
|
|
6
6
|
|
|
7
7
|
async function rollupBuildFunc(envConfig, curConfig) {
|
|
8
8
|
// create a bundle
|
|
@@ -75,7 +75,7 @@ module.exports = function (curConfig, curEnvConfig) {
|
|
|
75
75
|
],
|
|
76
76
|
output: {
|
|
77
77
|
dir: resolve('dist'),
|
|
78
|
-
format:
|
|
78
|
+
format: buildFormat, // which can be one of "amd", "cjs", "system", "es", "iife" or "umd".
|
|
79
79
|
preserveModules: true, // 关键:保留原始模块结构,不合并文件
|
|
80
80
|
preserveModulesRoot: 'src', // 指定模块根目录
|
|
81
81
|
exports: 'auto', // 自动处理导出(适配 ES 模块的默认导出/命名导出)
|