Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/babel-utils/babel-file-loader
Load files into memory to be parsed & traversed using Babylon/Babel
https://github.com/babel-utils/babel-file-loader
babel babel-util filesystem
Last synced: about 3 hours ago
JSON representation
Load files into memory to be parsed & traversed using Babylon/Babel
- Host: GitHub
- URL: https://github.com/babel-utils/babel-file-loader
- Owner: babel-utils
- License: mit
- Created: 2017-05-25T12:43:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-14T08:10:08.000Z (about 6 years ago)
- Last Synced: 2024-03-25T20:18:56.366Z (8 months ago)
- Topics: babel, babel-util, filesystem
- Language: JavaScript
- Size: 33.2 KB
- Stars: 9
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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).