vite-plugin-react-native-web 1.0.3 → 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/package.json +1 -1
- package/dist/cjs/index.js +0 -80
- package/dist/es/index.js +0 -75
- package/dist/es/package.json +0 -1
package/package.json
CHANGED
package/dist/cjs/index.js
DELETED
|
@@ -1,80 +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, {
|
|
68
|
-
loader: loader['.js'],
|
|
69
|
-
tsconfigRaw: {
|
|
70
|
-
compilerOptions: {
|
|
71
|
-
jsx: 'react-jsx',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
})).code;
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
exports.default = reactNativeWeb;
|
|
79
|
-
module.exports = Object.assign(exports.default, exports);
|
|
80
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
DELETED
|
@@ -1,75 +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, {
|
|
64
|
-
loader: loader['.js'],
|
|
65
|
-
tsconfigRaw: {
|
|
66
|
-
compilerOptions: {
|
|
67
|
-
jsx: 'react-jsx',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
})).code;
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export { reactNativeWeb as default };
|
|
75
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|