@purekit/rollup-config 1.1.1 → 1.2.0

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/index.mjs +20 -23
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @purekit/rollup-config
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: 调整打包不生成注释
8
+
3
9
  ## 1.1.1
4
10
 
5
11
  ### Patch Changes
package/index.mjs CHANGED
@@ -1,40 +1,35 @@
1
- import typescript from "@rollup/plugin-typescript";
2
- import resolve from "@rollup/plugin-node-resolve";
3
- import commonjs from "@rollup/plugin-commonjs";
4
- import terser from "@rollup/plugin-terser";
5
- import dts from "rollup-plugin-dts";
6
- import alias from "@rollup/plugin-alias";
7
- import path from "path";
1
+ import typescript from '@rollup/plugin-typescript';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import terser from '@rollup/plugin-terser';
5
+ import dts from 'rollup-plugin-dts';
6
+ import alias from '@rollup/plugin-alias';
7
+ import path from 'path';
8
8
 
9
9
  /**
10
10
  * 创建 Rollup 配置
11
11
  * @param {Object} options 自定义选项
12
12
  * @param {string} options.input 入口文件,默认为 "src/index.ts"
13
13
  */
14
-
15
14
  export function createConfig(options = {}) {
16
- const input = options.input || "src/index.ts";
17
- const dist = "dist";
15
+ const input = options.input || 'src/index.ts';
16
+ const dist = 'dist';
18
17
 
19
- // 2. 获取当前执行构建的项目根目录
20
18
  const projectRoot = process.cwd();
21
19
 
22
- // 1. 定义默认输出 (CJS + ESM)
23
20
  const defaultOutput = [
24
21
  {
25
22
  file: `${dist}/index.js`,
26
- format: "cjs",
23
+ format: 'cjs',
27
24
  },
28
25
  {
29
26
  file: `${dist}/index.mjs`,
30
- format: "es",
27
+ format: 'es',
31
28
  },
32
29
  ];
33
30
 
34
- // 2. 决定最终使用哪个 Output (优先用传入的,否则用默认的)
35
31
  let finalOutput = options.output || defaultOutput;
36
32
 
37
- // 3. 【关键】强制处理 sourcemap: false
38
33
  if (!Array.isArray(finalOutput)) {
39
34
  finalOutput = [finalOutput];
40
35
  }
@@ -43,32 +38,34 @@ export function createConfig(options = {}) {
43
38
  sourcemap: false,
44
39
  }));
45
40
 
41
+ const isMinify = /(build|publish)/.test(process.env.npm_lifecycle_event || '');
42
+
46
43
  const jsConfig = {
47
44
  input,
48
- output: finalOutput, // 使用处理后的 output
45
+ output: finalOutput,
49
46
  external: (id) => /node_modules/.test(id),
50
47
  plugins: [
51
48
  alias({
52
49
  entries: [
53
50
  {
54
- find: "@",
55
- replacement: path.resolve(projectRoot, "src"),
51
+ find: '@',
52
+ replacement: path.resolve(projectRoot, 'src'),
56
53
  },
57
54
  ],
58
55
  }),
59
56
  resolve(),
60
57
  commonjs(),
61
58
  typescript({
62
- tsconfig: "./tsconfig.json",
59
+ tsconfig: './tsconfig.json',
63
60
  declaration: false,
64
61
  }),
65
- /build/.test(process.env.npm_lifecycle_event || "")
62
+ isMinify
66
63
  ? terser({
67
64
  format: { comments: false },
68
65
  compress: {
69
66
  drop_console: false,
70
67
  drop_debugger: true,
71
- pure_funcs: ["console.log", "console.info", "console.debug"],
68
+ pure_funcs: ['console.log', 'console.info', 'console.debug'],
72
69
  },
73
70
  })
74
71
  : null,
@@ -77,7 +74,7 @@ export function createConfig(options = {}) {
77
74
 
78
75
  const dtsConfig = {
79
76
  input,
80
- output: [{ file: `${dist}/index.d.ts`, format: "es" }],
77
+ output: [{ file: `${dist}/index.d.ts`, format: 'es' }],
81
78
  plugins: [dts()],
82
79
  };
83
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purekit/rollup-config",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.mjs",