Skip to content

Commit bd1879a

Browse files
committed
Init commit
0 parents  commit bd1879a

File tree

11 files changed

+2877
-0
lines changed

11 files changed

+2877
-0
lines changed

.flowconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[options]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
*.log

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
language: node_js
3+
node_js:
4+
- '7'
5+
cache: yarn
6+
script: yarn test

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017-present James Kyle <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# babel-file-loader
2+
3+
> Load files into memory to be parsed & traversed using [Babylon](https://github.com/babel/babylon)/Babel
4+
5+
```js
6+
import {loadImportSync} from 'babel-file-loader';
7+
8+
export function plugin() {
9+
return {
10+
visitor: {
11+
ImportDefaultDeclaration(path) {
12+
let file = loadImportSync(path);
13+
14+
file.path.traverse({
15+
ExportDefaultDeclaration() {
16+
console.log('Found matching export default');
17+
},
18+
});
19+
},
20+
},
21+
},
22+
};
23+
```
24+
25+
## API
26+
27+
#### `resolveFilePath{Async,Sync}(path, filePath, resolveOpts)`
28+
29+
Resolve a `filePath` relative to the file a `path` belongs to. Returns string.
30+
31+
#### `resolveImportFilePath{Async,Sync}(path, resolveOpts)`
32+
33+
Resolve an import declaration `path` to extract a file path. Returns string.
34+
35+
#### `loadFile{Async,Sync}(filePath, parserOpts)`
36+
37+
Load and parse a file from a `filePath`. Returns [File](https://github.com/babel-utils/babel-file).
38+
39+
#### `loadImport{Async,Sync}(path, resolveOpts, parserOpts)`
40+
41+
Load and parse a file from an import declaration `path`. Returns [File](https://github.com/babel-utils/babel-file).

fixture.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// fixture

0 commit comments

Comments
 (0)