vite-plugin-svgr 2.0.0 → 2.1.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/{lib → dist}/index.d.ts +0 -0
- package/{lib → dist}/index.js +0 -0
- package/dist/index.mjs +24 -0
- package/package.json +14 -6
package/{lib → dist}/index.d.ts
RENAMED
|
File without changes
|
package/{lib → dist}/index.js
RENAMED
|
File without changes
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { transformWithEsbuild } from 'vite';
|
|
3
|
+
export default function viteSvgr({ exportAsDefault, svgrOptions, esbuildOptions, } = {}) {
|
|
4
|
+
return {
|
|
5
|
+
name: 'vite-plugin-svgr',
|
|
6
|
+
async transform(code, id) {
|
|
7
|
+
if (id.endsWith('.svg')) {
|
|
8
|
+
const { transform } = await import('@svgr/core');
|
|
9
|
+
const svgCode = await fs.promises.readFile(id, 'utf8');
|
|
10
|
+
const componentCode = await transform(svgCode, svgrOptions, {
|
|
11
|
+
filePath: id,
|
|
12
|
+
caller: {
|
|
13
|
+
previousExport: exportAsDefault ? null : code,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const res = await transformWithEsbuild(componentCode, id, Object.assign({ loader: 'jsx' }, esbuildOptions));
|
|
17
|
+
return {
|
|
18
|
+
code: res.code,
|
|
19
|
+
map: null, // TODO:
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-svgr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Vite plugin to transform SVGs into React components",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"scripts": {
|
|
8
16
|
"dev": "tsc --watch",
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"prepare": "npm run build"
|
|
17
|
+
"build": "tsc && tsc --module esnext --outDir temp && mv temp/index.js dist/index.mjs && rm -rf temp",
|
|
18
|
+
"prepare": "rm -rf lib && npm run build"
|
|
11
19
|
},
|
|
12
20
|
"repository": "pd4d10/vite-plugin-svgr",
|
|
13
21
|
"files": [
|
|
14
|
-
"
|
|
22
|
+
"dist",
|
|
15
23
|
"client.d.ts"
|
|
16
24
|
],
|
|
17
25
|
"keywords": [
|