@kbach/react-native 1.0.0-beta.32 → 1.0.0-beta.33
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 +1 -1
- package/src/babel-plugin.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/react-native",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.33",
|
|
4
4
|
"description": "Kbach's utility-class styling engine for React Native — the same class names as @kbach/react, resolved to a StyleSheet-ready style object via a Kotlin/JNI TurboModule (native), the same WASM engine @kbach/react uses (Expo Web / react-native-web), or a pure-JS fallback engine (Expo Go). Ships its own native Android module — one npm install, no separate native package. Beta. Native is Android-only (no iOS bridge yet); works with the React Native CLI, an Expo dev client, AND Expo Go (a reduced-coverage pure-JS fallback, since Expo Go can't load any custom native module).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
package/src/babel-plugin.js
CHANGED
|
@@ -124,6 +124,36 @@ module.exports = function kbachReactNativeBabelPlugin(_babel, options) {
|
|
|
124
124
|
const filename = file.opts && file.opts.filename;
|
|
125
125
|
if (filename && filename.indexOf('node_modules') !== -1) return;
|
|
126
126
|
|
|
127
|
+
// Metro/Expo's own internal polyfills (the Node.js-external-require
|
|
128
|
+
// shim, the assets-registry shim, node:/weak-ref virtualizations, ...)
|
|
129
|
+
// are synthetic "virtual modules" with no real file on disk. Expo's
|
|
130
|
+
// own Metro config marks every one of these with an embedded NUL
|
|
131
|
+
// control character in its module ID (Rollup's/Metro's own
|
|
132
|
+
// convention for "this isn't a real file"). These never sit inside
|
|
133
|
+
// node_modules, so the check above doesn't catch them — and Metro
|
|
134
|
+
// places them directly in the bundle PRELUDE, entirely outside any
|
|
135
|
+
// wrapped module, where `require` isn't defined as a real function
|
|
136
|
+
// at all. Confirmed as a real, reproducible runtime crash (not a
|
|
137
|
+
// hypothetical): injecting this plugin's applyKbachConfig() require()
|
|
138
|
+
// call into that exact polyfill produced Expo's own "[runtime not
|
|
139
|
+
// ready]: ReferenceError: Property 'require' doesn't exist" at app
|
|
140
|
+
// startup, verified by exporting a real dev bundle and finding the
|
|
141
|
+
// offending, un-instrumented require() call sitting inside
|
|
142
|
+
// withMetroMultiPlatform.js's own external-require polyfill — a file
|
|
143
|
+
// this plugin was never meant to touch at all.
|
|
144
|
+
//
|
|
145
|
+
// The control character is NOT at the start of `filename`, so
|
|
146
|
+
// `startsWith`/`charCodeAt(0)` (what an earlier version of this
|
|
147
|
+
// check used) never matches — confirmed by actually logging Babel's
|
|
148
|
+
// real `filename` for this file, not assumed: Metro joins the
|
|
149
|
+
// project root onto the raw virtual module ID first, so the control
|
|
150
|
+
// character ends up in the MIDDLE of the full string, right after
|
|
151
|
+
// the trailing path separator, not at index 0. A search anywhere in
|
|
152
|
+
// the string (rather than just its start) is what actually catches
|
|
153
|
+
// it — see this file's own test suite for the exact filename shape
|
|
154
|
+
// this was verified against.
|
|
155
|
+
if (filename && filename.indexOf(String.fromCharCode(0)) !== -1) return;
|
|
156
|
+
|
|
127
157
|
const comments = file.ast.comments || (file.ast.comments = []);
|
|
128
158
|
const alreadySet = comments.some((c) => /@jsxImportSource|@jsxRuntime/.test(c.value));
|
|
129
159
|
if (!alreadySet) {
|