@rsbuild/plugin-svgr 0.5.8 → 0.6.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.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={116:(e,t,i)=>{const r=i(839);e.exports=r.default;e.exports.raw=r.raw},839:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=loader;t.raw=void 0;var r=_interopRequireDefault(i(17));var o=i(72);var a=i(14);var n=_interopRequireDefault(i(65));var s=i(126);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loader(e){const t=(0,o.getOptions)(this);(0,a.validate)(n.default,t,{name:"File Loader",baseDataPath:"options"});const i=t.context||this.rootContext;const u=t.name||"[contenthash].[ext]";const p=(0,o.interpolateName)(this,u,{context:i,content:e,regExp:t.regExp});let l=p;if(t.outputPath){if(typeof t.outputPath==="function"){l=t.outputPath(p,this.resourcePath,i)}else{l=r.default.posix.join(t.outputPath,p)}}let c=`__webpack_public_path__ + ${JSON.stringify(l)}`;if(t.publicPath){if(typeof t.publicPath==="function"){c=t.publicPath(p,this.resourcePath,i)}else{c=`${t.publicPath.endsWith("/")?t.publicPath:`${t.publicPath}/`}${p}`}c=JSON.stringify(c)}if(t.postTransformPublicPath){c=t.postTransformPublicPath(c)}if(typeof t.emitFile==="undefined"||t.emitFile){const t={};if(typeof u==="string"){let e=u;const i=e.indexOf("?");if(i>=0){e=e.substr(0,i)}const r=/\[([^:\]]+:)?(hash|contenthash)(:[^\]]+)?]/gi.test(e);if(r===true){t.immutable=true}}t.sourceFilename=(0,s.normalizePath)(r.default.relative(this.rootContext,this.resourcePath));this.emitFile(l,e,null,t)}const f=typeof t.esModule!=="undefined"?t.esModule:true;return`${f?"export default":"module.exports ="} ${c};`}const u=true;t.raw=u},126:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.normalizePath=normalizePath;function normalizePath(e,t){if(e==="\\"||e==="/"){return"/"}const i=e.length;if(i<=1){return e}let r="";if(i>4&&e[3]==="\\"){const t=e[2];if((t==="?"||t===".")&&e.slice(0,2)==="\\\\"){e=e.slice(2);r="//"}}const o=e.split(/[/\\]+/);if(t!==false&&o[o.length-1]===""){o.pop()}return r+o.join("/")}},14:e=>{e.exports=require("./schema-utils")},72:e=>{e.exports=require("@rsbuild/shared/loader-utils2")},17:e=>{e.exports=require("path")},65:e=>{e.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"}')}};var t={};function __nccwpck_require__(i){var r=t[i];if(r!==undefined){return r.exports}var o=t[i]={exports:{}};var a=true;try{e[i](o,o.exports,__nccwpck_require__);a=false}finally{if(a)delete t[i]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(116);module.exports=i})();
1
+ (()=>{"use strict";var e={43:(e,t,i)=>{const r=i(86);e.exports=r.default;e.exports.raw=r.raw},86:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=loader;t.raw=void 0;var r=_interopRequireDefault(i(17));var o=i(72);var a=i(14);var n=_interopRequireDefault(i(284));var s=i(318);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loader(e){const t=(0,o.getOptions)(this);(0,a.validate)(n.default,t,{name:"File Loader",baseDataPath:"options"});const i=t.context||this.rootContext;const u=t.name||"[contenthash].[ext]";const p=(0,o.interpolateName)(this,u,{context:i,content:e,regExp:t.regExp});let l=p;if(t.outputPath){if(typeof t.outputPath==="function"){l=t.outputPath(p,this.resourcePath,i)}else{l=r.default.posix.join(t.outputPath,p)}}let c=`__webpack_public_path__ + ${JSON.stringify(l)}`;if(t.publicPath){if(typeof t.publicPath==="function"){c=t.publicPath(p,this.resourcePath,i)}else{c=`${t.publicPath.endsWith("/")?t.publicPath:`${t.publicPath}/`}${p}`}c=JSON.stringify(c)}if(t.postTransformPublicPath){c=t.postTransformPublicPath(c)}if(typeof t.emitFile==="undefined"||t.emitFile){const t={};if(typeof u==="string"){let e=u;const i=e.indexOf("?");if(i>=0){e=e.substr(0,i)}const r=/\[([^:\]]+:)?(hash|contenthash)(:[^\]]+)?]/gi.test(e);if(r===true){t.immutable=true}}t.sourceFilename=(0,s.normalizePath)(r.default.relative(this.rootContext,this.resourcePath));this.emitFile(l,e,null,t)}const f=typeof t.esModule!=="undefined"?t.esModule:true;return`${f?"export default":"module.exports ="} ${c};`}const u=true;t.raw=u},318:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.normalizePath=normalizePath;function normalizePath(e,t){if(e==="\\"||e==="/"){return"/"}const i=e.length;if(i<=1){return e}let r="";if(i>4&&e[3]==="\\"){const t=e[2];if((t==="?"||t===".")&&e.slice(0,2)==="\\\\"){e=e.slice(2);r="//"}}const o=e.split(/[/\\]+/);if(t!==false&&o[o.length-1]===""){o.pop()}return r+o.join("/")}},14:e=>{e.exports=require("./schema-utils")},72:e=>{e.exports=require("@rsbuild/shared/loader-utils2")},17:e=>{e.exports=require("path")},284:e=>{e.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"}')}};var t={};function __nccwpck_require__(i){var r=t[i];if(r!==undefined){return r.exports}var o=t[i]={exports:{}};var a=true;try{e[i](o,o.exports,__nccwpck_require__);a=false}finally{if(a)delete t[i]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(43);module.exports=i})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={394:(e,t,r)=>{const i=r(818);e.exports=i.default;e.exports.raw=i.raw},818:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=loader;t.raw=void 0;var i=_interopRequireDefault(r(17));var n=r(72);var o=r(14);var a=_interopRequireDefault(r(31));var s=_interopRequireDefault(r(387));var u=_interopRequireDefault(r(43));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function shouldTransform(e,t){if(typeof e==="boolean"){return e}if(typeof e==="string"){return t<=parseInt(e,10)}if(typeof e==="number"){return t<=e}return true}function getMimetype(e,t){if(typeof e==="boolean"){if(e){const e=a.default.contentType(i.default.extname(t));if(!e){return""}return e.replace(/;\s+charset/i,";charset")}return""}if(typeof e==="string"){return e}const r=a.default.contentType(i.default.extname(t));if(!r){return""}return r.replace(/;\s+charset/i,";charset")}function getEncoding(e){if(typeof e==="boolean"){return e?"base64":""}if(typeof e==="string"){return e}return"base64"}function getEncodedData(e,t,r,i,n){if(e){return e(i,t,r,n)}return`data:${t}${r?`;${r}`:""},${i.toString(r||undefined)}`}function loader(e){const t=(0,n.getOptions)(this)||{};(0,o.validate)(u.default,t,{name:"URL Loader",baseDataPath:"options"});if(shouldTransform(t.limit,e.length)){const{resourcePath:r}=this;const i=getMimetype(t.mimetype,r);const n=getEncoding(t.encoding);if(typeof e==="string"){e=Buffer.from(e)}const o=getEncodedData(t.generator,i,n,e,r);const a=typeof t.esModule!=="undefined"?t.esModule:true;return`${a?"export default":"module.exports ="} ${JSON.stringify(o)}`}const{loader:r,options:i}=(0,s.default)(t.fallback,t);const a=require(r);const l=Object.assign({},this,{query:i});return a.call(l,e)}const l=true;t.raw=l},387:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=normalizeFallback;var i=_interopRequireDefault(r(72));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function normalizeFallback(e,t){let r=require.resolve("../file-loader");let n={};if(typeof e==="string"){r=e;const t=e.indexOf("?");if(t>=0){r=e.substr(0,t);n=i.default.parseQuery(e.substr(t))}}if(e!==null&&typeof e==="object"){({loader:r,options:n}=e)}n=Object.assign({},t,n);delete n.fallback;return{loader:r,options:n}}},14:e=>{e.exports=require("./schema-utils")},72:e=>{e.exports=require("@rsbuild/shared/loader-utils2")},31:e=>{e.exports=require("@rsbuild/shared/mime-types")},17:e=>{e.exports=require("path")},43:e=>{e.exports=JSON.parse('{"type":"object","properties":{"limit":{"description":"Enables/Disables transformation target file into base64 URIs (https://github.com/webpack-contrib/url-loader#limit).","type":["boolean","number","string"]},"encoding":{"description":"Specify the encoding which the file will be in-lined with.","oneOf":[{"type":"boolean"},{"enum":["utf8","utf16le","latin1","base64","hex","ascii","binary","ucs2"]}]},"mimetype":{"description":"The MIME type for the file to be transformed (https://github.com/webpack-contrib/url-loader#mimetype).","oneOf":[{"type":"boolean"},{"type":"string"}]},"generator":{"description":"Adding custom implementation for encoding files.","instanceof":"Function"},"fallback":{"description":"An alternative loader to use when a target file\'s size exceeds the limit set in the limit option (https://github.com/webpack-contrib/url-loader#fallback).","anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"loader":{"description":"Fallback loader name.","type":"string"},"options":{"description":"Fallback loader options.","anyOf":[{"type":"object"},{"type":"string"}]}},"type":"object"}]},"esModule":{"description":"By default, url-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"additionalProperties":true}')}};var t={};function __nccwpck_require__(r){var i=t[r];if(i!==undefined){return i.exports}var n=t[r]={exports:{}};var o=true;try{e[r](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(394);module.exports=r})();
1
+ (()=>{"use strict";var e={521:(e,t,r)=>{const i=r(961);e.exports=i.default;e.exports.raw=i.raw},961:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=loader;t.raw=void 0;var i=_interopRequireDefault(r(17));var n=r(72);var o=r(14);var a=_interopRequireDefault(r(31));var s=_interopRequireDefault(r(976));var u=_interopRequireDefault(r(613));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function shouldTransform(e,t){if(typeof e==="boolean"){return e}if(typeof e==="string"){return t<=parseInt(e,10)}if(typeof e==="number"){return t<=e}return true}function getMimetype(e,t){if(typeof e==="boolean"){if(e){const e=a.default.contentType(i.default.extname(t));if(!e){return""}return e.replace(/;\s+charset/i,";charset")}return""}if(typeof e==="string"){return e}const r=a.default.contentType(i.default.extname(t));if(!r){return""}return r.replace(/;\s+charset/i,";charset")}function getEncoding(e){if(typeof e==="boolean"){return e?"base64":""}if(typeof e==="string"){return e}return"base64"}function getEncodedData(e,t,r,i,n){if(e){return e(i,t,r,n)}return`data:${t}${r?`;${r}`:""},${i.toString(r||undefined)}`}function loader(e){const t=(0,n.getOptions)(this)||{};(0,o.validate)(u.default,t,{name:"URL Loader",baseDataPath:"options"});if(shouldTransform(t.limit,e.length)){const{resourcePath:r}=this;const i=getMimetype(t.mimetype,r);const n=getEncoding(t.encoding);if(typeof e==="string"){e=Buffer.from(e)}const o=getEncodedData(t.generator,i,n,e,r);const a=typeof t.esModule!=="undefined"?t.esModule:true;return`${a?"export default":"module.exports ="} ${JSON.stringify(o)}`}const{loader:r,options:i}=(0,s.default)(t.fallback,t);const a=require(r);const l=Object.assign({},this,{query:i});return a.call(l,e)}const l=true;t.raw=l},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=normalizeFallback;var i=_interopRequireDefault(r(72));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function normalizeFallback(e,t){let r=require.resolve("../file-loader");let n={};if(typeof e==="string"){r=e;const t=e.indexOf("?");if(t>=0){r=e.substr(0,t);n=i.default.parseQuery(e.substr(t))}}if(e!==null&&typeof e==="object"){({loader:r,options:n}=e)}n=Object.assign({},t,n);delete n.fallback;return{loader:r,options:n}}},14:e=>{e.exports=require("./schema-utils")},72:e=>{e.exports=require("@rsbuild/shared/loader-utils2")},31:e=>{e.exports=require("@rsbuild/shared/mime-types")},17:e=>{e.exports=require("path")},613:e=>{e.exports=JSON.parse('{"type":"object","properties":{"limit":{"description":"Enables/Disables transformation target file into base64 URIs (https://github.com/webpack-contrib/url-loader#limit).","type":["boolean","number","string"]},"encoding":{"description":"Specify the encoding which the file will be in-lined with.","oneOf":[{"type":"boolean"},{"enum":["utf8","utf16le","latin1","base64","hex","ascii","binary","ucs2"]}]},"mimetype":{"description":"The MIME type for the file to be transformed (https://github.com/webpack-contrib/url-loader#mimetype).","oneOf":[{"type":"boolean"},{"type":"string"}]},"generator":{"description":"Adding custom implementation for encoding files.","instanceof":"Function"},"fallback":{"description":"An alternative loader to use when a target file\'s size exceeds the limit set in the limit option (https://github.com/webpack-contrib/url-loader#fallback).","anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"loader":{"description":"Fallback loader name.","type":"string"},"options":{"description":"Fallback loader options.","anyOf":[{"type":"object"},{"type":"string"}]}},"type":"object"}]},"esModule":{"description":"By default, url-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"additionalProperties":true}')}};var t={};function __nccwpck_require__(r){var i=t[r];if(i!==undefined){return i.exports}var n=t[r]={exports:{}};var o=true;try{e[r](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(521);module.exports=r})();
package/dist/index.d.ts CHANGED
@@ -19,9 +19,13 @@ type PluginSvgrOptions = {
19
19
  */
20
20
  query?: RegExp;
21
21
  /**
22
- * Exclude specific files to be transformed by SVGR.
22
+ * Exclude some SVG files, they will not be transformed by SVGR.
23
23
  */
24
24
  exclude?: Rspack.RuleSetCondition;
25
+ /**
26
+ * Exclude some modules, the SVGs imported by these modules will not be transformed by SVGR.
27
+ */
28
+ excludeImporter?: Rspack.RuleSetCondition;
25
29
  };
26
30
  declare const pluginSvgr: (options?: PluginSvgrOptions) => RsbuildPlugin;
27
31
 
package/dist/index.js CHANGED
@@ -85,8 +85,12 @@ var pluginSvgr = (options = {}) => ({
85
85
  if (mixedImport || svgrOptions.exportType) {
86
86
  const { exportType = mixedImport ? "named" : void 0 } = svgrOptions;
87
87
  const issuerInclude = [import_shared.SCRIPT_REGEX, /\.mdx$/];
88
- const issuer = options.exclude ? { and: [issuerInclude, { not: options.exclude }] } : issuerInclude;
89
- const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").set("issuer", issuer).use(CHAIN_ID.USE.SVGR).loader(import_node_path.default.resolve(__dirname, "./loader")).options({
88
+ const issuer = options.excludeImporter ? { and: [issuerInclude, { not: options.excludeImporter }] } : issuerInclude;
89
+ const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG);
90
+ if (options.exclude) {
91
+ svgRule.exclude.add(options.exclude);
92
+ }
93
+ svgRule.type("javascript/auto").set("issuer", issuer).use(CHAIN_ID.USE.SVGR).loader(import_node_path.default.resolve(__dirname, "./loader")).options({
90
94
  ...svgrOptions,
91
95
  exportType
92
96
  }).end();
package/dist/index.mjs 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.48.3/node_modules/@modern-js/module-tools/shims/esm.js
5
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.48.4/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);
@@ -68,8 +68,12 @@ var pluginSvgr = (options = {}) => ({
68
68
  if (mixedImport || svgrOptions.exportType) {
69
69
  const { exportType = mixedImport ? "named" : void 0 } = svgrOptions;
70
70
  const issuerInclude = [SCRIPT_REGEX, /\.mdx$/];
71
- const issuer = options.exclude ? { and: [issuerInclude, { not: options.exclude }] } : issuerInclude;
72
- const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").set("issuer", issuer).use(CHAIN_ID.USE.SVGR).loader(path2.resolve(__dirname, "./loader")).options({
71
+ const issuer = options.excludeImporter ? { and: [issuerInclude, { not: options.excludeImporter }] } : issuerInclude;
72
+ const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG);
73
+ if (options.exclude) {
74
+ svgRule.exclude.add(options.exclude);
75
+ }
76
+ svgRule.type("javascript/auto").set("issuer", issuer).use(CHAIN_ID.USE.SVGR).loader(path2.resolve(__dirname, "./loader")).options({
73
77
  ...svgrOptions,
74
78
  exportType
75
79
  }).end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svgr",
3
- "version": "0.5.8",
3
+ "version": "0.6.0",
4
4
  "description": "svgr plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,17 +26,17 @@
26
26
  "@svgr/core": "8.1.0",
27
27
  "@svgr/plugin-jsx": "8.1.0",
28
28
  "@svgr/plugin-svgo": "8.1.0",
29
- "@rsbuild/shared": "0.5.8",
30
- "@rsbuild/plugin-react": "0.5.8"
29
+ "@rsbuild/shared": "0.6.0",
30
+ "@rsbuild/plugin-react": "0.6.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "16.x",
34
34
  "typescript": "^5.4.2",
35
- "@rsbuild/core": "0.5.8",
36
- "@scripts/test-helper": "0.5.8"
35
+ "@rsbuild/core": "0.6.0",
36
+ "@scripts/test-helper": "0.6.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@rsbuild/core": "^0.5.8"
39
+ "@rsbuild/core": "^0.6.0"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public",