RN: Migrate to ESM - Libraries/Components/Image (#51434)

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

Migrates files to use ESM to mitigate the existing lint warning.

I am suppressing `RelativeImageStub` to preserve compatibility with the dynamic asset exports generated by Metro (i.e. not ESM with `default` exports).

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74943031

fbshipit-source-id: ac4b2afd96fe5446acb4452395d7cb42bb5a6c17
This commit is contained in:
Tim Yung
2025-05-17 23:17:37 -07:00
committed by Facebook GitHub Bot
parent 1218a8a6d0
commit f1697544cd
3 changed files with 9 additions and 15 deletions
+4 -10
View File
@@ -8,13 +8,7 @@
* @format
*/
'use strict';
import type {PackagerAsset} from '@react-native/assets-registry/registry';
const AssetRegistry = require('@react-native/assets-registry/registry') as {
registerAsset: (asset: PackagerAsset) => number,
getAssetByID: (assetId: number) => PackagerAsset,
};
module.exports = AssetRegistry;
export {
registerAsset,
getAssetByID,
} from '@react-native/assets-registry/registry';
@@ -27,4 +27,5 @@ const RelativeImageStub = (AssetRegistry.registerAsset({
type: 'png',
}): number);
// eslint-disable-next-line lint/no-commonjs-exports
module.exports = RelativeImageStub;
@@ -4219,11 +4219,10 @@ declare export default typeof RCTNativeAppEventEmitter;
`;
exports[`public API should not change unintentionally Libraries/Image/AssetRegistry.js 1`] = `
"declare const AssetRegistry: {
registerAsset: (asset: PackagerAsset) => number,
getAssetByID: (assetId: number) => PackagerAsset,
};
declare module.exports: typeof AssetRegistry;
"export {
registerAsset,
getAssetByID,
} from \\"@react-native/assets-registry/registry\\";
"
`;