vite-plugin-rnw 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -95,6 +95,43 @@ function transformReanimatedWebUtilsWithMap(code, id, isProduction, opts) {
95
95
  changed: true
96
96
  };
97
97
  }
98
+ /**
99
+ * Transforms react-native-css-interop doctor check to always return true.
100
+ * Looks for:
101
+ * return <react-native-css-interop-jsx-pragma-check /> === true;
102
+ * in node_modules/react-native-css-interop/dist/doctor.js and replaces with:
103
+ * return true;
104
+ */
105
+ function transformCssInteropDoctorCheck(code, id, opts) {
106
+ if (!id.includes("node_modules/react-native-css-interop/dist/doctor.js")) return {
107
+ code,
108
+ map: null,
109
+ changed: false
110
+ };
111
+ const pattern = /return\s*<react-native-css-interop-jsx-pragma-check\s*\/>\s*===\s*true\s*;/g;
112
+ if (!pattern.test(code)) return {
113
+ code,
114
+ map: null,
115
+ changed: false
116
+ };
117
+ const ms = new MagicString(code);
118
+ let match;
119
+ pattern.lastIndex = 0;
120
+ while ((match = pattern.exec(code)) !== null) {
121
+ const start = match.index;
122
+ const end = start + match[0].length;
123
+ ms.overwrite(start, end, "return true;");
124
+ }
125
+ return {
126
+ code: ms.toString(),
127
+ map: ms.generateMap({
128
+ source: (opts === null || opts === void 0 ? void 0 : opts.source) ?? id.split("?")[0],
129
+ includeContent: true,
130
+ hires: true
131
+ }),
132
+ changed: true
133
+ };
134
+ }
98
135
 
99
136
  //#endregion
100
137
  //#region src/index.ts
@@ -182,6 +219,11 @@ function rnw(opts = {}) {
182
219
  async handler(code, id, options) {
183
220
  const [filepath] = id.split("?");
184
221
  if (!filter(filepath)) return;
222
+ const cssInteropResult = transformCssInteropDoctorCheck(code, id, { source: filepath });
223
+ if (cssInteropResult.changed) return {
224
+ code: cssInteropResult.code,
225
+ map: cssInteropResult.map
226
+ };
185
227
  const transformResult = transformReanimatedWebUtilsWithMap(code, id, isProduction, { source: filepath });
186
228
  if (!transformResult.changed) return null;
187
229
  return {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.9",
2
+ "version": "0.0.10",
3
3
  "name": "vite-plugin-rnw",
4
4
  "type": "module",
5
5
  "author": "Daniel Williams",