@rslib/core 0.1.5 → 0.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.
- package/compiled/chokidar/index.d.ts +24 -6
- package/compiled/chokidar/index.js +16 -13
- package/compiled/chokidar/package.json +1 -1
- package/dist/index.js +116 -61
- package/dist/libCssExtractLoader.js +20 -4
- package/dist-types/asset/assetConfig.d.ts +2 -2
- package/dist-types/cli/build.d.ts +1 -1
- package/dist-types/cli/mf.d.ts +2 -1
- package/dist-types/config.d.ts +12 -9
- package/dist-types/css/LibCssExtractPlugin.d.ts +9 -0
- package/dist-types/css/cssConfig.d.ts +2 -2
- package/dist-types/css/libCssExtractLoader.d.ts +6 -0
- package/dist-types/css/utils.d.ts +7 -0
- package/dist-types/plugins/EntryChunkPlugin.d.ts +2 -2
- package/dist-types/types/config.d.ts +6 -6
- package/dist-types/types/utils.d.ts +3 -0
- package/dist-types/utils/syntax.d.ts +2 -2
- package/package.json +6 -6
- package/dist-types/css/RemoveCssExtractAssetPlugin.d.ts +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stats, Dirent } from 'fs';
|
|
1
|
+
import { Stats, Dirent, WatchEventType } from 'fs';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
4
|
|
|
@@ -72,6 +72,11 @@ declare const EVENTS: {
|
|
|
72
72
|
readonly ERROR: "error";
|
|
73
73
|
};
|
|
74
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
|
+
}
|
|
75
80
|
/**
|
|
76
81
|
* @mixin
|
|
77
82
|
*/
|
|
@@ -125,6 +130,8 @@ declare class NodeFsHandler {
|
|
|
125
130
|
_addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
|
|
126
131
|
}
|
|
127
132
|
|
|
133
|
+
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
134
|
+
|
|
128
135
|
type AWF = {
|
|
129
136
|
stabilityThreshold: number;
|
|
130
137
|
pollInterval: number;
|
|
@@ -156,7 +163,9 @@ type FSWInstanceOptions = BasicOpts & {
|
|
|
156
163
|
awaitWriteFinish: false | AWF;
|
|
157
164
|
};
|
|
158
165
|
type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
|
|
159
|
-
type EmitArgs = [
|
|
166
|
+
type EmitArgs = [path: Path, stats?: Stats];
|
|
167
|
+
type EmitErrorArgs = [error: Error, stats?: Stats];
|
|
168
|
+
type EmitArgsWithName = [event: EventName, ...EmitArgs];
|
|
160
169
|
type MatchFunction = (val: string, stats?: Stats) => boolean;
|
|
161
170
|
interface MatcherObject {
|
|
162
171
|
path: string;
|
|
@@ -190,6 +199,15 @@ declare class WatchHelper {
|
|
|
190
199
|
filterPath(entry: EntryInfo): boolean;
|
|
191
200
|
filterDir(entry: EntryInfo): boolean;
|
|
192
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
|
+
};
|
|
193
211
|
/**
|
|
194
212
|
* Watches files & directories for changes. Emitted events:
|
|
195
213
|
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
|
@@ -198,7 +216,7 @@ declare class WatchHelper {
|
|
|
198
216
|
* .add(directories)
|
|
199
217
|
* .on('add', path => log('File', path, 'was added'))
|
|
200
218
|
*/
|
|
201
|
-
declare class FSWatcher extends EventEmitter {
|
|
219
|
+
declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
|
|
202
220
|
closed: boolean;
|
|
203
221
|
options: FSWInstanceOptions;
|
|
204
222
|
_closers: Map<string, Array<any>>;
|
|
@@ -208,13 +226,13 @@ declare class FSWatcher extends EventEmitter {
|
|
|
208
226
|
_symlinkPaths: Map<Path, string | boolean>;
|
|
209
227
|
_watched: Map<string, DirEntry>;
|
|
210
228
|
_pendingWrites: Map<string, any>;
|
|
211
|
-
_pendingUnlinks: Map<string,
|
|
229
|
+
_pendingUnlinks: Map<string, EmitArgsWithName>;
|
|
212
230
|
_readyCount: number;
|
|
213
231
|
_emitReady: () => void;
|
|
214
232
|
_closePromise?: Promise<void>;
|
|
215
233
|
_userIgnored?: MatchFunction;
|
|
216
234
|
_readyEmitted: boolean;
|
|
217
|
-
_emitRaw:
|
|
235
|
+
_emitRaw: WatchHandlers['rawEmitter'];
|
|
218
236
|
_boundRemove: (dir: string, item: string) => void;
|
|
219
237
|
_nodeFsHandler: NodeFsHandler;
|
|
220
238
|
constructor(_opts?: ChokidarOptions);
|
|
@@ -324,4 +342,4 @@ declare const _default: {
|
|
|
324
342
|
FSWatcher: typeof FSWatcher;
|
|
325
343
|
};
|
|
326
344
|
|
|
327
|
-
export { type ChokidarOptions, type EmitArgs, type FSWInstanceOptions, FSWatcher, type MatchFunction, type Matcher, type MatcherObject, type ThrottleType, type Throttler, WatchHelper, _default as default, watch };
|
|
345
|
+
export { type ChokidarOptions, type EmitArgs, type EmitArgsWithName, type EmitErrorArgs, type FSWInstanceOptions, FSWatcher, type FSWatcherEventMap, type FSWatcherKnownEventMap, type MatchFunction, type Matcher, type MatcherObject, type ThrottleType, type Throttler, WatchHelper, _default as default, watch };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
4
|
+
457: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NodeFsHandler =
|
|
7
7
|
exports.EVENTS =
|
|
8
8
|
exports.isIBMi =
|
|
9
|
+
exports.isFreeBSD =
|
|
9
10
|
exports.isLinux =
|
|
10
11
|
exports.isMacos =
|
|
11
12
|
exports.isWindows =
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
exports.isWindows = pl === "win32";
|
|
31
32
|
exports.isMacos = pl === "darwin";
|
|
32
33
|
exports.isLinux = pl === "linux";
|
|
34
|
+
exports.isFreeBSD = pl === "freebsd";
|
|
33
35
|
exports.isIBMi = (0, os_1.type)() === "OS400";
|
|
34
36
|
exports.EVENTS = {
|
|
35
37
|
ALL: "all",
|
|
@@ -547,7 +549,7 @@
|
|
|
547
549
|
this.fsw._emit(EV.CHANGE, file, newStats);
|
|
548
550
|
}
|
|
549
551
|
if (
|
|
550
|
-
(exports.isMacos || exports.isLinux) &&
|
|
552
|
+
(exports.isMacos || exports.isLinux || exports.isFreeBSD) &&
|
|
551
553
|
prevStats.ino !== newStats.ino
|
|
552
554
|
) {
|
|
553
555
|
this.fsw._closeFile(path);
|
|
@@ -1100,12 +1102,13 @@
|
|
|
1100
1102
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1101
1103
|
exports.FSWatcher = exports.WatchHelper = void 0;
|
|
1102
1104
|
exports.watch = watch;
|
|
1103
|
-
const fs_1 =
|
|
1105
|
+
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */ const fs_1 =
|
|
1106
|
+
__nccwpck_require__(147);
|
|
1104
1107
|
const promises_1 = __nccwpck_require__(292);
|
|
1105
1108
|
const events_1 = __nccwpck_require__(361);
|
|
1106
1109
|
const sysPath = __nccwpck_require__(17);
|
|
1107
1110
|
const readdirp_1 = __nccwpck_require__(9);
|
|
1108
|
-
const handler_js_1 = __nccwpck_require__(
|
|
1111
|
+
const handler_js_1 = __nccwpck_require__(457);
|
|
1109
1112
|
const SLASH = "/";
|
|
1110
1113
|
const SLASH_SLASH = "//";
|
|
1111
1114
|
const ONE_DOT = ".";
|
|
@@ -1480,16 +1483,16 @@
|
|
|
1480
1483
|
return watchList;
|
|
1481
1484
|
}
|
|
1482
1485
|
emitWithAll(event, args) {
|
|
1483
|
-
this.emit(...args);
|
|
1486
|
+
this.emit(event, ...args);
|
|
1484
1487
|
if (event !== handler_js_1.EVENTS.ERROR)
|
|
1485
|
-
this.emit(handler_js_1.EVENTS.ALL, ...args);
|
|
1488
|
+
this.emit(handler_js_1.EVENTS.ALL, event, ...args);
|
|
1486
1489
|
}
|
|
1487
1490
|
async _emit(event, path, stats) {
|
|
1488
1491
|
if (this.closed) return;
|
|
1489
1492
|
const opts = this.options;
|
|
1490
1493
|
if (handler_js_1.isWindows) path = sysPath.normalize(path);
|
|
1491
1494
|
if (opts.cwd) path = sysPath.relative(opts.cwd, path);
|
|
1492
|
-
const args = [
|
|
1495
|
+
const args = [path];
|
|
1493
1496
|
if (stats != null) args.push(stats);
|
|
1494
1497
|
const awf = opts.awaitWriteFinish;
|
|
1495
1498
|
let pw;
|
|
@@ -1499,7 +1502,7 @@
|
|
|
1499
1502
|
}
|
|
1500
1503
|
if (opts.atomic) {
|
|
1501
1504
|
if (event === handler_js_1.EVENTS.UNLINK) {
|
|
1502
|
-
this._pendingUnlinks.set(path, args);
|
|
1505
|
+
this._pendingUnlinks.set(path, [event, ...args]);
|
|
1503
1506
|
setTimeout(
|
|
1504
1507
|
() => {
|
|
1505
1508
|
this._pendingUnlinks.forEach((entry, path) => {
|
|
@@ -1516,7 +1519,7 @@
|
|
|
1516
1519
|
event === handler_js_1.EVENTS.ADD &&
|
|
1517
1520
|
this._pendingUnlinks.has(path)
|
|
1518
1521
|
) {
|
|
1519
|
-
event =
|
|
1522
|
+
event = handler_js_1.EVENTS.CHANGE;
|
|
1520
1523
|
this._pendingUnlinks.delete(path);
|
|
1521
1524
|
}
|
|
1522
1525
|
}
|
|
@@ -1528,12 +1531,12 @@
|
|
|
1528
1531
|
) {
|
|
1529
1532
|
const awfEmit = (err, stats) => {
|
|
1530
1533
|
if (err) {
|
|
1531
|
-
event =
|
|
1532
|
-
args[
|
|
1534
|
+
event = handler_js_1.EVENTS.ERROR;
|
|
1535
|
+
args[0] = err;
|
|
1533
1536
|
this.emitWithAll(event, args);
|
|
1534
1537
|
} else if (stats) {
|
|
1535
|
-
if (args.length >
|
|
1536
|
-
args[
|
|
1538
|
+
if (args.length > 1) {
|
|
1539
|
+
args[1] = stats;
|
|
1537
1540
|
} else {
|
|
1538
1541
|
args.push(stats);
|
|
1539
1542
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"chokidar","author":"Paul Miller (https://paulmillr.com)","version":"4.0.
|
|
1
|
+
{"name":"chokidar","author":"Paul Miller (https://paulmillr.com)","version":"4.0.3","funding":"https://paulmillr.com/funding/","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/index.js
CHANGED
|
@@ -160,11 +160,11 @@ function prepareCli() {
|
|
|
160
160
|
initNodeEnv();
|
|
161
161
|
const { npm_execpath } = process.env;
|
|
162
162
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
163
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.
|
|
163
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.2.0\n`);
|
|
164
164
|
}
|
|
165
165
|
const composeAssetConfig = (bundle, format)=>{
|
|
166
166
|
if ('esm' === format || 'cjs' === format) {
|
|
167
|
-
|
|
167
|
+
return {
|
|
168
168
|
output: {
|
|
169
169
|
dataUriLimit: 0
|
|
170
170
|
}
|
|
@@ -213,23 +213,64 @@ const ENTRY_EXTENSIONS = [
|
|
|
213
213
|
const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
214
214
|
const CSS_EXTENSIONS_PATTERN = new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
215
215
|
const ENTRY_EXTENSIONS_PATTERN = new RegExp(`\\.(${ENTRY_EXTENSIONS.join('|')})$`);
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
const BASE_URI = 'webpack://';
|
|
217
|
+
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
218
|
+
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
219
|
+
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
220
|
+
function getUndoPath(filename, outputPathArg, enforceRelative) {
|
|
221
|
+
let depth = -1;
|
|
222
|
+
let append = '';
|
|
223
|
+
let outputPath = outputPathArg.replace(/[\\/]$/, '');
|
|
224
|
+
for (const part of filename.split(/[/\\]+/))if ('..' === part) {
|
|
225
|
+
if (depth > -1) depth--;
|
|
226
|
+
else {
|
|
227
|
+
const i = outputPath.lastIndexOf('/');
|
|
228
|
+
const j = outputPath.lastIndexOf('\\');
|
|
229
|
+
const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
|
|
230
|
+
if (pos < 0) return `${outputPath}/`;
|
|
231
|
+
append = `${outputPath.slice(pos + 1)}/${append}`;
|
|
232
|
+
outputPath = outputPath.slice(0, pos);
|
|
233
|
+
}
|
|
234
|
+
} else if ('.' !== part) depth++;
|
|
235
|
+
return depth > 0 ? `${'../'.repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
236
|
+
}
|
|
237
|
+
const LibCssExtractPlugin_pluginName = 'LIB_CSS_EXTRACT_PLUGIN';
|
|
238
|
+
class LibCssExtractPlugin {
|
|
239
|
+
name = LibCssExtractPlugin_pluginName;
|
|
219
240
|
options;
|
|
220
241
|
constructor(options){
|
|
221
|
-
this.options = options;
|
|
242
|
+
this.options = options ?? {};
|
|
222
243
|
}
|
|
223
244
|
apply(compiler) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
compilation.hooks.chunkAsset.tap(RemoveCssExtractAssetPlugin_pluginName, (_chunk, filename)=>{
|
|
245
|
+
compiler.hooks.thisCompilation.tap(LibCssExtractPlugin_pluginName, (compilation)=>{
|
|
246
|
+
compilation.hooks.chunkAsset.tap(LibCssExtractPlugin_pluginName, (_chunk, filename)=>{
|
|
227
247
|
const asset = compilation.getAsset(filename);
|
|
228
248
|
if (!asset) return;
|
|
229
|
-
const needRemove = Boolean(asset.name.match(
|
|
249
|
+
const needRemove = Boolean(asset.name.match(RSLIB_CSS_ENTRY_FLAG));
|
|
230
250
|
if (needRemove) compilation.deleteAsset(filename);
|
|
231
251
|
});
|
|
232
252
|
});
|
|
253
|
+
compiler.hooks.make.tap(LibCssExtractPlugin_pluginName, (compilation)=>{
|
|
254
|
+
compilation.hooks.processAssets.tap(LibCssExtractPlugin_pluginName, (assets)=>{
|
|
255
|
+
const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
|
|
256
|
+
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
257
|
+
const oldSource = old.source().toString();
|
|
258
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.rspack.sources.ReplaceSource(old);
|
|
259
|
+
function replace(searchValue, replaceValue) {
|
|
260
|
+
let start = oldSource.indexOf(searchValue);
|
|
261
|
+
while(-1 !== start){
|
|
262
|
+
replaceSource.replace(start, start + searchValue.length - 1, replaceValue);
|
|
263
|
+
start = oldSource.indexOf(searchValue, start + 1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
replace(ABSOLUTE_PUBLIC_PATH, '');
|
|
267
|
+
replace(SINGLE_DOT_PATH_SEGMENT, '.');
|
|
268
|
+
const undoPath = getUndoPath(name, compilation.outputOptions.path, false);
|
|
269
|
+
replace(AUTO_PUBLIC_PATH, undoPath);
|
|
270
|
+
return replaceSource;
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
});
|
|
233
274
|
}
|
|
234
275
|
}
|
|
235
276
|
const cssConfig_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
|
|
@@ -296,11 +337,7 @@ const pluginLibCss = (rootDir)=>({
|
|
|
296
337
|
if (isUsingCssExtract) {
|
|
297
338
|
const cssExtract = CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT;
|
|
298
339
|
config.plugins.delete(cssExtract);
|
|
299
|
-
config.plugin(
|
|
300
|
-
{
|
|
301
|
-
include: new RegExp(`^${RSLIB_CSS_ENTRY_FLAG}`)
|
|
302
|
-
}
|
|
303
|
-
]);
|
|
340
|
+
config.plugin(LibCssExtractPlugin.name).use(LibCssExtractPlugin);
|
|
304
341
|
}
|
|
305
342
|
});
|
|
306
343
|
}
|
|
@@ -356,7 +393,7 @@ const pluginEsmRequireShim = ()=>({
|
|
|
356
393
|
});
|
|
357
394
|
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
|
|
358
395
|
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
359
|
-
const
|
|
396
|
+
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
360
397
|
const matchFirstLine = (source, regex)=>{
|
|
361
398
|
const lineBreakPos = source.match(/(\r\n|\n)/);
|
|
362
399
|
const firstLineContent = source.slice(0, lineBreakPos?.index);
|
|
@@ -450,7 +487,7 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
|
|
|
450
487
|
name: EntryChunkPlugin_PLUGIN_NAME,
|
|
451
488
|
setup (api) {
|
|
452
489
|
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
453
|
-
config.module.rule(CHAIN_ID.RULE.JS).use(
|
|
490
|
+
config.module.rule(CHAIN_ID.RULE.JS).use(EntryChunkPlugin_LOADER_NAME).loader(EntryChunkPlugin_require.resolve('./entryModuleLoader.js'));
|
|
454
491
|
});
|
|
455
492
|
}
|
|
456
493
|
});
|
|
@@ -1389,7 +1426,6 @@ function composeDecoratorsConfig(compilerOptions, version) {
|
|
|
1389
1426
|
}
|
|
1390
1427
|
async function createConstantRsbuildConfig() {
|
|
1391
1428
|
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.defineConfig)({
|
|
1392
|
-
mode: 'production',
|
|
1393
1429
|
dev: {
|
|
1394
1430
|
progressBar: false
|
|
1395
1431
|
},
|
|
@@ -1917,9 +1953,9 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1917
1953
|
}
|
|
1918
1954
|
return defaultConfig;
|
|
1919
1955
|
};
|
|
1920
|
-
async function composeLibRsbuildConfig(config, sharedPlugins) {
|
|
1956
|
+
async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
1921
1957
|
checkMFPlugin(config, sharedPlugins);
|
|
1922
|
-
const rootPath =
|
|
1958
|
+
const rootPath = root ? getAbsolutePath(process.cwd(), root) : process.cwd();
|
|
1923
1959
|
const pkgJson = readPackageJson(rootPath);
|
|
1924
1960
|
const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
|
|
1925
1961
|
const cssModulesAuto = config.output?.cssModules?.auto ?? true;
|
|
@@ -1958,11 +1994,11 @@ async function composeLibRsbuildConfig(config, sharedPlugins) {
|
|
|
1958
1994
|
}
|
|
1959
1995
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
1960
1996
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
1961
|
-
const { lib: libConfigsArray, plugins: sharedPlugins, ...sharedRsbuildConfig } = rslibConfig;
|
|
1997
|
+
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
1962
1998
|
if (!libConfigsArray) throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
1963
1999
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
1964
2000
|
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
1965
|
-
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, sharedPlugins);
|
|
2001
|
+
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
1966
2002
|
userConfig.source ??= {};
|
|
1967
2003
|
userConfig.source.entry = {};
|
|
1968
2004
|
userConfig.output ??= {};
|
|
@@ -1993,6 +2029,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
1993
2029
|
}
|
|
1994
2030
|
async function composeRsbuildEnvironments(rslibConfig) {
|
|
1995
2031
|
const rsbuildConfigWithLibInfo = await composeCreateRsbuildConfig(rslibConfig);
|
|
2032
|
+
const environmentWithInfos = [];
|
|
1996
2033
|
const usedIds = rsbuildConfigWithLibInfo.map(({ id })=>id).filter(Boolean);
|
|
1997
2034
|
const environments = {};
|
|
1998
2035
|
const formatCount = rsbuildConfigWithLibInfo.reduce((acc, { format })=>{
|
|
@@ -2010,10 +2047,18 @@ async function composeRsbuildEnvironments(rslibConfig) {
|
|
|
2010
2047
|
for (const { format, id, config } of rsbuildConfigWithLibInfo){
|
|
2011
2048
|
const libId = 'string' == typeof id ? id : composeDefaultId(format);
|
|
2012
2049
|
environments[libId] = config;
|
|
2050
|
+
environmentWithInfos.push({
|
|
2051
|
+
id: libId,
|
|
2052
|
+
format,
|
|
2053
|
+
config
|
|
2054
|
+
});
|
|
2013
2055
|
}
|
|
2014
2056
|
const conflictIds = usedIds.filter((id, index)=>usedIds.indexOf(id) !== index);
|
|
2015
2057
|
if (conflictIds.length) throw new Error(`The following ids are duplicated: ${conflictIds.map((id)=>`"${id}"`).join(', ')}. Please change the "lib.id" to be unique.`);
|
|
2016
|
-
return
|
|
2058
|
+
return {
|
|
2059
|
+
environments,
|
|
2060
|
+
environmentWithInfos
|
|
2061
|
+
};
|
|
2017
2062
|
}
|
|
2018
2063
|
const pruneEnvironments = (environments, libs)=>{
|
|
2019
2064
|
if (!libs) return environments;
|
|
@@ -2054,10 +2099,14 @@ const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
|
2054
2099
|
cleaners = [];
|
|
2055
2100
|
};
|
|
2056
2101
|
async function build(config, options = {}) {
|
|
2057
|
-
const environments = await composeRsbuildEnvironments(config);
|
|
2102
|
+
const { environments } = await composeRsbuildEnvironments(config);
|
|
2058
2103
|
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2059
2104
|
rsbuildConfig: {
|
|
2105
|
+
mode: 'production',
|
|
2106
|
+
root: config.root,
|
|
2060
2107
|
plugins: config.plugins,
|
|
2108
|
+
dev: config.dev,
|
|
2109
|
+
server: config.server,
|
|
2061
2110
|
environments: pruneEnvironments(environments, options.lib)
|
|
2062
2111
|
}
|
|
2063
2112
|
});
|
|
@@ -2101,10 +2150,14 @@ async function init(options) {
|
|
|
2101
2150
|
};
|
|
2102
2151
|
}
|
|
2103
2152
|
async function inspect(config, options = {}) {
|
|
2104
|
-
const environments = await composeRsbuildEnvironments(config);
|
|
2153
|
+
const { environments } = await composeRsbuildEnvironments(config);
|
|
2105
2154
|
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2106
2155
|
rsbuildConfig: {
|
|
2156
|
+
mode: 'production',
|
|
2157
|
+
root: config.root,
|
|
2107
2158
|
plugins: config.plugins,
|
|
2159
|
+
dev: config.dev,
|
|
2160
|
+
server: config.server,
|
|
2108
2161
|
environments: pruneEnvironments(environments, options.lib)
|
|
2109
2162
|
}
|
|
2110
2163
|
});
|
|
@@ -2116,61 +2169,61 @@ async function inspect(config, options = {}) {
|
|
|
2116
2169
|
});
|
|
2117
2170
|
return rsbuildInstance;
|
|
2118
2171
|
}
|
|
2119
|
-
async function startMFDevServer(config) {
|
|
2120
|
-
const rsbuildInstance = await initMFRsbuild(config);
|
|
2172
|
+
async function startMFDevServer(config, options = {}) {
|
|
2173
|
+
const rsbuildInstance = await initMFRsbuild(config, options);
|
|
2121
2174
|
return rsbuildInstance;
|
|
2122
2175
|
}
|
|
2123
|
-
async function initMFRsbuild(
|
|
2124
|
-
const
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2127
|
-
|
|
2176
|
+
async function initMFRsbuild(config, options = {}) {
|
|
2177
|
+
const { environments, environmentWithInfos } = await composeRsbuildEnvironments(config);
|
|
2178
|
+
const selectedEnvironmentIds = environmentWithInfos.filter((env)=>{
|
|
2179
|
+
const isMf = 'mf' === env.format;
|
|
2180
|
+
if (!options?.lib) return isMf;
|
|
2181
|
+
return env.id && options.lib.includes(env.id);
|
|
2182
|
+
}).map((env)=>env.id);
|
|
2183
|
+
if (!selectedEnvironmentIds.length) throw new Error('No mf format found, please check your config.');
|
|
2184
|
+
const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
|
|
2128
2185
|
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2129
2186
|
rsbuildConfig: {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2187
|
+
mode: 'development',
|
|
2188
|
+
root: config.root,
|
|
2189
|
+
plugins: config.plugins,
|
|
2190
|
+
dev: {
|
|
2191
|
+
...config.dev ?? {},
|
|
2192
|
+
writeToDisk: true
|
|
2193
|
+
},
|
|
2194
|
+
server: config.server,
|
|
2195
|
+
tools: {
|
|
2196
|
+
rspack: {
|
|
2197
|
+
optimization: {
|
|
2198
|
+
nodeEnv: 'development',
|
|
2199
|
+
moduleIds: 'named'
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
},
|
|
2203
|
+
environments: selectedEnvironments
|
|
2135
2204
|
}
|
|
2136
2205
|
});
|
|
2137
2206
|
const devServer = await rsbuildInstance.startDevServer();
|
|
2138
2207
|
onBeforeRestart(devServer.server.close);
|
|
2139
2208
|
return rsbuildInstance;
|
|
2140
2209
|
}
|
|
2141
|
-
function changeEnvToDev(rsbuildConfig) {
|
|
2142
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(rsbuildConfig, {
|
|
2143
|
-
mode: 'development',
|
|
2144
|
-
dev: {
|
|
2145
|
-
writeToDisk: true
|
|
2146
|
-
},
|
|
2147
|
-
tools: {
|
|
2148
|
-
rspack: {
|
|
2149
|
-
optimization: {
|
|
2150
|
-
nodeEnv: 'development',
|
|
2151
|
-
moduleIds: 'named'
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
});
|
|
2156
|
-
}
|
|
2157
2210
|
const applyCommonOptions = (command)=>{
|
|
2158
|
-
command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('-r --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--env-dir <dir>', 'specify the directory to load `.env` files');
|
|
2211
|
+
command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('-r --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--env-dir <dir>', 'specify the directory to load `.env` files').option('--lib <id>', 'specify the library (repeatable, e.g. --lib esm --lib cjs)', repeatableOption);
|
|
2159
2212
|
};
|
|
2160
2213
|
const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
2161
2214
|
value
|
|
2162
2215
|
]);
|
|
2163
2216
|
function runCli() {
|
|
2164
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.
|
|
2217
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.2.0");
|
|
2165
2218
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2166
2219
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2167
|
-
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('mf
|
|
2220
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('mf-dev');
|
|
2168
2221
|
[
|
|
2169
2222
|
buildCommand,
|
|
2170
2223
|
inspectCommand,
|
|
2171
2224
|
mfDevCommand
|
|
2172
2225
|
].forEach(applyCommonOptions);
|
|
2173
|
-
buildCommand.option('
|
|
2226
|
+
buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the library for production').action(async (options)=>{
|
|
2174
2227
|
try {
|
|
2175
2228
|
const cliBuild = async ()=>{
|
|
2176
2229
|
const { config, watchFiles } = await init(options);
|
|
@@ -2186,7 +2239,7 @@ function runCli() {
|
|
|
2186
2239
|
process.exit(1);
|
|
2187
2240
|
}
|
|
2188
2241
|
});
|
|
2189
|
-
inspectCommand.description('inspect the Rsbuild / Rspack configs of Rslib projects').option('--
|
|
2242
|
+
inspectCommand.description('inspect the Rsbuild / Rspack configs of Rslib projects').option('--output <output>', 'specify inspect content output path', '.rsbuild').option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
2190
2243
|
try {
|
|
2191
2244
|
const { config } = await init(options);
|
|
2192
2245
|
await inspect(config, {
|
|
@@ -2205,20 +2258,22 @@ function runCli() {
|
|
|
2205
2258
|
try {
|
|
2206
2259
|
const cliMfDev = async ()=>{
|
|
2207
2260
|
const { config, watchFiles } = await init(options);
|
|
2208
|
-
await startMFDevServer(config
|
|
2261
|
+
await startMFDevServer(config, {
|
|
2262
|
+
lib: options.lib
|
|
2263
|
+
});
|
|
2209
2264
|
watchFilesForRestart(watchFiles, async ()=>{
|
|
2210
2265
|
await cliMfDev();
|
|
2211
2266
|
});
|
|
2212
2267
|
};
|
|
2213
2268
|
await cliMfDev();
|
|
2214
2269
|
} catch (err) {
|
|
2215
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start mf
|
|
2270
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start mf-dev.');
|
|
2216
2271
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
2217
2272
|
process.exit(1);
|
|
2218
2273
|
}
|
|
2219
2274
|
});
|
|
2220
2275
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2221
2276
|
}
|
|
2222
|
-
const src_rslib_entry_version = "0.
|
|
2277
|
+
const src_rslib_entry_version = "0.2.0";
|
|
2223
2278
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2224
2279
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
2
|
-
const
|
|
2
|
+
const BASE_URI = 'webpack://';
|
|
3
|
+
const MODULE_TYPE = 'css/mini-extract';
|
|
4
|
+
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
5
|
+
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
6
|
+
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
7
|
+
const LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
3
8
|
function stringifyLocal(value) {
|
|
4
9
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
5
10
|
}
|
|
@@ -18,6 +23,15 @@ const pitch = function(request, _, _data) {
|
|
|
18
23
|
const callback = this.async();
|
|
19
24
|
const filepath = this.resourcePath;
|
|
20
25
|
const rootDir = options.rootDir ?? this.rootContext;
|
|
26
|
+
let { publicPath } = this._compilation.outputOptions;
|
|
27
|
+
if ('string' == typeof options.publicPath) publicPath = options.publicPath;
|
|
28
|
+
else if ('function' == typeof options.publicPath) publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
29
|
+
if ('auto' === publicPath) publicPath = AUTO_PUBLIC_PATH;
|
|
30
|
+
let publicPathForExtract;
|
|
31
|
+
if ('string' == typeof publicPath) {
|
|
32
|
+
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
33
|
+
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
|
|
34
|
+
} else publicPathForExtract = publicPath;
|
|
21
35
|
const handleExports = (originalExports)=>{
|
|
22
36
|
let locals;
|
|
23
37
|
let namedExport;
|
|
@@ -79,7 +93,7 @@ const pitch = function(request, _, _data) {
|
|
|
79
93
|
if (esModule) return '\nexport {};';
|
|
80
94
|
return '';
|
|
81
95
|
}();
|
|
82
|
-
let resultSource = `// extracted by ${
|
|
96
|
+
let resultSource = `// extracted by ${LOADER_NAME}`;
|
|
83
97
|
let importCssFiles = '';
|
|
84
98
|
function getRelativePath(from, to) {
|
|
85
99
|
let relativePath = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(from, to);
|
|
@@ -105,7 +119,9 @@ const pitch = function(request, _, _data) {
|
|
|
105
119
|
callback(null, resultSource, void 0);
|
|
106
120
|
};
|
|
107
121
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
108
|
-
layer: options.layer
|
|
122
|
+
layer: options.layer,
|
|
123
|
+
publicPath: publicPathForExtract,
|
|
124
|
+
baseUri: `${BASE_URI}/`
|
|
109
125
|
}, (error, exports)=>{
|
|
110
126
|
if (error) {
|
|
111
127
|
callback(error);
|
|
@@ -115,4 +131,4 @@ const pitch = function(request, _, _data) {
|
|
|
115
131
|
});
|
|
116
132
|
};
|
|
117
133
|
const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
|
|
118
|
-
export { libCssExtractLoader_rslib_entry_ as default, pitch };
|
|
134
|
+
export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, MODULE_TYPE, SINGLE_DOT_PATH_SEGMENT, libCssExtractLoader_rslib_entry_ as default, pitch };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
import type { Format } from '../types';
|
|
3
|
-
export declare const composeAssetConfig: (bundle: boolean, format: Format) =>
|
|
3
|
+
export declare const composeAssetConfig: (bundle: boolean, format: Format) => EnvironmentConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { RslibConfig } from '../types/config';
|
|
3
3
|
import type { BuildOptions } from './commands';
|
|
4
|
-
export declare function build(config: RslibConfig, options?: Pick<BuildOptions, 'lib' | 'watch'>): Promise<RsbuildInstance>;
|
|
4
|
+
export declare function build(config: RslibConfig, options?: Pick<BuildOptions, 'lib' | 'watch' | 'root'>): Promise<RsbuildInstance>;
|
package/dist-types/cli/mf.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { RslibConfig } from '../types';
|
|
3
|
-
|
|
3
|
+
import type { CommonOptions } from './commands';
|
|
4
|
+
export declare function startMFDevServer(config: RslibConfig, options?: Pick<CommonOptions, 'lib'>): Promise<RsbuildInstance | undefined>;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EnvironmentConfig
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
1
|
+
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
2
|
+
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* This function helps you to autocomplete configuration types.
|
|
5
5
|
* It accepts a Rslib config object, or a function that returns a config.
|
|
@@ -20,14 +20,17 @@ export declare const composeAutoExternalConfig: (options: {
|
|
|
20
20
|
format: Format;
|
|
21
21
|
autoExternal?: AutoExternal;
|
|
22
22
|
pkgJson?: PkgJson;
|
|
23
|
-
userExternals?: NonNullable<
|
|
24
|
-
}) =>
|
|
25
|
-
export declare function composeMinifyConfig(config: LibConfig):
|
|
26
|
-
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter):
|
|
27
|
-
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<
|
|
28
|
-
export declare function createConstantRsbuildConfig(): Promise<
|
|
23
|
+
userExternals?: NonNullable<EnvironmentConfig["output"]>["externals"];
|
|
24
|
+
}) => EnvironmentConfig;
|
|
25
|
+
export declare function composeMinifyConfig(config: LibConfig): EnvironmentConfig;
|
|
26
|
+
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): EnvironmentConfig;
|
|
27
|
+
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
|
|
28
|
+
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
29
29
|
export declare const composeModuleImportWarn: (request: string) => string;
|
|
30
30
|
export declare const appendEntryQuery: (entry: RsbuildConfigEntry) => RsbuildConfigEntry;
|
|
31
31
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
32
|
-
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<
|
|
32
|
+
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
|
|
33
|
+
environments: Record<string, EnvironmentConfig>;
|
|
34
|
+
environmentWithInfos: RequireKey<RsbuildConfigWithLibInfo, 'id'>[];
|
|
35
|
+
}>;
|
|
33
36
|
export declare const pruneEnvironments: (environments: Record<string, EnvironmentConfig>, libs?: string[]) => Record<string, EnvironmentConfig>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Rspack } from '@rsbuild/core';
|
|
2
|
+
type Options = Record<string, unknown>;
|
|
3
|
+
declare class LibCssExtractPlugin implements Rspack.RspackPluginInstance {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
options: Options;
|
|
6
|
+
constructor(options?: Options);
|
|
7
|
+
apply(compiler: Rspack.Compiler): void;
|
|
8
|
+
}
|
|
9
|
+
export { LibCssExtractPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSLoaderOptions,
|
|
1
|
+
import type { CSSLoaderOptions, EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
export declare const RSLIB_CSS_ENTRY_FLAG = "__rslib_css__";
|
|
3
3
|
export type CssLoaderOptionsAuto = CSSLoaderOptions['modules'] extends infer T ? T extends {
|
|
4
4
|
auto?: any;
|
|
@@ -13,5 +13,5 @@ export declare function isCssModulesFile(filepath: string, auto: CssLoaderOption
|
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
14
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
15
|
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, isStyleRedirect: boolean): void | false;
|
|
16
|
-
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) =>
|
|
16
|
+
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => EnvironmentConfig;
|
|
17
17
|
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
export declare const BASE_URI = "webpack://";
|
|
3
|
+
export declare const MODULE_TYPE = "css/mini-extract";
|
|
4
|
+
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
5
|
+
export declare const ABSOLUTE_PUBLIC_PATH: string;
|
|
6
|
+
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
2
7
|
export interface CssExtractRspackLoaderOptions {
|
|
8
|
+
publicPath?: string | ((resourcePath: string, context: string) => string);
|
|
3
9
|
emit?: boolean;
|
|
4
10
|
esModule?: boolean;
|
|
5
11
|
layer?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function is copied from
|
|
3
|
+
* https://github.com/webpack-contrib/mini-css-extract-plugin/blob/3effaa0319bad5cc1bf0ae760553bf7abcbc35a4/src/utils.js#L169
|
|
4
|
+
* linted by biome
|
|
5
|
+
*/
|
|
6
|
+
declare function getUndoPath(filename: string, outputPathArg: string, enforceRelative: boolean): string;
|
|
7
|
+
export { getUndoPath };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, }: {
|
|
3
3
|
enabledImportMetaUrlShim: boolean;
|
|
4
|
-
}) =>
|
|
4
|
+
}) => EnvironmentConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
1
|
+
import type { EnvironmentConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
2
2
|
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
|
|
3
3
|
import type { GetAsyncFunctionFromUnion } from './utils';
|
|
4
4
|
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
|
|
@@ -8,12 +8,12 @@ export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
|
|
|
8
8
|
export type RsbuildConfigWithLibInfo = {
|
|
9
9
|
id?: string;
|
|
10
10
|
format: Format;
|
|
11
|
-
config:
|
|
11
|
+
config: EnvironmentConfig;
|
|
12
12
|
};
|
|
13
|
-
export type RsbuildConfigEntry = NonNullable<NonNullable<
|
|
13
|
+
export type RsbuildConfigEntry = NonNullable<NonNullable<EnvironmentConfig['source']>['entry']>;
|
|
14
14
|
export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
|
|
15
15
|
export type RspackResolver = GetAsyncFunctionFromUnion<ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>>;
|
|
16
|
-
export type RsbuildConfigOutputTarget = NonNullable<
|
|
16
|
+
export type RsbuildConfigOutputTarget = NonNullable<EnvironmentConfig['output']>['target'];
|
|
17
17
|
export type Syntax = EcmaScriptVersion | string[];
|
|
18
18
|
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
|
|
19
19
|
autoExtension?: boolean;
|
|
@@ -57,7 +57,7 @@ export type Redirect = {
|
|
|
57
57
|
/** Whether to redirect the import path of the style file. */
|
|
58
58
|
style?: boolean;
|
|
59
59
|
};
|
|
60
|
-
export interface LibConfig extends
|
|
60
|
+
export interface LibConfig extends EnvironmentConfig {
|
|
61
61
|
/**
|
|
62
62
|
* The unique identifier of the library.
|
|
63
63
|
* @defaultValue `undefined`
|
|
@@ -150,7 +150,7 @@ export interface LibConfig extends RsbuildConfig {
|
|
|
150
150
|
*/
|
|
151
151
|
umdName?: string;
|
|
152
152
|
}
|
|
153
|
-
export type LibOnlyConfig = Omit<LibConfig, keyof
|
|
153
|
+
export type LibOnlyConfig = Omit<LibConfig, keyof EnvironmentConfig>;
|
|
154
154
|
export interface RslibConfig extends RsbuildConfig {
|
|
155
155
|
lib: LibConfig[];
|
|
156
156
|
}
|
|
@@ -9,5 +9,8 @@ export type PkgJson = {
|
|
|
9
9
|
export type DeepRequired<T> = Required<{
|
|
10
10
|
[K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
|
|
11
11
|
}>;
|
|
12
|
+
export type RequireKey<T, K extends keyof T> = T & {
|
|
13
|
+
[P in K]-?: T[P];
|
|
14
|
+
};
|
|
12
15
|
export type ExcludesFalse = <T>(x: T | false | undefined | null) => x is T;
|
|
13
16
|
export type GetAsyncFunctionFromUnion<T> = T extends (...args: any[]) => Promise<any> ? T : never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentConfig, Rspack } from '@rsbuild/core';
|
|
2
2
|
import type { FixedEcmaVersions, LatestEcmaVersions, RsbuildConfigOutputTarget, Syntax } from '../types/config';
|
|
3
3
|
export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOutputTarget>, string[]>;
|
|
4
4
|
/**
|
|
@@ -10,4 +10,4 @@ export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOut
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string | string[]>> & Record<LatestEcmaVersions, (target: RsbuildConfigOutputTarget) => string[]>;
|
|
12
12
|
export declare function transformSyntaxToRspackTarget(syntax: Syntax): Rspack.Configuration['target'];
|
|
13
|
-
export declare function transformSyntaxToBrowserslist(syntax: Syntax, target: NonNullable<
|
|
13
|
+
export declare function transformSyntaxToBrowserslist(syntax: Syntax, target: NonNullable<EnvironmentConfig['output']>['target']): NonNullable<NonNullable<EnvironmentConfig['output']>['overrideBrowserslist']>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.1.
|
|
35
|
+
"@rsbuild/core": "~1.1.12",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.
|
|
37
|
+
"rsbuild-plugin-dts": "0.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
41
|
-
"chokidar": "^4.0.
|
|
41
|
+
"chokidar": "^4.0.3",
|
|
42
42
|
"commander": "^12.1.0",
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
|
-
"memfs": "^4.15.
|
|
44
|
+
"memfs": "^4.15.1",
|
|
45
45
|
"picocolors": "1.1.1",
|
|
46
46
|
"prebundle": "1.2.5",
|
|
47
47
|
"rsbuild-plugin-publint": "^0.2.1",
|
|
48
|
-
"rslib": "npm:@rslib/core@0.1.
|
|
48
|
+
"rslib": "npm:@rslib/core@0.1.5",
|
|
49
49
|
"rslog": "^1.2.3",
|
|
50
50
|
"tsconfck": "3.1.4",
|
|
51
51
|
"typescript": "^5.6.3",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Rspack } from '@rsbuild/core';
|
|
2
|
-
type Options = {
|
|
3
|
-
include: RegExp;
|
|
4
|
-
};
|
|
5
|
-
declare class RemoveCssExtractAssetPlugin implements Rspack.RspackPluginInstance {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
options: Options;
|
|
8
|
-
constructor(options: Options);
|
|
9
|
-
apply(compiler: Rspack.Compiler): void;
|
|
10
|
-
}
|
|
11
|
-
export { RemoveCssExtractAssetPlugin };
|