diff --git a/.travis.yml b/.travis.yml
index 5ab70bc..3ddc064 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,10 +2,11 @@ language: node_js
os:
- linux
node_js:
+ - "15"
+ - "14"
+ - "12"
- "10"
- - "9"
- - "8"
- - "6"
+ - "10.13"
before_install:
- 'nvm install-latest-npm'
script:
diff --git a/package.json b/package.json
index 9162282..faad619 100644
--- a/package.json
+++ b/package.json
@@ -30,12 +30,12 @@
},
"homepage": "https://github.com/kesne/babel-plugin-inline-react-svg#readme",
"devDependencies": {
- "@babel/cli": "^7.12.10",
+ "@babel/cli": "^7.12.16",
"@babel/core": "^7.0.0",
- "@babel/node": "^7.12.10",
- "@babel/preset-react": "^7.12.10",
+ "@babel/node": "^7.12.16",
+ "@babel/preset-react": "^7.12.13",
"babel-preset-airbnb": "^3.3.2",
- "eslint": "^7.17.0",
+ "eslint": "^7.20.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
@@ -49,7 +49,10 @@
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/parser": "^7.0.0",
"lodash.isplainobject": "^4.0.6",
- "resolve": "^1.19.0",
- "svgo": "^0.7.2"
+ "resolve": "^1.20.0",
+ "svgo": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=10.13"
}
}
diff --git a/src/escapeBraces.js b/src/escapeBraces.js
index 4cd0a16..eaa206a 100644
--- a/src/escapeBraces.js
+++ b/src/escapeBraces.js
@@ -7,5 +7,5 @@ export default function escapeBraces(raw) {
//
// to
//
- return raw.replace(/(\{|\})/g, '{`$1`}');
+ return { ...raw, data: raw.data.replace(/(\{|\})/g, '{`$1`}') };
}
diff --git a/src/index.js b/src/index.js
index 044d3fb..c88fc0e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -75,7 +75,7 @@ export default declare(({
const escapeSvgSource = escapeBraces(optimizedSource);
- const parsedSvgAst = parse(escapeSvgSource, {
+ const parsedSvgAst = parse(escapeSvgSource.data, {
sourceType: 'module',
plugins: ['jsx'],
});
diff --git a/src/optimize.js b/src/optimize.js
index db76ae2..d9e56e0 100644
--- a/src/optimize.js
+++ b/src/optimize.js
@@ -1,7 +1,7 @@
// validates svgo opts
// to contain minimal set of plugins that will strip some stuff
// for the babylon JSX parser to work
-import Svgo from 'svgo';
+import * as SVGO from 'svgo';
import isPlainObject from 'lodash.isplainobject';
const essentialPlugins = ['removeDoctype', 'removeComments'];
@@ -54,17 +54,6 @@ function validateAndFix(opts) {
export default function optimize(content, opts = {}) {
validateAndFix(opts);
- const svgo = new Svgo(opts);
- // Svgo isn't _really_ async, so let's do it this way:
- let returnValue;
- svgo.optimize(content, (response) => {
- if (response.error) {
- returnValue = response.error;
- } else {
- returnValue = response.data;
- }
- });
-
- return returnValue;
+ return SVGO.optimize(content, opts);
}