@rslib/core 0.3.1 → 0.4.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.js +21 -21
- package/compiled/commander/index.d.ts +1 -1
- package/compiled/commander/index.js +65 -46
- package/compiled/commander/package.json +1 -1
- package/compiled/picocolors/index.js +2 -2
- package/dist/entryModuleLoader.js +9 -6
- package/dist/index.js +184 -44
- package/dist/libCssExtractLoader.js +14 -2
- package/dist-types/asset/LibSvgrPatchPlugin.d.ts +6 -0
- package/dist-types/config.d.ts +1 -0
- package/dist-types/constant.d.ts +1 -1
- package/dist-types/css/cssConfig.d.ts +2 -2
- package/dist-types/css/libCssExtractLoader.d.ts +2 -0
- package/dist-types/types/config.d.ts +2 -0
- package/dist-types/utils/syntax.d.ts +1 -1
- package/package.json +11 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
4
|
+
187: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NodeFsHandler =
|
|
7
7
|
exports.EVENTS =
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
exports.STR_END =
|
|
17
17
|
exports.STR_DATA =
|
|
18
18
|
void 0;
|
|
19
|
-
const fs_1 = __nccwpck_require__(
|
|
20
|
-
const promises_1 = __nccwpck_require__(
|
|
21
|
-
const sysPath = __nccwpck_require__(
|
|
22
|
-
const os_1 = __nccwpck_require__(
|
|
19
|
+
const fs_1 = __nccwpck_require__(896);
|
|
20
|
+
const promises_1 = __nccwpck_require__(943);
|
|
21
|
+
const sysPath = __nccwpck_require__(928);
|
|
22
|
+
const os_1 = __nccwpck_require__(857);
|
|
23
23
|
exports.STR_DATA = "data";
|
|
24
24
|
exports.STR_END = "end";
|
|
25
25
|
exports.STR_CLOSE = "close";
|
|
@@ -803,15 +803,15 @@
|
|
|
803
803
|
}
|
|
804
804
|
exports.NodeFsHandler = NodeFsHandler;
|
|
805
805
|
},
|
|
806
|
-
|
|
806
|
+
300: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
807
807
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
808
808
|
exports.readdirpPromise =
|
|
809
809
|
exports.readdirp =
|
|
810
810
|
exports.ReaddirpStream =
|
|
811
811
|
void 0;
|
|
812
|
-
const promises_1 = __nccwpck_require__(
|
|
813
|
-
const stream_1 = __nccwpck_require__(
|
|
814
|
-
const path_1 = __nccwpck_require__(
|
|
812
|
+
const promises_1 = __nccwpck_require__(943);
|
|
813
|
+
const stream_1 = __nccwpck_require__(203);
|
|
814
|
+
const path_1 = __nccwpck_require__(928);
|
|
815
815
|
function defaultOptions() {
|
|
816
816
|
return {
|
|
817
817
|
root: ".",
|
|
@@ -1055,22 +1055,22 @@
|
|
|
1055
1055
|
exports.readdirpPromise = readdirpPromise;
|
|
1056
1056
|
exports["default"] = exports.readdirp;
|
|
1057
1057
|
},
|
|
1058
|
-
|
|
1058
|
+
434: (module) => {
|
|
1059
1059
|
module.exports = require("events");
|
|
1060
1060
|
},
|
|
1061
|
-
|
|
1061
|
+
896: (module) => {
|
|
1062
1062
|
module.exports = require("fs");
|
|
1063
1063
|
},
|
|
1064
|
-
|
|
1064
|
+
943: (module) => {
|
|
1065
1065
|
module.exports = require("fs/promises");
|
|
1066
1066
|
},
|
|
1067
|
-
|
|
1067
|
+
857: (module) => {
|
|
1068
1068
|
module.exports = require("os");
|
|
1069
1069
|
},
|
|
1070
|
-
|
|
1070
|
+
928: (module) => {
|
|
1071
1071
|
module.exports = require("path");
|
|
1072
1072
|
},
|
|
1073
|
-
|
|
1073
|
+
203: (module) => {
|
|
1074
1074
|
module.exports = require("stream");
|
|
1075
1075
|
},
|
|
1076
1076
|
};
|
|
@@ -1103,12 +1103,12 @@
|
|
|
1103
1103
|
exports.FSWatcher = exports.WatchHelper = void 0;
|
|
1104
1104
|
exports.watch = watch;
|
|
1105
1105
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */ const fs_1 =
|
|
1106
|
-
__nccwpck_require__(
|
|
1107
|
-
const promises_1 = __nccwpck_require__(
|
|
1108
|
-
const events_1 = __nccwpck_require__(
|
|
1109
|
-
const sysPath = __nccwpck_require__(
|
|
1110
|
-
const readdirp_1 = __nccwpck_require__(
|
|
1111
|
-
const handler_js_1 = __nccwpck_require__(
|
|
1106
|
+
__nccwpck_require__(896);
|
|
1107
|
+
const promises_1 = __nccwpck_require__(943);
|
|
1108
|
+
const events_1 = __nccwpck_require__(434);
|
|
1109
|
+
const sysPath = __nccwpck_require__(928);
|
|
1110
|
+
const readdirp_1 = __nccwpck_require__(300);
|
|
1111
|
+
const handler_js_1 = __nccwpck_require__(187);
|
|
1112
1112
|
const SLASH = "/";
|
|
1113
1113
|
const SLASH_SLASH = "//";
|
|
1114
1114
|
const ONE_DOT = ".";
|
|
@@ -617,7 +617,7 @@ declare class Command {
|
|
|
617
617
|
* ```js
|
|
618
618
|
* program
|
|
619
619
|
* .option('-p, --pepper', 'add pepper')
|
|
620
|
-
* .option('
|
|
620
|
+
* .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
|
621
621
|
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
|
622
622
|
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
|
623
623
|
* ```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 421:
|
|
5
5
|
/***/ ((module) => {
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
@@ -9,7 +9,7 @@ module.exports = require("node:child_process");
|
|
|
9
9
|
|
|
10
10
|
/***/ }),
|
|
11
11
|
|
|
12
|
-
/***/
|
|
12
|
+
/***/ 474:
|
|
13
13
|
/***/ ((module) => {
|
|
14
14
|
|
|
15
15
|
"use strict";
|
|
@@ -17,7 +17,7 @@ module.exports = require("node:events");
|
|
|
17
17
|
|
|
18
18
|
/***/ }),
|
|
19
19
|
|
|
20
|
-
/***/
|
|
20
|
+
/***/ 24:
|
|
21
21
|
/***/ ((module) => {
|
|
22
22
|
|
|
23
23
|
"use strict";
|
|
@@ -25,7 +25,7 @@ module.exports = require("node:fs");
|
|
|
25
25
|
|
|
26
26
|
/***/ }),
|
|
27
27
|
|
|
28
|
-
/***/
|
|
28
|
+
/***/ 760:
|
|
29
29
|
/***/ ((module) => {
|
|
30
30
|
|
|
31
31
|
"use strict";
|
|
@@ -33,7 +33,7 @@ module.exports = require("node:path");
|
|
|
33
33
|
|
|
34
34
|
/***/ }),
|
|
35
35
|
|
|
36
|
-
/***/
|
|
36
|
+
/***/ 708:
|
|
37
37
|
/***/ ((module) => {
|
|
38
38
|
|
|
39
39
|
"use strict";
|
|
@@ -41,10 +41,10 @@ module.exports = require("node:process");
|
|
|
41
41
|
|
|
42
42
|
/***/ }),
|
|
43
43
|
|
|
44
|
-
/***/
|
|
44
|
+
/***/ 277:
|
|
45
45
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
46
46
|
|
|
47
|
-
const { InvalidArgumentError } = __nccwpck_require__(
|
|
47
|
+
const { InvalidArgumentError } = __nccwpck_require__(910);
|
|
48
48
|
|
|
49
49
|
class Argument {
|
|
50
50
|
/**
|
|
@@ -197,20 +197,20 @@ exports.humanReadableArgName = humanReadableArgName;
|
|
|
197
197
|
|
|
198
198
|
/***/ }),
|
|
199
199
|
|
|
200
|
-
/***/
|
|
200
|
+
/***/ 393:
|
|
201
201
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
202
202
|
|
|
203
|
-
const EventEmitter = (__nccwpck_require__(
|
|
204
|
-
const childProcess = __nccwpck_require__(
|
|
205
|
-
const path = __nccwpck_require__(
|
|
206
|
-
const fs = __nccwpck_require__(
|
|
207
|
-
const process = __nccwpck_require__(
|
|
203
|
+
const EventEmitter = (__nccwpck_require__(474).EventEmitter);
|
|
204
|
+
const childProcess = __nccwpck_require__(421);
|
|
205
|
+
const path = __nccwpck_require__(760);
|
|
206
|
+
const fs = __nccwpck_require__(24);
|
|
207
|
+
const process = __nccwpck_require__(708);
|
|
208
208
|
|
|
209
|
-
const { Argument, humanReadableArgName } = __nccwpck_require__(
|
|
210
|
-
const { CommanderError } = __nccwpck_require__(
|
|
211
|
-
const { Help, stripColor } = __nccwpck_require__(
|
|
212
|
-
const { Option, DualOptions } = __nccwpck_require__(
|
|
213
|
-
const { suggestSimilar } = __nccwpck_require__(
|
|
209
|
+
const { Argument, humanReadableArgName } = __nccwpck_require__(277);
|
|
210
|
+
const { CommanderError } = __nccwpck_require__(910);
|
|
211
|
+
const { Help, stripColor } = __nccwpck_require__(945);
|
|
212
|
+
const { Option, DualOptions } = __nccwpck_require__(823);
|
|
213
|
+
const { suggestSimilar } = __nccwpck_require__(461);
|
|
214
214
|
|
|
215
215
|
class Command extends EventEmitter {
|
|
216
216
|
/**
|
|
@@ -958,7 +958,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
958
958
|
* @example
|
|
959
959
|
* program
|
|
960
960
|
* .option('-p, --pepper', 'add pepper')
|
|
961
|
-
* .option('
|
|
961
|
+
* .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
|
962
962
|
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
|
963
963
|
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
|
964
964
|
*
|
|
@@ -2866,7 +2866,7 @@ exports.useColor = useColor; // exporting for tests
|
|
|
2866
2866
|
|
|
2867
2867
|
/***/ }),
|
|
2868
2868
|
|
|
2869
|
-
/***/
|
|
2869
|
+
/***/ 910:
|
|
2870
2870
|
/***/ ((__unused_webpack_module, exports) => {
|
|
2871
2871
|
|
|
2872
2872
|
/**
|
|
@@ -2912,10 +2912,10 @@ exports.InvalidArgumentError = InvalidArgumentError;
|
|
|
2912
2912
|
|
|
2913
2913
|
/***/ }),
|
|
2914
2914
|
|
|
2915
|
-
/***/
|
|
2915
|
+
/***/ 945:
|
|
2916
2916
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2917
2917
|
|
|
2918
|
-
const { humanReadableArgName } = __nccwpck_require__(
|
|
2918
|
+
const { humanReadableArgName } = __nccwpck_require__(277);
|
|
2919
2919
|
|
|
2920
2920
|
/**
|
|
2921
2921
|
* TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`
|
|
@@ -3628,10 +3628,10 @@ exports.stripColor = stripColor;
|
|
|
3628
3628
|
|
|
3629
3629
|
/***/ }),
|
|
3630
3630
|
|
|
3631
|
-
/***/
|
|
3631
|
+
/***/ 823:
|
|
3632
3632
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
3633
3633
|
|
|
3634
|
-
const { InvalidArgumentError } = __nccwpck_require__(
|
|
3634
|
+
const { InvalidArgumentError } = __nccwpck_require__(910);
|
|
3635
3635
|
|
|
3636
3636
|
class Option {
|
|
3637
3637
|
/**
|
|
@@ -3651,7 +3651,7 @@ class Option {
|
|
|
3651
3651
|
this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values.
|
|
3652
3652
|
this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
|
|
3653
3653
|
const optionFlags = splitOptionFlags(flags);
|
|
3654
|
-
this.short = optionFlags.shortFlag;
|
|
3654
|
+
this.short = optionFlags.shortFlag; // May be a short flag, undefined, or even a long flag (if option has two long flags).
|
|
3655
3655
|
this.long = optionFlags.longFlag;
|
|
3656
3656
|
this.negate = false;
|
|
3657
3657
|
if (this.long) {
|
|
@@ -3954,25 +3954,44 @@ function splitOptionFlags(flags) {
|
|
|
3954
3954
|
const longFlagExp = /^--[^-]/;
|
|
3955
3955
|
|
|
3956
3956
|
const flagParts = flags.split(/[ |,]+/).concat('guard');
|
|
3957
|
+
// Normal is short and/or long.
|
|
3957
3958
|
if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
|
|
3958
3959
|
if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
|
|
3960
|
+
// Long then short. Rarely used but fine.
|
|
3961
|
+
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
3962
|
+
shortFlag = flagParts.shift();
|
|
3963
|
+
// Allow two long flags, like '--ws, --workspace'
|
|
3964
|
+
// This is the supported way to have a shortish option flag.
|
|
3965
|
+
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
3966
|
+
shortFlag = longFlag;
|
|
3967
|
+
longFlag = flagParts.shift();
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
// Check for unprocessed flag. Fail noisily rather than silently ignore.
|
|
3971
|
+
if (flagParts[0].startsWith('-')) {
|
|
3972
|
+
const unsupportedFlag = flagParts[0];
|
|
3973
|
+
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
3974
|
+
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
3975
|
+
throw new Error(
|
|
3976
|
+
`${baseError}
|
|
3977
|
+
- a short flag is a single dash and a single character
|
|
3978
|
+
- either use a single dash and a single character (for a short flag)
|
|
3979
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`,
|
|
3980
|
+
);
|
|
3981
|
+
if (shortFlagExp.test(unsupportedFlag))
|
|
3982
|
+
throw new Error(`${baseError}
|
|
3983
|
+
- too many short flags`);
|
|
3984
|
+
if (longFlagExp.test(unsupportedFlag))
|
|
3985
|
+
throw new Error(`${baseError}
|
|
3986
|
+
- too many long flags`);
|
|
3959
3987
|
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
);
|
|
3965
|
-
if (shortFlag && shortFlagExp.test(flagParts[0]))
|
|
3966
|
-
throw new Error(
|
|
3967
|
-
`invalid Option flags, more than one short flag: '${flags}'`,
|
|
3968
|
-
);
|
|
3969
|
-
if (longFlag && longFlagExp.test(flagParts[0]))
|
|
3988
|
+
throw new Error(`${baseError}
|
|
3989
|
+
- unrecognised flag format`);
|
|
3990
|
+
}
|
|
3991
|
+
if (shortFlag === undefined && longFlag === undefined)
|
|
3970
3992
|
throw new Error(
|
|
3971
|
-
`
|
|
3993
|
+
`option creation failed due to no flags found in '${flags}'.`,
|
|
3972
3994
|
);
|
|
3973
|
-
// Generic error if failed to find a flag or an unexpected flag left over.
|
|
3974
|
-
if (!(shortFlag || longFlag) || flagParts[0].startsWith('-'))
|
|
3975
|
-
throw new Error(`invalid Option flags: '${flags}'`);
|
|
3976
3995
|
|
|
3977
3996
|
return { shortFlag, longFlag };
|
|
3978
3997
|
}
|
|
@@ -3983,7 +4002,7 @@ exports.DualOptions = DualOptions;
|
|
|
3983
4002
|
|
|
3984
4003
|
/***/ }),
|
|
3985
4004
|
|
|
3986
|
-
/***/
|
|
4005
|
+
/***/ 461:
|
|
3987
4006
|
/***/ ((__unused_webpack_module, exports) => {
|
|
3988
4007
|
|
|
3989
4008
|
const maxDistance = 3;
|
|
@@ -4130,14 +4149,14 @@ exports.suggestSimilar = suggestSimilar;
|
|
|
4130
4149
|
/******/
|
|
4131
4150
|
/************************************************************************/
|
|
4132
4151
|
var __webpack_exports__ = {};
|
|
4133
|
-
// This entry need to be wrapped in an IIFE because it
|
|
4152
|
+
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
4134
4153
|
(() => {
|
|
4135
4154
|
var exports = __webpack_exports__;
|
|
4136
|
-
const { Argument } = __nccwpck_require__(
|
|
4137
|
-
const { Command } = __nccwpck_require__(
|
|
4138
|
-
const { CommanderError, InvalidArgumentError } = __nccwpck_require__(
|
|
4139
|
-
const { Help } = __nccwpck_require__(
|
|
4140
|
-
const { Option } = __nccwpck_require__(
|
|
4155
|
+
const { Argument } = __nccwpck_require__(277);
|
|
4156
|
+
const { Command } = __nccwpck_require__(393);
|
|
4157
|
+
const { CommanderError, InvalidArgumentError } = __nccwpck_require__(910);
|
|
4158
|
+
const { Help } = __nccwpck_require__(945);
|
|
4159
|
+
const { Option } = __nccwpck_require__(823);
|
|
4141
4160
|
|
|
4142
4161
|
exports.program = new Command();
|
|
4143
4162
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"13.
|
|
1
|
+
{"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"13.1.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 456:
|
|
5
5
|
/***/ ((module) => {
|
|
6
6
|
|
|
7
7
|
let p = process || {}, argv = p.argv || [], env = p.env || {}
|
|
@@ -125,7 +125,7 @@ module.exports.createColors = createColors
|
|
|
125
125
|
/******/ // startup
|
|
126
126
|
/******/ // Load entry module and return exports
|
|
127
127
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
128
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
128
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(456);
|
|
129
129
|
/******/ module.exports = __webpack_exports__;
|
|
130
130
|
/******/
|
|
131
131
|
/******/ })()
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const RSLIB_ENTRY_QUERY = '__rslib_entry__';
|
|
2
2
|
const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
|
|
3
3
|
const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
|
|
4
|
+
const DTS_EXTENSIONS = [
|
|
5
|
+
'd.ts',
|
|
6
|
+
'd.mts',
|
|
7
|
+
'd.cts'
|
|
8
|
+
];
|
|
4
9
|
const JS_EXTENSIONS = [
|
|
5
10
|
'js',
|
|
6
11
|
'mjs',
|
|
@@ -19,15 +24,13 @@ const CSS_EXTENSIONS = [
|
|
|
19
24
|
'css',
|
|
20
25
|
'sass',
|
|
21
26
|
'scss',
|
|
22
|
-
'less'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...JS_EXTENSIONS,
|
|
26
|
-
...CSS_EXTENSIONS
|
|
27
|
+
'less',
|
|
28
|
+
'styl',
|
|
29
|
+
'stylus'
|
|
27
30
|
];
|
|
28
31
|
new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
29
32
|
new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
30
|
-
new RegExp(`\\.(${
|
|
33
|
+
new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
|
|
31
34
|
function splitFromFirstLine(text) {
|
|
32
35
|
const match = text.match(/(\r\n|\n)/);
|
|
33
36
|
if (!match) return [
|
package/dist/index.js
CHANGED
|
@@ -160,16 +160,8 @@ 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_c302f6e3__.logger.greet(` Rslib v0.
|
|
163
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.4.0\n`);
|
|
164
164
|
}
|
|
165
|
-
const composeAssetConfig = (bundle, format)=>{
|
|
166
|
-
if ('esm' === format || 'cjs' === format) return {
|
|
167
|
-
output: {
|
|
168
|
-
dataUriLimit: 0
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
return {};
|
|
172
|
-
};
|
|
173
165
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
174
166
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
175
167
|
'.js',
|
|
@@ -184,6 +176,11 @@ const RSLIB_ENTRY_QUERY = '__rslib_entry__';
|
|
|
184
176
|
const SHEBANG_PREFIX = '#!';
|
|
185
177
|
const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
|
|
186
178
|
const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
|
|
179
|
+
const DTS_EXTENSIONS = [
|
|
180
|
+
'd.ts',
|
|
181
|
+
'd.mts',
|
|
182
|
+
'd.cts'
|
|
183
|
+
];
|
|
187
184
|
const JS_EXTENSIONS = [
|
|
188
185
|
'js',
|
|
189
186
|
'mjs',
|
|
@@ -202,19 +199,13 @@ const CSS_EXTENSIONS = [
|
|
|
202
199
|
'css',
|
|
203
200
|
'sass',
|
|
204
201
|
'scss',
|
|
205
|
-
'less'
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
...JS_EXTENSIONS,
|
|
209
|
-
...CSS_EXTENSIONS
|
|
202
|
+
'less',
|
|
203
|
+
'styl',
|
|
204
|
+
'stylus'
|
|
210
205
|
];
|
|
211
206
|
const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
212
207
|
const CSS_EXTENSIONS_PATTERN = new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
213
|
-
const
|
|
214
|
-
const BASE_URI = 'webpack://';
|
|
215
|
-
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
216
|
-
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
217
|
-
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
208
|
+
const DTS_EXTENSIONS_PATTERN = new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
|
|
218
209
|
function getUndoPath(filename, outputPathArg, enforceRelative) {
|
|
219
210
|
let depth = -1;
|
|
220
211
|
let append = '';
|
|
@@ -232,6 +223,144 @@ function getUndoPath(filename, outputPathArg, enforceRelative) {
|
|
|
232
223
|
} else if ('.' !== part) depth++;
|
|
233
224
|
return depth > 0 ? `${'../'.repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
234
225
|
}
|
|
226
|
+
const LibSvgrPatchPlugin_pluginName = 'LIB_SVGR_PATCH_PLUGIN';
|
|
227
|
+
const PUBLIC_PATH_PLACEHOLDER = '__RSLIB_SVGR_AUTO_PUBLIC_PATH__';
|
|
228
|
+
class LibSvgrPatchPlugin {
|
|
229
|
+
name = LibSvgrPatchPlugin_pluginName;
|
|
230
|
+
apply(compiler) {
|
|
231
|
+
compiler.hooks.make.tap(this.name, (compilation)=>{
|
|
232
|
+
compilation.hooks.processAssets.tap(this.name, (assets)=>{
|
|
233
|
+
const isEsm = Boolean(compilation.options.output.module);
|
|
234
|
+
const chunkAsset = Object.keys(assets).filter((name)=>/js$/.test(name));
|
|
235
|
+
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
236
|
+
const oldSource = old.source().toString();
|
|
237
|
+
const newSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
238
|
+
const pattern = new RegExp(`\\(?['"]${PUBLIC_PATH_PLACEHOLDER}(.*)['"]\\)?`, 'g');
|
|
239
|
+
const matches = [
|
|
240
|
+
...oldSource.matchAll(pattern)
|
|
241
|
+
];
|
|
242
|
+
const len = matches.length;
|
|
243
|
+
if (0 === len) return old;
|
|
244
|
+
const undoPath = getUndoPath(name, compilation.outputOptions.path, true);
|
|
245
|
+
for(let i = 0; i < len; i++){
|
|
246
|
+
const match = matches[i];
|
|
247
|
+
const filename = match[1];
|
|
248
|
+
const requirePath = `${undoPath}${filename}`;
|
|
249
|
+
let replaced = '';
|
|
250
|
+
replaced = isEsm ? `__rslib_svgr_url__${i}__` : `require("${requirePath}")`;
|
|
251
|
+
newSource.replace(match.index, match.index + match[0].length - 1, replaced);
|
|
252
|
+
if (isEsm) newSource.insert(0, `import __rslib_svgr_url__${i}__ from "${requirePath}";\n`);
|
|
253
|
+
}
|
|
254
|
+
return newSource;
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const PLUGIN_NAME = 'rsbuild:lib-asset';
|
|
261
|
+
const RSBUILD_SVGR_PLUGIN_NAME = 'rsbuild:svgr';
|
|
262
|
+
const pluginLibAsset = ({ bundle })=>({
|
|
263
|
+
name: PLUGIN_NAME,
|
|
264
|
+
pre: [
|
|
265
|
+
RSBUILD_SVGR_PLUGIN_NAME
|
|
266
|
+
],
|
|
267
|
+
setup (api) {
|
|
268
|
+
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
269
|
+
const svgAssetRule = config.module.rules.get(CHAIN_ID.RULE.SVG).oneOfs.get(CHAIN_ID.ONE_OF.SVG_ASSET);
|
|
270
|
+
const originalTypeOptions = svgAssetRule.get('type');
|
|
271
|
+
const originalParserOptions = svgAssetRule.get('parser');
|
|
272
|
+
const originalGeneratorOptions = svgAssetRule.get('generator');
|
|
273
|
+
const isUserSetPublicPath = 'auto' !== config.output.get('publicPath');
|
|
274
|
+
const generatorOptions = isUserSetPublicPath ? originalGeneratorOptions : {
|
|
275
|
+
...originalGeneratorOptions,
|
|
276
|
+
importMode: 'preserve'
|
|
277
|
+
};
|
|
278
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG);
|
|
279
|
+
rule.oneOf(CHAIN_ID.ONE_OF.SVG_ASSET).generator(generatorOptions).issuer({
|
|
280
|
+
not: CSS_EXTENSIONS_PATTERN
|
|
281
|
+
});
|
|
282
|
+
rule.oneOf(`${CHAIN_ID.ONE_OF.SVG_ASSET}-for-css`).type(originalTypeOptions).parser(originalParserOptions).generator(originalGeneratorOptions).issuer(CSS_EXTENSIONS_PATTERN);
|
|
283
|
+
const ruleIds = [
|
|
284
|
+
CHAIN_ID.RULE.FONT,
|
|
285
|
+
CHAIN_ID.RULE.MEDIA,
|
|
286
|
+
CHAIN_ID.RULE.IMAGE,
|
|
287
|
+
CHAIN_ID.RULE.ADDITIONAL_ASSETS
|
|
288
|
+
];
|
|
289
|
+
for (const ruleId of ruleIds){
|
|
290
|
+
const oneOfId = `${ruleId}-asset`;
|
|
291
|
+
const assetRule = config.module.rules.get(ruleId);
|
|
292
|
+
if (!assetRule) continue;
|
|
293
|
+
const assetRuleOneOf = assetRule.oneOfs.get(oneOfId);
|
|
294
|
+
const originalTypeOptions = assetRuleOneOf.get('type');
|
|
295
|
+
const originalParserOptions = assetRuleOneOf.get('parser');
|
|
296
|
+
const originalGeneratorOptions = assetRuleOneOf.get('generator');
|
|
297
|
+
const generatorOptions = isUserSetPublicPath ? originalGeneratorOptions : {
|
|
298
|
+
...originalGeneratorOptions,
|
|
299
|
+
importMode: 'preserve'
|
|
300
|
+
};
|
|
301
|
+
const rule = config.module.rule(ruleId);
|
|
302
|
+
rule.oneOf(oneOfId).generator(generatorOptions).issuer({
|
|
303
|
+
not: CSS_EXTENSIONS_PATTERN
|
|
304
|
+
});
|
|
305
|
+
rule.oneOf(`${oneOfId}-for-css`).type(originalTypeOptions).parser(originalParserOptions).generator(originalGeneratorOptions).issuer(CSS_EXTENSIONS_PATTERN);
|
|
306
|
+
}
|
|
307
|
+
const isUsingSvgr = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.RULE.SVG).uses.has(CHAIN_ID.USE.SVGR);
|
|
308
|
+
const isUsingSvgrUrlLoader = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG).uses.has(CHAIN_ID.USE.URL);
|
|
309
|
+
if (isUsingSvgr && isUsingSvgrUrlLoader) {
|
|
310
|
+
const urlLoaderRule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG).use(CHAIN_ID.USE.URL);
|
|
311
|
+
const originalOptions = urlLoaderRule.get('options');
|
|
312
|
+
urlLoaderRule.options({
|
|
313
|
+
...originalOptions,
|
|
314
|
+
publicPath: (url)=>`${PUBLIC_PATH_PLACEHOLDER}${url}`
|
|
315
|
+
});
|
|
316
|
+
config.plugin(LibSvgrPatchPlugin.name).use(LibSvgrPatchPlugin, []);
|
|
317
|
+
}
|
|
318
|
+
if (!bundle) {
|
|
319
|
+
if (isUsingSvgr) {
|
|
320
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG);
|
|
321
|
+
rule.issuer([]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (bundle) config.plugins.get(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)?.tap((options)=>[
|
|
325
|
+
{
|
|
326
|
+
...options[0],
|
|
327
|
+
enforceRelative: true
|
|
328
|
+
}
|
|
329
|
+
]);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
const composeAssetConfig = (bundle, format)=>{
|
|
334
|
+
if ('esm' === format || 'cjs' === format) {
|
|
335
|
+
if (bundle) return {
|
|
336
|
+
output: {
|
|
337
|
+
dataUriLimit: 0,
|
|
338
|
+
assetPrefix: 'auto'
|
|
339
|
+
},
|
|
340
|
+
plugins: [
|
|
341
|
+
pluginLibAsset({
|
|
342
|
+
bundle: true
|
|
343
|
+
})
|
|
344
|
+
]
|
|
345
|
+
};
|
|
346
|
+
return {
|
|
347
|
+
output: {
|
|
348
|
+
dataUriLimit: 0,
|
|
349
|
+
assetPrefix: 'auto'
|
|
350
|
+
},
|
|
351
|
+
plugins: [
|
|
352
|
+
pluginLibAsset({
|
|
353
|
+
bundle: false
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return {};
|
|
359
|
+
};
|
|
360
|
+
const BASE_URI = 'webpack://';
|
|
361
|
+
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
362
|
+
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
363
|
+
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
235
364
|
const LibCssExtractPlugin_pluginName = 'LIB_CSS_EXTRACT_PLUGIN';
|
|
236
365
|
class LibCssExtractPlugin {
|
|
237
366
|
name = LibCssExtractPlugin_pluginName;
|
|
@@ -261,10 +390,11 @@ class LibCssExtractPlugin {
|
|
|
261
390
|
start = oldSource.indexOf(searchValue, start + 1);
|
|
262
391
|
}
|
|
263
392
|
}
|
|
264
|
-
replace(ABSOLUTE_PUBLIC_PATH, '');
|
|
265
393
|
replace(SINGLE_DOT_PATH_SEGMENT, '.');
|
|
266
|
-
const undoPath = getUndoPath(name, compilation.outputOptions.path,
|
|
267
|
-
replace(AUTO_PUBLIC_PATH
|
|
394
|
+
const undoPath = getUndoPath(name, compilation.outputOptions.path, true);
|
|
395
|
+
replace(`${ABSOLUTE_PUBLIC_PATH}${AUTO_PUBLIC_PATH}`, undoPath);
|
|
396
|
+
replace(ABSOLUTE_PUBLIC_PATH, '');
|
|
397
|
+
replace(`${BASE_URI}/`, '');
|
|
268
398
|
return replaceSource;
|
|
269
399
|
});
|
|
270
400
|
});
|
|
@@ -302,14 +432,17 @@ function isCssGlobalFile(filepath, auto) {
|
|
|
302
432
|
const isCssModules = isCssModulesFile(filepath, auto);
|
|
303
433
|
return !isCssModules;
|
|
304
434
|
}
|
|
305
|
-
async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath) {
|
|
435
|
+
async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer) {
|
|
306
436
|
if (/compiled\/css-loader\//.test(request)) return callback();
|
|
307
437
|
let resolvedRequest = request;
|
|
308
438
|
if (styleRedirectPath) {
|
|
309
439
|
const resolved = await redirectPath(resolvedRequest);
|
|
310
440
|
if (resolved) resolvedRequest = resolved;
|
|
311
441
|
}
|
|
312
|
-
if (!isCssFile(resolvedRequest))
|
|
442
|
+
if (!isCssFile(resolvedRequest)) {
|
|
443
|
+
if (isCssFile(issuer)) return callback();
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
313
446
|
if (styleRedirectExtension) {
|
|
314
447
|
const isCssModulesRequest = isCssModulesFile(resolvedRequest, auto);
|
|
315
448
|
if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
|
|
@@ -317,9 +450,9 @@ async function cssExternalHandler(request, callback, jsExtension, auto, styleRed
|
|
|
317
450
|
}
|
|
318
451
|
return callback(void 0, resolvedRequest);
|
|
319
452
|
}
|
|
320
|
-
const
|
|
321
|
-
const pluginLibCss = (rootDir)=>({
|
|
322
|
-
name:
|
|
453
|
+
const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
|
|
454
|
+
const pluginLibCss = (rootDir, banner, footer)=>({
|
|
455
|
+
name: cssConfig_PLUGIN_NAME,
|
|
323
456
|
setup (api) {
|
|
324
457
|
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
325
458
|
let isUsingCssExtract = false;
|
|
@@ -333,7 +466,9 @@ const pluginLibCss = (rootDir)=>({
|
|
|
333
466
|
if (rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
|
|
334
467
|
isUsingCssExtract = true;
|
|
335
468
|
rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
|
|
336
|
-
rootDir
|
|
469
|
+
rootDir,
|
|
470
|
+
banner,
|
|
471
|
+
footer
|
|
337
472
|
});
|
|
338
473
|
}
|
|
339
474
|
}
|
|
@@ -345,11 +480,11 @@ const pluginLibCss = (rootDir)=>({
|
|
|
345
480
|
});
|
|
346
481
|
}
|
|
347
482
|
});
|
|
348
|
-
const composeCssConfig = (rootDir, bundle = true)=>{
|
|
483
|
+
const composeCssConfig = (rootDir, bundle = true, banner, footer)=>{
|
|
349
484
|
if (bundle || null === rootDir) return {};
|
|
350
485
|
return {
|
|
351
486
|
plugins: [
|
|
352
|
-
pluginLibCss(rootDir)
|
|
487
|
+
pluginLibCss(rootDir, banner, footer)
|
|
353
488
|
],
|
|
354
489
|
tools: {
|
|
355
490
|
cssLoader: {
|
|
@@ -1781,6 +1916,7 @@ const traverseEntryQuery = (entry, callback)=>{
|
|
|
1781
1916
|
return newEntry;
|
|
1782
1917
|
};
|
|
1783
1918
|
const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
|
|
1919
|
+
const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, item));
|
|
1784
1920
|
const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
1785
1921
|
let entries = rawEntry;
|
|
1786
1922
|
if (!entries) {
|
|
@@ -1792,6 +1928,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1792
1928
|
index: 'src/**'
|
|
1793
1929
|
};
|
|
1794
1930
|
}
|
|
1931
|
+
if ('object' != typeof entries) throw new Error(`The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan('source.entry')} configuration should be an object, but received ${typeof entries}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(entries)}. Checkout ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('https://lib.rsbuild.dev/config/rsbuild/source#sourceentry')} for more details.`);
|
|
1795
1932
|
if (false !== bundle) {
|
|
1796
1933
|
const entryErrorReasons = [];
|
|
1797
1934
|
traverseEntryQuery(entries, (entry)=>{
|
|
@@ -1809,7 +1946,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1809
1946
|
return {
|
|
1810
1947
|
entryConfig: {
|
|
1811
1948
|
source: {
|
|
1812
|
-
entry: appendEntryQuery(entries)
|
|
1949
|
+
entry: appendEntryQuery(resolveEntryPath(entries, root))
|
|
1813
1950
|
}
|
|
1814
1951
|
},
|
|
1815
1952
|
lcp: null
|
|
@@ -1827,7 +1964,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1827
1964
|
cwd: root,
|
|
1828
1965
|
absolute: true
|
|
1829
1966
|
});
|
|
1830
|
-
const resolvedEntryFiles = globEntryFiles.filter((
|
|
1967
|
+
const resolvedEntryFiles = globEntryFiles.filter((i)=>!DTS_EXTENSIONS_PATTERN.test(i));
|
|
1831
1968
|
if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
|
|
1832
1969
|
const lcp = await calcLongestCommonPath(resolvedEntryFiles);
|
|
1833
1970
|
const outBase = null === lcp ? root : lcp;
|
|
@@ -1839,7 +1976,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1839
1976
|
}
|
|
1840
1977
|
for (const file of resolvedEntryFiles){
|
|
1841
1978
|
const entryName = getEntryName(file);
|
|
1842
|
-
if (resolvedEntries[entryName]) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`
|
|
1979
|
+
if (resolvedEntries[entryName]) calcLcp && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Duplicate entry ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(entryName)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file))} and ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, resolvedEntries[entryName]))}, which may lead to the incorrect output, please rename the file.`);
|
|
1843
1980
|
resolvedEntries[entryName] = file;
|
|
1844
1981
|
}
|
|
1845
1982
|
}
|
|
@@ -1871,7 +2008,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1871
2008
|
lcp
|
|
1872
2009
|
};
|
|
1873
2010
|
};
|
|
1874
|
-
const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto, bundle)=>{
|
|
2011
|
+
const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto, bundle, rootPath)=>{
|
|
1875
2012
|
if (bundle) return {
|
|
1876
2013
|
config: {}
|
|
1877
2014
|
};
|
|
@@ -1879,6 +2016,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1879
2016
|
const styleRedirectExtension = redirect.style?.extension ?? true;
|
|
1880
2017
|
const jsRedirectPath = redirect.js?.path ?? true;
|
|
1881
2018
|
const jsRedirectExtension = redirect.js?.extension ?? true;
|
|
2019
|
+
const assetRedirect = redirect.asset ?? true;
|
|
1882
2020
|
let resolver;
|
|
1883
2021
|
return {
|
|
1884
2022
|
resolvedJsRedirect: {
|
|
@@ -1897,7 +2035,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1897
2035
|
try {
|
|
1898
2036
|
let resolvedRequest = request;
|
|
1899
2037
|
resolvedRequest = await resolver(context, resolvedRequest);
|
|
1900
|
-
|
|
2038
|
+
const isSubpath = resolvedRequest.startsWith(rootPath + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep);
|
|
2039
|
+
if (isSubpath) {
|
|
1901
2040
|
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(issuer), resolvedRequest));
|
|
1902
2041
|
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
1903
2042
|
return resolvedRequest;
|
|
@@ -1910,19 +2049,20 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1910
2049
|
}
|
|
1911
2050
|
if (issuer) {
|
|
1912
2051
|
let resolvedRequest = request;
|
|
1913
|
-
const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath);
|
|
2052
|
+
const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer);
|
|
1914
2053
|
if (false !== cssExternal) return cssExternal;
|
|
1915
2054
|
if (jsRedirectPath) {
|
|
1916
2055
|
const redirectedPath = await redirectPath(resolvedRequest);
|
|
1917
2056
|
if (void 0 === redirectedPath) return callback(void 0, request);
|
|
1918
2057
|
resolvedRequest = redirectedPath;
|
|
1919
2058
|
}
|
|
1920
|
-
if (
|
|
2059
|
+
if (resolvedRequest.startsWith('.')) {
|
|
1921
2060
|
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(resolvedRequest);
|
|
1922
2061
|
if (ext) {
|
|
1923
|
-
if (
|
|
1924
|
-
|
|
1925
|
-
|
|
2062
|
+
if (JS_EXTENSIONS_PATTERN.test(resolvedRequest)) {
|
|
2063
|
+
if (jsRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
2064
|
+
} else if (assetRedirect) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
2065
|
+
} else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
|
|
1926
2066
|
}
|
|
1927
2067
|
return callback(void 0, resolvedRequest);
|
|
1928
2068
|
}
|
|
@@ -2043,7 +2183,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2043
2183
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
2044
2184
|
const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
2045
2185
|
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
2046
|
-
const { config: bundlelessExternalConfig } = composeBundlelessExternalConfig(jsExtension, redirect, cssModulesAuto, bundle);
|
|
2186
|
+
const { config: bundlelessExternalConfig } = composeBundlelessExternalConfig(jsExtension, redirect, cssModulesAuto, bundle, rootPath);
|
|
2047
2187
|
const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
|
|
2048
2188
|
const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
|
|
2049
2189
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
@@ -2054,7 +2194,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2054
2194
|
userExternals: config.output?.externals
|
|
2055
2195
|
});
|
|
2056
2196
|
const { entryConfig, lcp } = await composeEntryConfig(config.source?.entry, config.bundle, rootPath, cssModulesAuto);
|
|
2057
|
-
const cssConfig = composeCssConfig(lcp, config.bundle);
|
|
2197
|
+
const cssConfig = composeCssConfig(lcp, config.bundle, banner?.css, footer?.css);
|
|
2058
2198
|
const assetConfig = composeAssetConfig(bundle, format);
|
|
2059
2199
|
const entryChunkConfig = composeEntryChunkConfig({
|
|
2060
2200
|
enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
|
|
@@ -2280,7 +2420,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2280
2420
|
value
|
|
2281
2421
|
]);
|
|
2282
2422
|
function runCli() {
|
|
2283
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.
|
|
2423
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.4.0");
|
|
2284
2424
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2285
2425
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2286
2426
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2341,6 +2481,6 @@ function runCli() {
|
|
|
2341
2481
|
});
|
|
2342
2482
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2343
2483
|
}
|
|
2344
|
-
const src_rslib_entry_version = "0.
|
|
2484
|
+
const src_rslib_entry_version = "0.4.0";
|
|
2345
2485
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2346
2486
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -23,6 +23,8 @@ const pitch = function(request, _, _data) {
|
|
|
23
23
|
const callback = this.async();
|
|
24
24
|
const filepath = this.resourcePath;
|
|
25
25
|
const rootDir = options.rootDir ?? this.rootContext;
|
|
26
|
+
const banner = options.banner;
|
|
27
|
+
const footer = options.footer;
|
|
26
28
|
let { publicPath } = this._compilation.outputOptions;
|
|
27
29
|
if ('string' == typeof options.publicPath) publicPath = options.publicPath;
|
|
28
30
|
else if ('function' == typeof options.publicPath) publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
@@ -101,7 +103,7 @@ const pitch = function(request, _, _data) {
|
|
|
101
103
|
return relativePath;
|
|
102
104
|
}
|
|
103
105
|
const m = new Map();
|
|
104
|
-
for (const { content, filepath } of dependencies){
|
|
106
|
+
for (const { content, filepath, sourceMap } of dependencies){
|
|
105
107
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
106
108
|
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
107
109
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
@@ -112,8 +114,18 @@ const pitch = function(request, _, _data) {
|
|
|
112
114
|
importCssFiles += '\n';
|
|
113
115
|
importCssFiles += `import "./${cssFilename}"`;
|
|
114
116
|
}
|
|
117
|
+
if (sourceMap) {
|
|
118
|
+
const sourceMapPath = `${distFilepath}.map`;
|
|
119
|
+
m.set(sourceMapPath, `${sourceMap}`);
|
|
120
|
+
const sourceMappingURL = `/*# sourceMappingURL=${cssFilename}.map */`;
|
|
121
|
+
m.set(distFilepath, `${m.get(distFilepath)}\n${sourceMappingURL}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (let [distFilepath, content] of m.entries()){
|
|
125
|
+
if (banner) content = `${banner}\n${content}`;
|
|
126
|
+
if (footer) content = `${content}\n${footer}\n`;
|
|
127
|
+
this.emitFile(distFilepath, content);
|
|
115
128
|
}
|
|
116
|
-
for (const [distFilepath, content] of m.entries())this.emitFile(distFilepath, content);
|
|
117
129
|
resultSource += importCssFiles;
|
|
118
130
|
resultSource += result;
|
|
119
131
|
callback(null, resultSource, void 0);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Rspack } from '@rsbuild/core';
|
|
2
|
+
export declare const PUBLIC_PATH_PLACEHOLDER = "__RSLIB_SVGR_AUTO_PUBLIC_PATH__";
|
|
3
|
+
export declare class LibSvgrPatchPlugin implements Rspack.RspackPluginInstance {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
apply(compiler: Rspack.Compiler): void;
|
|
6
|
+
}
|
package/dist-types/config.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare function composeDecoratorsConfig(compilerOptions?: Record<string,
|
|
|
29
29
|
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
30
30
|
export declare const composeModuleImportWarn: (request: string) => string;
|
|
31
31
|
export declare const appendEntryQuery: (entries: RsbuildConfigEntry) => RsbuildEntry;
|
|
32
|
+
export declare const resolveEntryPath: (entries: RsbuildConfigEntry, root: string) => RsbuildEntry;
|
|
32
33
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
33
34
|
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
|
|
34
35
|
environments: Record<string, EnvironmentConfig>;
|
package/dist-types/constant.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare const SHEBANG_REGEX: RegExp;
|
|
|
7
7
|
export declare const REACT_DIRECTIVE_REGEX: RegExp;
|
|
8
8
|
export declare const JS_EXTENSIONS_PATTERN: RegExp;
|
|
9
9
|
export declare const CSS_EXTENSIONS_PATTERN: RegExp;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const DTS_EXTENSIONS_PATTERN: RegExp;
|
|
@@ -12,6 +12,6 @@ export declare function parsePathQueryFragment(str: string): {
|
|
|
12
12
|
export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
14
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
|
-
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined
|
|
16
|
-
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => EnvironmentConfig;
|
|
15
|
+
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined>, issuer: string): Promise<false | void>;
|
|
16
|
+
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
|
|
17
17
|
export {};
|
|
@@ -11,6 +11,8 @@ export interface CssExtractRspackLoaderOptions {
|
|
|
11
11
|
layer?: string;
|
|
12
12
|
defaultExport?: boolean;
|
|
13
13
|
rootDir?: string;
|
|
14
|
+
banner?: string;
|
|
15
|
+
footer?: string;
|
|
14
16
|
}
|
|
15
17
|
declare const loader: Rspack.LoaderDefinition;
|
|
16
18
|
export declare const pitch: Rspack.LoaderDefinition['pitch'];
|
|
@@ -144,6 +144,8 @@ export type Redirect = {
|
|
|
144
144
|
js?: JsRedirect;
|
|
145
145
|
/** Controls the redirect of the import paths of output style files. */
|
|
146
146
|
style?: StyleRedirect;
|
|
147
|
+
/** Controls the redirect of the import paths of output asset files. */
|
|
148
|
+
asset?: boolean;
|
|
147
149
|
};
|
|
148
150
|
export interface LibConfig extends EnvironmentConfig {
|
|
149
151
|
/**
|
|
@@ -8,6 +8,6 @@ export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOut
|
|
|
8
8
|
* https://github.com/rspack-contrib/browserslist-to-es-version
|
|
9
9
|
* TODO: align with Rsbuild, we may should align with SWC
|
|
10
10
|
*/
|
|
11
|
-
export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string
|
|
11
|
+
export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string>> & Record<LatestEcmaVersions, (target: RsbuildConfigOutputTarget) => string[]>;
|
|
12
12
|
export declare function transformSyntaxToRspackTarget(syntax: Syntax): Rspack.Configuration['target'];
|
|
13
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.4.0",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "1.2.
|
|
35
|
+
"@rsbuild/core": "~1.2.3",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.
|
|
37
|
+
"rsbuild-plugin-dts": "0.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@module-federation/rsbuild-plugin": "^0.8.
|
|
40
|
+
"@module-federation/rsbuild-plugin": "^0.8.9",
|
|
41
41
|
"@types/fs-extra": "^11.0.4",
|
|
42
42
|
"chokidar": "^4.0.3",
|
|
43
|
-
"commander": "^13.
|
|
44
|
-
"fs-extra": "^11.
|
|
45
|
-
"memfs": "^4.
|
|
43
|
+
"commander": "^13.1.0",
|
|
44
|
+
"fs-extra": "^11.3.0",
|
|
45
|
+
"memfs": "^4.17.0",
|
|
46
46
|
"picocolors": "1.1.1",
|
|
47
|
-
"prebundle": "1.2.
|
|
47
|
+
"prebundle": "1.2.7",
|
|
48
48
|
"rsbuild-plugin-publint": "^0.2.1",
|
|
49
|
-
"rslib": "npm:@rslib/core@0.3.
|
|
49
|
+
"rslib": "npm:@rslib/core@0.3.2",
|
|
50
50
|
"rslog": "^1.2.3",
|
|
51
51
|
"tsconfck": "3.1.4",
|
|
52
52
|
"typescript": "^5.7.3",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "rslib build",
|
|
77
77
|
"dev": "rslib build --watch",
|
|
78
|
-
"prebundle": "prebundle"
|
|
78
|
+
"prebundle": "prebundle",
|
|
79
|
+
"type-check": "tsc --noEmit && tsc --noEmit -p tests"
|
|
79
80
|
}
|
|
80
81
|
}
|