# babel-plugin-import-to-string

> import 路径转换为字符串

Latest version **0.0.1** (published 2023-07-14) · 0 weekly downloads

## Install

```sh
npm install babel-plugin-import-to-string
pnpm add babel-plugin-import-to-string
yarn add babel-plugin-import-to-string
bun add babel-plugin-import-to-string
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-07-14 |
| First published | 2023-07-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zfitness |
| Maintainers | zfitness |
| Keywords | import, babel, babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-import-to-string
- Repository: https://github.com/zfitness/babel-plugin-import-to-string
- npm.io page: https://npm.io/package/babel-plugin-import-to-string

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.10.5

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-07-14

## README

# babel-plugin-import-to-string

将 import 语句中的路径提取出来。

----

## Example

#### 转换前

```javascript
import otherRouter from "./otherRouter";
import Cmp from "./Cmp";

/* -------------------------- 首页 -------------------------- */
const index = () => import("../pages/home/index.vue");
const home = () => import("../pages/home/home.vue");

const routes = [
  {
    path: "*",
    redirect: "/home",
    menu: false,
    component: Cmp,
  },
  {
    path: "/index",
    name: "index",
    component: index,
    text: "首页",
    menu: true,
  },
  ...otherRouter
];


export default routes;
```
#### 配置文件
* babelrc

```javascript
{
  "plugins": [
    [
      "babel-plugin-import-to-string",
      {
        "ignoreImport": ["./otherRouter", "../pages/home/home.vue"]
      }
    ]
  ],
  "presets": []
}


```


#### 转换后

```javascript
import otherRouter from "./otherRouter";
const Cmp = "./Cmp";
/* -------------------------- 首页 -------------------------- */
const index = "../pages/home/index.vue";
const home = () => import("../pages/home/home.vue");
const routes = [{
  path: "*",
  redirect: "/home",
  menu: false,
  component: Cmp
}, {
  path: "/index",
  name: "index",
  component: index,
  text: "首页",
  menu: true
}, ...otherRouter];
export default routes;
```

---
_Source: https://npm.io/package/babel-plugin-import-to-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
