vite-plugin-svgr 3.2.0 → 3.3.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.
- package/dist/index.cjs +4 -2
- package/dist/index.js +4 -2
- package/package.json +7 -8
package/dist/index.cjs
CHANGED
|
@@ -31,15 +31,17 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
31
31
|
const vite_1 = require("vite");
|
|
32
32
|
function viteSvgr({ exportAsDefault, svgrOptions, esbuildOptions, include = "**/*.svg", exclude, } = {}) {
|
|
33
33
|
const filter = (0, pluginutils_1.createFilter)(include, exclude);
|
|
34
|
+
const postfixRE = /[?#].*$/s;
|
|
34
35
|
return {
|
|
35
36
|
name: "vite-plugin-svgr",
|
|
36
37
|
async transform(code, id) {
|
|
37
38
|
if (filter(id)) {
|
|
38
39
|
const { transform } = await Promise.resolve().then(() => __importStar(require("@svgr/core")));
|
|
39
40
|
const { default: jsx } = await Promise.resolve().then(() => __importStar(require("@svgr/plugin-jsx")));
|
|
40
|
-
const
|
|
41
|
+
const filePath = id.replace(postfixRE, "");
|
|
42
|
+
const svgCode = await fs_1.default.promises.readFile(filePath, "utf8");
|
|
41
43
|
const componentCode = await transform(svgCode, svgrOptions, {
|
|
42
|
-
filePath
|
|
44
|
+
filePath,
|
|
43
45
|
caller: {
|
|
44
46
|
previousExport: exportAsDefault ? null : code,
|
|
45
47
|
defaultPlugins: [jsx],
|
package/dist/index.js
CHANGED
|
@@ -3,15 +3,17 @@ import fs from "fs";
|
|
|
3
3
|
import { transformWithEsbuild } from "vite";
|
|
4
4
|
export default function viteSvgr({ exportAsDefault, svgrOptions, esbuildOptions, include = "**/*.svg", exclude, } = {}) {
|
|
5
5
|
const filter = createFilter(include, exclude);
|
|
6
|
+
const postfixRE = /[?#].*$/s;
|
|
6
7
|
return {
|
|
7
8
|
name: "vite-plugin-svgr",
|
|
8
9
|
async transform(code, id) {
|
|
9
10
|
if (filter(id)) {
|
|
10
11
|
const { transform } = await import("@svgr/core");
|
|
11
12
|
const { default: jsx } = await import("@svgr/plugin-jsx");
|
|
12
|
-
const
|
|
13
|
+
const filePath = id.replace(postfixRE, "");
|
|
14
|
+
const svgCode = await fs.promises.readFile(filePath, "utf8");
|
|
13
15
|
const componentCode = await transform(svgCode, svgrOptions, {
|
|
14
|
-
filePath
|
|
16
|
+
filePath,
|
|
15
17
|
caller: {
|
|
16
18
|
previousExport: exportAsDefault ? null : code,
|
|
17
19
|
defaultPlugins: [jsx],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-svgr",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Vite plugin to transform SVGs into React components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"author": "Rongjian Zhang",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^
|
|
36
|
-
"typescript": "^5.
|
|
37
|
-
"vite": "^4.3.2"
|
|
35
|
+
"@types/node": "^20.6.2",
|
|
36
|
+
"typescript": "^5.2.2"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|
|
40
39
|
"vite": "^2.6.0 || 3 || 4"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@rollup/pluginutils": "^5.0.
|
|
44
|
-
"@svgr/core": "^
|
|
45
|
-
"@svgr/plugin-jsx": "^
|
|
42
|
+
"@rollup/pluginutils": "^5.0.4",
|
|
43
|
+
"@svgr/core": "^8.1.0",
|
|
44
|
+
"@svgr/plugin-jsx": "^8.1.0"
|
|
46
45
|
},
|
|
47
|
-
"packageManager": "pnpm@8.
|
|
46
|
+
"packageManager": "pnpm@8.7.6"
|
|
48
47
|
}
|