Migrate Node.js builtin imports to node: scheme (#57611)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57611

Directly follows D112733139 (Metro).

**Motivation**

- New Node builtins are *only* available under the prefix (e.g. `node:sqlite`), as this allows Node to introduce them without ecosystem-breaking changes, so this is the direction of travel and the only choice that'll allow consistency.
- Encouraging them and grouping them separately makes it easier to reason about a module's 3rd party dependencies.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D112803684

fbshipit-source-id: 40668d746a7151b3aa4800ff8af997902a18d198
This commit is contained in:
Alex Hunt authored and meta-codesync[bot] committed 2026-07-21 09:01:41 -07:00
1 parent 94d208d96f
commit 89300acb9c
271 files changed
+822 -581

No files matched your search

@@ -14,8 +14,8 @@ import type {SchemaType} from '../../CodegenSchema.js';
const {FlowParser} = require('../../parsers/flow/parser');
const {TypeScriptParser} = require('../../parsers/typescript/parser');
const {filterJSFile} = require('./combine-utils');
const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');
const {globSync} = require('tinyglobby');
const flowParser = new FlowParser();
@@ -16,8 +16,8 @@ import type {
SchemaType,
} from '../../CodegenSchema.js';
const assert = require('assert');
const fs = require('fs');
const assert = require('node:assert');
const fs = require('node:fs');
const yargs = require('yargs');
const argv = yargs
@@ -10,7 +10,7 @@
'use strict';
const path = require('path');
const path = require('node:path');
/**
* This function is used by the CLI to decide whether a JS/TS file has to be
@@ -15,7 +15,7 @@
'use strict';
const RNCodegen = require('../../generators/RNCodegen.js');
const fs = require('fs');
const fs = require('node:fs');
const args = process.argv.slice(2);
if (args.length < 3) {
+1 -1
View File
@@ -12,7 +12,7 @@
const {FlowParser} = require('../../parsers/flow/parser');
const {TypeScriptParser} = require('../../parsers/typescript/parser');
const path = require('path');
const path = require('node:path');
const flowParser = new FlowParser();
const typescriptParser = new TypeScriptParser();
+2 -2
View File
@@ -35,8 +35,8 @@ const generateModuleJavaSpec = require('./modules/GenerateModuleJavaSpec.js');
const generateModuleJniCpp = require('./modules/GenerateModuleJniCpp.js');
const generateModuleJniH = require('./modules/GenerateModuleJniH.js');
const generateModuleObjCpp = require('./modules/GenerateModuleObjCpp');
const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');
const ALL_GENERATORS = {
generateComponentDescriptorH: generateComponentDescriptorH.generate,
@@ -21,7 +21,7 @@ describe('RNCodegen.generate', () => {
});
it('when type `all`, with default paths', () => {
jest.mock('fs', () => ({
jest.mock('node:fs', () => ({
existsSync: location => {
return true;
},
@@ -29,7 +29,7 @@ describe('RNCodegen.generate', () => {
// Jest in the OSS does not allow to capture variables in closures.
// Therefore, we have to bring the variables inside the closure.
// see: https://github.com/facebook/jest/issues/2567
const path = require('path');
const path = require('node:path');
const outputDirectory = 'tmp/out/';
const componentsOutputDir = 'react/renderer/components/library';
const modulesOutputDir = 'library';
@@ -14,7 +14,7 @@ const failureFixtures = require('../__test_fixtures__/failures.js');
const fixtures = require('../__test_fixtures__/fixtures.js');
const {FlowParser} = require('../../parser');
jest.mock('fs', () => ({
jest.mock('node:fs', () => ({
readFileSync: filename => {
// Jest in the OSS does not allow to capture variables in closures.
// Therefore, we have to bring the variables inside the closure.
@@ -16,7 +16,7 @@ const {FlowParser} = require('../../parser');
const flowParser = new FlowParser();
jest.mock('fs', () => ({
jest.mock('node:fs', () => ({
readFileSync: filename => {
// Jest in the OSS does not allow to capture variables in closures.
// Therefore, we have to bring the variables inside the closure.
+1 -1
View File
@@ -56,8 +56,8 @@ const {
} = require('./components/componentsUtils');
const {flowTranslateTypeAnnotation} = require('./modules');
const {parseFlowAndThrowErrors} = require('./parseFlowAndThrowErrors');
const fs = require('fs');
const invariant = require('invariant');
const fs = require('node:fs');
type ExtendsForProp = null | {
type: 'ReactNativeBuiltInType',
@@ -14,7 +14,7 @@ const failureFixtures = require('../__test_fixtures__/failures.js');
const fixtures = require('../__test_fixtures__/fixtures.js');
const {TypeScriptParser} = require('../../parser');
jest.mock('fs', () => ({
jest.mock('node:fs', () => ({
readFileSync: filename => {
// Jest in the OSS does not allow to capture variables in closures.
// Therefore, we have to bring the variables inside the closure.
@@ -16,7 +16,7 @@ const {TypeScriptParser} = require('../../parser');
const typeScriptParser = new TypeScriptParser();
jest.mock('fs', () => ({
jest.mock('node:fs', () => ({
readFileSync: filename => {
// Jest in the OSS does not allow to capture variables in closures.
// Therefore, we have to bring the variables inside the closure.
@@ -59,8 +59,8 @@ const {typeScriptTranslateTypeAnnotation} = require('./modules');
const {parseTopLevelType} = require('./parseTopLevelType');
// $FlowFixMe[untyped-import] Use flow-types for @babel/parser
const babelParser = require('@babel/parser');
const fs = require('fs');
const invariant = require('invariant');
const fs = require('node:fs');
class TypeScriptParser implements Parser {
typeParameterInstantiation: string = 'TSTypeParameterInstantiation';
+1 -1
View File
@@ -11,7 +11,7 @@
'use strict';
const {ParserError} = require('./errors');
const path = require('path');
const path = require('node:path');
export type TypeDeclarationMap = {[declarationName: string]: $FlowFixMe};