# babel-file-loader

> Load files into memory to be parsed & traversed using Babylon/Babel

Latest version **2.0.0** (published 2018-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-file-loader
pnpm add babel-file-loader
yarn add babel-file-loader
bun add babel-file-loader
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-08-13 |
| First published | 2017-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Kyle |
| Maintainers | thejameskyle |

## Links

- npm: https://www.npmjs.com/package/babel-file-loader
- Repository: https://github.com/thejameskyle/babel-multi-file
- Homepage: https://github.com/thejameskyle/babel-multi-file#readme
- Issues: https://github.com/thejameskyle/babel-multi-file/issues
- npm.io page: https://npm.io/package/babel-file-loader

## Dependencies (7)

- [resolve](https://npm.io/package/resolve.md) ^1.3.3
- [babel-file](https://npm.io/package/babel-file.md) ^3.0.0
- [babel-types](https://npm.io/package/babel-types.md) ^6.24.1
- [babel-errors](https://npm.io/package/babel-errors.md) ^1.0.1
- [resolve-async](https://npm.io/package/resolve-async.md) ^1.0.1
- [read-file-async](https://npm.io/package/read-file-async.md) ^1.0.0
- [babel-plugin-tester](https://npm.io/package/babel-plugin-tester.md) ^3.0.0

## Recent versions

- 2.0.0 (latest) — 2018-08-13
- 1.0.3 — 2017-08-08
- 1.0.2 — 2017-05-29
- 1.0.1 — 2017-05-27
- 1.0.0 — 2017-05-25

## README

# babel-file-loader

> Load files into memory to be parsed & traversed using [Babylon](https://github.com/babel/babylon)/Babel

```js
import {loadImportSync} from 'babel-file-loader';

export function plugin() {
  return {
    visitor: {
      ImportDefaultDeclaration(path) {
        let file = loadImportSync(path);

        file.path.traverse({
          ExportDefaultDeclaration() {
            console.log('Found matching export default');
          },
        });
      },
    },
  },
};
```

## API

#### `resolveFilePath{Async,Sync}(path, filePath, resolveOpts)`

Resolve a `filePath` relative to the file a `path` belongs to. Returns string.

#### `resolveImportFilePath{Async,Sync}(path, resolveOpts)`

Resolve an import declaration `path` to extract a file path. Returns string.

#### `loadFile{Async,Sync}(filePath, parserOpts)`

Load and parse a file from a `filePath`. Returns [File](https://github.com/babel-utils/babel-file).

#### `loadImport{Async,Sync}(path, resolveOpts, parserOpts)`

Load and parse a file from an import declaration `path`. Returns [File](https://github.com/babel-utils/babel-file).

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