Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@svgr/babel-plugin-transform-svg-component

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgr/babel-plugin-transform-svg-component - npm Package Compare versions

Comparing version 6.0.0-alpha.1 to 6.0.0-alpha.2

10

dist/index.d.ts

@@ -25,2 +25,7 @@ import { types, ConfigAPI, NodePath } from '@babel/core';

}
interface JSXRuntimeImport {
source: string;
namespace?: string;
specifiers?: string[];
}
interface Options {

@@ -36,3 +41,6 @@ typescript?: boolean;

exportType?: 'named' | 'default';
namedExport: string;
namedExport?: string;
jsxRuntime?: 'automatic' | 'classic';
jsxRuntimeImport?: JSXRuntimeImport;
importSource?: string;
}

@@ -39,0 +47,0 @@

@@ -58,3 +58,3 @@ 'use strict';

const identifier = core.types.identifier("SVGProps");
getOrCreateImport(ctx, "react").specifiers.push(core.types.importSpecifier(identifier, identifier));
getOrCreateImport(ctx, ctx.importSource).specifiers.push(core.types.importSpecifier(identifier, identifier));
return core.types.tsTypeReference(identifier, core.types.tsTypeParameterInstantiation([

@@ -66,3 +66,3 @@ core.types.tsTypeReference(core.types.identifier("SVGSVGElement"))

const identifier = core.types.identifier("Ref");
getOrCreateImport(ctx, "react").specifiers.push(core.types.importSpecifier(identifier, identifier));
getOrCreateImport(ctx, ctx.importSource).specifiers.push(core.types.importSpecifier(identifier, identifier));
return core.types.tsTypeReference(identifier, core.types.tsTypeParameterInstantiation([

@@ -72,2 +72,20 @@ core.types.tsTypeReference(core.types.identifier("SVGSVGElement"))

};
const getJsxRuntimeImport = (cfg) => {
const specifiers = (() => {
if (cfg.namespace)
return [core.types.importNamespaceSpecifier(core.types.identifier(cfg.namespace))];
if (cfg.specifiers)
return cfg.specifiers.map((specifier) => {
const identifier = core.types.identifier(specifier);
return core.types.importSpecifier(identifier, identifier);
});
throw new Error(`Specify either "namespace" or "specifiers" in "jsxRuntimeImport" option`);
})();
return core.types.importDeclaration(specifiers, core.types.stringLiteral(cfg.source));
};
const defaultJsxRuntimeImport = {
source: "react",
namespace: "React"
};
const defaultImportSource = "react";
const getVariables = ({

@@ -77,3 +95,3 @@ opts,

}) => {
var _a;
var _a, _b, _c;
const componentName = core.types.identifier(opts.state.componentName);

@@ -85,2 +103,3 @@ const interfaces = [];

const ctx = {
importSource: (_a = opts.importSource) != null ? _a : defaultImportSource,
exportIdentifier: componentName,

@@ -93,3 +112,5 @@ opts,

};
imports.push(core.types.importDeclaration([core.types.importNamespaceSpecifier(core.types.identifier("React"))], core.types.stringLiteral("react")));
if (opts.jsxRuntime !== "automatic") {
imports.push(getJsxRuntimeImport((_b = opts.jsxRuntimeImport) != null ? _b : defaultJsxRuntimeImport));
}
if (opts.native) {

@@ -140,3 +161,3 @@ getOrCreateImport(ctx, "react-native-svg").specifiers.push(core.types.importDefaultSpecifier(core.types.identifier("Svg")));

const ForwardRef = core.types.identifier("ForwardRef");
getOrCreateImport(ctx, "react").specifiers.push(core.types.importSpecifier(forwardRef, forwardRef));
getOrCreateImport(ctx, ctx.importSource).specifiers.push(core.types.importSpecifier(forwardRef, forwardRef));
exports.push(core.types.variableDeclaration("const", [

@@ -150,3 +171,3 @@ core.types.variableDeclarator(ForwardRef, core.types.callExpression(forwardRef, [ctx.exportIdentifier]))

const Memo = core.types.identifier("Memo");
getOrCreateImport(ctx, "react").specifiers.push(core.types.importSpecifier(memo, memo));
getOrCreateImport(ctx, ctx.importSource).specifiers.push(core.types.importSpecifier(memo, memo));
exports.push(core.types.variableDeclaration("const", [

@@ -157,3 +178,6 @@ core.types.variableDeclarator(Memo, core.types.callExpression(memo, [ctx.exportIdentifier]))

}
if (((_a = opts.state.caller) == null ? void 0 : _a.previousExport) || opts.exportType === "named") {
if (((_c = opts.state.caller) == null ? void 0 : _c.previousExport) || opts.exportType === "named") {
if (!opts.namedExport) {
throw new Error(`"namedExport" not specified`);
}
exports.push(core.types.exportNamedDeclaration(null, [

@@ -160,0 +184,0 @@ core.types.exportSpecifier(ctx.exportIdentifier, core.types.identifier(opts.namedExport))

4

package.json
{
"name": "@svgr/babel-plugin-transform-svg-component",
"description": "Transform SVG into component",
"version": "6.0.0-alpha.1",
"version": "6.0.0-alpha.2",
"main": "./dist/index.js",

@@ -33,3 +33,3 @@ "exports": "./dist/index.js",

},
"gitHead": "22e2736665552263fff88683e1551b8ad852b150"
"gitHead": "f729efaad6e2ec22a27972b025737f41cf661045"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc