vite-plugin-svgr 2.2.1 → 2.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/client.d.ts +2 -1
- package/dist/index.js +24 -23
- package/dist/index.mjs +5 -2
- package/package.json +10 -9
package/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// https://github.com/facebook/create-react-app/blob/0ee4765c39f820e5f4820abf4bf2e47b3324da7f/packages/react-scripts/lib/react-app.d.ts#L47-L56
|
|
2
|
+
// https://github.com/pd4d10/vite-plugin-svgr/pull/56 for preact compatiblility
|
|
2
3
|
|
|
3
4
|
declare module '*.svg' {
|
|
4
5
|
import * as React from 'react'
|
|
5
6
|
|
|
6
7
|
export const ReactComponent: React.FunctionComponent<
|
|
7
|
-
React.
|
|
8
|
+
React.ComponentProps<'svg'> & { title?: string }
|
|
8
9
|
>
|
|
9
10
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
|
+
mod
|
|
19
|
+
));
|
|
20
|
+
const pluginutils = require("@rollup/pluginutils");
|
|
2
21
|
const fs = require("fs");
|
|
3
22
|
const vite = require("vite");
|
|
4
|
-
const pluginutils = require("@rollup/pluginutils");
|
|
5
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
6
|
-
function _interopNamespace(e) {
|
|
7
|
-
if (e && e.__esModule)
|
|
8
|
-
return e;
|
|
9
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
-
if (e) {
|
|
11
|
-
for (const k in e) {
|
|
12
|
-
if (k !== "default") {
|
|
13
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: () => e[k]
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
const fs__default = /* @__PURE__ */ _interopDefaultLegacy(fs);
|
|
25
23
|
function viteSvgr({
|
|
26
24
|
exportAsDefault,
|
|
27
25
|
svgrOptions,
|
|
@@ -34,8 +32,11 @@ function viteSvgr({
|
|
|
34
32
|
name: "vite-plugin-svgr",
|
|
35
33
|
async transform(code, id) {
|
|
36
34
|
if (filter(id)) {
|
|
37
|
-
const { transform } = await
|
|
38
|
-
const svgCode = await
|
|
35
|
+
const { transform } = await import("@svgr/core");
|
|
36
|
+
const svgCode = await fs.promises.readFile(
|
|
37
|
+
id.replace(/\?.*$/, ""),
|
|
38
|
+
"utf8"
|
|
39
|
+
);
|
|
39
40
|
const componentCode = await transform(svgCode, svgrOptions, {
|
|
40
41
|
filePath: id,
|
|
41
42
|
caller: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
1
2
|
import fs from "fs";
|
|
2
3
|
import { transformWithEsbuild } from "vite";
|
|
3
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
4
4
|
function viteSvgr({
|
|
5
5
|
exportAsDefault,
|
|
6
6
|
svgrOptions,
|
|
@@ -14,7 +14,10 @@ function viteSvgr({
|
|
|
14
14
|
async transform(code, id) {
|
|
15
15
|
if (filter(id)) {
|
|
16
16
|
const { transform } = await import("@svgr/core");
|
|
17
|
-
const svgCode = await fs.promises.readFile(
|
|
17
|
+
const svgCode = await fs.promises.readFile(
|
|
18
|
+
id.replace(/\?.*$/, ""),
|
|
19
|
+
"utf8"
|
|
20
|
+
);
|
|
18
21
|
const componentCode = await transform(svgCode, svgrOptions, {
|
|
19
22
|
filePath: id,
|
|
20
23
|
caller: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-svgr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Vite plugin to transform SVGs into React components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,16 +29,17 @@
|
|
|
29
29
|
"author": "Rongjian Zhang",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^18.
|
|
33
|
-
"tsdv": "^0.
|
|
34
|
-
"typescript": "^4.
|
|
35
|
-
"vite": "^
|
|
32
|
+
"@types/node": "^18.11.12",
|
|
33
|
+
"tsdv": "^0.8.0",
|
|
34
|
+
"typescript": "^4.9.4",
|
|
35
|
+
"vite": "^4.0.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"vite": "^2.6.0 || 3"
|
|
38
|
+
"vite": "^2.6.0 || 3 || 4"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@rollup/pluginutils": "^
|
|
42
|
-
"@svgr/core": "^6.
|
|
43
|
-
}
|
|
41
|
+
"@rollup/pluginutils": "^5.0.2",
|
|
42
|
+
"@svgr/core": "^6.5.1"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": "pnpm@7.14.2"
|
|
44
45
|
}
|