Socket
Socket
Sign inDemoInstall

babel-plugin-reshow-import-extension

Package Overview
Dependencies
55
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

9

package.json
{
"version": "0.0.4",
"version": "0.0.5",
"name": "babel-plugin-reshow-import-extension",

@@ -11,3 +11,8 @@ "repository": {

"description": "TODO: description",
"keywords": [],
"keywords": [
"Add import extension",
"Add import extensionis",
"Replace import extension",
"Replace import extensionis"
],
"author": "Hill <hill@kimo.com>",

@@ -14,0 +19,0 @@ "license": "ISC",

# `babel-plugin-reshow-import-extension`
> TODO: description
> A tool help u add or replace local import extensions.

@@ -13,4 +13,20 @@ ## Repository

* `Add Import Extensions`
```js
plugins: [
["reshow-import-extension", { extMapping: {"": "js"} }], // will add js extension
];
```
* `Replace Import Extensions`
```js
plugins: [
["reshow-import-extension", { extMapping: {"js": "mjs"} }], // will replace js extension with mjs
];
```
* Whole babel.config.js
https://github.com/react-atomic/react-atomic-atom/blob/main/babel.config.js

@@ -26,11 +26,6 @@ const { parseSync } = require("@babel/core");

visitor: {
ImportDeclaration(path, state) {
resetNodeSource(path, state);
},
ImportDeclaration: resetNodeSource,
ExportAllDeclaration: resetNodeSource,
ExportNamedDeclaration: resetNodeSource,
// For re-exporting
"ExportNamedDeclaration|ExportAllDeclaration"(path, state) {
resetNodeSource(path, state);
},
// For dynamic import

@@ -42,11 +37,11 @@ CallExpression(path, state) {

}
if (!path.node.callee || path.node.callee.type !== "Import") {
if (!path.get("callee").isImport()) {
return;
}
const argument = path.get("arguments.0");
const nextPath = resolveExt(argument.node.quasis[0].value.raw, {
const arg = path.get("arguments.0");
const nextPath = resolveExt(arg.node.quasis[0].value.raw, {
...extMap,
});
argument.replaceWithSourceString(`"${nextPath}"`);
arg.replaceWithSourceString(`"${nextPath}"`);
},

@@ -53,0 +48,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc