@kbach/native 0.1.5 → 0.1.6
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/README.md +2 -12
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -29
- package/dist/index.mjs +2 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,17 +53,7 @@ module.exports = withKbachBabel({
|
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
### 2.
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
const { getDefaultConfig } = require('expo/metro-config');
|
|
60
|
-
const { withKbach } = require('@kbach/native');
|
|
61
|
-
|
|
62
|
-
const config = getDefaultConfig(__dirname);
|
|
63
|
-
module.exports = withKbach(config);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 3. Wrap your app
|
|
56
|
+
### 2. Wrap your app
|
|
67
57
|
|
|
68
58
|
```
|
|
69
59
|
import { ThemeProvider } from '@kbach/native';
|
|
@@ -77,7 +67,7 @@ export default function App() {
|
|
|
77
67
|
}
|
|
78
68
|
```
|
|
79
69
|
|
|
80
|
-
After changing `babel.config.js
|
|
70
|
+
After changing `babel.config.js`, clear the Metro cache:
|
|
81
71
|
|
|
82
72
|
```
|
|
83
73
|
npx expo start --clear
|
package/dist/index.d.mts
CHANGED
|
@@ -34,7 +34,7 @@ interface KbachOptions {
|
|
|
34
34
|
* module.exports = withKbach(config);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
declare function withKbach(metroConfig: Record<string, any>,
|
|
37
|
+
declare function withKbach(metroConfig: Record<string, any>, _options?: KbachOptions): Record<string, any>;
|
|
38
38
|
/**
|
|
39
39
|
* Add the Kbach plugin to an existing Babel config.
|
|
40
40
|
* Use this when you have a custom babel.config.js and want to keep it.
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ interface KbachOptions {
|
|
|
34
34
|
* module.exports = withKbach(config);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
declare function withKbach(metroConfig: Record<string, any>,
|
|
37
|
+
declare function withKbach(metroConfig: Record<string, any>, _options?: KbachOptions): Record<string, any>;
|
|
38
38
|
/**
|
|
39
39
|
* Add the Kbach plugin to an existing Babel config.
|
|
40
40
|
* Use this when you have a custom babel.config.js and want to keep it.
|
package/dist/index.js
CHANGED
|
@@ -29,35 +29,8 @@ module.exports = __toCommonJS(index_exports);
|
|
|
29
29
|
__reExport(index_exports, require("@kbach/react"), module.exports);
|
|
30
30
|
|
|
31
31
|
// src/setup.ts
|
|
32
|
-
function withKbach(metroConfig,
|
|
33
|
-
|
|
34
|
-
configFile = "kbach.config.js",
|
|
35
|
-
attributes = ["tw", "className"],
|
|
36
|
-
debug = false
|
|
37
|
-
} = options;
|
|
38
|
-
const pluginEntry = ["babel-plugin-kbach", { configFile, attributes, debug }];
|
|
39
|
-
return {
|
|
40
|
-
...metroConfig,
|
|
41
|
-
transformer: {
|
|
42
|
-
...metroConfig.transformer ?? {},
|
|
43
|
-
getTransformOptions: wrapTransformOptions(
|
|
44
|
-
metroConfig.transformer?.getTransformOptions,
|
|
45
|
-
pluginEntry
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function wrapTransformOptions(existing, pluginEntry) {
|
|
51
|
-
return async function getTransformOptions(...args) {
|
|
52
|
-
const base = existing ? await existing(...args) : {};
|
|
53
|
-
const existingPlugins = base.transform?.customTransformOptions?.babelPlugins ?? [];
|
|
54
|
-
base.transform = base.transform ?? {};
|
|
55
|
-
base.transform.customTransformOptions = {
|
|
56
|
-
...base.transform.customTransformOptions ?? {},
|
|
57
|
-
babelPlugins: [pluginEntry, ...existingPlugins]
|
|
58
|
-
};
|
|
59
|
-
return base;
|
|
60
|
-
};
|
|
32
|
+
function withKbach(metroConfig, _options = {}) {
|
|
33
|
+
return metroConfig;
|
|
61
34
|
}
|
|
62
35
|
function withKbachBabel(babelConfig, options = {}) {
|
|
63
36
|
const {
|
package/dist/index.mjs
CHANGED
|
@@ -2,35 +2,8 @@
|
|
|
2
2
|
export * from "@kbach/react";
|
|
3
3
|
|
|
4
4
|
// src/setup.ts
|
|
5
|
-
function withKbach(metroConfig,
|
|
6
|
-
|
|
7
|
-
configFile = "kbach.config.js",
|
|
8
|
-
attributes = ["tw", "className"],
|
|
9
|
-
debug = false
|
|
10
|
-
} = options;
|
|
11
|
-
const pluginEntry = ["babel-plugin-kbach", { configFile, attributes, debug }];
|
|
12
|
-
return {
|
|
13
|
-
...metroConfig,
|
|
14
|
-
transformer: {
|
|
15
|
-
...metroConfig.transformer ?? {},
|
|
16
|
-
getTransformOptions: wrapTransformOptions(
|
|
17
|
-
metroConfig.transformer?.getTransformOptions,
|
|
18
|
-
pluginEntry
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function wrapTransformOptions(existing, pluginEntry) {
|
|
24
|
-
return async function getTransformOptions(...args) {
|
|
25
|
-
const base = existing ? await existing(...args) : {};
|
|
26
|
-
const existingPlugins = base.transform?.customTransformOptions?.babelPlugins ?? [];
|
|
27
|
-
base.transform = base.transform ?? {};
|
|
28
|
-
base.transform.customTransformOptions = {
|
|
29
|
-
...base.transform.customTransformOptions ?? {},
|
|
30
|
-
babelPlugins: [pluginEntry, ...existingPlugins]
|
|
31
|
-
};
|
|
32
|
-
return base;
|
|
33
|
-
};
|
|
5
|
+
function withKbach(metroConfig, _options = {}) {
|
|
6
|
+
return metroConfig;
|
|
34
7
|
}
|
|
35
8
|
function withKbachBabel(babelConfig, options = {}) {
|
|
36
9
|
const {
|
package/package.json
CHANGED