@rsbuild/plugin-svgr 1.0.4 → 1.0.5

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/dist/index.cjs CHANGED
@@ -3,12 +3,12 @@
3
3
  var __webpack_require__ = {};
4
4
  /************************************************************************/ // webpack/runtime/compat_get_default_export
5
5
  (()=>{
6
- // getDefaultExport function for compatibility with non-harmony modules
7
- __webpack_require__.n = function(module) {
8
- var getter = module && module.__esModule ? function() {
9
- return module['default'];
6
+ // getDefaultExport function for compatibility with non-ESM modules
7
+ __webpack_require__.n = function(module1) {
8
+ var getter = module1 && module1.__esModule ? function() {
9
+ return module1['default'];
10
10
  } : function() {
11
- return module;
11
+ return module1;
12
12
  };
13
13
  __webpack_require__.d(getter, {
14
14
  a: getter
@@ -53,9 +53,13 @@ __webpack_require__.d(__webpack_exports__, {
53
53
  });
54
54
  const external_node_path_namespaceObject = require("node:path");
55
55
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
56
+ const external_node_url_namespaceObject = require("node:url");
56
57
  const plugin_react_namespaceObject = require("@rsbuild/plugin-react");
57
58
  const external_deepmerge_namespaceObject = require("deepmerge");
58
59
  var external_deepmerge_default = /*#__PURE__*/ __webpack_require__.n(external_deepmerge_namespaceObject);
60
+ const src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(/*#__PURE__*/ function() {
61
+ return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
62
+ }()));
59
63
  const SVG_REGEX = /\.svg$/;
60
64
  const getSvgoDefaultConfig = ()=>({
61
65
  plugins: [
@@ -117,16 +121,13 @@ const getSvgoDefaultConfig = ()=>({
117
121
  return config;
118
122
  };
119
123
  const PLUGIN_SVGR_NAME = 'rsbuild:svgr';
120
- const pluginSvgr = function() {
121
- let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
122
- return {
124
+ const pluginSvgr = (options = {})=>({
123
125
  name: PLUGIN_SVGR_NAME,
124
126
  pre: [
125
127
  plugin_react_namespaceObject.PLUGIN_REACT_NAME
126
128
  ],
127
129
  setup (api) {
128
- api.modifyBundlerChain(async (chain, param)=>{
129
- let { CHAIN_ID, environment } = param;
130
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
130
131
  const { config } = environment;
131
132
  const { dataUriLimit } = config.output;
132
133
  const maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.svg;
@@ -147,7 +148,7 @@ const pluginSvgr = function() {
147
148
  // force to inline: "foo.svg?inline"
148
149
  rule.oneOf(CHAIN_ID.ONE_OF.SVG_INLINE).type('asset/inline').resourceQuery(/inline/);
149
150
  // force to react component: "foo.svg?react"
150
- rule.oneOf(CHAIN_ID.ONE_OF.SVG_REACT).type('javascript/auto').resourceQuery(options.query || /react/).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(__dirname, './loader.cjs')).options({
151
+ rule.oneOf(CHAIN_ID.ONE_OF.SVG_REACT).type('javascript/auto').resourceQuery(options.query || /react/).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(src_dirname, './loader.cjs')).options({
151
152
  ...svgrOptions,
152
153
  exportType: 'default'
153
154
  }).end();
@@ -170,14 +171,14 @@ const pluginSvgr = function() {
170
171
  const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG);
171
172
  if (options.exclude) svgRule.exclude.add(options.exclude);
172
173
  svgRule.type('javascript/auto') // The issuer option ensures that SVGR will only apply if the SVG is imported from a JS file.
173
- .set('issuer', issuer).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(__dirname, './loader.cjs')).options({
174
+ .set('issuer', issuer).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(src_dirname, './loader.cjs')).options({
174
175
  ...svgrOptions,
175
176
  exportType
176
177
  }).end();
177
178
  /**
178
179
  * For mixed import.
179
180
  * @example import logoUrl, { ReactComponent } from './logo.svg';`
180
- */ if (mixedImport && 'named' === exportType) svgRule.use(CHAIN_ID.USE.URL).loader(external_node_path_default().join(__dirname, '../compiled', 'url-loader/index.js')).options({
181
+ */ if (mixedImport && 'named' === exportType) svgRule.use(CHAIN_ID.USE.URL).loader(external_node_path_default().join(src_dirname, '../compiled', 'url-loader/index.js')).options({
181
182
  limit: maxSize,
182
183
  name: null == generatorOptions ? void 0 : generatorOptions.filename
183
184
  });
@@ -207,8 +208,7 @@ const pluginSvgr = function() {
207
208
  });
208
209
  });
209
210
  }
210
- };
211
- };
211
+ });
212
212
  var __webpack_export_target__ = exports;
213
213
  for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
214
214
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
- import { fileURLToPath as __webpack_fileURLToPath__ } from "url";
2
- import { dirname as __webpack_dirname__ } from "path";
3
1
  import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_node_url__ from "node:url";
4
3
  import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react__ from "@rsbuild/plugin-react";
5
4
  import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
6
- var src_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
5
+ const src_dirname = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url__.fileURLToPath)(import.meta.url));
7
6
  const SVG_REGEX = /\.svg$/;
8
7
  const getSvgoDefaultConfig = ()=>({
9
8
  plugins: [
@@ -65,16 +64,13 @@ const getSvgoDefaultConfig = ()=>({
65
64
  return config;
66
65
  };
67
66
  const PLUGIN_SVGR_NAME = 'rsbuild:svgr';
68
- const pluginSvgr = function() {
69
- let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
70
- return {
67
+ const pluginSvgr = (options = {})=>({
71
68
  name: PLUGIN_SVGR_NAME,
72
69
  pre: [
73
70
  __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react__.PLUGIN_REACT_NAME
74
71
  ],
75
72
  setup (api) {
76
- api.modifyBundlerChain(async (chain, param)=>{
77
- let { CHAIN_ID, environment } = param;
73
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
78
74
  const { config } = environment;
79
75
  const { dataUriLimit } = config.output;
80
76
  const maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.svg;
@@ -155,6 +151,5 @@ const pluginSvgr = function() {
155
151
  });
156
152
  });
157
153
  }
158
- };
159
- };
154
+ });
160
155
  export { PLUGIN_SVGR_NAME, pluginSvgr };
package/dist/loader.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  var __webpack_require__ = {};
4
4
  /************************************************************************/ // webpack/runtime/compat_get_default_export
5
5
  (()=>{
6
- // getDefaultExport function for compatibility with non-harmony modules
6
+ // getDefaultExport function for compatibility with non-ESM modules
7
7
  __webpack_require__.n = function(module) {
8
8
  var getter = module && module.__esModule ? function() {
9
9
  return module['default'];
@@ -100,7 +100,7 @@ function svgrLoader(contents) {
100
100
  });
101
101
  else transformSvg(contents, options, state, callback);
102
102
  }
103
- /* harmony default export */ const loader = svgrLoader;
103
+ /* ESM default export */ const loader = svgrLoader;
104
104
  var __webpack_export_target__ = exports;
105
105
  for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
106
106
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svgr",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "svgr plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "@svgr/plugin-svgo": "8.1.0",
29
29
  "deepmerge": "^4.3.1",
30
30
  "loader-utils": "^2.0.4",
31
- "@rsbuild/plugin-react": "1.0.4"
31
+ "@rsbuild/plugin-react": "1.0.6"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "18.x",
@@ -37,11 +37,11 @@
37
37
  "svgo": "^3.3.2",
38
38
  "typescript": "^5.6.3",
39
39
  "url-loader": "4.1.1",
40
- "@rsbuild/core": "1.0.14",
40
+ "@rsbuild/core": "1.0.19",
41
41
  "@scripts/test-helper": "1.0.1"
42
42
  },
43
43
  "peerDependencies": {
44
- "@rsbuild/core": "1.x || ^1.0.1-rc.0"
44
+ "@rsbuild/core": "1.x"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public",