vite-plugin-rnw 0.0.11 → 0.0.12

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.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  import { Options } from "@vitejs/plugin-react";
3
-
4
3
  //#region src/index.d.ts
5
4
  type RnwOptions = Options;
6
5
  declare function rnw(opts?: RnwOptions): Array<Plugin | Plugin[]>;
package/dist/index.mjs CHANGED
@@ -237,6 +237,24 @@ const extensions = [
237
237
  ];
238
238
  const defaultIncludeRE = /\.[tj]sx?$/;
239
239
  const defaultExcludeRE = /\/node_modules\/(?!react-native|@react-native|expo|@expo)/;
240
+ const expoWebDefines = {
241
+ EXPO_OS: JSON.stringify("web"),
242
+ "process.env.EXPO_OS": JSON.stringify("web")
243
+ };
244
+ const getRuntimeDefines = (mode) => {
245
+ const development = mode === "development";
246
+ return {
247
+ global: "window",
248
+ DEV: JSON.stringify(development),
249
+ "global.__x": "{}",
250
+ _frameTimestamp: "undefined",
251
+ _WORKLET: "false",
252
+ __DEV__: JSON.stringify(development),
253
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || mode),
254
+ ...expoWebDefines,
255
+ "global.Error": "Error"
256
+ };
257
+ };
240
258
  const getJsxOption = (jsxRuntime) => {
241
259
  const jsxOptionMapping = {
242
260
  automatic: "automatic",
@@ -271,13 +289,17 @@ function getBuildOptions() {
271
289
  plugins: [treeshakePlugin]
272
290
  } };
273
291
  }
274
- function getOptimizeDepsOptions(opts) {
292
+ function getOptimizeDepsOptions(opts, defines) {
275
293
  if (shouldUseRollDown) return { rolldownOptions: {
294
+ shimMissingExports: true,
276
295
  resolve: { extensions },
277
- transform: { jsx: {
278
- importSource: opts.jsxImportSource,
279
- runtime: opts.jsxRuntime
280
- } },
296
+ transform: {
297
+ define: defines,
298
+ jsx: {
299
+ importSource: opts.jsxImportSource,
300
+ runtime: opts.jsxRuntime
301
+ }
302
+ },
281
303
  moduleTypes: {
282
304
  ".js": "jsx",
283
305
  ".mjs": "jsx"
@@ -285,6 +307,7 @@ function getOptimizeDepsOptions(opts) {
285
307
  plugins: [rollDownFlowPlugin(/* @__PURE__ */ new RegExp(/\.(flow|jsx?)$/), (_path) => "jsx")]
286
308
  } };
287
309
  return { esbuildOptions: {
310
+ define: defines,
288
311
  resolveExtensions: extensions,
289
312
  jsx: getJsxOption(opts.jsxRuntime),
290
313
  jsxImportSource: opts.jsxImportSource,
@@ -304,21 +327,10 @@ function rnw(opts = {}) {
304
327
  name: "vite:react-native-web-babel",
305
328
  enforce: "pre",
306
329
  config(_userConfig, { mode }) {
307
- const development = mode === "development";
330
+ const defines = getRuntimeDefines(mode);
308
331
  return {
309
- define: {
310
- global: "window",
311
- DEV: JSON.stringify(development),
312
- "global.__x": {},
313
- _frameTimestamp: void 0,
314
- _WORKLET: false,
315
- __DEV__: JSON.stringify(development),
316
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || mode),
317
- EXPO_OS: JSON.stringify("web"),
318
- "process.env.EXPO_OS": JSON.stringify("web"),
319
- "global.Error": "Error"
320
- },
321
- optimizeDeps: getOptimizeDepsOptions(opts),
332
+ define: defines,
333
+ optimizeDeps: getOptimizeDepsOptions(opts, defines),
322
334
  build: getBuildOptions(),
323
335
  resolve: {
324
336
  extensions,
@@ -334,7 +346,7 @@ function rnw(opts = {}) {
334
346
  include: makeIdFiltersToMatchWithQuery(include),
335
347
  exclude: makeIdFiltersToMatchWithQuery(exclude)
336
348
  } },
337
- async handler(code, id, options) {
349
+ async handler(code, id, _options) {
338
350
  const [filepath] = id.split("?");
339
351
  if (!filter(filepath)) return;
340
352
  const cssInteropResult = transformCssInteropDoctorCheck(code, id, { source: filepath });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
- "version": "0.0.11",
2
+ "version": "0.0.12",
3
3
  "name": "vite-plugin-rnw",
4
4
  "type": "module",
5
5
  "author": "Daniel Williams",
6
+ "license": "MIT",
6
7
  "description": "Vite plugin for React Native Web",
7
8
  "keywords": [
8
9
  "vite",
@@ -27,12 +28,14 @@
27
28
  "type": "git",
28
29
  "url": "git+https://github.com/dannyhw/vite-plugin-rnw.git"
29
30
  },
31
+ "homepage": "https://github.com/dannyhw/vite-plugin-rnw#readme",
30
32
  "bugs": {
31
33
  "url": "https://github.com/dannyhw/vite-plugin-rnw/issues"
32
34
  },
33
35
  "scripts": {
34
36
  "dev": "tsdown --watch",
35
37
  "build": "tsdown",
38
+ "typecheck": "tsc --noEmit -p tsconfig.json",
36
39
  "prepublishOnly": "npm run build",
37
40
  "test": "node --no-warnings --experimental-strip-types --test --experimental-test-coverage src/**/*.test.ts",
38
41
  "test:watch": "node --no-warnings --experimental-strip-types --test --watch src/**/*.test.ts"
@@ -41,20 +44,20 @@
41
44
  "node": "^14.18.0 || >=16.0.0"
42
45
  },
43
46
  "devDependencies": {
44
- "@types/node": "^22",
45
- "tsdown": "^0.21.2",
46
- "vite": "^8.0.0"
47
+ "@types/node": "^26.1.1",
48
+ "tsdown": "^0.22.9",
49
+ "typescript": "~7.0.2",
50
+ "vite": "^8.1.5"
47
51
  },
48
52
  "peerDependencies": {
49
53
  "react-native-web": "*",
50
- "typescript": "^5",
51
54
  "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
52
55
  },
53
56
  "dependencies": {
54
- "flow-remove-types": "^2.305.0",
55
- "@rolldown/pluginutils": "^1.0.0-rc.9",
57
+ "@rolldown/pluginutils": "^1.0.1",
56
58
  "@vitejs/plugin-react": "^5.2.0",
57
- "magic-string": "^0.30.21",
59
+ "flow-remove-types": "^2.322.0",
60
+ "magic-string": "^1.0.0",
58
61
  "vite-plugin-commonjs": "^0.10.4"
59
62
  }
60
63
  }