@rock-js/plugin-metro 0.9.1 → 0.10.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/dist/src/lib/start/OpenDebuggerKeyboardHandler.d.ts +1 -1
- package/dist/src/lib/start/attachKeyHandlers.d.ts +1 -1
- package/dist/src/lib/start/createDevMiddlewareLogger.d.ts +1 -1
- package/dist/src/lib/start/loadMetroConfig.js +28 -3
- package/dist/src/lib/start/loadMetroConfig.js.map +1 -1
- package/dist/src/lib/start/runServer.js +8 -3
- package/dist/src/lib/start/runServer.js.map +1 -1
- package/package.json +10 -10
- package/template/package.json +2 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.d.ts +0 -8
- package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.js +0 -29
- package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.js.map +0 -1
- package/dist/src/lib/bundle/assetCatalogIOS.d.ts +0 -21
- package/dist/src/lib/bundle/assetCatalogIOS.js +0 -54
- package/dist/src/lib/bundle/assetCatalogIOS.js.map +0 -1
- package/dist/src/lib/bundle/assetPathUtils.d.ts +0 -28
- package/dist/src/lib/bundle/assetPathUtils.js +0 -72
- package/dist/src/lib/bundle/assetPathUtils.js.map +0 -1
- package/dist/src/lib/bundle/buildBundle.d.ts +0 -57
- package/dist/src/lib/bundle/buildBundle.js +0 -99
- package/dist/src/lib/bundle/buildBundle.js.map +0 -1
- package/dist/src/lib/bundle/command.d.ts.map +0 -1
- package/dist/src/lib/bundle/createKeepFileAsync.d.ts +0 -10
- package/dist/src/lib/bundle/createKeepFileAsync.js +0 -28
- package/dist/src/lib/bundle/createKeepFileAsync.js.map +0 -1
- package/dist/src/lib/bundle/filterPlatformAssetScales.d.ts +0 -9
- package/dist/src/lib/bundle/filterPlatformAssetScales.js +0 -36
- package/dist/src/lib/bundle/filterPlatformAssetScales.js.map +0 -1
- package/dist/src/lib/bundle/getAssetDestPathAndroid.d.ts +0 -10
- package/dist/src/lib/bundle/getAssetDestPathAndroid.js +0 -16
- package/dist/src/lib/bundle/getAssetDestPathAndroid.js.map +0 -1
- package/dist/src/lib/bundle/getAssetDestPathIOS.d.ts +0 -10
- package/dist/src/lib/bundle/getAssetDestPathIOS.js +0 -19
- package/dist/src/lib/bundle/getAssetDestPathIOS.js.map +0 -1
- package/dist/src/lib/bundle/index.d.ts +0 -11
- package/dist/src/lib/bundle/index.js +0 -106
- package/dist/src/lib/bundle/index.js.map +0 -1
- package/dist/src/lib/bundle/saveAssets.d.ts +0 -10
- package/dist/src/lib/bundle/saveAssets.js +0 -112
- package/dist/src/lib/bundle/saveAssets.js.map +0 -1
- package/dist/src/lib/getDevMiddleware.d.ts +0 -2
- package/dist/src/lib/getDevMiddleware.js +0 -15
- package/dist/src/lib/getDevMiddleware.js.map +0 -1
- package/dist/src/lib/loadMetroConfig.d.ts +0 -24
- package/dist/src/lib/loadMetroConfig.js +0 -76
- package/dist/src/lib/loadMetroConfig.js.map +0 -1
- package/dist/src/lib/pluginMetro.d.ts.map +0 -1
- package/dist/src/lib/start/OpenDebuggerKeyboardHandler.d.ts.map +0 -1
- package/dist/src/lib/start/attachKeyHandlers.d.ts.map +0 -1
- package/dist/src/lib/start/command.d.ts.map +0 -1
- package/dist/src/lib/start/createDevMiddlewareLogger.d.ts.map +0 -1
- package/dist/src/lib/start/loadMetroConfig.d.ts.map +0 -1
- package/dist/src/lib/start/metroPlatformResolver.d.ts.map +0 -1
- package/dist/src/lib/start/runServer.d.ts.map +0 -1
- package/dist/src/utils/loadMetroConfig.d.ts +0 -24
- package/dist/src/utils/loadMetroConfig.js +0 -76
- package/dist/src/utils/loadMetroConfig.js.map +0 -1
- package/dist/src/utils/metroPlatformResolver.d.ts +0 -24
- package/dist/src/utils/metroPlatformResolver.js +0 -38
- package/dist/src/utils/metroPlatformResolver.js.map +0 -1
- package/dist/src/utils/parseKeyValueParamArray.d.ts +0 -8
- package/dist/src/utils/parseKeyValueParamArray.js +0 -21
- package/dist/src/utils/parseKeyValueParamArray.js.map +0 -1
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import { createRequire } from 'node:module';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { logger, RnefError } from '@rnef/tools';
|
|
10
|
-
import { loadConfig, mergeConfig, resolveConfig } from 'metro-config';
|
|
11
|
-
import { reactNativePlatformResolver } from './metroPlatformResolver.js';
|
|
12
|
-
/**
|
|
13
|
-
* Get the config options to override based on RN CLI inputs.
|
|
14
|
-
*/
|
|
15
|
-
function getOverrideConfig(ctx, config) {
|
|
16
|
-
const outOfTreePlatforms = Object.keys(ctx.platforms).filter(
|
|
17
|
-
// @ts-expect-error - TBD
|
|
18
|
-
(platform) => ctx.platforms[platform].npmPackageName);
|
|
19
|
-
const resolver = {
|
|
20
|
-
platforms: [...Object.keys(ctx.platforms), 'native'],
|
|
21
|
-
};
|
|
22
|
-
if (outOfTreePlatforms.length) {
|
|
23
|
-
// @ts-expect-error - TBD
|
|
24
|
-
resolver.resolveRequest = reactNativePlatformResolver(outOfTreePlatforms.reduce((result, platform) => {
|
|
25
|
-
// @ts-expect-error - TBD
|
|
26
|
-
result[platform] = ctx.platforms[platform].npmPackageName;
|
|
27
|
-
return result;
|
|
28
|
-
}, {}), config.resolver?.resolveRequest);
|
|
29
|
-
}
|
|
30
|
-
const require = createRequire(import.meta.url);
|
|
31
|
-
return {
|
|
32
|
-
resolver,
|
|
33
|
-
serializer: {
|
|
34
|
-
// We can include multiple copies of InitializeCore here because metro will
|
|
35
|
-
// only add ones that are already part of the bundle
|
|
36
|
-
getModulesRunBeforeMainModule: () => [
|
|
37
|
-
require.resolve(path.join(ctx.reactNativePath, 'Libraries/Core/InitializeCore'), { paths: [ctx.root] }),
|
|
38
|
-
...outOfTreePlatforms.map((platform) => require.resolve(
|
|
39
|
-
// @ts-expect-error - TBD
|
|
40
|
-
`${ctx.platforms[platform].npmPackageName}/Libraries/Core/InitializeCore`, { paths: [ctx.root] })),
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Load Metro config.
|
|
47
|
-
*
|
|
48
|
-
* Allows the CLI to override select values in `metro.config.js` based on
|
|
49
|
-
* dynamic user options in `ctx`.
|
|
50
|
-
*/
|
|
51
|
-
export default async function loadMetroConfig(ctx, options = {}) {
|
|
52
|
-
const cwd = ctx.root;
|
|
53
|
-
const projectConfig = await resolveConfig(options.config, cwd);
|
|
54
|
-
if (projectConfig.isEmpty) {
|
|
55
|
-
throw new RnefError(`No Metro config found in ${cwd}`);
|
|
56
|
-
}
|
|
57
|
-
logger.debug(`Reading Metro config from ${projectConfig.filepath}`);
|
|
58
|
-
// @ts-expect-error - we're fine with this
|
|
59
|
-
if (!global.__REACT_NATIVE_METRO_CONFIG_LOADED) {
|
|
60
|
-
const warning = `
|
|
61
|
-
=================================================================================================
|
|
62
|
-
From React Native 0.73, your project's Metro config should extend '@react-native/metro-config'
|
|
63
|
-
or it will fail to build. Please copy the template at:
|
|
64
|
-
https://github.com/react-native-community/template/blob/main/template/metro.config.js
|
|
65
|
-
This warning will be removed in future (https://github.com/facebook/metro/issues/1018).
|
|
66
|
-
=================================================================================================
|
|
67
|
-
`;
|
|
68
|
-
for (const line of warning.trim().split('\n')) {
|
|
69
|
-
console.warn(line);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const config = await loadConfig({ cwd, ...options });
|
|
73
|
-
const overrideConfig = getOverrideConfig(ctx, config);
|
|
74
|
-
return mergeConfig(config, overrideConfig);
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=loadMetroConfig.js.map
|
|
@@ -1 +0,0 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AAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEtD,OAAO,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import type { CustomResolver } from 'metro-resolver';
|
|
8
|
-
/**
|
|
9
|
-
* This is an implementation of a metro resolveRequest option which will remap react-native imports
|
|
10
|
-
* to different npm packages based on the platform requested. This allows a single metro instance/config
|
|
11
|
-
* to produce bundles for multiple out of tree platforms at a time.
|
|
12
|
-
*
|
|
13
|
-
* @param platformImplementations
|
|
14
|
-
* A map of platform to npm package that implements that platform
|
|
15
|
-
*
|
|
16
|
-
* Ex:
|
|
17
|
-
* {
|
|
18
|
-
* windows: 'react-native-windows'
|
|
19
|
-
* macos: 'react-native-macos'
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
|
-
export declare function reactNativePlatformResolver(platformImplementations: {
|
|
23
|
-
[platform: string]: string;
|
|
24
|
-
}, customResolver: CustomResolver | null | undefined): CustomResolver;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* This is an implementation of a metro resolveRequest option which will remap react-native imports
|
|
9
|
-
* to different npm packages based on the platform requested. This allows a single metro instance/config
|
|
10
|
-
* to produce bundles for multiple out of tree platforms at a time.
|
|
11
|
-
*
|
|
12
|
-
* @param platformImplementations
|
|
13
|
-
* A map of platform to npm package that implements that platform
|
|
14
|
-
*
|
|
15
|
-
* Ex:
|
|
16
|
-
* {
|
|
17
|
-
* windows: 'react-native-windows'
|
|
18
|
-
* macos: 'react-native-macos'
|
|
19
|
-
* }
|
|
20
|
-
*/
|
|
21
|
-
export function reactNativePlatformResolver(platformImplementations, customResolver) {
|
|
22
|
-
return (context, moduleName, platform) => {
|
|
23
|
-
let modifiedModuleName = moduleName;
|
|
24
|
-
if (platform != null && platformImplementations[platform]) {
|
|
25
|
-
if (moduleName === 'react-native') {
|
|
26
|
-
modifiedModuleName = platformImplementations[platform];
|
|
27
|
-
}
|
|
28
|
-
else if (moduleName.startsWith('react-native/')) {
|
|
29
|
-
modifiedModuleName = `${platformImplementations[platform]}/${modifiedModuleName.slice('react-native/'.length)}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (customResolver) {
|
|
33
|
-
return customResolver(context, modifiedModuleName, platform);
|
|
34
|
-
}
|
|
35
|
-
return context.resolveRequest(context, modifiedModuleName, platform);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=metroPlatformResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metroPlatformResolver.js","sourceRoot":"","sources":["../../../src/utils/metroPlatformResolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,2BAA2B,CACzC,uBAEC,EACD,cAAiD;IAEjD,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;QACvC,IAAI,kBAAkB,GAAG,UAAU,CAAC;QACpC,IAAI,QAAQ,IAAI,IAAI,IAAI,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1D,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;gBAClC,kBAAkB,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YACzD,CAAC;iBAAM,IAAI,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;gBAClD,kBAAkB,GAAG,GACnB,uBAAuB,CAAC,QAAQ,CAClC,IAAI,kBAAkB,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;YACzD,CAAC;QACH,CAAC;QACD,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export default function parseKeyValueParamArray(paramArray: Array<string>): Record<string, string>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export default function parseKeyValueParamArray(paramArray) {
|
|
9
|
-
const result = {};
|
|
10
|
-
for (const param of paramArray) {
|
|
11
|
-
const equalIndex = param.indexOf('=');
|
|
12
|
-
if (equalIndex === -1) {
|
|
13
|
-
throw new Error(`Invalid key-value param: ${param}. Expected format: key=value`);
|
|
14
|
-
}
|
|
15
|
-
const key = decodeURIComponent(param.slice(0, equalIndex));
|
|
16
|
-
const value = decodeURIComponent(param.slice(equalIndex + 1));
|
|
17
|
-
result[key] = value;
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=parseKeyValueParamArray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseKeyValueParamArray.js","sourceRoot":"","sources":["../../../src/utils/parseKeyValueParamArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,UAAyB;IAEzB,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,8BAA8B,CAAC,CAAC;QACnF,CAAC;QAED,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;QAE9D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|