@apocryphilia/babel-plugin-svgr-replace-jsx-tags 1.0.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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/package.json +15 -0
  3. package/src/index.js +21 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # babel-plugin-svgr-replace-jsx-tags
2
+
3
+ This is a super basic Babel plugin to use in conjunction with [SVGR](https://react-svgr.com/) - it can rename the JSX tags generated by SVGR to new values, allowing us to shadow real SVG elements with custom React components.
4
+
5
+ Shout out to [Greg Bergé](https://github.com/gregberge) [for validating my first attempt at a SVGR/AST hack](https://github.com/gregberge/svgr/discussions/681).
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@apocryphilia/babel-plugin-svgr-replace-jsx-tags",
3
+ "version": "1.0.0",
4
+ "main": "src/index.js",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "devDependencies": {
8
+ "simple-node-logger": "^21.8.12"
9
+ },
10
+ "dependencies": {},
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/simonhildebrandt/svgr-workflow.git"
14
+ }
15
+ }
package/src/index.js ADDED
@@ -0,0 +1,21 @@
1
+ //const logger = require('simple-node-logger').createSimpleLogger('build.log');
2
+
3
+
4
+ function replaceJSXTags(_config, options) {
5
+ return {
6
+ visitor: {
7
+ JSXOpeningElement(path) {
8
+ if (options[path.node.name.name]) {
9
+ path.node.name.name = options[path.node.name.name];
10
+ }
11
+ },
12
+ JSXClosingElement(path) {
13
+ if (options[path.node.name.name]) {
14
+ path.node.name.name = options[path.node.name.name];
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ module.exports = replaceJSXTags;