@vxrn/vite-plugin-metro 2.22.0 → 2.23.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/vite-plugin-metro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"@oxc-project/runtime": "^0.112.0",
|
|
70
70
|
"@react-native/babel-preset": "^0.88.0",
|
|
71
71
|
"@react-native/metro-config": "^0.88.0",
|
|
72
|
-
"@vxrn/compiler": "2.
|
|
73
|
-
"@vxrn/debug": "2.
|
|
74
|
-
"@vxrn/utils": "2.
|
|
72
|
+
"@vxrn/compiler": "2.23.1",
|
|
73
|
+
"@vxrn/debug": "2.23.1",
|
|
74
|
+
"@vxrn/utils": "2.23.1",
|
|
75
75
|
"esbuild": "^0.28.1",
|
|
76
76
|
"flow-parser": "^0.336.0",
|
|
77
77
|
"launch-editor": "^2.14.2",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"publishConfig": {
|
|
100
100
|
"access": "public"
|
|
101
101
|
},
|
|
102
|
-
"releaseSourceCommit": "
|
|
102
|
+
"releaseSourceCommit": "2c8b460e0f8ab1addc495a07f8f172a88d997915",
|
|
103
103
|
"repository": {
|
|
104
104
|
"type": "git",
|
|
105
105
|
"url": "git+https://github.com/onejs/one.git",
|
|
@@ -12,87 +12,29 @@ const { debug } = createDebugger('vite-plugin-metro')
|
|
|
12
12
|
// for Metro, we only import types here. `projectImport` loads the actual modules
|
|
13
13
|
// at runtime to ensure they are loaded from the user's project root.
|
|
14
14
|
import type MetroT from 'metro'
|
|
15
|
-
import type { loadConfig as loadConfigT } from 'metro'
|
|
16
15
|
import type MetroHmrServerT from 'metro/private/HmrServer'
|
|
17
16
|
import type { Client as MetroHmrClientT } from 'metro/private/HmrServer'
|
|
18
17
|
import type createWebsocketServerT from 'metro/private/lib/createWebsocketServer'
|
|
19
18
|
import type { createDevMiddleware as createDevMiddlewareT } from '@react-native/dev-middleware'
|
|
20
19
|
|
|
21
20
|
import { projectImport } from '../utils/projectImport'
|
|
22
|
-
import type { TransformOptions } from '../transformer/babel-core'
|
|
23
21
|
import { getMetroConfigFromViteConfig } from '../metro-config/getMetroConfigFromViteConfig'
|
|
24
22
|
import { patchMetroServerWithViteConfigAndMetroPluginOptions } from '../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions'
|
|
25
23
|
|
|
26
|
-
type
|
|
27
|
-
type
|
|
24
|
+
import type { MetroPluginOptions as SharedMetroPluginOptions } from '@vxrn/utils/metroTypes'
|
|
25
|
+
import type { loadConfig } from 'metro'
|
|
26
|
+
import type { TransformOptions } from '../transformer/babel-core'
|
|
28
27
|
|
|
29
|
-
export type MetroPluginOptions =
|
|
30
|
-
|
|
28
|
+
export type MetroPluginOptions = Omit<
|
|
29
|
+
SharedMetroPluginOptions,
|
|
30
|
+
'argv' | 'defaultConfigOverrides' | 'babelConfig' | 'babelConfigOverrides'
|
|
31
|
+
> & {
|
|
32
|
+
argv?: Parameters<typeof loadConfig>[0]
|
|
31
33
|
defaultConfigOverrides?:
|
|
32
|
-
|
|
|
33
|
-
| ((defaultConfig:
|
|
34
|
-
/**
|
|
35
|
-
* Shorthand for setting `useWatchman` in Metro's resolver config.
|
|
36
|
-
* When true, enables Watchman for file watching. When false, disables it.
|
|
37
|
-
*/
|
|
38
|
-
watchman?: boolean
|
|
39
|
-
/**
|
|
40
|
-
* Array of module names or glob patterns that should be resolved to an empty module.
|
|
41
|
-
* This is useful for excluding modules that break the React Native build.
|
|
42
|
-
*
|
|
43
|
-
* Supports glob patterns via micromatch:
|
|
44
|
-
* - Exact match: `'jsonwebtoken'`
|
|
45
|
-
* - Wildcard: `'@aws-sdk/*'`
|
|
46
|
-
* - Multiple wildcards: `'@aws-sdk/**'`
|
|
47
|
-
*
|
|
48
|
-
* Example: `['node:http2', 'jsonwebtoken', '@aws-sdk/*']`
|
|
49
|
-
*/
|
|
50
|
-
excludeModules?: string[]
|
|
51
|
-
/** Consider using babelConfigOverrides instead */
|
|
34
|
+
| Parameters<typeof loadConfig>[1]
|
|
35
|
+
| ((defaultConfig: Parameters<typeof loadConfig>[1]) => Parameters<typeof loadConfig>[1])
|
|
52
36
|
babelConfig?: TransformOptions
|
|
53
37
|
babelConfigOverrides?: (defaultConfig: TransformOptions) => TransformOptions
|
|
54
|
-
/**
|
|
55
|
-
* Module ids of transforms to run on the native transform path (the
|
|
56
|
-
* default), which runs no babel at all. Each module
|
|
57
|
-
* default-exports a `NativeTransform`: `(code, ctx) => string | null`. They
|
|
58
|
-
* run in order, on the original source, before one's own ports — the same
|
|
59
|
-
* view of the file a babel plugin gets.
|
|
60
|
-
*
|
|
61
|
-
* This is how a babel plugin that has no native port gets replaced rather
|
|
62
|
-
* than dropped. The worker refuses to build when it sees a babel plugin it
|
|
63
|
-
* cannot run, so porting it here is the way through.
|
|
64
|
-
*/
|
|
65
|
-
nativeTransformModules?: string[]
|
|
66
|
-
/**
|
|
67
|
-
* internal marker used by one's babel preset to avoid double-applying its
|
|
68
|
-
* plugin chain when one already supplied the vite metro babel config.
|
|
69
|
-
*/
|
|
70
|
-
oneViteMetroBabelConfig?: boolean
|
|
71
|
-
/**
|
|
72
|
-
* Overrides the main module name which is normally defined as the `main` field in `package.json`.
|
|
73
|
-
*
|
|
74
|
-
* Changes the React Native entry point without requiring a `main` field in
|
|
75
|
-
* `package.json`.
|
|
76
|
-
*/
|
|
77
|
-
mainModuleName?: string
|
|
78
|
-
/**
|
|
79
|
-
* Controls when Metro bundler starts:
|
|
80
|
-
* - 'eager' (default): Start Metro as soon as Vite server is listening
|
|
81
|
-
* - 'lazy': Defer Metro startup until a bundle request or simulator connection is detected
|
|
82
|
-
*
|
|
83
|
-
* Use 'lazy' to speed up dev server startup when you don't always need Metro.
|
|
84
|
-
*/
|
|
85
|
-
startup?: 'eager' | 'lazy'
|
|
86
|
-
/**
|
|
87
|
-
* Run Metro's transforms through the oxc worker, which uses no babel at all.
|
|
88
|
-
*
|
|
89
|
-
* On by default. The worker refuses to build when it sees a babel plugin it
|
|
90
|
-
* has no port for, so a plugin is never silently dropped: port it and list it
|
|
91
|
-
* in `nativeTransformModules`, or set this to `false` to go back to babel.
|
|
92
|
-
*
|
|
93
|
-
* `ONE_METRO_NATIVE_TRANSFORMS=0` turns it off for one run.
|
|
94
|
-
*/
|
|
95
|
-
nativeTransforms?: boolean
|
|
96
38
|
}
|
|
97
39
|
|
|
98
40
|
export function metroPlugin(options: MetroPluginOptions = {}): PluginOption {
|
|
@@ -1,74 +1,12 @@
|
|
|
1
1
|
import type { PluginOption } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MetroPluginOptions as SharedMetroPluginOptions } from '@vxrn/utils/metroTypes';
|
|
3
|
+
import type { loadConfig } from 'metro';
|
|
3
4
|
import type { TransformOptions } from '../transformer/babel-core.js';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
argv?: MetroYargArguments;
|
|
8
|
-
defaultConfigOverrides?: MetroInputConfig | ((defaultConfig: MetroInputConfig) => MetroInputConfig);
|
|
9
|
-
/**
|
|
10
|
-
* Shorthand for setting `useWatchman` in Metro's resolver config.
|
|
11
|
-
* When true, enables Watchman for file watching. When false, disables it.
|
|
12
|
-
*/
|
|
13
|
-
watchman?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Array of module names or glob patterns that should be resolved to an empty module.
|
|
16
|
-
* This is useful for excluding modules that break the React Native build.
|
|
17
|
-
*
|
|
18
|
-
* Supports glob patterns via micromatch:
|
|
19
|
-
* - Exact match: `'jsonwebtoken'`
|
|
20
|
-
* - Wildcard: `'@aws-sdk/*'`
|
|
21
|
-
* - Multiple wildcards: `'@aws-sdk/**'`
|
|
22
|
-
*
|
|
23
|
-
* Example: `['node:http2', 'jsonwebtoken', '@aws-sdk/*']`
|
|
24
|
-
*/
|
|
25
|
-
excludeModules?: string[];
|
|
26
|
-
/** Consider using babelConfigOverrides instead */
|
|
5
|
+
export type MetroPluginOptions = Omit<SharedMetroPluginOptions, 'argv' | 'defaultConfigOverrides' | 'babelConfig' | 'babelConfigOverrides'> & {
|
|
6
|
+
argv?: Parameters<typeof loadConfig>[0];
|
|
7
|
+
defaultConfigOverrides?: Parameters<typeof loadConfig>[1] | ((defaultConfig: Parameters<typeof loadConfig>[1]) => Parameters<typeof loadConfig>[1]);
|
|
27
8
|
babelConfig?: TransformOptions;
|
|
28
9
|
babelConfigOverrides?: (defaultConfig: TransformOptions) => TransformOptions;
|
|
29
|
-
/**
|
|
30
|
-
* Module ids of transforms to run on the native transform path (the
|
|
31
|
-
* default), which runs no babel at all. Each module
|
|
32
|
-
* default-exports a `NativeTransform`: `(code, ctx) => string | null`. They
|
|
33
|
-
* run in order, on the original source, before one's own ports — the same
|
|
34
|
-
* view of the file a babel plugin gets.
|
|
35
|
-
*
|
|
36
|
-
* This is how a babel plugin that has no native port gets replaced rather
|
|
37
|
-
* than dropped. The worker refuses to build when it sees a babel plugin it
|
|
38
|
-
* cannot run, so porting it here is the way through.
|
|
39
|
-
*/
|
|
40
|
-
nativeTransformModules?: string[];
|
|
41
|
-
/**
|
|
42
|
-
* internal marker used by one's babel preset to avoid double-applying its
|
|
43
|
-
* plugin chain when one already supplied the vite metro babel config.
|
|
44
|
-
*/
|
|
45
|
-
oneViteMetroBabelConfig?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Overrides the main module name which is normally defined as the `main` field in `package.json`.
|
|
48
|
-
*
|
|
49
|
-
* Changes the React Native entry point without requiring a `main` field in
|
|
50
|
-
* `package.json`.
|
|
51
|
-
*/
|
|
52
|
-
mainModuleName?: string;
|
|
53
|
-
/**
|
|
54
|
-
* Controls when Metro bundler starts:
|
|
55
|
-
* - 'eager' (default): Start Metro as soon as Vite server is listening
|
|
56
|
-
* - 'lazy': Defer Metro startup until a bundle request or simulator connection is detected
|
|
57
|
-
*
|
|
58
|
-
* Use 'lazy' to speed up dev server startup when you don't always need Metro.
|
|
59
|
-
*/
|
|
60
|
-
startup?: 'eager' | 'lazy';
|
|
61
|
-
/**
|
|
62
|
-
* Run Metro's transforms through the oxc worker, which uses no babel at all.
|
|
63
|
-
*
|
|
64
|
-
* On by default. The worker refuses to build when it sees a babel plugin it
|
|
65
|
-
* has no port for, so a plugin is never silently dropped: port it and list it
|
|
66
|
-
* in `nativeTransformModules`, or set this to `false` to go back to babel.
|
|
67
|
-
*
|
|
68
|
-
* `ONE_METRO_NATIVE_TRANSFORMS=0` turns it off for one run.
|
|
69
|
-
*/
|
|
70
|
-
nativeTransforms?: boolean;
|
|
71
10
|
};
|
|
72
11
|
export declare function metroPlugin(options?: MetroPluginOptions): PluginOption;
|
|
73
|
-
export {};
|
|
74
12
|
//# sourceMappingURL=metroPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metroPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/metroPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"metroPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/metroPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoBxC,OAAO,KAAK,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAEjE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,wBAAwB,EACxB,MAAM,GAAG,wBAAwB,GAAG,aAAa,GAAG,sBAAsB,CAC3E,GAAG;IACF,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,sBAAsB,CAAC,EACnB,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3F,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,oBAAoB,CAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,KAAK,gBAAgB,CAAA;CAC7E,CAAA;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,YAAY,CA2T1E"}
|