@doracli/rollup 0.0.2 → 0.0.4

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.
@@ -1,60 +1,77 @@
1
- import * as rollup from 'rollup';
2
- import { RollupBuild, RollupOutput, RollupOptions, RollupWatcher, OutputOptions, RollupWatchOptions, ExternalOption, InputOption, WatcherOptions, Plugin } from 'rollup';
3
- export { RollupBuild } from 'rollup';
4
- import { CompilerBase, ConfigCtx } from '@doracli/helper';
5
- import { TPlainObject } from '@cclr/lang';
6
- import { RollupAliasOptions } from '@rollup/plugin-alias';
7
- import { RollupBabelInputPluginOptions } from '@rollup/plugin-babel';
8
- import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
9
- import { CopyOptions } from 'rollup-plugin-copy';
10
- import * as _doracli_type from '@doracli/type';
11
- import { TDoraConfigCommon, TDoraConfigRollup } from '@doracli/type';
12
- import { Options } from 'rollup-plugin-dts';
13
- import { RollupJsonOptions } from '@rollup/plugin-json';
14
- import { PostCSSPluginConf } from 'rollup-plugin-postcss';
15
- import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
1
+ import type * as rollup from 'rollup';
2
+ import type {
3
+ ExternalOption,
4
+ InputOption,
5
+ OutputOptions,
6
+ Plugin,
7
+ RollupBuild,
8
+ RollupOptions,
9
+ RollupOutput,
10
+ RollupWatcher,
11
+ RollupWatchOptions,
12
+ WatcherOptions,
13
+ } from 'rollup';
14
+ export { RollupBuild, RollupOptions } from 'rollup';
15
+ import type { CopyOptions } from 'rollup-plugin-copy';
16
+ import type { Options } from 'rollup-plugin-dts';
17
+ import type { PostCSSPluginConf } from 'rollup-plugin-postcss';
18
+ import type { TPlainObject } from '@cclr/lang';
19
+ import type { TOnionFun } from '@cclr/utils';
20
+ import type { ConfigCtx } from '@doracli/helper';
21
+ import { CompilerBase } from '@doracli/helper';
22
+ import type * as _doracli_type from '@doracli/type';
23
+ import type { TDoraConfigCommon, TDoraConfigRollup } from '@doracli/type';
24
+ import type { RollupAliasOptions } from '@rollup/plugin-alias';
25
+ import type { RollupBabelInputPluginOptions } from '@rollup/plugin-babel';
26
+ import type { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
27
+ import type { RollupJsonOptions } from '@rollup/plugin-json';
28
+ import type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
16
29
 
17
30
  type TBuildResult = {
18
- rollupBuild: RollupBuild;
19
- outputOptions: RollupOutput[];
31
+ rollupBuild: RollupBuild;
32
+ outputOptions?: RollupOutput[];
33
+ outputOption?: RollupOutput;
20
34
  };
21
- declare class Compiler extends CompilerBase<RollupOptions, {
35
+ declare class Compiler extends CompilerBase<
36
+ RollupOptions,
37
+ {
22
38
  build: Promise<TBuildResult>;
23
39
  watch: RollupWatcher;
24
40
  server: Promise<void>;
25
- }> {
26
- context: (options: RollupOptions) => Promise<{
27
- rebuild: () => Promise<{
28
- rollupBuild: RollupBuild;
29
- outputOptions: RollupOutput[];
30
- }>;
31
- cancel: () => Promise<void>;
32
- }>;
33
- inOutMap: (inputOutputMap: Record<string, string>) => Promise<{
34
- rollupBuild: RollupBuild;
35
- outputOptions: RollupOutput[];
36
- }>;
37
- input: (input: string) => Promise<{
38
- output: (output: OutputOptions) => Promise<{
39
- rollupBuild: RollupBuild;
40
- outputOptions: RollupOutput[];
41
- }>;
41
+ }
42
+ > {
43
+ context: (options: RollupOptions) => Promise<{
44
+ rebuild: () => Promise<{
45
+ rollupBuild: RollupBuild;
46
+ outputOptions: RollupOutput[];
42
47
  }>;
43
- build: (options: RollupOptions) => Promise<{
44
- rollupBuild: RollupBuild;
45
- outputOptions: RollupOutput[];
48
+ cancel: () => Promise<void>;
49
+ }>;
50
+ inOutMap: (inputOutputMap: Record<string, string>) => Promise<{
51
+ rollupBuild: RollupBuild;
52
+ outputOptions: RollupOutput[];
53
+ }>;
54
+ input: (input?: string) => Promise<{
55
+ output: (output: OutputOptions) => Promise<{
56
+ rollupBuild: RollupBuild;
57
+ outputOption: RollupOutput;
46
58
  }>;
47
- watch: (options: RollupWatchOptions) => RollupWatcher;
48
- server: () => Promise<void>;
59
+ }>;
60
+ build: (options: RollupOptions) => Promise<{
61
+ rollupBuild: RollupBuild;
62
+ outputOptions: RollupOutput[];
63
+ }>;
64
+ watch: (options: RollupWatchOptions) => RollupWatcher;
65
+ server: () => Promise<void>;
49
66
  }
50
67
 
51
68
  /** 动作 */
52
69
  type TAction = 'build' | 'dev' | 'watch';
53
70
  type TEnvParams = {
54
- /** 开发模式 */
55
- action: TAction;
56
- /** 工作目录,绝对路径 cwd */
57
- workRootDir: string;
71
+ /** 开发模式 */
72
+ action: TAction;
73
+ /** 工作目录,绝对路径 cwd */
74
+ workRootDir: string;
58
75
  };
59
76
 
60
77
  type TOutputOptions = OutputOptions;
@@ -62,17 +79,17 @@ type TInputOption = InputOption;
62
79
  type TWatcherOptions = WatcherOptions;
63
80
  type TExternalOption = ExternalOption;
64
81
  type TUserExternalOption = {
65
- /**
66
- * 过滤器,判断是否需要包含模块
67
- * @param source 模块名
68
- * @return boolean 返回true表示 - 会被打包进产物
69
- */
70
- filter?: (source: string) => boolean;
71
- externals?: string[] | Record<string, string>;
72
- internals?: string[] | Record<string, string>;
73
- dependencies?: Record<string, string>;
74
- peerDependencies?: Record<string, string>;
75
- devDependencies?: Record<string, string>;
82
+ /**
83
+ * 过滤器,判断是否需要包含模块
84
+ * @param source 模块名
85
+ * @return boolean 返回true表示 - 会被打包进产物
86
+ */
87
+ filter?: (source: string) => boolean;
88
+ externals?: string[] | Record<string, string>;
89
+ internals?: string[] | Record<string, string>;
90
+ dependencies?: Record<string, string>;
91
+ peerDependencies?: Record<string, string>;
92
+ devDependencies?: Record<string, string>;
76
93
  };
77
94
 
78
95
  /**
@@ -81,7 +98,10 @@ type TUserExternalOption = {
81
98
  * @param options 用户配置的external选项
82
99
  * @returns TExternalOption
83
100
  */
84
- declare const getExternal: (_envParams: TEnvParams, options?: TUserExternalOption) => TExternalOption;
101
+ declare const getExternal: (
102
+ _envParams: TEnvParams,
103
+ options?: TUserExternalOption
104
+ ) => TExternalOption;
85
105
 
86
106
  type TInputParams = string | Record<string, string>;
87
107
  /**
@@ -91,7 +111,10 @@ type TInputParams = string | Record<string, string>;
91
111
  * @param input 入口文件路径
92
112
  * @returnscj
93
113
  */
94
- declare const getInput: (envParams: TEnvParams, input?: TInputParams) => Promise<TInputOption>;
114
+ declare const getInput: (
115
+ envParams: TEnvParams,
116
+ input?: TInputParams
117
+ ) => Promise<TInputOption>;
95
118
 
96
119
  /**
97
120
  * 生成单个output
@@ -100,7 +123,10 @@ declare const getInput: (envParams: TEnvParams, input?: TInputParams) => Promise
100
123
  * @param optionsOutput
101
124
  * @returns
102
125
  */
103
- declare const getOutput: (envParams: TEnvParams, options?: TOutputOptions) => TOutputOptions;
126
+ declare const getOutput: (
127
+ envParams: TEnvParams,
128
+ options?: TOutputOptions
129
+ ) => TOutputOptions;
104
130
 
105
131
  /**
106
132
  * 获取别名插件
@@ -108,10 +134,13 @@ declare const getOutput: (envParams: TEnvParams, options?: TOutputOptions) => TO
108
134
  * @param pluginConfig 标准配置
109
135
  * @returns 别名插件
110
136
  */
111
- declare const getAliasPlugin: (config: {
137
+ declare const getAliasPlugin: (
138
+ config: {
112
139
  tsConfigPath?: TPlainObject;
113
140
  alias?: TPlainObject;
114
- }, pluginConfig?: RollupAliasOptions) => rollup.Plugin<any>;
141
+ },
142
+ pluginConfig?: RollupAliasOptions
143
+ ) => rollup.Plugin<any>;
115
144
 
116
145
  /**
117
146
  * 获取Babel插件
@@ -119,7 +148,10 @@ declare const getAliasPlugin: (config: {
119
148
  * @param pluginConfig 标准配置
120
149
  * @returns Babel插件
121
150
  */
122
- declare const getBabelPlugin: (_config: TPlainObject, pluginConfig?: RollupBabelInputPluginOptions) => rollup.Plugin<any>;
151
+ declare const getBabelPlugin: (
152
+ _config: TPlainObject,
153
+ pluginConfig?: RollupBabelInputPluginOptions
154
+ ) => rollup.Plugin<any>;
123
155
 
124
156
  /**
125
157
  * 获取CommonJS插件
@@ -128,7 +160,10 @@ declare const getBabelPlugin: (_config: TPlainObject, pluginConfig?: RollupBabel
128
160
  * @param pluginConfig
129
161
  * @returns
130
162
  */
131
- declare const getCommonjsPlugin: (_config: TPlainObject, pluginConfig?: RollupCommonJSOptions) => rollup.Plugin<any>;
163
+ declare const getCommonjsPlugin: (
164
+ _config: TPlainObject,
165
+ pluginConfig?: RollupCommonJSOptions
166
+ ) => rollup.Plugin<any>;
132
167
 
133
168
  /**
134
169
  * 获取拷贝插件
@@ -136,9 +171,12 @@ declare const getCommonjsPlugin: (_config: TPlainObject, pluginConfig?: RollupCo
136
171
  * @param pluginConfig 标准配置
137
172
  * @returns 拷贝插件
138
173
  */
139
- declare const getCopyPlugin: (config: {
140
- copyList?: TDoraConfigCommon["copy"];
141
- }, pluginConfig?: CopyOptions) => rollup.Plugin<any>;
174
+ declare const getCopyPlugin: (
175
+ config: {
176
+ copyList?: TDoraConfigCommon['copy'];
177
+ },
178
+ pluginConfig?: CopyOptions
179
+ ) => rollup.Plugin<any>;
142
180
 
143
181
  /**
144
182
  * 获取 dts 插件
@@ -146,7 +184,10 @@ declare const getCopyPlugin: (config: {
146
184
  * @param pluginConfig
147
185
  * @returns
148
186
  */
149
- declare const getDtsPlugin: (_config: TPlainObject, pluginConfig?: Options) => rollup.Plugin<any>;
187
+ declare const getDtsPlugin: (
188
+ _config: TPlainObject,
189
+ pluginConfig?: Options
190
+ ) => rollup.Plugin<any>;
150
191
 
151
192
  /**
152
193
  * 获取Json插件
@@ -155,7 +196,10 @@ declare const getDtsPlugin: (_config: TPlainObject, pluginConfig?: Options) => r
155
196
  * @param pluginConfig
156
197
  * @returns
157
198
  */
158
- declare const getJsonPlugin: (_config: TPlainObject, pluginConfig?: RollupJsonOptions) => rollup.Plugin<any>;
199
+ declare const getJsonPlugin: (
200
+ _config: TPlainObject,
201
+ pluginConfig?: RollupJsonOptions
202
+ ) => rollup.Plugin<any>;
159
203
 
160
204
  /**
161
205
  * 获取代码压缩插件
@@ -169,10 +213,13 @@ declare const getMinimizePlugin: () => rollup.Plugin<any>;
169
213
  * @param pluginConfig 标准配置
170
214
  * @returns Postcss插件
171
215
  */
172
- declare const getPostcssPlugin: (config: {
216
+ declare const getPostcssPlugin: (
217
+ config: {
173
218
  minimize?: boolean;
174
219
  output: string;
175
- }, pluginConfig?: PostCSSPluginConf) => rollup.Plugin<any>;
220
+ },
221
+ pluginConfig?: PostCSSPluginConf
222
+ ) => rollup.Plugin<any>;
176
223
 
177
224
  /**
178
225
  * 获取解析插件
@@ -180,9 +227,12 @@ declare const getPostcssPlugin: (config: {
180
227
  * @param pluginConfig 标准配置
181
228
  * @returns 解析插件
182
229
  */
183
- declare const getResolvePlugin: (config: {
230
+ declare const getResolvePlugin: (
231
+ config: {
184
232
  extensions?: string[];
185
- }, pluginConfig?: RollupNodeResolveOptions) => rollup.Plugin<any>;
233
+ },
234
+ pluginConfig?: RollupNodeResolveOptions
235
+ ) => rollup.Plugin<any>;
186
236
 
187
237
  /**
188
238
  * 获取Node环境下的插件集合
@@ -190,9 +240,9 @@ declare const getResolvePlugin: (config: {
190
240
  * @returns
191
241
  */
192
242
  declare const getNodePlugins: (config: {
193
- minimize?: boolean;
194
- alias?: Record<string, string>;
195
- copyMap?: Record<string, string>;
243
+ minimize?: boolean;
244
+ alias?: Record<string, string>;
245
+ copyList?: TDoraConfigCommon['copy'];
196
246
  }) => rollup.Plugin<any>[];
197
247
 
198
248
  /**
@@ -201,10 +251,10 @@ declare const getNodePlugins: (config: {
201
251
  * @returns
202
252
  */
203
253
  declare const getReactPlugins: (config: {
204
- minimize?: boolean;
205
- cssOutput?: string;
206
- alias?: Record<string, string>;
207
- copy?: TDoraConfigCommon["copy"];
254
+ minimize?: boolean;
255
+ cssOutput?: string;
256
+ alias?: Record<string, string>;
257
+ copy?: TDoraConfigCommon['copy'];
208
258
  }) => Promise<Plugin<any>[]>;
209
259
 
210
260
  /**
@@ -212,60 +262,120 @@ declare const getReactPlugins: (config: {
212
262
  * @param options
213
263
  * @returns
214
264
  */
215
- declare const getWatch: (envParams: TEnvParams, options?: TWatcherOptions) => TWatcherOptions;
216
-
217
- /**
218
- * Create a Rollup build with the given options.
219
- * @param options RollupOptions
220
- * @returns
221
- */
222
- declare const createRollupBuild: (options: RollupOptions) => Promise<rollup.RollupBuild>;
265
+ declare const getWatch: (
266
+ envParams: TEnvParams,
267
+ options?: TWatcherOptions
268
+ ) => TWatcherOptions;
223
269
 
224
270
  declare class Ctx {
225
- configCtx: ConfigCtx;
226
- rollupOptions: RollupOptions;
227
- rollupOutputList: TOutputOptions[];
228
- envParams: TEnvParams;
229
- constructor(configCtx: ConfigCtx);
230
- updateEnvParams(argv: Partial<TEnvParams>): void;
231
- updateRollupOptions(options: Partial<RollupOptions>): void;
232
- updateRollupOutputList(list: TOutputOptions[], force?: boolean): void;
233
- getDoraConfig(): _doracli_type.TDoraConfig;
234
- geTDoraConfigRollup(): TDoraConfigRollup;
271
+ configCtx: ConfigCtx;
272
+ rollupOptions: RollupOptions;
273
+ rollupOutputList: TOutputOptions[];
274
+ envParams: TEnvParams;
275
+ constructor(configCtx: ConfigCtx);
276
+ updateEnvParams(argv: Partial<TEnvParams>): void;
277
+ updateRollupOptions(options: Partial<RollupOptions>): void;
278
+ updateRollupOutputList(list: TOutputOptions[], force?: boolean): void;
279
+ getDoraConfig(): _doracli_type.TDoraConfig;
280
+ geTDoraConfigRollup(): TDoraConfigRollup;
235
281
  }
236
282
 
283
+ declare const envParamsMw: (envParams: TEnvParams) => TOnionFun<Ctx>;
284
+
285
+ declare const rollupExternalMw: () => TOnionFun<Ctx>;
286
+ declare const rollupDtsExternalMw: () => TOnionFun<Ctx>;
287
+
288
+ declare const rollupInputMw: () => TOnionFun<Ctx>;
289
+ declare const rollupOutputListMw: () => TOnionFun<Ctx>;
290
+ declare const rollupInoutMw: () => TOnionFun<Ctx>;
291
+ declare const rollupWatchOutputMw: () => TOnionFun<Ctx>;
292
+ declare const rollupDtsInoutMw: () => TOnionFun<Ctx>;
293
+
294
+ declare const insertTsMw: () => TOnionFun<Ctx>;
295
+
296
+ declare const rollupReactPluginMw: () => TOnionFun<Ctx>;
297
+ declare const rollupNodePluginMw: () => TOnionFun<Ctx>;
298
+ declare const rollupDtsPluginMw: () => TOnionFun<Ctx>;
299
+
300
+ declare const rollupWatchMw: () => TOnionFun<Ctx>;
301
+
237
302
  /**
238
- * 打包ts
239
- * @param config 配置
303
+ * 获取运行时输出配置
304
+ * @param output
305
+ * @param isMultiple
306
+ * @param workRootDir
307
+ * @returns
240
308
  */
241
- declare const dealDts: (config: {
242
- input: string;
243
- output: string;
244
- }) => Promise<void>;
309
+ declare const getOutputRuntime: (
310
+ output: TOutputOptions,
311
+ isMultiple: boolean,
312
+ workRootDir: string
313
+ ) => TOutputOptions;
245
314
 
246
315
  /**
247
316
  * 从rollup配置中,获取第一个input
248
317
  * @param inputOrigin
249
318
  * @returns
250
319
  */
251
- declare const getFirstInput: (inputOrigin: TInputOption) => {
252
- path: string;
253
- name: string;
254
- } | undefined;
320
+ declare const getFirstInput: (inputOrigin: TInputOption) =>
321
+ | {
322
+ path: string;
323
+ name: string;
324
+ }
325
+ | undefined;
255
326
 
256
327
  declare const rollupWatchLog: (watcher: RollupWatcher) => void;
257
328
  declare function handleError(error: any, recover?: boolean): void;
258
329
 
259
- declare const mergeRollupOptions: <T extends Partial<RollupOptions>>(first: T, second: T) => T;
260
-
261
- declare const rollupWatch: (config: RollupWatchOptions | RollupWatchOptions[]) => rollup.RollupWatcher;
330
+ declare const mergeRollupOptions: <T extends Partial<RollupOptions>>(
331
+ first: T,
332
+ second: T
333
+ ) => T;
262
334
 
263
- /**
264
- * Get a function to write the Rollup bundle with the given output options.
265
- * @param rollupBuild RollupBuild
266
- * @returns function that takes output options and writes the bundle
267
- */
268
- declare const getRollupWrite: (rollupBuild: RollupBuild) => (output: TOutputOptions) => Promise<rollup.RollupOutput>;
269
-
270
- export { Compiler, Ctx, createRollupBuild, dealDts, getAliasPlugin, getBabelPlugin, getCommonjsPlugin, getCopyPlugin, getDtsPlugin, getExternal, getFirstInput, getInput, getJsonPlugin, getMinimizePlugin, getNodePlugins, getOutput, getPostcssPlugin, getReactPlugins, getResolvePlugin, getRollupWrite, getWatch, handleError, mergeRollupOptions, rollupWatch, rollupWatchLog };
271
- export type { TAction, TBuildResult, TEnvParams, TExternalOption, TInputOption, TOutputOptions, TUserExternalOption, TWatcherOptions };
335
+ export {
336
+ Compiler,
337
+ Ctx,
338
+ envParamsMw,
339
+ getAliasPlugin,
340
+ getBabelPlugin,
341
+ getCommonjsPlugin,
342
+ getCopyPlugin,
343
+ getDtsPlugin,
344
+ getExternal,
345
+ getFirstInput,
346
+ getInput,
347
+ getJsonPlugin,
348
+ getMinimizePlugin,
349
+ getNodePlugins,
350
+ getOutput,
351
+ getOutputRuntime,
352
+ getPostcssPlugin,
353
+ getReactPlugins,
354
+ getResolvePlugin,
355
+ getWatch,
356
+ handleError,
357
+ insertTsMw,
358
+ mergeRollupOptions,
359
+ rollupDtsExternalMw,
360
+ rollupDtsInoutMw,
361
+ rollupDtsPluginMw,
362
+ rollupExternalMw,
363
+ rollupInoutMw,
364
+ rollupInputMw,
365
+ rollupNodePluginMw,
366
+ rollupOutputListMw,
367
+ rollupReactPluginMw,
368
+ rollupWatchLog,
369
+ rollupWatchMw,
370
+ rollupWatchOutputMw,
371
+ };
372
+ export type {
373
+ TAction,
374
+ TBuildResult,
375
+ TEnvParams,
376
+ TExternalOption,
377
+ TInputOption,
378
+ TOutputOptions,
379
+ TUserExternalOption,
380
+ TWatcherOptions,
381
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doracli/rollup",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "use rollup",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -28,27 +28,27 @@
28
28
  "build": "ccf build"
29
29
  },
30
30
  "dependencies": {
31
- "@cclr/lang": "^0.1.28",
32
- "@cclr/utils": "^0.1.28",
31
+ "@cclr/lang": "^0.1.44",
32
+ "@cclr/utils": "^0.1.44",
33
33
  "@dorabag/file-pro": "^1.0.10",
34
- "@dorabag/srv-tool": "^1.0.10",
35
- "@doracli/helper": "^0.0.2",
36
- "@doracli/preset-babel": "^0.0.2",
37
- "@doracli/type": "^0.0.2",
34
+ "@dorabag/srv-tool": "^1.0.16",
35
+ "@doracli/helper": "^0.0.4",
36
+ "@doracli/preset-babel": "^0.0.4",
37
+ "@doracli/type": "^0.0.4",
38
38
  "@rollup/plugin-alias": "^5.1.1",
39
39
  "@rollup/plugin-babel": "^6.1.0",
40
- "@rollup/plugin-commonjs": "^28.0.8",
40
+ "@rollup/plugin-commonjs": "^28.0.9",
41
41
  "@rollup/plugin-json": "^6.1.0",
42
42
  "@rollup/plugin-node-resolve": "^16.0.3",
43
43
  "@rollup/plugin-terser": "^0.4.4",
44
44
  "@rollup/plugin-typescript": "^12.3.0",
45
- "autoprefixer": "^10.4.21",
46
- "cssnano": "^7.1.1",
45
+ "autoprefixer": "^10.4.23",
46
+ "cssnano": "^7.1.2",
47
47
  "postcss": "^8.5.6",
48
- "rollup": "^4.52.5",
48
+ "rollup": "^4.53.5",
49
49
  "rollup-plugin-copy": "^3.5.0",
50
- "rollup-plugin-dts": "^6.2.3",
50
+ "rollup-plugin-dts": "^6.3.0",
51
51
  "rollup-plugin-postcss": "^4.0.2"
52
52
  },
53
- "gitHead": "912cb44292b64679630a799974d18c22b2e69738"
53
+ "gitHead": "a978bb7e7b32c192b1eb527dae5f25bbe1a2af86"
54
54
  }