@react-native-community/cli-plugin-metro
Advanced tools
Comparing version 12.0.0-alpha.7 to 12.0.0-alpha.8
@@ -8,6 +8,6 @@ /** | ||
*/ | ||
import type { Config } from '@react-native-community/cli-types'; | ||
import type { ConfigT } from 'metro-config'; | ||
import outputBundle from 'metro/src/shared/output/bundle'; | ||
import type { ConfigT } from 'metro-config'; | ||
import { CommandLineArgs } from './bundleCommandLineArgs'; | ||
import type { Config } from '@react-native-community/cli-types'; | ||
declare function buildBundle(args: CommandLineArgs, ctx: Config, output?: typeof outputBundle): Promise<void | undefined>; | ||
@@ -14,0 +14,0 @@ /** |
@@ -8,2 +8,23 @@ "use strict"; | ||
exports.default = void 0; | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _chalk() { | ||
const data = _interopRequireDefault(require("chalk")); | ||
_chalk = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _fs() { | ||
const data = _interopRequireDefault(require("fs")); | ||
_fs = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _Server() { | ||
@@ -30,18 +51,4 @@ const data = _interopRequireDefault(require("metro/src/Server")); | ||
} | ||
function _chalk() { | ||
const data = _interopRequireDefault(require("chalk")); | ||
_chalk = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig")); | ||
var _saveAssets = _interopRequireDefault(require("./saveAssets")); | ||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig")); | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -95,2 +102,9 @@ /** | ||
const bundle = await output.build(server, requestOpts); | ||
// Ensure destination directory exists before saving the bundle | ||
const mkdirOptions = { | ||
recursive: true, | ||
mode: 0o755 | ||
}; | ||
_fs().default.mkdirSync(_path().default.dirname(args.bundleOutput), mkdirOptions); | ||
await output.save(bundle, args, _cliTools().logger.info); | ||
@@ -97,0 +111,0 @@ |
@@ -5,2 +5,5 @@ import { ConfigT } from 'metro-config'; | ||
export type ConfigLoadingContext = Pick<Config, 'root' | 'reactNativePath' | 'platforms'>; | ||
declare global { | ||
var __REACT_NATIVE_METRO_CONFIG_LOADED: boolean; | ||
} | ||
export interface ConfigOptionsT { | ||
@@ -7,0 +10,0 @@ maxWorkers?: number; |
@@ -7,9 +7,2 @@ "use strict"; | ||
exports.default = loadMetroConfig; | ||
function _fs() { | ||
const data = _interopRequireDefault(require("fs")); | ||
_fs = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _path() { | ||
@@ -36,3 +29,2 @@ const data = _interopRequireDefault(require("path")); | ||
} | ||
var _getDefaultMetroConfig = _interopRequireDefault(require("./getDefaultMetroConfig")); | ||
var _metroPlatformResolver = require("./metroPlatformResolver"); | ||
@@ -76,20 +68,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
} | ||
const projectConfig = await (0, _metroConfig().resolveConfig)(undefined, ctx.root); | ||
const cwd = ctx.root; | ||
const projectConfig = await (0, _metroConfig().resolveConfig)(options.config, cwd); | ||
if (projectConfig.isEmpty) { | ||
throw new (_cliTools().CLIError)(`No metro config found in ${ctx.root}`); | ||
throw new (_cliTools().CLIError)(`No Metro config found in ${cwd}`); | ||
} | ||
_cliTools().logger.debug(`Reading Metro config from ${projectConfig.filepath}`); | ||
if (!/['"']@react-native\/metro-config['"']/.test(_fs().default.readFileSync(projectConfig.filepath, 'utf8'))) { | ||
_cliTools().logger.warn('From React Native 0.72, your metro.config.js file should extend' + "'@react-native/metro-config'. Please see the React Native 0.72 " + 'changelog, or copy the template at:\n' + 'https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js'); | ||
_cliTools().logger.warn('Falling back to internal defaults.'); | ||
const loadedConfig = await (0, _metroConfig().loadConfig)({ | ||
cwd: ctx.root, | ||
...options | ||
}, | ||
// Provide React Native defaults on top of Metro defaults | ||
(0, _getDefaultMetroConfig.default)(ctx)); | ||
return (0, _metroConfig().mergeConfig)(loadedConfig, overrideConfig); | ||
if (!global.__REACT_NATIVE_METRO_CONFIG_LOADED) { | ||
const warning = ` | ||
================================================================================================= | ||
From React Native 0.73, your project's Metro config should extend '@react-native/metro-config' | ||
or it will fail to build. Please copy the template at: | ||
https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js | ||
This warning will be removed in future (https://github.com/facebook/metro/issues/1018). | ||
================================================================================================= | ||
`; | ||
for (const line of warning.trim().split('\n')) { | ||
_cliTools().logger.warn(line); | ||
} | ||
} | ||
return (0, _metroConfig().mergeConfig)(await (0, _metroConfig().loadConfig)({ | ||
cwd: ctx.root, | ||
cwd, | ||
...options | ||
@@ -96,0 +94,0 @@ }), overrideConfig); |
{ | ||
"name": "@react-native-community/cli-plugin-metro", | ||
"version": "12.0.0-alpha.7", | ||
"version": "12.0.0-alpha.8", | ||
"license": "MIT", | ||
@@ -10,16 +10,14 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@react-native-community/cli-server-api": "12.0.0-alpha.7", | ||
"@react-native-community/cli-tools": "12.0.0-alpha.7", | ||
"@react-native-community/cli-server-api": "12.0.0-alpha.8", | ||
"@react-native-community/cli-tools": "12.0.0-alpha.8", | ||
"chalk": "^4.1.2", | ||
"execa": "^5.0.0", | ||
"metro": "0.77.0", | ||
"metro-config": "0.77.0", | ||
"metro-core": "0.77.0", | ||
"metro-react-native-babel-transformer": "0.77.0", | ||
"metro-resolver": "0.77.0", | ||
"metro-runtime": "0.77.0", | ||
"metro": "0.78.0", | ||
"metro-config": "0.78.0", | ||
"metro-core": "0.78.0", | ||
"readline": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
"@react-native-community/cli-types": "12.0.0-alpha.7" | ||
"@react-native-community/cli-types": "12.0.0-alpha.8", | ||
"metro-resolver": "0.78.0" | ||
}, | ||
@@ -36,3 +34,3 @@ "files": [ | ||
}, | ||
"gitHead": "dcda33c412399f1c7dd39e94e7b660c70f32ce75" | ||
"gitHead": "3d3616ed5149318984e33a2a5fb2d80744b6bd3a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
8
10
149376
2
81
1803
+ Added@react-native-community/cli-debugger-ui@12.0.0-alpha.8(transitive)
+ Added@react-native-community/cli-server-api@12.0.0-alpha.8(transitive)
+ Added@react-native-community/cli-tools@12.0.0-alpha.8(transitive)
+ Addedhermes-estree@0.15.0(transitive)
+ Addedhermes-parser@0.15.0(transitive)
+ Addedmetro@0.78.0(transitive)
+ Addedmetro-babel-transformer@0.78.0(transitive)
+ Addedmetro-cache@0.78.0(transitive)
+ Addedmetro-cache-key@0.78.0(transitive)
+ Addedmetro-config@0.78.0(transitive)
+ Addedmetro-core@0.78.0(transitive)
+ Addedmetro-file-map@0.78.0(transitive)
+ Addedmetro-minify-terser@0.78.0(transitive)
+ Addedmetro-resolver@0.78.0(transitive)
+ Addedmetro-runtime@0.78.0(transitive)
+ Addedmetro-source-map@0.78.0(transitive)
+ Addedmetro-symbolicate@0.78.0(transitive)
+ Addedmetro-transform-plugins@0.78.0(transitive)
+ Addedmetro-transform-worker@0.78.0(transitive)
+ Addedob1@0.78.0(transitive)
- Removedmetro-resolver@0.77.0
- Removedmetro-runtime@0.77.0
- Removed@babel/helper-annotate-as-pure@7.25.9(transitive)
- Removed@babel/helper-create-class-features-plugin@7.25.9(transitive)
- Removed@babel/helper-create-regexp-features-plugin@7.25.9(transitive)
- Removed@babel/helper-define-polyfill-provider@0.6.2(transitive)
- Removed@babel/helper-environment-visitor@7.24.7(transitive)
- Removed@babel/helper-member-expression-to-functions@7.25.9(transitive)
- Removed@babel/helper-optimise-call-expression@7.25.9(transitive)
- Removed@babel/helper-plugin-utils@7.25.9(transitive)
- Removed@babel/helper-remap-async-to-generator@7.25.9(transitive)
- Removed@babel/helper-replace-supers@7.25.9(transitive)
- Removed@babel/helper-simple-access@7.25.9(transitive)
- Removed@babel/helper-skip-transparent-expression-wrappers@7.25.9(transitive)
- Removed@babel/helper-wrap-function@7.25.9(transitive)
- Removed@babel/plugin-proposal-async-generator-functions@7.20.7(transitive)
- Removed@babel/plugin-proposal-class-properties@7.18.6(transitive)
- Removed@babel/plugin-proposal-export-default-from@7.25.9(transitive)
- Removed@babel/plugin-proposal-nullish-coalescing-operator@7.18.6(transitive)
- Removed@babel/plugin-proposal-numeric-separator@7.18.6(transitive)
- Removed@babel/plugin-proposal-object-rest-spread@7.20.7(transitive)
- Removed@babel/plugin-proposal-optional-catch-binding@7.18.6(transitive)
- Removed@babel/plugin-proposal-optional-chaining@7.21.0(transitive)
- Removed@babel/plugin-syntax-async-generators@7.8.4(transitive)
- Removed@babel/plugin-syntax-class-properties@7.12.13(transitive)
- Removed@babel/plugin-syntax-dynamic-import@7.8.3(transitive)
- Removed@babel/plugin-syntax-export-default-from@7.25.9(transitive)
- Removed@babel/plugin-syntax-flow@7.26.0(transitive)
- Removed@babel/plugin-syntax-jsx@7.25.9(transitive)
- Removed@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(transitive)
- Removed@babel/plugin-syntax-numeric-separator@7.10.4(transitive)
- Removed@babel/plugin-syntax-object-rest-spread@7.8.3(transitive)
- Removed@babel/plugin-syntax-optional-catch-binding@7.8.3(transitive)
- Removed@babel/plugin-syntax-optional-chaining@7.8.3(transitive)
- Removed@babel/plugin-syntax-typescript@7.25.9(transitive)
- Removed@babel/plugin-transform-arrow-functions@7.25.9(transitive)
- Removed@babel/plugin-transform-async-to-generator@7.25.9(transitive)
- Removed@babel/plugin-transform-block-scoped-functions@7.25.9(transitive)
- Removed@babel/plugin-transform-block-scoping@7.25.9(transitive)
- Removed@babel/plugin-transform-classes@7.25.9(transitive)
- Removed@babel/plugin-transform-computed-properties@7.25.9(transitive)
- Removed@babel/plugin-transform-destructuring@7.25.9(transitive)
- Removed@babel/plugin-transform-flow-strip-types@7.25.9(transitive)
- Removed@babel/plugin-transform-for-of@7.25.9(transitive)
- Removed@babel/plugin-transform-function-name@7.25.9(transitive)
- Removed@babel/plugin-transform-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-member-expression-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-modules-commonjs@7.25.9(transitive)
- Removed@babel/plugin-transform-named-capturing-groups-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-object-super@7.25.9(transitive)
- Removed@babel/plugin-transform-parameters@7.25.9(transitive)
- Removed@babel/plugin-transform-property-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-react-display-name@7.25.9(transitive)
- Removed@babel/plugin-transform-react-jsx@7.25.9(transitive)
- Removed@babel/plugin-transform-react-jsx-self@7.25.9(transitive)
- Removed@babel/plugin-transform-react-jsx-source@7.25.9(transitive)
- Removed@babel/plugin-transform-runtime@7.25.9(transitive)
- Removed@babel/plugin-transform-shorthand-properties@7.25.9(transitive)
- Removed@babel/plugin-transform-spread@7.25.9(transitive)
- Removed@babel/plugin-transform-sticky-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-template-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-typescript@7.25.9(transitive)
- Removed@babel/plugin-transform-unicode-regex@7.25.9(transitive)
- Removed@react-native-community/cli-debugger-ui@12.0.0-alpha.7(transitive)
- Removed@react-native-community/cli-server-api@12.0.0-alpha.7(transitive)
- Removed@react-native-community/cli-tools@12.0.0-alpha.7(transitive)
- Removedbabel-plugin-polyfill-corejs2@0.4.11(transitive)
- Removedbabel-plugin-polyfill-corejs3@0.10.6(transitive)
- Removedbabel-plugin-polyfill-regenerator@0.6.2(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@7.0.0-beta.0(transitive)
- Removedbabel-plugin-transform-flow-enums@0.0.2(transitive)
- Removedbabel-preset-fbjs@3.4.0(transitive)
- Removedcore-js-compat@3.39.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhermes-estree@0.14.0(transitive)
- Removedhermes-parser@0.14.0(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedjest-regex-util@27.5.1(transitive)
- Removedlodash.debounce@4.0.8(transitive)
- Removedmetro@0.77.0(transitive)
- Removedmetro-babel-transformer@0.77.0(transitive)
- Removedmetro-cache@0.77.0(transitive)
- Removedmetro-cache-key@0.77.0(transitive)
- Removedmetro-config@0.77.0(transitive)
- Removedmetro-core@0.77.0(transitive)
- Removedmetro-file-map@0.77.0(transitive)
- Removedmetro-inspector-proxy@0.77.0(transitive)
- Removedmetro-minify-terser@0.77.0(transitive)
- Removedmetro-react-native-babel-preset@0.77.0(transitive)
- Removedmetro-react-native-babel-transformer@0.77.0(transitive)
- Removedmetro-resolver@0.77.0(transitive)
- Removedmetro-runtime@0.77.0(transitive)
- Removedmetro-source-map@0.77.0(transitive)
- Removedmetro-symbolicate@0.77.0(transitive)
- Removedmetro-transform-plugins@0.77.0(transitive)
- Removedmetro-transform-worker@0.77.0(transitive)
- Removedob1@0.77.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerate-unicode-properties@10.2.0(transitive)
- Removedregexpu-core@6.1.1(transitive)
- Removedregjsgen@0.8.0(transitive)
- Removedregjsparser@0.11.2(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedunicode-canonical-property-names-ecmascript@2.0.1(transitive)
- Removedunicode-match-property-ecmascript@2.0.0(transitive)
- Removedunicode-match-property-value-ecmascript@2.2.0(transitive)
- Removedunicode-property-aliases-ecmascript@2.1.0(transitive)
Updated@react-native-community/cli-server-api@12.0.0-alpha.8
Updatedmetro@0.78.0
Updatedmetro-config@0.78.0
Updatedmetro-core@0.78.0