vite-plugin-react-native-web 1.0.2 → 1.1.0

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 CHANGED
@@ -26,10 +26,10 @@ export default defineConfig({
26
26
 
27
27
  If you are getting errors please report them in the issues section.
28
28
 
29
- The following variables are transformed by the plugin:
30
- - `global` is transformed to `window`
31
- - `__DEV__` is transformed to `JSON.stringify(process.env.NODE_ENV === 'development')`
32
- - `process.env.NODE_ENV` is transformed to `JSON.stringify(process.env.NODE_ENV)`
29
+ The following variables are defined in the transformed files: (inferred during Vite's build process)
30
+ - `global` as `window`
31
+ - `__DEV__` as `process.env.NODE_ENV === 'development'`
32
+ - `process.env.NODE_ENV` as `process.env.NODE_ENV`
33
33
 
34
34
  ## Contributing
35
35
  Please feel free to contribute to this project. Just fork it and submit a PR.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-native-web",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/dist/cjs/index.js DELETED
@@ -1,73 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var vite = require('vite');
6
- var flowRemoveTypes = require('flow-remove-types');
7
- var fs = require('fs/promises');
8
-
9
- // import type { ViteReactNativeWebOptions } from '../types'
10
- const development = process.env.NODE_ENV === 'development';
11
- const extensions = [
12
- '.web.mjs',
13
- '.mjs',
14
- '.web.js',
15
- '.js',
16
- '.web.mts',
17
- '.mts',
18
- '.web.ts',
19
- '.ts',
20
- '.web.jsx',
21
- '.jsx',
22
- '.web.tsx',
23
- '.tsx',
24
- '.json',
25
- ];
26
- const loader = {
27
- '.js': 'jsx',
28
- };
29
- const filter = /\.(js|flow)$/;
30
- const esbuildPlugin = () => ({
31
- name: 'react-native-web',
32
- setup: build => {
33
- build.onLoad({ filter }, async ({ path }) => {
34
- const src = await fs.readFile(path, 'utf-8');
35
- return {
36
- contents: flowRemoveTypes(src).toString(),
37
- loader: loader['.js'],
38
- };
39
- });
40
- },
41
- });
42
- const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
43
- enforce: 'pre',
44
- name: 'react-native-web',
45
- config: () => ({
46
- define: {
47
- global: 'window',
48
- __DEV__: JSON.stringify(development),
49
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
50
- },
51
- resolve: {
52
- extensions,
53
- alias: [{ find: 'react-native', replacement: 'react-native-web' }],
54
- },
55
- optimizeDeps: {
56
- esbuildOptions: {
57
- plugins: [esbuildPlugin()],
58
- resolveExtensions: extensions,
59
- },
60
- },
61
- }),
62
- async transform(code, id) {
63
- if (!filter.test(id))
64
- return code;
65
- if (code.includes('@flow'))
66
- code = flowRemoveTypes(code).toString();
67
- return (await vite.transformWithEsbuild(code, id, { loader: loader['.js'] })).code;
68
- },
69
- });
70
-
71
- exports.default = reactNativeWeb;
72
- module.exports = Object.assign(exports.default, exports);
73
- //# sourceMappingURL=index.js.map
package/dist/es/index.js DELETED
@@ -1,68 +0,0 @@
1
- import { transformWithEsbuild } from 'vite';
2
- import flowRemoveTypes from 'flow-remove-types';
3
- import fs from 'fs/promises';
4
-
5
- // import type { ViteReactNativeWebOptions } from '../types'
6
- const development = process.env.NODE_ENV === 'development';
7
- const extensions = [
8
- '.web.mjs',
9
- '.mjs',
10
- '.web.js',
11
- '.js',
12
- '.web.mts',
13
- '.mts',
14
- '.web.ts',
15
- '.ts',
16
- '.web.jsx',
17
- '.jsx',
18
- '.web.tsx',
19
- '.tsx',
20
- '.json',
21
- ];
22
- const loader = {
23
- '.js': 'jsx',
24
- };
25
- const filter = /\.(js|flow)$/;
26
- const esbuildPlugin = () => ({
27
- name: 'react-native-web',
28
- setup: build => {
29
- build.onLoad({ filter }, async ({ path }) => {
30
- const src = await fs.readFile(path, 'utf-8');
31
- return {
32
- contents: flowRemoveTypes(src).toString(),
33
- loader: loader['.js'],
34
- };
35
- });
36
- },
37
- });
38
- const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
39
- enforce: 'pre',
40
- name: 'react-native-web',
41
- config: () => ({
42
- define: {
43
- global: 'window',
44
- __DEV__: JSON.stringify(development),
45
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
46
- },
47
- resolve: {
48
- extensions,
49
- alias: [{ find: 'react-native', replacement: 'react-native-web' }],
50
- },
51
- optimizeDeps: {
52
- esbuildOptions: {
53
- plugins: [esbuildPlugin()],
54
- resolveExtensions: extensions,
55
- },
56
- },
57
- }),
58
- async transform(code, id) {
59
- if (!filter.test(id))
60
- return code;
61
- if (code.includes('@flow'))
62
- code = flowRemoveTypes(code).toString();
63
- return (await transformWithEsbuild(code, id, { loader: loader['.js'] })).code;
64
- },
65
- });
66
-
67
- export { reactNativeWeb as default };
68
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"type":"module"}