vite-plugin-rnw 0.0.8 → 0.0.9
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/dist/index.js +21 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -99,21 +99,30 @@ function transformReanimatedWebUtilsWithMap(code, id, isProduction, opts) {
|
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/index.ts
|
|
101
101
|
const extensions = [
|
|
102
|
+
".web.mjs",
|
|
102
103
|
".web.js",
|
|
104
|
+
".web.mts",
|
|
103
105
|
".web.ts",
|
|
104
106
|
".web.tsx",
|
|
105
|
-
".web.mjs",
|
|
106
107
|
".web.cjs",
|
|
108
|
+
".mjs",
|
|
107
109
|
".js",
|
|
108
110
|
".jsx",
|
|
109
111
|
".json",
|
|
112
|
+
".mts",
|
|
110
113
|
".ts",
|
|
111
114
|
".tsx",
|
|
112
|
-
".mjs",
|
|
113
115
|
".cjs"
|
|
114
116
|
];
|
|
115
117
|
const defaultIncludeRE = /\.[tj]sx?$/;
|
|
116
118
|
const defaultExcludeRE = /\/node_modules\/(?!react-native|@react-native|expo|@expo)/;
|
|
119
|
+
const getJsxOption = (jsxRuntime) => {
|
|
120
|
+
const jsxOptionMapping = {
|
|
121
|
+
automatic: "automatic",
|
|
122
|
+
classic: "transform"
|
|
123
|
+
};
|
|
124
|
+
return jsxRuntime && jsxRuntime in jsxOptionMapping ? jsxOptionMapping[jsxRuntime] : "automatic";
|
|
125
|
+
};
|
|
117
126
|
function rnw(opts = {}) {
|
|
118
127
|
const include = opts.include ?? defaultIncludeRE;
|
|
119
128
|
const exclude = opts.exclude ?? defaultExcludeRE;
|
|
@@ -139,6 +148,8 @@ function rnw(opts = {}) {
|
|
|
139
148
|
},
|
|
140
149
|
optimizeDeps: { esbuildOptions: {
|
|
141
150
|
resolveExtensions: extensions,
|
|
151
|
+
jsx: getJsxOption(opts.jsxRuntime),
|
|
152
|
+
jsxImportSource: opts.jsxImportSource,
|
|
142
153
|
loader: {
|
|
143
154
|
".js": "jsx",
|
|
144
155
|
".mjs": "jsx"
|
|
@@ -185,10 +196,14 @@ function rnw(opts = {}) {
|
|
|
185
196
|
{
|
|
186
197
|
name: "treat-js-files-as-jsx",
|
|
187
198
|
async transform(code, id) {
|
|
188
|
-
if (id.match(/\.js$/) || id.match(/\.mjs$/))
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
199
|
+
if (id.match(/\.js$/) || id.match(/\.mjs$/)) {
|
|
200
|
+
const jsxOption = getJsxOption(opts.jsxRuntime);
|
|
201
|
+
return vite.transformWithEsbuild(code, id, {
|
|
202
|
+
loader: "jsx",
|
|
203
|
+
jsx: jsxOption,
|
|
204
|
+
jsxImportSource: opts.jsxImportSource
|
|
205
|
+
});
|
|
206
|
+
}
|
|
192
207
|
return null;
|
|
193
208
|
}
|
|
194
209
|
},
|
package/package.json
CHANGED