@rsbuild/plugin-svgr 1.2.2 → 1.2.3
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/file-loader/index.js +6 -6
- package/compiled/url-loader/index.js +10 -10
- package/dist/index.cjs +21 -9
- package/dist/index.js +15 -3
- package/dist/loader.d.ts +1 -1
- package/dist/loader.mjs +3 -3
- package/package.json +8 -8
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
const loader = __nccwpck_require__(
|
|
4
|
+
160: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
const loader = __nccwpck_require__(102);
|
|
6
6
|
module.exports = loader.default;
|
|
7
7
|
module.exports.raw = loader.raw;
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
102: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports["default"] = loader;
|
|
12
12
|
exports.raw = void 0;
|
|
13
13
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
14
14
|
var _loaderUtils = __nccwpck_require__(328);
|
|
15
|
-
var _utils = __nccwpck_require__(
|
|
15
|
+
var _utils = __nccwpck_require__(559);
|
|
16
16
|
function _interopRequireDefault(obj) {
|
|
17
17
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
18
18
|
}
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
const raw = true;
|
|
74
74
|
exports.raw = raw;
|
|
75
75
|
},
|
|
76
|
-
|
|
76
|
+
559: (__unused_webpack_module, exports) => {
|
|
77
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
78
|
exports.normalizePath = normalizePath;
|
|
79
79
|
function normalizePath(path, stripTrailing) {
|
|
@@ -128,6 +128,6 @@
|
|
|
128
128
|
}
|
|
129
129
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
130
130
|
__nccwpck_require__.ab = __dirname + "/";
|
|
131
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
131
|
+
var __webpack_exports__ = __nccwpck_require__(160);
|
|
132
132
|
module.exports = __webpack_exports__;
|
|
133
133
|
})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
331: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
/*!
|
|
5
5
|
* mime-db
|
|
6
6
|
* Copyright(c) 2014 Jonathan Ong
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
module.exports = __nccwpck_require__(87);
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
574: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
13
13
|
"use strict";
|
|
14
14
|
/*!
|
|
15
15
|
* mime-types
|
|
16
16
|
* Copyright(c) 2014 Jonathan Ong
|
|
17
17
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
18
18
|
* MIT Licensed
|
|
19
|
-
*/ var db = __nccwpck_require__(
|
|
19
|
+
*/ var db = __nccwpck_require__(331);
|
|
20
20
|
var extname = __nccwpck_require__(928).extname;
|
|
21
21
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
22
22
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
@@ -107,20 +107,20 @@
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
|
|
110
|
+
111: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
111
111
|
"use strict";
|
|
112
|
-
const loader = __nccwpck_require__(
|
|
112
|
+
const loader = __nccwpck_require__(97);
|
|
113
113
|
module.exports = loader.default;
|
|
114
114
|
module.exports.raw = loader.raw;
|
|
115
115
|
},
|
|
116
|
-
|
|
116
|
+
97: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
117
117
|
"use strict";
|
|
118
118
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
119
119
|
exports["default"] = loader;
|
|
120
120
|
exports.raw = void 0;
|
|
121
121
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
122
|
-
var _mimeTypes = _interopRequireDefault(__nccwpck_require__(
|
|
123
|
-
var _normalizeFallback = _interopRequireDefault(__nccwpck_require__(
|
|
122
|
+
var _mimeTypes = _interopRequireDefault(__nccwpck_require__(574));
|
|
123
|
+
var _normalizeFallback = _interopRequireDefault(__nccwpck_require__(442));
|
|
124
124
|
function _interopRequireDefault(obj) {
|
|
125
125
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
126
126
|
}
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
const raw = true;
|
|
213
213
|
exports.raw = raw;
|
|
214
214
|
},
|
|
215
|
-
|
|
215
|
+
442: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
216
216
|
"use strict";
|
|
217
217
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
218
218
|
exports["default"] = normalizeFallback;
|
|
@@ -276,6 +276,6 @@
|
|
|
276
276
|
}
|
|
277
277
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
278
278
|
__nccwpck_require__.ab = __dirname + "/";
|
|
279
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
279
|
+
var __webpack_exports__ = __nccwpck_require__(111);
|
|
280
280
|
module.exports = __webpack_exports__;
|
|
281
281
|
})();
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
__webpack_require__.n = (module)=>{
|
|
5
5
|
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
@@ -23,11 +23,11 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
|
|
|
23
23
|
pluginSvgr: ()=>pluginSvgr,
|
|
24
24
|
PLUGIN_SVGR_NAME: ()=>PLUGIN_SVGR_NAME
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
27
27
|
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
|
|
28
|
-
|
|
28
|
+
const external_node_url_namespaceObject = require("node:url"), plugin_react_namespaceObject = require("@rsbuild/plugin-react"), external_deepmerge_namespaceObject = require("deepmerge");
|
|
29
29
|
var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
|
|
30
|
-
|
|
30
|
+
const src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), SVG_REGEX = /\.svg$/, getSvgoDefaultConfig = ()=>({
|
|
31
31
|
plugins: [
|
|
32
32
|
{
|
|
33
33
|
name: 'preset-default',
|
|
@@ -62,7 +62,7 @@ let src_dirname = external_node_path_default().dirname((0, external_node_url_nam
|
|
|
62
62
|
plugin_react_namespaceObject.PLUGIN_REACT_NAME
|
|
63
63
|
],
|
|
64
64
|
setup (api) {
|
|
65
|
-
api.modifyBundlerChain(
|
|
65
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
66
66
|
let { config } = environment, { dataUriLimit } = config.output, maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.svg, generatorOptions = {};
|
|
67
67
|
chain.module.rules.has(CHAIN_ID.RULE.SVG) && (generatorOptions = chain.module.rules.get(CHAIN_ID.RULE.SVG).oneOfs.get(CHAIN_ID.ONE_OF.SVG_URL).get('generator'), chain.module.rules.delete(CHAIN_ID.RULE.SVG));
|
|
68
68
|
let rule = chain.module.rule(CHAIN_ID.RULE.SVG).test(SVG_REGEX), svgrOptions = external_deepmerge_default()({
|
|
@@ -91,7 +91,7 @@ let src_dirname = external_node_path_default().dirname((0, external_node_url_nam
|
|
|
91
91
|
exportType
|
|
92
92
|
}).end(), mixedImport && 'named' === exportType && svgRule.use(CHAIN_ID.USE.URL).loader(external_node_path_default().join(src_dirname, '../compiled', 'url-loader/index.js')).options({
|
|
93
93
|
limit: maxSize,
|
|
94
|
-
name:
|
|
94
|
+
name: generatorOptions?.filename
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
rule.oneOf(CHAIN_ID.ONE_OF.SVG_ASSET).type('asset').parser({
|
|
@@ -109,16 +109,28 @@ let src_dirname = external_node_path_default().dirname((0, external_node_url_nam
|
|
|
109
109
|
for (let oneOfId of [
|
|
110
110
|
CHAIN_ID.ONE_OF.SVG,
|
|
111
111
|
CHAIN_ID.ONE_OF.SVG_REACT
|
|
112
|
-
])
|
|
112
|
+
]){
|
|
113
|
+
if (!rule.oneOfs.has(oneOfId)) continue;
|
|
114
|
+
let loaderOptions = use.get('options');
|
|
115
|
+
jsUseId === CHAIN_ID.USE.SWC && (loaderOptions = external_deepmerge_default()(loaderOptions, {
|
|
116
|
+
jsc: {
|
|
117
|
+
transform: {
|
|
118
|
+
react: {
|
|
119
|
+
refresh: !1
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})), rule.oneOf(oneOfId).use(jsUseId).before(CHAIN_ID.USE.SVGR).loader(use.get('loader')).options(loaderOptions);
|
|
124
|
+
}
|
|
113
125
|
return !0;
|
|
114
126
|
});
|
|
115
127
|
});
|
|
116
128
|
}
|
|
117
129
|
});
|
|
118
|
-
for(var
|
|
130
|
+
for(var __rspack_i in exports.PLUGIN_SVGR_NAME = __webpack_exports__.PLUGIN_SVGR_NAME, exports.pluginSvgr = __webpack_exports__.pluginSvgr, __webpack_exports__)-1 === [
|
|
119
131
|
"PLUGIN_SVGR_NAME",
|
|
120
132
|
"pluginSvgr"
|
|
121
|
-
].indexOf(
|
|
133
|
+
].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
|
|
122
134
|
Object.defineProperty(exports, '__esModule', {
|
|
123
135
|
value: !0
|
|
124
136
|
});
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ let src_dirname = node_path.dirname(fileURLToPath(import.meta.url)), SVG_REGEX =
|
|
|
8
8
|
PLUGIN_REACT_NAME
|
|
9
9
|
],
|
|
10
10
|
setup (api) {
|
|
11
|
-
api.modifyBundlerChain(
|
|
11
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
|
|
12
12
|
let { config } = environment, { dataUriLimit } = config.output, maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.svg, generatorOptions = {};
|
|
13
13
|
chain.module.rules.has(CHAIN_ID.RULE.SVG) && (generatorOptions = chain.module.rules.get(CHAIN_ID.RULE.SVG).oneOfs.get(CHAIN_ID.ONE_OF.SVG_URL).get('generator'), chain.module.rules.delete(CHAIN_ID.RULE.SVG));
|
|
14
14
|
let rule = chain.module.rule(CHAIN_ID.RULE.SVG).test(SVG_REGEX), svgrOptions = deepmerge({
|
|
@@ -66,7 +66,7 @@ let src_dirname = node_path.dirname(fileURLToPath(import.meta.url)), SVG_REGEX =
|
|
|
66
66
|
exportType
|
|
67
67
|
}).end(), mixedImport && 'named' === exportType && svgRule.use(CHAIN_ID.USE.URL).loader(node_path.join(src_dirname, '../compiled', 'url-loader/index.js')).options({
|
|
68
68
|
limit: maxSize,
|
|
69
|
-
name:
|
|
69
|
+
name: generatorOptions?.filename
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
rule.oneOf(CHAIN_ID.ONE_OF.SVG_ASSET).type('asset').parser({
|
|
@@ -84,7 +84,19 @@ let src_dirname = node_path.dirname(fileURLToPath(import.meta.url)), SVG_REGEX =
|
|
|
84
84
|
for (let oneOfId of [
|
|
85
85
|
CHAIN_ID.ONE_OF.SVG,
|
|
86
86
|
CHAIN_ID.ONE_OF.SVG_REACT
|
|
87
|
-
])
|
|
87
|
+
]){
|
|
88
|
+
if (!rule.oneOfs.has(oneOfId)) continue;
|
|
89
|
+
let loaderOptions = use.get('options');
|
|
90
|
+
jsUseId === CHAIN_ID.USE.SWC && (loaderOptions = deepmerge(loaderOptions, {
|
|
91
|
+
jsc: {
|
|
92
|
+
transform: {
|
|
93
|
+
react: {
|
|
94
|
+
refresh: !1
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})), rule.oneOf(oneOfId).use(jsUseId).before(CHAIN_ID.USE.SVGR).loader(use.get('loader')).options(loaderOptions);
|
|
99
|
+
}
|
|
88
100
|
return !0;
|
|
89
101
|
});
|
|
90
102
|
});
|
package/dist/loader.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Rspack } from '@rsbuild/core';
|
|
9
9
|
import { type Config } from '@svgr/core';
|
|
10
|
-
declare
|
|
10
|
+
declare const svgrLoader: Rspack.LoaderDefinition<Config>;
|
|
11
11
|
export default svgrLoader;
|
package/dist/loader.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { transform } from "@svgr/core";
|
|
|
4
4
|
import plugin_jsx from "@svgr/plugin-jsx";
|
|
5
5
|
import plugin_svgo from "@svgr/plugin-svgo";
|
|
6
6
|
const transformSvg = callbackify(async (contents, config, state)=>transform(contents, config, state));
|
|
7
|
-
|
|
7
|
+
const svgrLoader = function(contents) {
|
|
8
8
|
this?.cacheable();
|
|
9
9
|
const callback = this.async();
|
|
10
10
|
const options = this.getOptions();
|
|
@@ -32,6 +32,6 @@ function svgrLoader(contents) {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
else transformSvg(contents, options, state, callback);
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
const loader = svgrLoader;
|
|
37
|
-
export
|
|
37
|
+
export default loader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svgr",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "SVGR plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"loader-utils": "^3.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@rslib/core": "0.
|
|
35
|
-
"@types/node": "^
|
|
34
|
+
"@rslib/core": "0.18.3",
|
|
35
|
+
"@types/node": "^24.10.1",
|
|
36
36
|
"file-loader": "6.2.0",
|
|
37
|
-
"prebundle": "1.
|
|
37
|
+
"prebundle": "1.6.0",
|
|
38
38
|
"svgo": "^3.3.2",
|
|
39
|
-
"typescript": "^5.9.
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
40
|
"url-loader": "4.1.1",
|
|
41
|
-
"@rsbuild/core": "1.
|
|
41
|
+
"@rsbuild/core": "1.6.13",
|
|
42
42
|
"@scripts/test-helper": "1.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "rslib build",
|
|
53
|
-
"dev": "rslib build
|
|
53
|
+
"dev": "rslib build -w",
|
|
54
54
|
"prebundle": "prebundle",
|
|
55
|
-
"bump": "
|
|
55
|
+
"bump": "pnpx bumpp --no-tag"
|
|
56
56
|
}
|
|
57
57
|
}
|