@rsbuild/plugin-svgr 0.5.8 → 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
@@ -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
@@ -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.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.8",
30
- "@rsbuild/plugin-react": "0.5.8"
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.8",
36
- "@scripts/test-helper": "0.5.8"
35
+ "@rsbuild/core": "0.5.9",
36
+ "@scripts/test-helper": "0.5.9"
37
37
  },
38
38
  "peerDependencies": {
39
- "@rsbuild/core": "^0.5.8"
39
+ "@rsbuild/core": "^0.5.9"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public",