Skip to content

Commit 923435b

Browse files
authored
feat: add a babel-plugin to add extensions to imports and handle aliases (#576)
1 parent 1ff7d0c commit 923435b

File tree

20 files changed

+2096
-119
lines changed

20 files changed

+2096
-119
lines changed

.github/workflows/check-project.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ jobs:
2626
- name: Typecheck
2727
run: yarn typecheck
2828

29+
- name: Test
30+
run: yarn test
31+
2932
- name: Build packages
3033
run: yarn lerna run prepare

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"lint": "eslint \"**/*.{js,ts,tsx}\"",
1919
"typecheck": "tsc --noEmit",
2020
"watch": "concurrently 'yarn typecheck --watch' 'lerna run --parallel prepare -- --watch'",
21+
"test": "yarn workspace react-native-builder-bob test",
2122
"docs": "yarn workspace docs"
2223
},
2324
"devDependencies": {
@@ -48,7 +49,8 @@
4849
"node_modules/",
4950
"coverage/",
5051
"lib/",
51-
"templates/"
52+
"templates/",
53+
"__fixtures__/"
5254
],
5355
"prettier": {
5456
"singleQuote": true,

packages/react-native-builder-bob/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
"registry": "https://registry.npmjs.org/"
3535
},
3636
"scripts": {
37-
"prepare": "babel --extensions .ts,.tsx src --out-dir lib --source-maps --delete-dir-on-start"
37+
"prepare": "babel --extensions .ts,.tsx src --out-dir lib --source-maps --delete-dir-on-start",
38+
"test": "jest"
39+
},
40+
"jest": {
41+
"testPathIgnorePatterns": [
42+
"/lib/"
43+
]
3844
},
3945
"dependencies": {
4046
"@babel/core": "^7.18.5",
@@ -59,6 +65,7 @@
5965
},
6066
"devDependencies": {
6167
"@babel/cli": "^7.17.10",
68+
"@jest/globals": "^29.7.0",
6269
"@types/babel__core": "^7.1.19",
6370
"@types/browserslist": "^4.15.0",
6471
"@types/cross-spawn": "^6.0.2",
@@ -70,6 +77,7 @@
7077
"@types/prompts": "^2.0.14",
7178
"@types/which": "^2.0.1",
7279
"@types/yargs": "^17.0.10",
73-
"concurrently": "^7.2.2"
80+
"concurrently": "^7.2.2",
81+
"jest": "^29.7.0"
7482
}
7583
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "@";
2+
import f from "@/f";
3+
import "@something";
4+
import "./@";
5+
import "file";
6+
import { something } from "something";
7+
import "something/somefile";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "..";
2+
import f from "../f";
3+
import "@something";
4+
import "./@";
5+
import "../f";
6+
import { something } from "another";
7+
import "another/somefile";
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export * as a from "a";
2+
export * as b from "./b";
3+
export * as c from "./c";
4+
export * as d from "./d";
5+
export * as e from "./e.story";
6+
export * as f from "../f";
7+
export * as pac from "..";
8+
export * as pak from "../";
9+
export * as pax from "../index";
10+
11+
export { a as a1 } from "./a";
12+
export * from "./b";
13+
14+
export type { A } from "./a";
15+
16+
export const foo = "foo";
17+
18+
const bar = "bar";
19+
20+
export { bar };
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export * as a from "a";
2+
export * as b from "./b.mjs";
3+
export * as c from "./c.mjs";
4+
export * as d from "./d";
5+
export * as e from "./e.story.mjs";
6+
export * as f from "../f.mjs";
7+
export * as pac from "../index.mjs";
8+
export * as pak from "../index.mjs";
9+
export * as pax from "../index.mjs";
10+
export { a as a1 } from "./a.mjs";
11+
export * from "./b.mjs";
12+
export type { A } from "./a";
13+
export const foo = "foo";
14+
const bar = "bar";
15+
export { bar };
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "./a";
2+
import a from "a";
3+
import b from "./b";
4+
import c from "./c";
5+
import d from "./d";
6+
import e from "./e.story";
7+
import f from "../f";
8+
import pac from "..";
9+
import pak from "../";
10+
import pax from "../index";
11+
12+
import { a as a1 } from "./a";
13+
import * as b1 from "./b";
14+
import something, { c as c1 } from "./c";
15+
16+
import type { A } from "./a";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "./a.mjs";
2+
import a from "a";
3+
import b from "./b.mjs";
4+
import c from "./c.mjs";
5+
import d from "./d";
6+
import e from "./e.story.mjs";
7+
import f from "../f.mjs";
8+
import pac from "../index.mjs";
9+
import pak from "../index.mjs";
10+
import pax from "../index.mjs";
11+
import { a as a1 } from "./a.mjs";
12+
import * as b1 from "./b.mjs";
13+
import something, { c as c1 } from "./c.mjs";
14+
import type { A } from "./a";

packages/react-native-builder-bob/src/__fixtures__/project/code/a.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)