@doracli/rollup 0.0.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.
@@ -0,0 +1,235 @@
1
+ import * as rollup from 'rollup';
2
+ import { ExternalOption, InputOption, OutputOptions, WatcherOptions, Plugin, RollupOptions, RollupWatcher, RollupWatchOptions, RollupBuild } from 'rollup';
3
+ export { RollupBuild } from 'rollup';
4
+ import { TPlainObject } from '@cclr/lang';
5
+ import { RollupAliasOptions } from '@rollup/plugin-alias';
6
+ import { RollupBabelInputPluginOptions } from '@rollup/plugin-babel';
7
+ import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
8
+ import { CopyOptions } from 'rollup-plugin-copy';
9
+ import * as _doracli_type from '@doracli/type';
10
+ import { TDoraConfigCommon, TDoraConfigRollup } from '@doracli/type';
11
+ import { Options } from 'rollup-plugin-dts';
12
+ import { RollupJsonOptions } from '@rollup/plugin-json';
13
+ import { PostCSSPluginConf } from 'rollup-plugin-postcss';
14
+ import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
15
+ import { ConfigCtx } from '@doracli/helper';
16
+
17
+ /** 动作 */
18
+ type TAction = 'build' | 'dev' | 'watch';
19
+ type TEnvParams = {
20
+ /** 开发模式 */
21
+ action: TAction;
22
+ /** 工作目录,绝对路径 cwd */
23
+ workRootDir: string;
24
+ };
25
+
26
+ type TOutputOptions = OutputOptions;
27
+ type TInputOption = InputOption;
28
+ type TWatcherOptions = WatcherOptions;
29
+ type TExternalOption = ExternalOption;
30
+ type TUserExternalOption = {
31
+ /**
32
+ * 过滤器,判断是否需要包含模块
33
+ * @param source 模块名
34
+ * @return boolean 返回true表示 - 会被打包进产物
35
+ */
36
+ filter?: (source: string) => boolean;
37
+ externals?: string[] | Record<string, string>;
38
+ internals?: string[] | Record<string, string>;
39
+ dependencies?: Record<string, string>;
40
+ peerDependencies?: Record<string, string>;
41
+ devDependencies?: Record<string, string>;
42
+ };
43
+
44
+ /**
45
+ * 获取external配置
46
+ * @param envParams 环境参数
47
+ * @param options 用户配置的external选项
48
+ * @returns TExternalOption
49
+ */
50
+ declare const getExternal: (_envParams: TEnvParams, options?: TUserExternalOption) => TExternalOption;
51
+
52
+ type TInputParams = string | Record<string, string>;
53
+ /**
54
+ * 获取入口文件
55
+ * @description input 不传,则自动寻找
56
+ * @param envParams 环境参数
57
+ * @param input 入口文件路径
58
+ * @returnscj
59
+ */
60
+ declare const getInput: (envParams: TEnvParams, input?: TInputParams) => Promise<TInputOption>;
61
+
62
+ /**
63
+ * 生成单个output
64
+ * @description 如果不配置output,则默认生成cjs格式的output,输出路径为`lib/index.js`
65
+ * @description 自动组合完整的file
66
+ * @param optionsOutput
67
+ * @returns
68
+ */
69
+ declare const getOutput: (envParams: TEnvParams, options?: TOutputOptions) => TOutputOptions;
70
+
71
+ /**
72
+ * 获取别名插件
73
+ * @param config 快捷配置
74
+ * @param pluginConfig 标准配置
75
+ * @returns 别名插件
76
+ */
77
+ declare const getAliasPlugin: (config: {
78
+ tsConfigPath?: TPlainObject;
79
+ alias?: TPlainObject;
80
+ }, pluginConfig?: RollupAliasOptions) => rollup.Plugin<any>;
81
+
82
+ /**
83
+ * 获取Babel插件
84
+ * @param _config 快捷配置
85
+ * @param pluginConfig 标准配置
86
+ * @returns Babel插件
87
+ */
88
+ declare const getBabelPlugin: (_config: TPlainObject, pluginConfig?: RollupBabelInputPluginOptions) => rollup.Plugin<any>;
89
+
90
+ /**
91
+ * 获取CommonJS插件
92
+ * @description 将 CommonJS 转换成 ES2015 模块供 Rollup 处理
93
+ * @param _config
94
+ * @param pluginConfig
95
+ * @returns
96
+ */
97
+ declare const getCommonjsPlugin: (_config: TPlainObject, pluginConfig?: RollupCommonJSOptions) => rollup.Plugin<any>;
98
+
99
+ /**
100
+ * 获取拷贝插件
101
+ * @param config 快捷配置
102
+ * @param pluginConfig 标准配置
103
+ * @returns 拷贝插件
104
+ */
105
+ declare const getCopyPlugin: (config: {
106
+ copyList?: TDoraConfigCommon["copy"];
107
+ }, pluginConfig?: CopyOptions) => rollup.Plugin<any>;
108
+
109
+ /**
110
+ * 获取 dts 插件
111
+ * @param _config
112
+ * @param pluginConfig
113
+ * @returns
114
+ */
115
+ declare const getDtsPlugin: (_config: TPlainObject, pluginConfig?: Options) => rollup.Plugin<any>;
116
+
117
+ /**
118
+ * 获取Json插件
119
+ * @description 允许将 .json 文件作为 ES6 模块导入
120
+ * @param _config
121
+ * @param pluginConfig
122
+ * @returns
123
+ */
124
+ declare const getJsonPlugin: (_config: TPlainObject, pluginConfig?: RollupJsonOptions) => rollup.Plugin<any>;
125
+
126
+ /**
127
+ * 获取代码压缩插件
128
+ * @returns Minimize插件
129
+ */
130
+ declare const getMinimizePlugin: () => rollup.Plugin<any>;
131
+
132
+ /**
133
+ * 创建Postcss插件
134
+ * @param config 快捷配置
135
+ * @param pluginConfig 标准配置
136
+ * @returns Postcss插件
137
+ */
138
+ declare const getPostcssPlugin: (config: {
139
+ minimize?: boolean;
140
+ output: string;
141
+ }, pluginConfig?: PostCSSPluginConf) => rollup.Plugin<any>;
142
+
143
+ /**
144
+ * 获取解析插件
145
+ * @param config 快捷配置
146
+ * @param pluginConfig 标准配置
147
+ * @returns 解析插件
148
+ */
149
+ declare const getResolvePlugin: (config: {
150
+ extensions?: string[];
151
+ }, pluginConfig?: RollupNodeResolveOptions) => rollup.Plugin<any>;
152
+
153
+ /**
154
+ * 获取Node环境下的插件集合
155
+ * @param config 快捷配置
156
+ * @returns
157
+ */
158
+ declare const getNodePlugins: (config: {
159
+ minimize?: boolean;
160
+ alias?: Record<string, string>;
161
+ copyMap?: Record<string, string>;
162
+ }) => rollup.Plugin<any>[];
163
+
164
+ /**
165
+ * 获取Node环境下的插件集合
166
+ * @param config 快捷配置
167
+ * @returns
168
+ */
169
+ declare const getReactPlugins: (config: {
170
+ minimize?: boolean;
171
+ cssOutput?: string;
172
+ alias?: Record<string, string>;
173
+ copy?: TDoraConfigCommon["copy"];
174
+ }) => Promise<Plugin<any>[]>;
175
+
176
+ /**
177
+ * 获取watch配置
178
+ * @param options
179
+ * @returns
180
+ */
181
+ declare const getWatch: (envParams: TEnvParams, options?: TWatcherOptions) => TWatcherOptions;
182
+
183
+ /**
184
+ * Create a Rollup build with the given options.
185
+ * @param options RollupOptions
186
+ * @returns
187
+ */
188
+ declare const createRollupBuild: (options: RollupOptions) => Promise<rollup.RollupBuild>;
189
+
190
+ declare class Ctx {
191
+ configCtx: ConfigCtx;
192
+ rollupOptions: RollupOptions;
193
+ rollupOutputList: TOutputOptions[];
194
+ envParams: TEnvParams;
195
+ constructor(configCtx: ConfigCtx);
196
+ updateEnvParams(argv: Partial<TEnvParams>): void;
197
+ updateRollupOptions(options: Partial<RollupOptions>): void;
198
+ updateRollupOutputList(list: TOutputOptions[], force?: boolean): void;
199
+ getDoraConfig(): _doracli_type.TDoraConfig;
200
+ geTDoraConfigRollup(): TDoraConfigRollup;
201
+ }
202
+
203
+ /**
204
+ * 打包ts
205
+ * @param config 配置
206
+ */
207
+ declare const dealDts: (config: {
208
+ input: string;
209
+ output: string;
210
+ }) => Promise<void>;
211
+
212
+ /**
213
+ * 从rollup配置中,获取第一个input
214
+ * @param inputOrigin
215
+ * @returns
216
+ */
217
+ declare const getFirstInput: (inputOrigin: TInputOption) => {
218
+ path: string;
219
+ name: string;
220
+ } | undefined;
221
+
222
+ declare const rollupWatchLog: (watcher: RollupWatcher) => void;
223
+ declare function handleError(error: any, recover?: boolean): void;
224
+
225
+ declare const rollupWatch: (config: RollupWatchOptions | RollupWatchOptions[]) => rollup.RollupWatcher;
226
+
227
+ /**
228
+ * Get a function to write the Rollup bundle with the given output options.
229
+ * @param rollupBuild RollupBuild
230
+ * @returns function that takes output options and writes the bundle
231
+ */
232
+ declare const getRollupWrite: (rollupBuild: RollupBuild) => (output: TOutputOptions) => Promise<rollup.RollupOutput>;
233
+
234
+ export { Ctx, createRollupBuild, dealDts, getAliasPlugin, getBabelPlugin, getCommonjsPlugin, getCopyPlugin, getDtsPlugin, getExternal, getFirstInput, getInput, getJsonPlugin, getMinimizePlugin, getNodePlugins, getOutput, getPostcssPlugin, getReactPlugins, getResolvePlugin, getRollupWrite, getWatch, handleError, rollupWatch, rollupWatchLog };
235
+ export type { TAction, TEnvParams, TExternalOption, TInputOption, TOutputOptions, TUserExternalOption, TWatcherOptions };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@doracli/rollup",
3
+ "version": "0.0.1",
4
+ "description": "use rollup",
5
+ "author": "cclr <18843152354@163.com>",
6
+ "homepage": "",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/cjs/index.js"
12
+ },
13
+ "types": "lib/type/index.d.ts",
14
+ "directories": {
15
+ "lib": "lib"
16
+ },
17
+ "files": [
18
+ "lib",
19
+ "README.md"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
25
+ "scripts": {
26
+ "test": "vitest",
27
+ "g:test": "vitest run",
28
+ "build": "ccf build"
29
+ },
30
+ "dependencies": {
31
+ "@cclr/lang": "^0.1.28",
32
+ "@cclr/utils": "^0.1.28",
33
+ "@dorabag/file-pro": "^1.0.10",
34
+ "@dorabag/srv-tool": "^1.0.10",
35
+ "@doracli/helper": "^0.0.1",
36
+ "@doracli/preset-babel": "^0.0.1",
37
+ "@doracli/type": "^0.0.1",
38
+ "@rollup/plugin-alias": "^5.1.1",
39
+ "@rollup/plugin-babel": "^6.1.0",
40
+ "@rollup/plugin-commonjs": "^28.0.8",
41
+ "@rollup/plugin-json": "^6.1.0",
42
+ "@rollup/plugin-node-resolve": "^16.0.3",
43
+ "@rollup/plugin-terser": "^0.4.4",
44
+ "@rollup/plugin-typescript": "^12.1.4",
45
+ "autoprefixer": "^10.4.21",
46
+ "cssnano": "^7.1.1",
47
+ "postcss": "^8.5.6",
48
+ "rollup": "^4.52.4",
49
+ "rollup-plugin-copy": "^3.5.0",
50
+ "rollup-plugin-dts": "^6.2.3",
51
+ "rollup-plugin-postcss": "^4.0.2"
52
+ },
53
+ "gitHead": "40ab496f25042487a671979074515f3345c96453"
54
+ }