Skip to content

Commit

Permalink
Add files for react-native export compatibility (#2451)
Browse files Browse the repository at this point in the history
`@metamask/snaps-controllers` has a `/react-native` export, but React
Native seemingly doesn't support exports (or at least the version we use
in the mobile repository)? This adds a `react-native.js` and
`react-native.d.ts` file to support tools that don't support exports.
  • Loading branch information
Mrtenz authored May 31, 2024
1 parent 3431866 commit 0d59bdc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ gen_enforced_field(WorkspaceCwd, 'files', ['dist']) :-
WorkspaceCwd \= '.',
WorkspaceCwd \= 'packages/snaps-jest',
WorkspaceCwd \= 'packages/snaps-cli',
WorkspaceCwd \= 'packages/snaps-controllers',
WorkspaceCwd \= 'packages/snaps-sdk'.
gen_enforced_field(WorkspaceCwd, 'files', ['dist', 'jest-preset.js']) :-
WorkspaceCwd = 'packages/snaps-jest'.
Expand Down
4 changes: 3 additions & 1 deletion packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"files": [
"dist"
"dist",
"react-native.d.ts",
"react-native.js"
],
"scripts": {
"test:prepare": "yarn mkdirp test/fixtures && ./scripts/generate-fixtures.sh",
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-controllers/react-native.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/types/react-native';
5 changes: 5 additions & 0 deletions packages/snaps-controllers/react-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable */

// Re-exported for compatibility with build tools that don't support the
// `exports` field in package.json
module.exports = require('./dist/react-native');
8 changes: 7 additions & 1 deletion packages/snaps-controllers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"compilerOptions": {
"baseUrl": "./"
},
"include": ["./src", "scripts", "package.json", "tsup.config.ts"],
"include": [
"./src",
"scripts",
"package.json",
"tsup.config.ts",
"react-native.d.ts"
],
"references": [
{ "path": "../snaps-execution-environments" },
{ "path": "../snaps-rpc-methods" },
Expand Down

0 comments on commit 0d59bdc

Please sign in to comment.