Skip to content

Commit 379f6c0

Browse files
ashuvssutbobbor
andauthored
fix(react): export dist CSS entrypoints for Metro compatibility (#6962)
* fix(react): export dist CSS entrypoints for Metro compatibility Metro warns when resolving Amplify UI CSS from React Native web/DOM usage because it probes the built subpath `./dist/styles.css`, which was not listed in package `exports`. Add explicit `./dist/styles.css` export aliases for `@aws-amplify/ui-react` and `@aws-amplify/ui-react-liveness` so Metro no longer have to implicitly fallback to file-based resolution. ``` WARN Attempted to import the module "…/node_modules/styles.css" which is not listed in the "exports" of "…/@aws-amplify/ui-react" under the requested subpath "./dist/styles.css". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API. WARN Attempted to import the module "…/node_modules/styles.css" which is not listed in the "exports" of "…/@aws-amplify/ui-react-liveness" under the requested subpath "./dist/styles.css". Falling back to file-based resolution. … ``` * chore: add changeset --------- Co-authored-by: Philipp Andreas Paul <phandpau@amazon.de>
1 parent d6b6813 commit 379f6c0

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

.changeset/warm-dogs-return.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@aws-amplify/ui-react-liveness': patch
3+
'@aws-amplify/ui-react': patch
4+
---
5+
6+
Fix Metro warnings by explicitly exporting dist CSS entrypoints in package.json. Added `./dist/styles.css` export aliases to prevent Metro from implicitly falling back to file-based resolution.

packages/react-liveness/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
"import": "./dist/esm/index.mjs",
1010
"require": "./dist/index.js"
1111
},
12-
"./styles.css": "./dist/styles.css"
12+
"./styles.css": "./dist/styles.css",
13+
"./dist/styles.css": "./dist/styles.css"
1314
},
1415
"browser": {
15-
"./styles.css": "./dist/styles.css"
16+
"./styles.css": "./dist/styles.css",
17+
"./dist/styles.css": "./dist/styles.css"
1618
},
1719
"types": "dist/types/index.d.ts",
1820
"sideEffects": [
@@ -87,4 +89,4 @@
8789
"limit": "229 kB"
8890
}
8991
]
90-
}
92+
}

packages/react/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
"require": "./dist/server.js"
2121
},
2222
"./styles.css": "./dist/styles.css",
23+
"./dist/styles.css": "./dist/styles.css",
2324
"./styles.layer.css": "./dist/styles.layer.css",
2425
"./styles/*": "./dist/styles/*",
2526
"./primitives.json": "./dist/primitives.json"
2627
},
2728
"browser": {
28-
"./styles.css": "./dist/styles.css"
29+
"./styles.css": "./dist/styles.css",
30+
"./dist/styles.css": "./dist/styles.css"
2931
},
3032
"types": "dist/types/index.d.ts",
3133
"license": "Apache-2.0",

0 commit comments

Comments
 (0)