@rsbuild/plugin-svgr 0.7.9 → 1.0.0-alpha.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.
@@ -2,19 +2,19 @@
2
2
  /******/ "use strict";
3
3
  /******/ var __webpack_modules__ = ({
4
4
 
5
- /***/ 547:
5
+ /***/ 929:
6
6
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
7
7
 
8
8
 
9
9
 
10
- const loader = __nccwpck_require__(259);
10
+ const loader = __nccwpck_require__(769);
11
11
 
12
12
  module.exports = loader.default;
13
13
  module.exports.raw = loader.raw;
14
14
 
15
15
  /***/ }),
16
16
 
17
- /***/ 259:
17
+ /***/ 769:
18
18
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
19
19
 
20
20
 
@@ -31,9 +31,9 @@ var _loaderUtils = __nccwpck_require__(429);
31
31
 
32
32
  var _schemaUtils = __nccwpck_require__(14);
33
33
 
34
- var _options = _interopRequireDefault(__nccwpck_require__(647));
34
+ var _options = _interopRequireDefault(__nccwpck_require__(503));
35
35
 
36
- var _utils = __nccwpck_require__(898);
36
+ var _utils = __nccwpck_require__(754);
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
@@ -107,7 +107,7 @@ exports.raw = raw;
107
107
 
108
108
  /***/ }),
109
109
 
110
- /***/ 898:
110
+ /***/ 754:
111
111
  /***/ ((__unused_webpack_module, exports) => {
112
112
 
113
113
 
@@ -176,7 +176,7 @@ module.exports = require("path");
176
176
 
177
177
  /***/ }),
178
178
 
179
- /***/ 647:
179
+ /***/ 503:
180
180
  /***/ ((module) => {
181
181
 
182
182
  module.exports = JSON.parse('{"additionalProperties":true,"properties":{"name":{"description":"The filename template for the target file(s) (https://github.com/webpack-contrib/file-loader#name).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"outputPath":{"description":"A filesystem path where the target file(s) will be placed (https://github.com/webpack-contrib/file-loader#outputpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"publicPath":{"description":"A custom public path for the target file(s) (https://github.com/webpack-contrib/file-loader#publicpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"postTransformPublicPath":{"description":"A custom transformation function for post-processing the publicPath (https://github.com/webpack-contrib/file-loader#posttransformpublicpath).","instanceof":"Function"},"context":{"description":"A custom file context (https://github.com/webpack-contrib/file-loader#context).","type":"string"},"emitFile":{"description":"Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile).","type":"boolean"},"regExp":{"description":"A Regular Expression to one or many parts of the target file path. The capture groups can be reused in the name property using [N] placeholder (https://github.com/webpack-contrib/file-loader#regexp).","anyOf":[{"type":"string"},{"instanceof":"RegExp"}]},"esModule":{"description":"By default, file-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"type":"object"}');
@@ -225,7 +225,7 @@ module.exports = JSON.parse('{"additionalProperties":true,"properties":{"name":{
225
225
  /******/ // startup
226
226
  /******/ // Load entry module and return exports
227
227
  /******/ // This entry module is referenced by other modules so it can't be inlined
228
- /******/ var __webpack_exports__ = __nccwpck_require__(547);
228
+ /******/ var __webpack_exports__ = __nccwpck_require__(929);
229
229
  /******/ module.exports = __webpack_exports__;
230
230
  /******/
231
231
  /******/ })()
@@ -216,20 +216,20 @@ function populateMaps (extensions, types) {
216
216
 
217
217
  /***/ }),
218
218
 
219
- /***/ 288:
219
+ /***/ 714:
220
220
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
221
221
 
222
222
  "use strict";
223
223
 
224
224
 
225
- const loader = __nccwpck_require__(998);
225
+ const loader = __nccwpck_require__(114);
226
226
 
227
227
  module.exports = loader.default;
228
228
  module.exports.raw = loader.raw;
229
229
 
230
230
  /***/ }),
231
231
 
232
- /***/ 998:
232
+ /***/ 114:
233
233
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
234
234
 
235
235
  "use strict";
@@ -249,9 +249,9 @@ var _schemaUtils = __nccwpck_require__(14);
249
249
 
250
250
  var _mimeTypes = _interopRequireDefault(__nccwpck_require__(588));
251
251
 
252
- var _normalizeFallback = _interopRequireDefault(__nccwpck_require__(6));
252
+ var _normalizeFallback = _interopRequireDefault(__nccwpck_require__(226));
253
253
 
254
- var _options = _interopRequireDefault(__nccwpck_require__(225));
254
+ var _options = _interopRequireDefault(__nccwpck_require__(31));
255
255
 
256
256
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
257
257
 
@@ -368,7 +368,7 @@ exports.raw = raw;
368
368
 
369
369
  /***/ }),
370
370
 
371
- /***/ 6:
371
+ /***/ 226:
372
372
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
373
373
 
374
374
  "use strict";
@@ -446,7 +446,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
446
446
 
447
447
  /***/ }),
448
448
 
449
- /***/ 225:
449
+ /***/ 31:
450
450
  /***/ ((module) => {
451
451
 
452
452
  "use strict";
@@ -496,7 +496,7 @@ module.exports = JSON.parse('{"type":"object","properties":{"limit":{"descriptio
496
496
  /******/ // startup
497
497
  /******/ // Load entry module and return exports
498
498
  /******/ // This entry module is referenced by other modules so it can't be inlined
499
- /******/ var __webpack_exports__ = __nccwpck_require__(288);
499
+ /******/ var __webpack_exports__ = __nccwpck_require__(714);
500
500
  /******/ module.exports = __webpack_exports__;
501
501
  /******/
502
502
  /******/ })()
package/dist/index.cjs CHANGED
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  PLUGIN_SVGR_NAME: () => PLUGIN_SVGR_NAME,
34
- SVG_REGEX: () => SVG_REGEX,
35
34
  pluginSvgr: () => pluginSvgr
36
35
  });
37
36
  module.exports = __toCommonJS(src_exports);
@@ -61,8 +60,8 @@ var pluginSvgr = (options = {}) => ({
61
60
  name: PLUGIN_SVGR_NAME,
62
61
  pre: [import_plugin_react.PLUGIN_REACT_NAME],
63
62
  setup(api) {
64
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
65
- const config = api.getNormalizedConfig();
63
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
64
+ const { config } = environment;
66
65
  const { dataUriLimit } = config.output;
67
66
  const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit.svg;
68
67
  let generatorOptions = {};
@@ -133,6 +132,5 @@ var pluginSvgr = (options = {}) => ({
133
132
  // Annotate the CommonJS export names for ESM import in node:
134
133
  0 && (module.exports = {
135
134
  PLUGIN_SVGR_NAME,
136
- SVG_REGEX,
137
135
  pluginSvgr
138
136
  });
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import { Rspack, RsbuildPlugin } from '@rsbuild/core';
2
- import { Config } from '@svgr/core';
3
-
4
- type SvgDefaultExport = 'component' | 'url';
5
- declare const SVG_REGEX: RegExp;
6
- type PluginSvgrOptions = {
1
+ import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
2
+ import type { Config } from '@svgr/core';
3
+ export type SvgDefaultExport = 'component' | 'url';
4
+ export type PluginSvgrOptions = {
7
5
  /**
8
6
  * Configure SVGR options.
9
7
  * @see https://react-svgr.com/docs/options/
@@ -28,7 +26,5 @@ type PluginSvgrOptions = {
28
26
  */
29
27
  excludeImporter?: Rspack.RuleSetCondition;
30
28
  };
31
- declare const PLUGIN_SVGR_NAME = "rsbuild:svgr";
32
- declare const pluginSvgr: (options?: PluginSvgrOptions) => RsbuildPlugin;
33
-
34
- export { PLUGIN_SVGR_NAME, type PluginSvgrOptions, SVG_REGEX, type SvgDefaultExport, pluginSvgr };
29
+ export declare const PLUGIN_SVGR_NAME = "rsbuild:svgr";
30
+ export declare const pluginSvgr: (options?: PluginSvgrOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { createRequire } from 'module';
2
2
  var require = createRequire(import.meta['url']);
3
3
 
4
4
 
5
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.5.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
5
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.54.5_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
6
6
  import { fileURLToPath } from "url";
7
7
  import path from "path";
8
8
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -36,8 +36,8 @@ var pluginSvgr = (options = {}) => ({
36
36
  name: PLUGIN_SVGR_NAME,
37
37
  pre: [PLUGIN_REACT_NAME],
38
38
  setup(api) {
39
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
40
- const config = api.getNormalizedConfig();
39
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment }) => {
40
+ const { config } = environment;
41
41
  const { dataUriLimit } = config.output;
42
42
  const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit.svg;
43
43
  let generatorOptions = {};
@@ -107,6 +107,5 @@ var pluginSvgr = (options = {}) => ({
107
107
  });
108
108
  export {
109
109
  PLUGIN_SVGR_NAME,
110
- SVG_REGEX,
111
110
  pluginSvgr
112
111
  };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2017, Smooth Code
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * modified from https://github.com/gregberge/svgr/blob/7595d378b73d4826a4cead165b3f32386b07315b/packages/webpack/src/index.ts
7
+ */
8
+ import type { Rspack } from '@rsbuild/core';
9
+ import { type Config } from '@svgr/core';
10
+ declare function svgrLoader(this: Rspack.LoaderContext<Config>, contents: string): void;
11
+ export default svgrLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svgr",
3
- "version": "0.7.9",
3
+ "version": "1.0.0-alpha.0",
4
4
  "description": "svgr plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,20 +27,20 @@
27
27
  "@svgr/plugin-jsx": "8.1.0",
28
28
  "@svgr/plugin-svgo": "8.1.0",
29
29
  "loader-utils": "^2.0.4",
30
- "@rsbuild/plugin-react": "0.7.9",
31
- "@rsbuild/shared": "0.7.9"
30
+ "@rsbuild/plugin-react": "1.0.0-alpha.0",
31
+ "@rsbuild/shared": "1.0.0-alpha.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "18.x",
35
35
  "file-loader": "6.2.0",
36
36
  "prebundle": "1.1.0",
37
- "typescript": "^5.4.2",
37
+ "typescript": "^5.5.2",
38
38
  "url-loader": "4.1.1",
39
- "@rsbuild/core": "0.7.9",
40
- "@scripts/test-helper": "0.7.9"
39
+ "@rsbuild/core": "1.0.0-alpha.0",
40
+ "@scripts/test-helper": "1.0.0-alpha.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rsbuild/core": "^0.7.9"
43
+ "@rsbuild/core": "^1.0.0-alpha.0"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",