@rslib/core 0.1.0 → 0.1.2
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 +327 -0
- package/compiled/chokidar/index.js +1775 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/dist/entryModuleLoader.js +3 -3
- package/dist/index.js +111 -23
- package/dist/libCssExtractLoader.js +3 -3
- package/dist-types/cli/init.d.ts +4 -1
- package/dist-types/cli/restart.d.ts +7 -0
- package/dist-types/config.d.ts +6 -2
- package/dist-types/types/config/index.d.ts +2 -0
- package/dist-types/utils/helper.d.ts +5 -0
- package/package.json +6 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"chokidar","author":"Paul Miller (https://paulmillr.com)","version":"4.0.1","funding":"https://paulmillr.com/funding/","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -39,7 +39,7 @@ function splitFromFirstLine(text) {
|
|
|
39
39
|
text.slice(match.index)
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const entryModuleLoader_rslib_entry_loader = function(source) {
|
|
43
43
|
let result = source;
|
|
44
44
|
if (this.resourceQuery === `?${RSLIB_ENTRY_QUERY}`) {
|
|
45
45
|
const [firstLine1, rest] = splitFromFirstLine(result);
|
|
@@ -49,5 +49,5 @@ const entryModuleLoader_loader = function(source) {
|
|
|
49
49
|
}
|
|
50
50
|
return result;
|
|
51
51
|
};
|
|
52
|
-
/* ESM default export */ const
|
|
53
|
-
export {
|
|
52
|
+
/* ESM default export */ const entryModuleLoader_rslib_entry_ = entryModuleLoader_rslib_entry_loader;
|
|
53
|
+
export { entryModuleLoader_rslib_entry_ as default };
|
package/dist/index.js
CHANGED
|
@@ -138,6 +138,18 @@ function checkMFPlugin(config) {
|
|
|
138
138
|
}
|
|
139
139
|
return added;
|
|
140
140
|
}
|
|
141
|
+
function debounce(func, wait) {
|
|
142
|
+
let timeoutId = null;
|
|
143
|
+
return (...args)=>{
|
|
144
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
145
|
+
timeoutId = setTimeout(()=>{
|
|
146
|
+
func(...args);
|
|
147
|
+
}, wait);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if running in a TTY context
|
|
152
|
+
*/ const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
|
|
141
153
|
// setup the logger level
|
|
142
154
|
if (process.env.DEBUG) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level = 'verbose';
|
|
143
155
|
function initNodeEnv() {
|
|
@@ -154,7 +166,7 @@ function prepareCli() {
|
|
|
154
166
|
// Some package managers automatically output a blank line, some do not.
|
|
155
167
|
const { npm_execpath } = process.env;
|
|
156
168
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
157
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.1.
|
|
169
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.1.2\n`);
|
|
158
170
|
}
|
|
159
171
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
160
172
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -1434,7 +1446,10 @@ async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
|
1434
1446
|
path: configFilePath,
|
|
1435
1447
|
envMode
|
|
1436
1448
|
});
|
|
1437
|
-
return
|
|
1449
|
+
return {
|
|
1450
|
+
content: content,
|
|
1451
|
+
filePath: configFilePath
|
|
1452
|
+
};
|
|
1438
1453
|
}
|
|
1439
1454
|
const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
1440
1455
|
if ('esm' !== format) return {};
|
|
@@ -1807,9 +1822,9 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1807
1822
|
},
|
|
1808
1823
|
// can not set nodeEnv to false, because mf format should build shared module.
|
|
1809
1824
|
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
|
|
1810
|
-
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
|
|
1811
1825
|
optimization: {
|
|
1812
|
-
nodeEnv: 'production'
|
|
1826
|
+
nodeEnv: 'production',
|
|
1827
|
+
moduleIds: 'deterministic'
|
|
1813
1828
|
}
|
|
1814
1829
|
}
|
|
1815
1830
|
},
|
|
@@ -1821,6 +1836,18 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1821
1836
|
throw new Error(`Unsupported format: ${format}`);
|
|
1822
1837
|
}
|
|
1823
1838
|
};
|
|
1839
|
+
const formatRsbuildPlugin = ()=>({
|
|
1840
|
+
name: 'rsbuild:format',
|
|
1841
|
+
setup (api) {
|
|
1842
|
+
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
1843
|
+
// Fix for https://github.com/web-infra-dev/rslib/issues/499.
|
|
1844
|
+
// Prevent parsing and try bundling `new URL()` in ESM format.
|
|
1845
|
+
config.module.rule(CHAIN_ID.RULE.JS).parser({
|
|
1846
|
+
url: false
|
|
1847
|
+
});
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1824
1851
|
const composeShimsConfig = (format, shims)=>{
|
|
1825
1852
|
const resolvedShims = {
|
|
1826
1853
|
cjs: {
|
|
@@ -1856,7 +1883,8 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1856
1883
|
}
|
|
1857
1884
|
},
|
|
1858
1885
|
plugins: [
|
|
1859
|
-
resolvedShims.esm.require && pluginEsmRequireShim()
|
|
1886
|
+
resolvedShims.esm.require && pluginEsmRequireShim(),
|
|
1887
|
+
formatRsbuildPlugin()
|
|
1860
1888
|
].filter(Boolean)
|
|
1861
1889
|
};
|
|
1862
1890
|
break;
|
|
@@ -1961,7 +1989,14 @@ const composeSyntaxConfig = (target, syntax)=>{
|
|
|
1961
1989
|
};
|
|
1962
1990
|
const appendEntryQuery = (entry)=>{
|
|
1963
1991
|
const newEntry = {};
|
|
1964
|
-
for(const key
|
|
1992
|
+
for (const [key, value] of Object.entries(entry)){
|
|
1993
|
+
let result = value;
|
|
1994
|
+
result = 'string' == typeof value ? `${value}?${RSLIB_ENTRY_QUERY}` : Array.isArray(value) ? value.map((item)=>`${item}?${RSLIB_ENTRY_QUERY}`) : {
|
|
1995
|
+
...value,
|
|
1996
|
+
import: 'string' == typeof value.import ? `${value.import}?${RSLIB_ENTRY_QUERY}` : value.import.map((item)=>`${item}?${RSLIB_ENTRY_QUERY}`)
|
|
1997
|
+
};
|
|
1998
|
+
newEntry[key] = result;
|
|
1999
|
+
}
|
|
1965
2000
|
return newEntry;
|
|
1966
2001
|
};
|
|
1967
2002
|
const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
@@ -2282,6 +2317,43 @@ const pruneEnvironments = (environments, libs)=>{
|
|
|
2282
2317
|
if (!libs) return environments;
|
|
2283
2318
|
return Object.fromEntries(Object.entries(environments).filter(([name])=>libs.includes(name)));
|
|
2284
2319
|
};
|
|
2320
|
+
async function watchFilesForRestart(files, restart) {
|
|
2321
|
+
if (!files.length) return;
|
|
2322
|
+
const chokidar = await import("../compiled/chokidar/index.js");
|
|
2323
|
+
const watcher = chokidar.watch(files, {
|
|
2324
|
+
ignoreInitial: true,
|
|
2325
|
+
// If watching fails due to read permissions, the errors will be suppressed silently.
|
|
2326
|
+
ignorePermissionErrors: true
|
|
2327
|
+
});
|
|
2328
|
+
const callback = debounce(async (filePath)=>{
|
|
2329
|
+
watcher.close();
|
|
2330
|
+
await beforeRestart({
|
|
2331
|
+
filePath
|
|
2332
|
+
});
|
|
2333
|
+
await restart();
|
|
2334
|
+
}, 300);
|
|
2335
|
+
watcher.on('add', callback);
|
|
2336
|
+
watcher.on('change', callback);
|
|
2337
|
+
watcher.on('unlink', callback);
|
|
2338
|
+
}
|
|
2339
|
+
let cleaners = [];
|
|
2340
|
+
/**
|
|
2341
|
+
* Add a cleaner to handle side effects
|
|
2342
|
+
*/ const onBeforeRestart = (cleaner)=>{
|
|
2343
|
+
cleaners.push(cleaner);
|
|
2344
|
+
};
|
|
2345
|
+
const clearConsole = ()=>{
|
|
2346
|
+
if (isTTY() && !process.env.DEBUG) process.stdout.write('\x1B[H\x1B[2J');
|
|
2347
|
+
};
|
|
2348
|
+
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2349
|
+
if (clear) clearConsole();
|
|
2350
|
+
if (filePath) {
|
|
2351
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].basename(filePath);
|
|
2352
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].yellow(filename)} is changed.\n`);
|
|
2353
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info('Restarting...\n');
|
|
2354
|
+
for (const cleaner of cleaners)await cleaner();
|
|
2355
|
+
cleaners = [];
|
|
2356
|
+
};
|
|
2285
2357
|
async function build(config, options = {}) {
|
|
2286
2358
|
const environments = await composeRsbuildEnvironments(config);
|
|
2287
2359
|
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
@@ -2289,20 +2361,21 @@ async function build(config, options = {}) {
|
|
|
2289
2361
|
environments: pruneEnvironments(environments, options.lib)
|
|
2290
2362
|
}
|
|
2291
2363
|
});
|
|
2292
|
-
await rsbuildInstance.build({
|
|
2364
|
+
const buildInstance = await rsbuildInstance.build({
|
|
2293
2365
|
watch: options.watch
|
|
2294
2366
|
});
|
|
2367
|
+
if (options.watch) onBeforeRestart(buildInstance.close);
|
|
2368
|
+
else await buildInstance.close();
|
|
2295
2369
|
return rsbuildInstance;
|
|
2296
2370
|
}
|
|
2297
2371
|
async function loadRslibConfig(options) {
|
|
2298
2372
|
const cwd = process.cwd();
|
|
2299
2373
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
2300
|
-
|
|
2374
|
+
return loadConfig({
|
|
2301
2375
|
cwd: root,
|
|
2302
2376
|
path: options.config,
|
|
2303
2377
|
envMode: options.envMode
|
|
2304
2378
|
});
|
|
2305
|
-
return rslibConfig;
|
|
2306
2379
|
}
|
|
2307
2380
|
async function inspect(config, options = {}) {
|
|
2308
2381
|
const environments = await composeRsbuildEnvironments(config);
|
|
@@ -2332,7 +2405,8 @@ async function initMFRsbuild(rslibConfig) {
|
|
|
2332
2405
|
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2333
2406
|
rsbuildConfig: mfRsbuildConfig.config
|
|
2334
2407
|
});
|
|
2335
|
-
await rsbuildInstance.startDevServer();
|
|
2408
|
+
const devServer = await rsbuildInstance.startDevServer();
|
|
2409
|
+
onBeforeRestart(devServer.server.close);
|
|
2336
2410
|
return rsbuildInstance;
|
|
2337
2411
|
}
|
|
2338
2412
|
function changeEnvToDev(rsbuildConfig) {
|
|
@@ -2344,7 +2418,8 @@ function changeEnvToDev(rsbuildConfig) {
|
|
|
2344
2418
|
tools: {
|
|
2345
2419
|
rspack: {
|
|
2346
2420
|
optimization: {
|
|
2347
|
-
nodeEnv: 'development'
|
|
2421
|
+
nodeEnv: 'development',
|
|
2422
|
+
moduleIds: 'named'
|
|
2348
2423
|
}
|
|
2349
2424
|
}
|
|
2350
2425
|
}
|
|
@@ -2357,7 +2432,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2357
2432
|
value
|
|
2358
2433
|
]);
|
|
2359
2434
|
function runCli() {
|
|
2360
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.1.
|
|
2435
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.1.2");
|
|
2361
2436
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2362
2437
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2363
2438
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('mf dev');
|
|
@@ -2368,11 +2443,16 @@ function runCli() {
|
|
|
2368
2443
|
].forEach(applyCommonOptions);
|
|
2369
2444
|
buildCommand.option('--lib <id>', 'build the specified library (may be repeated)', repeatableOption).option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the library for production').action(async (options)=>{
|
|
2370
2445
|
try {
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2446
|
+
const cliBuild = async ()=>{
|
|
2447
|
+
const { content: rslibConfig, filePath } = await loadRslibConfig(options);
|
|
2448
|
+
await build(rslibConfig, options);
|
|
2449
|
+
if (options.watch) watchFilesForRestart([
|
|
2450
|
+
filePath
|
|
2451
|
+
], async ()=>{
|
|
2452
|
+
await cliBuild();
|
|
2453
|
+
});
|
|
2454
|
+
};
|
|
2455
|
+
await cliBuild();
|
|
2376
2456
|
} catch (err) {
|
|
2377
2457
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to build.');
|
|
2378
2458
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
@@ -2382,7 +2462,7 @@ function runCli() {
|
|
|
2382
2462
|
inspectCommand.description('inspect the Rsbuild / Rspack configs of Rslib projects').option('--lib <id>', 'inspect the specified library (may be repeated)', repeatableOption).option('--output <output>', 'specify inspect content output path', '.rsbuild').option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
2383
2463
|
try {
|
|
2384
2464
|
// TODO: inspect should output Rslib's config
|
|
2385
|
-
const rslibConfig = await loadRslibConfig(options);
|
|
2465
|
+
const { content: rslibConfig } = await loadRslibConfig(options);
|
|
2386
2466
|
await inspect(rslibConfig, {
|
|
2387
2467
|
lib: options.lib,
|
|
2388
2468
|
mode: options.mode,
|
|
@@ -2397,9 +2477,17 @@ function runCli() {
|
|
|
2397
2477
|
});
|
|
2398
2478
|
mfDevCommand.description('start Rsbuild dev server of Module Federation format').action(async (options)=>{
|
|
2399
2479
|
try {
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
|
|
2480
|
+
const cliMfDev = async ()=>{
|
|
2481
|
+
const { content: rslibConfig, filePath } = await loadRslibConfig(options);
|
|
2482
|
+
// TODO: support lib option in mf dev server
|
|
2483
|
+
await startMFDevServer(rslibConfig);
|
|
2484
|
+
watchFilesForRestart([
|
|
2485
|
+
filePath
|
|
2486
|
+
], async ()=>{
|
|
2487
|
+
await cliMfDev();
|
|
2488
|
+
});
|
|
2489
|
+
};
|
|
2490
|
+
await cliMfDev();
|
|
2403
2491
|
} catch (err) {
|
|
2404
2492
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start mf dev.');
|
|
2405
2493
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
@@ -2408,6 +2496,6 @@ function runCli() {
|
|
|
2408
2496
|
});
|
|
2409
2497
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2410
2498
|
}
|
|
2411
|
-
const
|
|
2499
|
+
const src_rslib_entry_version = "0.1.2";
|
|
2412
2500
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2413
|
-
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig,
|
|
2501
|
+
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -9,7 +9,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
|
9
9
|
function stringifyLocal(value) {
|
|
10
10
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const libCssExtractLoader_rslib_entry_loader = function(content) {
|
|
13
13
|
if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) return content;
|
|
14
14
|
};
|
|
15
15
|
const pitch = function(request, _, _data) {
|
|
@@ -121,5 +121,5 @@ const pitch = function(request, _, _data) {
|
|
|
121
121
|
handleExports(exports);
|
|
122
122
|
});
|
|
123
123
|
};
|
|
124
|
-
/* ESM default export */ const
|
|
125
|
-
export {
|
|
124
|
+
/* ESM default export */ const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
|
|
125
|
+
export { libCssExtractLoader_rslib_entry_ as default, pitch };
|
package/dist-types/cli/init.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { RslibConfig } from '../types';
|
|
2
2
|
import type { CommonOptions } from './commands';
|
|
3
|
-
export declare function loadRslibConfig(options: CommonOptions): Promise<
|
|
3
|
+
export declare function loadRslibConfig(options: CommonOptions): Promise<{
|
|
4
|
+
content: RslibConfig;
|
|
5
|
+
filePath: string;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function watchFilesForRestart(files: string[], restart: () => Promise<void>): Promise<void>;
|
|
2
|
+
type Cleaner = () => Promise<unknown> | unknown;
|
|
3
|
+
/**
|
|
4
|
+
* Add a cleaner to handle side effects
|
|
5
|
+
*/
|
|
6
|
+
export declare const onBeforeRestart: (cleaner: Cleaner) => void;
|
|
7
|
+
export {};
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EnvironmentConfig, type RsbuildConfig } from '@rsbuild/core';
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, LibConfig, PkgJson, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
2
|
+
import type { AutoExternal, BannerAndFooter, LibConfig, PkgJson, 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.
|
|
@@ -12,7 +12,10 @@ export declare function loadConfig({ cwd, path, envMode, }: {
|
|
|
12
12
|
cwd?: string;
|
|
13
13
|
path?: string;
|
|
14
14
|
envMode?: string;
|
|
15
|
-
}): Promise<
|
|
15
|
+
}): Promise<{
|
|
16
|
+
content: RslibConfig;
|
|
17
|
+
filePath: string;
|
|
18
|
+
}>;
|
|
16
19
|
export declare const composeAutoExternalConfig: (options: {
|
|
17
20
|
autoExternal: AutoExternal;
|
|
18
21
|
pkgJson?: PkgJson;
|
|
@@ -23,6 +26,7 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
|
|
|
23
26
|
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<RsbuildConfig['source']>['decorators']>['version']): RsbuildConfig;
|
|
24
27
|
export declare function createConstantRsbuildConfig(): Promise<RsbuildConfig>;
|
|
25
28
|
export declare const composeModuleImportWarn: (request: string) => string;
|
|
29
|
+
export declare const appendEntryQuery: (entry: RsbuildConfigEntry) => RsbuildConfigEntry;
|
|
26
30
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
27
31
|
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<Record<string, EnvironmentConfig>>;
|
|
28
32
|
export declare const pruneEnvironments: (environments: Record<string, EnvironmentConfig>, libs?: string[]) => Record<string, EnvironmentConfig>;
|
|
@@ -9,6 +9,8 @@ export type RsbuildConfigWithLibInfo = {
|
|
|
9
9
|
format: Format;
|
|
10
10
|
config: RsbuildConfig;
|
|
11
11
|
};
|
|
12
|
+
export type RsbuildConfigEntry = NonNullable<NonNullable<RsbuildConfig['source']>['entry']>;
|
|
13
|
+
export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
|
|
12
14
|
export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
|
|
13
15
|
export type Syntax = EcmaScriptVersion | string[];
|
|
14
16
|
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
|
|
@@ -15,4 +15,9 @@ export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U
|
|
|
15
15
|
export declare function omit<T extends object, U extends keyof T>(obj: T, keysObj: Record<U, boolean>): Omit<T, keyof U>;
|
|
16
16
|
export declare function isPluginIncluded(pluginName: string, plugins?: RsbuildPlugins): boolean;
|
|
17
17
|
export declare function checkMFPlugin(config: LibConfig): boolean;
|
|
18
|
+
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Check if running in a TTY context
|
|
21
|
+
*/
|
|
22
|
+
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
18
23
|
export { color };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,18 +32,19 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.1.
|
|
35
|
+
"@rsbuild/core": "~1.1.7",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.1.
|
|
37
|
+
"rsbuild-plugin-dts": "0.1.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
41
|
+
"chokidar": "^4.0.1",
|
|
41
42
|
"commander": "^12.1.0",
|
|
42
43
|
"fs-extra": "^11.2.0",
|
|
43
|
-
"memfs": "^4.14.
|
|
44
|
+
"memfs": "^4.14.1",
|
|
44
45
|
"picocolors": "1.1.1",
|
|
45
46
|
"prebundle": "1.2.5",
|
|
46
|
-
"rslib": "npm:@rslib/core@0.
|
|
47
|
+
"rslib": "npm:@rslib/core@0.1.1",
|
|
47
48
|
"rslog": "^1.2.3",
|
|
48
49
|
"tsconfck": "3.1.4",
|
|
49
50
|
"typescript": "^5.6.3",
|