diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-18 08:54:52 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-18 08:54:52 +0800 |
commit | 91ce2e47013f18e85a08bc9d368130673b67f6ea (patch) | |
tree | 1b6e1a313c449228122dc397361acce43ed8ecb9 /babel-import-promise | |
parent | 4498618aed3b2c4e7e55c0c2942fbfd7c0c0f903 (diff) | |
download | SoopyV2-91ce2e47013f18e85a08bc9d368130673b67f6ea.tar.gz SoopyV2-91ce2e47013f18e85a08bc9d368130673b67f6ea.tar.bz2 SoopyV2-91ce2e47013f18e85a08bc9d368130673b67f6ea.zip |
+ make babel add fetch import
+ reduce hot reload cooldown
Diffstat (limited to 'babel-import-promise')
-rw-r--r-- | babel-import-promise/babel-import-promise.mjs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/babel-import-promise/babel-import-promise.mjs b/babel-import-promise/babel-import-promise.mjs index 10aee6a..24cc28f 100644 --- a/babel-import-promise/babel-import-promise.mjs +++ b/babel-import-promise/babel-import-promise.mjs @@ -25,6 +25,23 @@ export default function ({ types: t }) { const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'PromiseV2')); path.unshiftContainer('body', importDeclaration); } + + let shouldAdd2 = false + const MyVisitor2 = { + Identifier(path) { + if (path.node.name === "fetch") { + shouldAdd = true + } + } + }; + path.traverse(MyVisitor2) + if (shouldAdd2) { + let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 3 + const identifier = t.identifier('fetch'); + const importDefaultSpecifier = t.importDefaultSpecifier(identifier); + const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'utils/networkUtils')); + path.unshiftContainer('body', importDeclaration); + } } } }; |