Skip to content

Commit 97727ba

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Fix compat with extensionless scripts/* imports (#57718)
Summary: Pull Request resolved: #57718 **Context** Replaces #57709, which identified a real bug in 0.87 from the combination of: - #57276 - #57652 ``` $ npx react-native spm add error Cannot find module '.../node_modules/react-native/scripts/setup-apple-spm' $ npx react-native codegen error Cannot find module '.../node_modules/react-native/scripts/codegen/generate-artifacts-executor' ``` **This diff** - Fix — and exclusively switch to — extensionless imports rather than requiring `.js`. - Update in-repo consumers. The previous single mapping is now an extension-aware mapping: - `./scripts/*` now appends `.js`, so `react-native/scripts/foo` resolves to `foo.js`. - `.sh` and `.rb` stay reachable via explicit `./scripts/*.sh` and `./scripts/*.rb` passthrough patterns. **Impact** - Explicit `react-native/scripts/*.js` specifiers no longer resolve, so JavaScript paths must be imported without an extension. - Files under `scripts/` with extensions other than `.js`, `.sh`, or `.rb` are no longer exposed through `./scripts/*`. - These have no open source consumers. Changelog: [General][Fixed] - (RC4 only, drop for main changelog): `react-native/scripts/*` imports once again expand `.js` extensions [General][Breaking] - Extensionless `react-native/scripts/*` imports are now **mandated**; explicit `.js` import specifiers are rejected. Reviewed By: rubennorte Differential Revision: D113898792 fbshipit-source-id: d72f60be2c08ab97871e336645856c9029e74ae2
1 parent 3958c7f commit 97727ba

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/community-cli-plugin/src/commands/codegen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const codegenCommand: Command = {
4747
args: CodegenCommandArgs,
4848
): void => {
4949
const generateArtifactsExecutor = require.resolve(
50-
'react-native/scripts/codegen/generate-artifacts-executor',
50+
'react-native/scripts/codegen/generate-artifacts-executor/index',
5151
{paths: [config.root]},
5252
);
5353
// $FlowFixMe[unsupported-syntax] dynamic require of a resolved path

packages/react-native/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"types": null,
4343
"default": "./Libraries/*.js"
4444
},
45-
"./scripts/*": "./scripts/*",
45+
"./scripts/*": "./scripts/*.js",
46+
"./scripts/*.sh": "./scripts/*.sh",
47+
"./scripts/*.rb": "./scripts/*.rb",
4648
"./asset-registry": {
4749
"types": null,
4850
"default": "./src/asset-registry.js"

private/core-cli-utils/src/private/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const bundleApp = (
187187
'Check if SourceMap script available',
188188
() => {
189189
composeSourceMaps = getNodePackagePath(
190-
'react-native/scripts/compose-source-maps.js',
190+
'react-native/scripts/compose-source-maps',
191191
);
192192
},
193193
);

0 commit comments

Comments
 (0)