@rsbuild/plugin-svgr 0.3.0 → 0.3.1

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.
@@ -0,0 +1 @@
1
+ export = any;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={53:(e,t,i)=>{const r=i(126);e.exports=r.default;e.exports.raw=r.raw},126:(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(525));var s=i(250);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},250:(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")},525: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__(53);module.exports=i})();
@@ -0,0 +1,20 @@
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"file-loader","author":"Tobias Koppers @sokra","version":"6.2.0","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1 @@
1
+ module.exports.validate = () => {};
@@ -0,0 +1 @@
1
+ export = any;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={991:(e,t,r)=>{const i=r(755);e.exports=i.default;e.exports.raw=i.raw},755:(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(490));var u=_interopRequireDefault(r(521));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},490:(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")},521: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__(991);module.exports=r})();
@@ -0,0 +1,20 @@
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"url-loader","author":"Tobias Koppers @sokra","version":"4.1.1","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1 @@
1
+ module.exports.validate = () => {};
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ type PluginSvgrOptions = {
9
9
  svgrOptions?: Config;
10
10
  /**
11
11
  * Configure the default export type of SVG files.
12
+ * @default 'url'
12
13
  */
13
14
  svgDefaultExport?: SvgDefaultExport;
14
15
  };
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ var pluginSvgr = (options = {}) => ({
99
99
  );
100
100
  svgrRule.use(CHAIN_ID.USE.SVGR).loader(import_path.default.resolve(__dirname, "./loader")).options(svgrOptions).end().when(
101
101
  svgDefaultExport === "url",
102
- (c) => c.use(CHAIN_ID.USE.URL).loader(require.resolve("url-loader")).options({
102
+ (c) => c.use(CHAIN_ID.USE.URL).loader(import_path.default.join(__dirname, "../compiled", "url-loader")).options({
103
103
  limit: config.output.dataUriLimit.svg,
104
104
  name: outputName
105
105
  })
package/dist/index.mjs CHANGED
@@ -1,11 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
1
  // ../../node_modules/.pnpm/@modern-js+module-tools@2.45.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
10
2
  import { fileURLToPath } from "url";
11
3
  import path from "path";
@@ -92,7 +84,7 @@ var pluginSvgr = (options = {}) => ({
92
84
  );
93
85
  svgrRule.use(CHAIN_ID.USE.SVGR).loader(path2.resolve(__dirname, "./loader")).options(svgrOptions).end().when(
94
86
  svgDefaultExport === "url",
95
- (c) => c.use(CHAIN_ID.USE.URL).loader(__require.resolve("url-loader")).options({
87
+ (c) => c.use(CHAIN_ID.USE.URL).loader(path2.join(__dirname, "../compiled", "url-loader")).options({
96
88
  limit: config.output.dataUriLimit.svg,
97
89
  name: outputName
98
90
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svgr",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "svgr plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,20 +19,20 @@
19
19
  "main": "./dist/index.js",
20
20
  "types": "./dist/index.d.ts",
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "compiled"
23
24
  ],
24
25
  "dependencies": {
25
26
  "@svgr/core": "8.1.0",
26
27
  "@svgr/plugin-jsx": "8.1.0",
27
28
  "@svgr/plugin-svgo": "8.1.0",
28
- "url-loader": "4.1.1",
29
- "@rsbuild/shared": "0.3.0"
29
+ "@rsbuild/shared": "0.3.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "16.x",
33
33
  "typescript": "^5.3.0",
34
- "@rsbuild/core": "0.3.0",
35
- "@rsbuild/test-helper": "0.3.0"
34
+ "@scripts/test-helper": "1.0.0",
35
+ "@rsbuild/core": "0.3.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",