@kbach/native 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +58 -58
- package/src/babel-plugin/index.js +9 -34
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kbach/native",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Single-package Kbach install for React Native and Expo — includes core, components, Babel plugin, and Metro config",
|
|
5
|
-
"source": "./src/index.ts",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"source": "./src/index.ts",
|
|
13
|
-
"import": "./dist/index.mjs",
|
|
14
|
-
"require": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./jsx-runtime": {
|
|
17
|
-
"types": "./dist/jsx-runtime.d.ts",
|
|
18
|
-
"source": "./src/jsx-runtime.ts",
|
|
19
|
-
"import": "./dist/jsx-runtime.mjs",
|
|
20
|
-
"require": "./dist/jsx-runtime.js"
|
|
21
|
-
},
|
|
22
|
-
"./jsx-dev-runtime": {
|
|
23
|
-
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
24
|
-
"source": "./src/jsx-dev-runtime.ts",
|
|
25
|
-
"import": "./dist/jsx-dev-runtime.mjs",
|
|
26
|
-
"require": "./dist/jsx-dev-runtime.js"
|
|
27
|
-
},
|
|
28
|
-
"./babel-plugin": "./src/babel-plugin/index.js",
|
|
29
|
-
"./babel": "./src/babel/index.js"
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsup src/index.ts src/jsx-runtime.ts src/jsx-dev-runtime.ts --format esm,cjs --dts --clean",
|
|
33
|
-
"dev": "tsup src/index.ts src/jsx-runtime.ts src/jsx-dev-runtime.ts --format esm,cjs --dts --watch",
|
|
34
|
-
"test": "jest --passWithNoTests",
|
|
35
|
-
"lint": "tsc --noEmit"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@kbach/react": "0.1
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/react": "^19.2.0",
|
|
42
|
-
"tsup": "^8.0.0"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"@babel/core": "^7.0.0",
|
|
46
|
-
"react": ">=17.0.0",
|
|
47
|
-
"react-native": ">=0.70.0"
|
|
48
|
-
},
|
|
49
|
-
"peerDependenciesMeta": {
|
|
50
|
-
"@babel/core": { "optional": true },
|
|
51
|
-
"react-native": { "optional": true }
|
|
52
|
-
},
|
|
53
|
-
"publishConfig": {
|
|
54
|
-
"access": "public"
|
|
55
|
-
},
|
|
56
|
-
"files": ["dist", "src/babel-plugin", "src/babel"],
|
|
57
|
-
"keywords": ["react-native", "expo", "tailwind", "css-in-js", "styling", "framework", "frontend", "mobile"]
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@kbach/native",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Single-package Kbach install for React Native and Expo — includes core, components, Babel plugin, and Metro config",
|
|
5
|
+
"source": "./src/index.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"source": "./src/index.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./jsx-runtime": {
|
|
17
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
18
|
+
"source": "./src/jsx-runtime.ts",
|
|
19
|
+
"import": "./dist/jsx-runtime.mjs",
|
|
20
|
+
"require": "./dist/jsx-runtime.js"
|
|
21
|
+
},
|
|
22
|
+
"./jsx-dev-runtime": {
|
|
23
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
24
|
+
"source": "./src/jsx-dev-runtime.ts",
|
|
25
|
+
"import": "./dist/jsx-dev-runtime.mjs",
|
|
26
|
+
"require": "./dist/jsx-dev-runtime.js"
|
|
27
|
+
},
|
|
28
|
+
"./babel-plugin": "./src/babel-plugin/index.js",
|
|
29
|
+
"./babel": "./src/babel/index.js"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup src/index.ts src/jsx-runtime.ts src/jsx-dev-runtime.ts --format esm,cjs --dts --clean",
|
|
33
|
+
"dev": "tsup src/index.ts src/jsx-runtime.ts src/jsx-dev-runtime.ts --format esm,cjs --dts --watch",
|
|
34
|
+
"test": "jest --passWithNoTests",
|
|
35
|
+
"lint": "tsc --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@kbach/react": "0.2.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/react": "^19.2.0",
|
|
42
|
+
"tsup": "^8.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@babel/core": "^7.0.0",
|
|
46
|
+
"react": ">=17.0.0",
|
|
47
|
+
"react-native": ">=0.70.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@babel/core": { "optional": true },
|
|
51
|
+
"react-native": { "optional": true }
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"files": ["dist", "src/babel-plugin", "src/babel"],
|
|
57
|
+
"keywords": ["react-native", "expo", "tailwind", "css-in-js", "styling", "framework", "frontend", "mobile"]
|
|
58
|
+
}
|
|
@@ -112,41 +112,16 @@ module.exports = function kbachBabelPlugin(api, options = {}) {
|
|
|
112
112
|
return {
|
|
113
113
|
name: 'babel-plugin-kbach',
|
|
114
114
|
|
|
115
|
-
//
|
|
115
|
+
// JSX runtime setup: pre() injects a @jsxImportSource comment so that
|
|
116
|
+
// @babel/plugin-transform-react-jsx (from babel-preset-expo or any React preset)
|
|
117
|
+
// uses @kbach/native/jsx-runtime. Our pre() runs before the preset's pre(), so the
|
|
118
|
+
// comment is in place when the JSX transform reads it.
|
|
116
119
|
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// 2. If there is NO React preset, we add @babel/plugin-transform-react-jsx ourselves
|
|
123
|
-
// (pushed after kbach so kbach's JSXAttribute visitor runs first).
|
|
124
|
-
manipulateOptions(opts) {
|
|
125
|
-
const presets = opts.presets || [];
|
|
126
|
-
const hasReactPreset = presets.some(p => {
|
|
127
|
-
const name = Array.isArray(p) ? p[0] : p;
|
|
128
|
-
return (
|
|
129
|
-
typeof name === 'string' &&
|
|
130
|
-
(name.includes('babel-preset-expo') || name.includes('preset-react'))
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
if (hasReactPreset) return; // pre() comment pragma handles it
|
|
135
|
-
|
|
136
|
-
// No preset — add the JSX transform plugin directly so JSX files work
|
|
137
|
-
// without any manual configuration.
|
|
138
|
-
const plugins = opts.plugins || (opts.plugins = []);
|
|
139
|
-
const hasJsxTransform = plugins.some(p => {
|
|
140
|
-
const n = Array.isArray(p) ? p[0] : p;
|
|
141
|
-
return typeof n === 'string' && n.includes('transform-react-jsx');
|
|
142
|
-
});
|
|
143
|
-
if (!hasJsxTransform) {
|
|
144
|
-
plugins.push([
|
|
145
|
-
require.resolve('@babel/plugin-transform-react-jsx'),
|
|
146
|
-
{ runtime: 'automatic', importSource: '@kbach/native' },
|
|
147
|
-
]);
|
|
148
|
-
}
|
|
149
|
-
},
|
|
120
|
+
// NOTE: Do NOT add plugins dynamically inside manipulateOptions. By the time
|
|
121
|
+
// manipulateOptions runs, opts.presets has already been resolved from strings to
|
|
122
|
+
// functions — preset detection by name is impossible — and pushing a new entry into
|
|
123
|
+
// opts.plugins at that stage produces an uninstantiated plugin with visitor: undefined,
|
|
124
|
+
// which crashes @babel/traverse's visitors.merge().
|
|
150
125
|
|
|
151
126
|
pre(file) {
|
|
152
127
|
// Skip node_modules — they have their own JSX runtime configuration
|