Skip to content

Commit 8c9fe7d

Browse files
authored
fix(babel-plugin): new build process (#4)
1 parent a546012 commit 8c9fe7d

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/src/
2-
/babel-plugin/
32
.github/
43
node_modules/
54
bun.lock

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ https://github.com/user-attachments/assets/dffe5803-fb6a-4b45-9621-48cbbdb25ad2
8585

8686
- React Native 0.79+
8787
- React 19+
88+
- Node 18+
8889

8990
## License
9091

babel-plugin/preview-babel-plugin-metadata.ts renamed to babel-plugin/preview-babel-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PluginObj } from "@babel/core";
22
import { NodePath } from "@babel/traverse";
33
import * as t from "@babel/types";
4-
import path from "path";
4+
import path from "node:path";
55
import { isInsideReactComponent } from "./react-helper";
66

77
/**

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
"types": "./dist/react-native.d.ts",
99
"exports": {
1010
".": {
11+
"types": "./dist/react-native.d.ts",
1112
"import": "./dist/react-native.js",
12-
"require": "./dist/react-native.cjs",
13-
"types": "./dist/react-native.d.ts"
13+
"require": "./dist/react-native.cjs"
1414
},
15-
"./babel-plugin": "./dist/babel-plugin/preview-babel-plugin-metadata.js"
15+
"./babel-plugin": {
16+
"require": "./dist/preview-babel-plugin.cjs",
17+
"import": "./dist/preview-babel-plugin.js"
18+
}
1619
},
1720
"scripts": {
18-
"prepublishOnly": "bun run build",
21+
"prepublishOnly": "bun run build && bun run build:babel-plugin",
1922
"semantic-release": "semantic-release",
20-
"build": "rozenite build && tsc --project tsconfig.babel-plugin.json",
23+
"build": "rozenite build",
24+
"build:babel-plugin": "vite build --config vite.babel-plugin.config.ts",
2125
"dev": "rozenite dev"
2226
},
2327
"repository": {

tsconfig.babel-plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"isolatedModules": true,
1313
"noEmit": false
1414
},
15-
"include": ["babel-plugin/preview-babel-plugin-metadata.ts", "babel-plugin/react-helper.ts"],
15+
"include": ["babel-plugin/preview-babel-plugin.ts", "babel-plugin/react-helper.ts"],
1616
"exclude": ["node_modules", "dist", "build"]
1717
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"react-native.ts",
2323
"rozenite.config.ts"
2424
],
25-
"exclude": ["node_modules", "dist", "build", "babel-plugin"]
25+
"exclude": ["node_modules", "dist", "build"]
2626
}

vite.babel-plugin.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { resolve } from "node:path";
2+
import { defineConfig } from "vite";
3+
4+
export default defineConfig({
5+
root: __dirname,
6+
base: "./",
7+
build: {
8+
outDir: "./dist",
9+
target: "node18",
10+
emptyOutDir: false,
11+
reportCompressedSize: false,
12+
minify: true,
13+
sourcemap: false,
14+
lib: {
15+
entry: resolve(__dirname, "babel-plugin/preview-babel-plugin.ts"),
16+
formats: ["es" as const, "cjs" as const],
17+
fileName: "preview-babel-plugin",
18+
},
19+
rollupOptions: {
20+
external: [/^node:.*$/, /^@babel\/.*$/],
21+
},
22+
},
23+
});

vite.config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/// <reference types='vitest' />
2-
import { defineConfig } from 'vite';
3-
import { rozenitePlugin } from '@rozenite/vite-plugin';
1+
import { rozenitePlugin } from "@rozenite/vite-plugin";
2+
import { defineConfig } from "vite";
43

54
export default defineConfig({
65
root: __dirname,
76
plugins: [rozenitePlugin()],
8-
base: './',
7+
base: "./",
98
build: {
10-
outDir: './dist',
9+
outDir: "./dist",
1110
emptyOutDir: false,
1211
reportCompressedSize: false,
1312
minify: true,

0 commit comments

Comments
 (0)