diff --git a/.babelrc b/.babelrc index 0603fc0a..43b29050 100644 --- a/.babelrc +++ b/.babelrc @@ -14,6 +14,9 @@ "polyfill": false, "regenerator": true }], - "./src/babel/babel-plugin-import.js" + ["babel-plugin-root-import", { + "rootPathSuffix": "./src", + "rootPathPrefix": "~" + }] ] } \ No newline at end of file diff --git a/package.json b/package.json index 6c66591f..4e3004e6 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "test-unit:watch": "jest -o --watch" }, "dependencies": { - "bignumber.js": "^7.2.1", "color-hash": "^1.0.3", "copy-webpack-plugin": "^4.5.2", "ethereumjs-tx": "^1.3.3", diff --git a/src/babel/babel-plugin-import.js b/src/babel/babel-plugin-import.js deleted file mode 100644 index adaefac9..00000000 --- a/src/babel/babel-plugin-import.js +++ /dev/null @@ -1,58 +0,0 @@ -// inspired by: -// https://github.com/entwicklerstube/babel-plugin-root-import/ -// Simple plugin allows es6 import from '~/' which is src root - -const cwd = process.cwd(); - -const replacePrefix = (path, opts = [], sourceFile) => { - const options = [].concat(opts); - if (typeof path === 'string') { - if (path.indexOf('~/') === 0) { - return path.replace('~/', `${cwd}/src/`); - } - } - return path; -}; - - -export default ({ types: t }) => { - const visitor = { - CallExpression(path, state) { - if (path.node.callee.name !== 'require') { - return; - } - - const args = path.node.arguments; - if (!args.length) { - return; - } - - const firstArg = traverseExpression(t, args[0]); - - if (firstArg) { - firstArg.value = replacePrefix(firstArg.value, state.opts, state.file.opts.filename); - } - }, - ImportDeclaration(path, state) { - path.node.source.value = replacePrefix(path.node.source.value, state.opts, state.file.opts.filename); - }, - ExportNamedDeclaration(path, state) { - if (path.node.source) { - path.node.source.value = replacePrefix(path.node.source.value, state.opts, state.file.opts.filename); - } - }, - ExportAllDeclaration(path, state) { - if (path.node.source) { - path.node.source.value = replacePrefix(path.node.source.value, state.opts, state.file.opts.filename); - } - }, - }; - - return { - visitor: { - Program(path, state) { - path.traverse(visitor, state); - }, - }, - }; -}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 9d62a9ea..3cc1f727 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1503,10 +1503,6 @@ bignumber.js@^4.0.2: version "4.1.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1" -bignumber.js@^7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" - binary-extensions@^1.0.0: version "1.11.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205"