Skip to content

Commit 77ebfb4

Browse files
committed
Fix build issue with empty source maps [publish]
1 parent 09c5d81 commit 77ebfb4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.1
4+
5+
Fix build issue with empty source maps
6+
37
## 0.1.0
48

59
Initial release

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-plugin-fast-react-svg",
33
"description": "Turn SVG into React components, without Babel",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"license": "MIT",
66
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
77
"main": "dist/index.js",

src/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ export default function svgPlugin(): Plugin {
1414
return readFileSync(id.replace("?inline", ""), "utf-8");
1515
}
1616
},
17-
transform(code, id) {
17+
async transform(svg, id) {
1818
if (id.endsWith(".svg")) {
19-
return transform(svgToJSX(code), { loader: "jsx" });
19+
const { code, warnings } = await transform(svgToJSX(svg), {
20+
loader: "jsx",
21+
});
22+
for (const warning of warnings) {
23+
console.log(warning.location, warning.text);
24+
}
25+
return code;
2026
}
2127
if (id.endsWith(".svg?inline")) {
22-
const base64 = Buffer.from(code).toString("base64");
28+
const base64 = Buffer.from(svg).toString("base64");
2329
return `export default "data:image/svg+xml;base64,${base64}"`;
2430
}
2531
},

0 commit comments

Comments
 (0)