Skip to content

Commit 7665543

Browse files
committed
[Refactor] no need to directly depend on babel-template or babel-traverse
1 parent 85ec7c3 commit 7665543

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
"react": "^15.3.1"
4343
},
4444
"dependencies": {
45-
"babel-template": "^6.26.0",
46-
"babel-traverse": "^6.26.0",
4745
"babylon": "^6.18.0",
4846
"lodash.isplainobject": "^4.0.6",
4947
"resolve": "^1.8.1",

src/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { extname, dirname } from 'path';
22
import { readFileSync } from 'fs';
3-
import template from 'babel-template';
4-
import traverse from 'babel-traverse';
53
import { parse } from 'babylon';
64
import resolve from 'resolve';
75

@@ -10,18 +8,18 @@ import escapeBraces from './escapeBraces';
108
import transformSvg from './transformSvg';
119
import fileExistsWithCaseSync from './fileExistsWithCaseSync';
1210

13-
const buildSvg = template(`
11+
let ignoreRegex;
12+
13+
export default ({ template, traverse, types: t }) => {
14+
const buildSvg = template(`
1415
var SVG_NAME = function SVG_NAME(props) { return SVG_CODE; };
1516
`);
1617

17-
const buildSvgWithDefaults = template(`
18+
const buildSvgWithDefaults = template(`
1819
var SVG_NAME = function SVG_NAME(props) { return SVG_CODE; };
1920
SVG_NAME.defaultProps = SVG_DEFAULT_PROPS_CODE;
2021
`);
2122

22-
let ignoreRegex;
23-
24-
export default ({ types: t }) => {
2523
function applyPlugin(importIdentifier, importPath, path, state) {
2624
if (typeof importPath !== 'string') {
2725
throw new TypeError('`applyPlugin` `importPath` must be a string');

0 commit comments

Comments
 (0)