@purekit/rollup-config 1.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @purekit/rollup-config
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8a64a1b: feat:修改前缀
8
+
9
+ ## 1.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 46b1d53: feat:新增 ts 类型合并打入
14
+
15
+ ## 1.0.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 64885f9: feat:新增 ts 类型
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 purekit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.mjs ADDED
@@ -0,0 +1,69 @@
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
+
7
+ /**
8
+ * 创建 Rollup 配置
9
+ * @param {Object} options 自定义选项
10
+ * @param {string} options.input 入口文件,默认为 "src/index.ts"
11
+ */
12
+ export function createConfig(options = {}) {
13
+ const input = options.input || "src/index.ts";
14
+ const dist = "dist";
15
+
16
+ // 1. 定义默认输出 (CJS + ESM)
17
+ const defaultOutput = [
18
+ {
19
+ file: `${dist}/index.js`,
20
+ format: "cjs",
21
+ },
22
+ {
23
+ file: `${dist}/index.mjs`,
24
+ format: "es",
25
+ },
26
+ ];
27
+
28
+ // 2. 决定最终使用哪个 Output (优先用传入的,否则用默认的)
29
+ let finalOutput = options.output || defaultOutput;
30
+
31
+ // 3. 【关键】强制处理 sourcemap: false
32
+ if (!Array.isArray(finalOutput)) {
33
+ finalOutput = [finalOutput];
34
+ }
35
+ finalOutput = finalOutput.map((item) => ({
36
+ ...item,
37
+ sourcemap: false, // 👈 强制覆盖
38
+ }));
39
+
40
+ const jsConfig = {
41
+ input,
42
+ output: finalOutput, // 使用处理后的 output
43
+ external: (id) => /node_modules/.test(id),
44
+ plugins: [
45
+ resolve(),
46
+ commonjs(),
47
+ typescript({
48
+ tsconfig: "./tsconfig.json",
49
+ declaration: false,
50
+ }),
51
+ terser({
52
+ format: { comments: false },
53
+ compress: {
54
+ drop_console: false,
55
+ drop_debugger: true,
56
+ pure_funcs: ["console.log", "console.info", "console.debug"],
57
+ },
58
+ }),
59
+ ],
60
+ };
61
+
62
+ const dtsConfig = {
63
+ input,
64
+ output: [{ file: `${dist}/index.d.ts`, format: "es" }],
65
+ plugins: [dts()],
66
+ };
67
+
68
+ return [jsConfig, dtsConfig];
69
+ }
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@purekit/rollup-config",
3
+ "version": "1.1.0",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "index.mjs",
7
+ "exports": {
8
+ ".": "./index.mjs"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC"
13
+ }