@rollipop/plugin-svg 0.0.0 → 0.1.0-alpha.18

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/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @rollipop/plugin-svg
2
+
3
+ ## 0.1.0-alpha.18
4
+
5
+ ### Patch Changes
6
+
7
+ - fa83644: trigger publish
8
+ - Updated dependencies [fa83644]
9
+ - rollipop@0.1.0-alpha.18
@@ -0,0 +1,6 @@
1
+ import { Plugin } from "rollipop";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare function svgPlugin(): Plugin;
5
+ //#endregion
6
+ export { svgPlugin as svg };
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import { transform } from "@svgr/core";
4
+ //#region \0rolldown/runtime.js
5
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
6
+ //#endregion
7
+ //#region src/plugin.ts
8
+ const SVG_EXTENSION = "svg";
9
+ function svgPlugin() {
10
+ return {
11
+ name: "rollipop:svg",
12
+ config(config) {
13
+ const resolver = config.resolver ??= {};
14
+ const sourceExtensions = resolver.sourceExtensions ??= [];
15
+ const assetExtensions = resolver.assetExtensions ??= [];
16
+ if (!sourceExtensions.includes(SVG_EXTENSION)) sourceExtensions.push(SVG_EXTENSION);
17
+ resolver.assetExtensions = assetExtensions.filter((extension) => extension !== SVG_EXTENSION);
18
+ },
19
+ load: {
20
+ filter: { id: /\.svg$/ },
21
+ async handler(id) {
22
+ return {
23
+ code: await transform(fs.readFileSync(id, "utf-8"), {
24
+ template: defaultTemplate,
25
+ plugins: [__require.resolve("@svgr/plugin-jsx")],
26
+ native: true
27
+ }, { filePath: id }),
28
+ moduleType: "jsx"
29
+ };
30
+ }
31
+ }
32
+ };
33
+ }
34
+ const SVG_COMPONENT_NAME = "SvgLogo";
35
+ const defaultTemplate = (variables, { tpl }) => {
36
+ return tpl`${variables.imports};
37
+
38
+ ${variables.interfaces};
39
+
40
+ const ${SVG_COMPONENT_NAME} = (${variables.props}) => (
41
+ ${variables.jsx}
42
+ );
43
+
44
+ export default ${SVG_COMPONENT_NAME};`;
45
+ };
46
+ //#endregion
47
+ export { svgPlugin as svg };
package/package.json CHANGED
@@ -1,4 +1,45 @@
1
1
  {
2
2
  "name": "@rollipop/plugin-svg",
3
- "version": "0.0.0"
4
- }
3
+ "version": "0.1.0-alpha.18",
4
+ "homepage": "https://github.com/leegeunhyeok/rollipop#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/leegeunhyeok/rollipop/issues"
7
+ },
8
+ "license": "MIT",
9
+ "author": "leegeunhyeok <dev.ghlee@gmail.com> (https://github.com/leegeunhyeok)",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/leegeunhyeok/rollipop.git",
13
+ "directory": "packages/plugin-svg"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "scripts": {
29
+ "prepack": "yarn build",
30
+ "typecheck": "tsc --noEmit",
31
+ "build": "vp pack"
32
+ },
33
+ "dependencies": {
34
+ "@svgr/core": "^8.1.0",
35
+ "@svgr/plugin-jsx": "^8.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "rollipop": "0.1.0-alpha.18",
39
+ "typescript": "6.0.3",
40
+ "vite-plus": "latest"
41
+ },
42
+ "peerDependencies": {
43
+ "rollipop": "0.1.0-alpha.18"
44
+ }
45
+ }
package/.editorconfig DELETED
@@ -1,10 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- end_of_line = lf
5
- insert_final_newline = true
6
-
7
- [*.{js,json,yml}]
8
- charset = utf-8
9
- indent_style = space
10
- indent_size = 2
package/.gitattributes DELETED
@@ -1,4 +0,0 @@
1
- /.yarn/** linguist-vendored
2
- /.yarn/releases/* binary
3
- /.yarn/plugins/**/* binary
4
- /.pnp.* binary linguist-generated
package/README.md DELETED
@@ -1 +0,0 @@
1
- # rollipop-empty