@rsbuild/plugin-svgr 0.5.7 → 0.5.9

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
1
+ import { Rspack, RsbuildPlugin } from '@rsbuild/core';
2
2
  import { Config } from '@svgr/core';
3
3
 
4
4
  type SvgDefaultExport = 'component' | 'url';
@@ -18,6 +18,14 @@ type PluginSvgrOptions = {
18
18
  * @default /react/
19
19
  */
20
20
  query?: RegExp;
21
+ /**
22
+ * Exclude some SVG files, they will not be transformed by SVGR.
23
+ */
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;
21
29
  };
22
30
  declare const pluginSvgr: (options?: PluginSvgrOptions) => RsbuildPlugin;
23
31
 
package/dist/index.js CHANGED
@@ -84,7 +84,13 @@ var pluginSvgr = (options = {}) => ({
84
84
  const { mixedImport = false } = options;
85
85
  if (mixedImport || svgrOptions.exportType) {
86
86
  const { exportType = mixedImport ? "named" : void 0 } = svgrOptions;
87
- const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").set("issuer", [import_shared.SCRIPT_REGEX, /\.mdx$/]).use(CHAIN_ID.USE.SVGR).loader(import_node_path.default.resolve(__dirname, "./loader")).options({
87
+ const issuerInclude = [import_shared.SCRIPT_REGEX, /\.mdx$/];
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({
88
94
  ...svgrOptions,
89
95
  exportType
90
96
  }).end();
package/dist/index.mjs CHANGED
@@ -67,7 +67,13 @@ var pluginSvgr = (options = {}) => ({
67
67
  const { mixedImport = false } = options;
68
68
  if (mixedImport || svgrOptions.exportType) {
69
69
  const { exportType = mixedImport ? "named" : void 0 } = svgrOptions;
70
- const svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").set("issuer", [SCRIPT_REGEX, /\.mdx$/]).use(CHAIN_ID.USE.SVGR).loader(path2.resolve(__dirname, "./loader")).options({
70
+ const issuerInclude = [SCRIPT_REGEX, /\.mdx$/];
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({
71
77
  ...svgrOptions,
72
78
  exportType
73
79
  }).end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svgr",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
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.7",
30
- "@rsbuild/plugin-react": "0.5.7"
29
+ "@rsbuild/shared": "0.5.9",
30
+ "@rsbuild/plugin-react": "0.5.9"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "16.x",
34
34
  "typescript": "^5.4.2",
35
- "@rsbuild/core": "0.5.7",
36
- "@scripts/test-helper": "0.5.7"
35
+ "@rsbuild/core": "0.5.9",
36
+ "@scripts/test-helper": "0.5.9"
37
37
  },
38
38
  "peerDependencies": {
39
- "@rsbuild/core": "^0.5.7"
39
+ "@rsbuild/core": "^0.5.9"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public",