@rslib/core 0.20.0 → 0.20.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.
@@ -1,4 +1,4 @@
1
- import { type EnvironmentConfig, type RsbuildEntry } from '@rsbuild/core';
1
+ import { type EnvironmentConfig, type RsbuildEntry, type Rspack } from '@rsbuild/core';
2
2
  import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigOutputTarget, RsbuildConfigWithLibInfo, RslibConfig } from './types';
3
3
  export declare const composeAutoExternalConfig: (options: {
4
4
  bundle: boolean;
@@ -12,6 +12,11 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
12
12
  export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
13
13
  export declare function composePrintFileSizeConfig(bundle: LibConfig['bundle'], target: RsbuildConfigOutputTarget): EnvironmentConfig;
14
14
  export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
15
+ export declare const getRuntimeChunkConfig: ({ bundle, multiCompilerIndex, sourceEntry, }: {
16
+ bundle: boolean;
17
+ multiCompilerIndex: number | null;
18
+ sourceEntry?: RsbuildConfigEntry;
19
+ }) => NonNullable<Rspack.Configuration["optimization"]>["runtimeChunk"];
15
20
  export declare const composeModuleImportWarn: (request: string, issuer: string) => string;
16
21
  export declare const resolveEntryPath: (entries: RsbuildConfigEntry, root: string) => RsbuildEntry;
17
22
  export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
@@ -2,6 +2,6 @@ import type { EnvironmentConfig } from '@rsbuild/core';
2
2
  import { type CssLoaderOptionsAuto } from './utils';
3
3
  export declare const RSLIB_CSS_ENTRY_FLAG = "__rslib_css__";
4
4
  type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
5
- export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectedPath: string | undefined, issuer: string): Promise<false | void>;
6
- export declare const composeCssConfig: (rootDir: string | null, auto: CssLoaderOptionsAuto, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
5
+ export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectedPath: string | undefined, issuer: string): Promise<false | undefined>;
6
+ export declare function composeCssConfig(rootDir: string | null, auto: CssLoaderOptionsAuto, bundle?: boolean, banner?: string, footer?: string): EnvironmentConfig;
7
7
  export {};
@@ -1,2 +1 @@
1
- import color from '../../compiled/picocolors';
2
- export { color };
1
+ export { color } from '../../compiled/rslog';
@@ -18,7 +18,7 @@ export declare function debounce<T extends (...args: any[]) => void>(func: T, wa
18
18
  /**
19
19
  * Check if running in a TTY context
20
20
  */
21
- export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
21
+ export declare function isTTY(type?: 'stdin' | 'stdout'): boolean;
22
22
  export declare const isIntermediateOutputFormat: (format: Format) => boolean;
23
23
  export declare function normalizeSlash(p: string): string;
24
24
  export declare function isDirectory(filePath: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,30 +36,29 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "2.0.0-beta.8",
40
- "rsbuild-plugin-dts": "0.20.0"
39
+ "@rsbuild/core": "2.0.0-beta.10",
40
+ "rsbuild-plugin-dts": "0.20.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@module-federation/rsbuild-plugin": "^0.24.1",
43
+ "@module-federation/rsbuild-plugin": "^2.2.3",
44
44
  "@types/fs-extra": "^11.0.4",
45
45
  "cac": "^7.0.0",
46
- "chokidar": "^4.0.3",
46
+ "chokidar": "^5.0.0",
47
47
  "fs-extra": "^11.3.4",
48
- "memfs": "^4.56.11",
49
- "path-serializer": "0.5.1",
50
- "picocolors": "1.1.1",
51
- "prebundle": "1.6.2",
48
+ "memfs": "^4.57.1",
49
+ "path-serializer": "0.6.0",
50
+ "prebundle": "1.6.4",
52
51
  "rsbuild-plugin-publint": "^0.3.4",
53
- "rslib": "npm:@rslib/core@0.20.0-canary-202603101",
54
- "rslog": "^1.3.2",
55
- "tinyglobby": "0.2.14",
52
+ "rslib": "npm:@rslib/core@0.20.0",
53
+ "rslog": "^2.0.1",
54
+ "tinyglobby": "^0.2.15",
56
55
  "tsconfck": "3.1.6",
57
- "typescript": "^5.9.3",
56
+ "typescript": "^6.0.2",
58
57
  "@rslib/tsconfig": "0.0.1"
59
58
  },
60
59
  "peerDependencies": {
61
60
  "@microsoft/api-extractor": "^7",
62
- "typescript": "^5"
61
+ "typescript": "^5 || ^6"
63
62
  },
64
63
  "peerDependenciesMeta": {
65
64
  "@microsoft/api-extractor": {
@@ -1,346 +0,0 @@
1
- import { Dirent, Stats, WatchEventType } from 'fs';
2
- import { EventEmitter } from 'events';
3
- import { Readable } from 'stream';
4
-
5
- type Path$1 = string;
6
- interface EntryInfo {
7
- path: string;
8
- fullPath: string;
9
- stats?: Stats;
10
- dirent?: Dirent;
11
- basename: string;
12
- }
13
- type PathOrDirent = Dirent | Path$1;
14
- type Tester = (path: EntryInfo) => boolean;
15
- declare function defaultOptions(): {
16
- root: string;
17
- fileFilter: (_path: EntryInfo) => boolean;
18
- directoryFilter: (_path: EntryInfo) => boolean;
19
- type: string;
20
- lstat: boolean;
21
- depth: number;
22
- alwaysStat: boolean;
23
- highWaterMark: number;
24
- };
25
- type ReaddirpOptions = ReturnType<typeof defaultOptions>;
26
- interface DirEntry$1 {
27
- files: PathOrDirent[];
28
- depth: number;
29
- path: Path$1;
30
- }
31
- declare class ReaddirpStream extends Readable {
32
- parents: any[];
33
- reading: boolean;
34
- parent?: DirEntry$1;
35
- _stat: Function;
36
- _maxDepth: number;
37
- _wantsDir: boolean;
38
- _wantsFile: boolean;
39
- _wantsEverything: boolean;
40
- _root: Path$1;
41
- _isDirent: boolean;
42
- _statsProp: 'dirent' | 'stats';
43
- _rdOptions: {
44
- encoding: 'utf8';
45
- withFileTypes: boolean;
46
- };
47
- _fileFilter: Tester;
48
- _directoryFilter: Tester;
49
- constructor(options?: Partial<ReaddirpOptions>);
50
- _read(batch: number): Promise<void>;
51
- _exploreDir(path: Path$1, depth: number): Promise<{
52
- files: string[] | undefined;
53
- depth: number;
54
- path: string;
55
- }>;
56
- _formatEntry(dirent: PathOrDirent, path: Path$1): Promise<EntryInfo | undefined>;
57
- _onError(err: Error): void;
58
- _getEntryType(entry: EntryInfo): Promise<void | "" | "file" | "directory">;
59
- _includeAsFile(entry: EntryInfo): boolean | undefined;
60
- }
61
-
62
- type Path = string;
63
- declare const EVENTS: {
64
- readonly ALL: "all";
65
- readonly READY: "ready";
66
- readonly ADD: "add";
67
- readonly CHANGE: "change";
68
- readonly ADD_DIR: "addDir";
69
- readonly UNLINK: "unlink";
70
- readonly UNLINK_DIR: "unlinkDir";
71
- readonly RAW: "raw";
72
- readonly ERROR: "error";
73
- };
74
- type EventName = (typeof EVENTS)[keyof typeof EVENTS];
75
- interface WatchHandlers {
76
- listener: (path: string) => void;
77
- errHandler: (err: unknown) => void;
78
- rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
79
- }
80
- /**
81
- * @mixin
82
- */
83
- declare class NodeFsHandler {
84
- fsw: FSWatcher;
85
- _boundHandleError: (error: unknown) => void;
86
- constructor(fsW: FSWatcher);
87
- /**
88
- * Watch file for changes with fs_watchFile or fs_watch.
89
- * @param path to file or dir
90
- * @param listener on fs change
91
- * @returns closer for the watcher instance
92
- */
93
- _watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
94
- /**
95
- * Watch a file and emit add event if warranted.
96
- * @returns closer for the watcher instance
97
- */
98
- _handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
99
- /**
100
- * Handle symlinks encountered while reading a dir.
101
- * @param entry returned by readdirp
102
- * @param directory path of dir being read
103
- * @param path of this item
104
- * @param item basename of this item
105
- * @returns true if no more processing is needed for this entry.
106
- */
107
- _handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
108
- _handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
109
- /**
110
- * Read directory to add / remove files from `@watched` list and re-read it on change.
111
- * @param dir fs path
112
- * @param stats
113
- * @param initialAdd
114
- * @param depth relative to user-supplied path
115
- * @param target child path targeted for watch
116
- * @param wh Common watch helpers for this path
117
- * @param realpath
118
- * @returns closer for the watcher instance.
119
- */
120
- _handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
121
- /**
122
- * Handle added file, directory, or glob pattern.
123
- * Delegates call to _handleFile / _handleDir after checks.
124
- * @param path to file or ir
125
- * @param initialAdd was the file added at watch instantiation?
126
- * @param priorWh depth relative to user-supplied path
127
- * @param depth Child path actually targeted for watch
128
- * @param target Child path actually targeted for watch
129
- */
130
- _addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
131
- }
132
-
133
- /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
134
-
135
- type AWF = {
136
- stabilityThreshold: number;
137
- pollInterval: number;
138
- };
139
- type BasicOpts = {
140
- persistent: boolean;
141
- ignoreInitial: boolean;
142
- followSymlinks: boolean;
143
- cwd?: string;
144
- usePolling: boolean;
145
- interval: number;
146
- binaryInterval: number;
147
- alwaysStat?: boolean;
148
- depth?: number;
149
- ignorePermissionErrors: boolean;
150
- atomic: boolean | number;
151
- };
152
- type Throttler = {
153
- timeoutObject: NodeJS.Timeout;
154
- clear: () => void;
155
- count: number;
156
- };
157
- type ChokidarOptions = Partial<BasicOpts & {
158
- ignored: Matcher | Matcher[];
159
- awaitWriteFinish: boolean | Partial<AWF>;
160
- }>;
161
- type FSWInstanceOptions = BasicOpts & {
162
- ignored: Matcher[];
163
- awaitWriteFinish: false | AWF;
164
- };
165
- type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
166
- type EmitArgs = [path: Path, stats?: Stats];
167
- type EmitErrorArgs = [error: Error, stats?: Stats];
168
- type EmitArgsWithName = [event: EventName, ...EmitArgs];
169
- type MatchFunction = (val: string, stats?: Stats) => boolean;
170
- interface MatcherObject {
171
- path: string;
172
- recursive?: boolean;
173
- }
174
- type Matcher = string | RegExp | MatchFunction | MatcherObject;
175
- /**
176
- * Directory entry.
177
- */
178
- declare class DirEntry {
179
- path: Path;
180
- _removeWatcher: (dir: string, base: string) => void;
181
- items: Set<Path>;
182
- constructor(dir: Path, removeWatcher: (dir: string, base: string) => void);
183
- add(item: string): void;
184
- remove(item: string): Promise<void>;
185
- has(item: string): boolean | undefined;
186
- getChildren(): string[];
187
- dispose(): void;
188
- }
189
- declare class WatchHelper {
190
- fsw: FSWatcher;
191
- path: string;
192
- watchPath: string;
193
- fullWatchPath: string;
194
- dirParts: string[][];
195
- followSymlinks: boolean;
196
- statMethod: 'stat' | 'lstat';
197
- constructor(path: string, follow: boolean, fsw: FSWatcher);
198
- entryPath(entry: EntryInfo): Path;
199
- filterPath(entry: EntryInfo): boolean;
200
- filterDir(entry: EntryInfo): boolean;
201
- }
202
- interface FSWatcherKnownEventMap {
203
- [EVENTS.READY]: [];
204
- [EVENTS.RAW]: Parameters<WatchHandlers['rawEmitter']>;
205
- [EVENTS.ERROR]: Parameters<WatchHandlers['errHandler']>;
206
- [EVENTS.ALL]: [event: EventName, ...EmitArgs];
207
- }
208
- type FSWatcherEventMap = FSWatcherKnownEventMap & {
209
- [k in Exclude<EventName, keyof FSWatcherKnownEventMap>]: EmitArgs;
210
- };
211
- /**
212
- * Watches files & directories for changes. Emitted events:
213
- * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
214
- *
215
- * new FSWatcher()
216
- * .add(directories)
217
- * .on('add', path => log('File', path, 'was added'))
218
- */
219
- declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
220
- closed: boolean;
221
- options: FSWInstanceOptions;
222
- _closers: Map<string, Array<any>>;
223
- _ignoredPaths: Set<Matcher>;
224
- _throttled: Map<ThrottleType, Map<any, any>>;
225
- _streams: Set<ReaddirpStream>;
226
- _symlinkPaths: Map<Path, string | boolean>;
227
- _watched: Map<string, DirEntry>;
228
- _pendingWrites: Map<string, any>;
229
- _pendingUnlinks: Map<string, EmitArgsWithName>;
230
- _readyCount: number;
231
- _emitReady: () => void;
232
- _closePromise?: Promise<void>;
233
- _userIgnored?: MatchFunction;
234
- _readyEmitted: boolean;
235
- _emitRaw: WatchHandlers['rawEmitter'];
236
- _boundRemove: (dir: string, item: string) => void;
237
- _nodeFsHandler: NodeFsHandler;
238
- constructor(_opts?: ChokidarOptions);
239
- _addIgnoredPath(matcher: Matcher): void;
240
- _removeIgnoredPath(matcher: Matcher): void;
241
- /**
242
- * Adds paths to be watched on an existing FSWatcher instance.
243
- * @param paths_ file or file list. Other arguments are unused
244
- */
245
- add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher;
246
- /**
247
- * Close watchers or start ignoring events from specified paths.
248
- */
249
- unwatch(paths_: Path | Path[]): FSWatcher;
250
- /**
251
- * Close watchers and remove all listeners from watched paths.
252
- */
253
- close(): Promise<void>;
254
- /**
255
- * Expose list of watched paths
256
- * @returns for chaining
257
- */
258
- getWatched(): Record<string, string[]>;
259
- emitWithAll(event: EventName, args: EmitArgs): void;
260
- /**
261
- * Normalize and emit events.
262
- * Calling _emit DOES NOT MEAN emit() would be called!
263
- * @param event Type of event
264
- * @param path File or directory path
265
- * @param stats arguments to be passed with event
266
- * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
267
- */
268
- _emit(event: EventName, path: Path, stats?: Stats): Promise<this | undefined>;
269
- /**
270
- * Common handler for errors
271
- * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
272
- */
273
- _handleError(error: Error): Error | boolean;
274
- /**
275
- * Helper utility for throttling
276
- * @param actionType type being throttled
277
- * @param path being acted upon
278
- * @param timeout duration of time to suppress duplicate actions
279
- * @returns tracking object or false if action should be suppressed
280
- */
281
- _throttle(actionType: ThrottleType, path: Path, timeout: number): Throttler | false;
282
- _incrReadyCount(): number;
283
- /**
284
- * Awaits write operation to finish.
285
- * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
286
- * @param path being acted upon
287
- * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
288
- * @param event
289
- * @param awfEmit Callback to be called when ready for event to be emitted.
290
- */
291
- _awaitWriteFinish(path: Path, threshold: number, event: EventName, awfEmit: (err?: Error, stat?: Stats) => void): void;
292
- /**
293
- * Determines whether user has asked to ignore this path.
294
- */
295
- _isIgnored(path: Path, stats?: Stats): boolean;
296
- _isntIgnored(path: Path, stat?: Stats): boolean;
297
- /**
298
- * Provides a set of common helpers and properties relating to symlink handling.
299
- * @param path file or directory pattern being watched
300
- */
301
- _getWatchHelpers(path: Path): WatchHelper;
302
- /**
303
- * Provides directory tracking objects
304
- * @param directory path of the directory
305
- */
306
- _getWatchedDir(directory: string): DirEntry;
307
- /**
308
- * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
309
- */
310
- _hasReadPermissions(stats: Stats): boolean;
311
- /**
312
- * Handles emitting unlink events for
313
- * files and directories, and via recursion, for
314
- * files and directories within directories that are unlinked
315
- * @param directory within which the following item is located
316
- * @param item base path of item/directory
317
- */
318
- _remove(directory: string, item: string, isDirectory?: boolean): void;
319
- /**
320
- * Closes all watchers for a path
321
- */
322
- _closePath(path: Path): void;
323
- /**
324
- * Closes only file-specific watchers
325
- */
326
- _closeFile(path: Path): void;
327
- _addPathCloser(path: Path, closer: () => void): void;
328
- _readdirp(root: Path, opts?: Partial<ReaddirpOptions>): ReaddirpStream | undefined;
329
- }
330
- /**
331
- * Instantiates watcher with paths to be tracked.
332
- * @param paths file / directory paths
333
- * @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
334
- * @returns an instance of FSWatcher for chaining.
335
- * @example
336
- * const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
337
- * watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
338
- */
339
- declare function watch(paths: string | string[], options?: ChokidarOptions): FSWatcher;
340
- declare const _default: {
341
- watch: typeof watch;
342
- FSWatcher: typeof FSWatcher;
343
- };
344
-
345
- export { FSWatcher, WatchHelper, _default as default, watch };
346
- export type { ChokidarOptions, EmitArgs, EmitArgsWithName, EmitErrorArgs, FSWInstanceOptions, FSWatcherEventMap, FSWatcherKnownEventMap, MatchFunction, Matcher, MatcherObject, ThrottleType, Throttler };