What happened?
When using any esm metro config such as metro.config.mjs, metro.config.ts (react/metro#1560) or setting "type": "module", I get the following error when running the metro/expo build.
> uniwind-esm-import-repro@1.0.0 start /<dev>/uniwind-esm-import-repro
> expo start
Starting project at /<dev>/uniwind-esm-import-repro
Using src/app as the root directory for Expo Router.
TypeError: Error loading Metro config at: /<dev>/uniwind-esm-import-repro/metro.config.ts
Class extends value #<Object> is not a constructor or null
TypeError: Class extends value #<Object> is not a constructor or null
at file:///<dev>/uniwind-esm-import-repro/node_modules/uniwind/dist/metro/index.mjs:8:25
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:534:37)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:382:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1626:24)
at Module._compile (node:internal/modules/cjs/loader:1791:5)
at Object..js (node:internal/modules/cjs/loader:1940:10)
at Module.load (node:internal/modules/cjs/loader:1530:32)
at Module._load (node:internal/modules/cjs/loader:1332:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.require (node:internal/modules/cjs/loader:1553:12)
ELIFECYCLE Command failed with exit code 1.
The issue goes away when I patch the uniwind exports to specifically use the cjs build.
file: uniwind/package.json
"./metro": {
"types": "./dist/metro/index.d.ts",
+ "node": "./dist/metro/index.cjs",
"import": "./dist/metro/index.mjs",
"default": "./dist/metro/index.cjs"
},
Steps to Reproduce
In the repro repository:
pnpm install
pnpm start
Snack or Repository Link
https://github.com/stevezhu/uniwind-esm-import-repro
Uniwind version
1.3.0
React Native Version
0.83.1
Platforms
iOS, Android, Web
Expo
Yes
Additional information
What happened?
When using any esm metro config such as
metro.config.mjs,metro.config.ts(react/metro#1560) or setting"type": "module", I get the following error when running the metro/expo build.The issue goes away when I patch the uniwind exports to specifically use the cjs build.
file:
uniwind/package.json"./metro": { "types": "./dist/metro/index.d.ts", + "node": "./dist/metro/index.cjs", "import": "./dist/metro/index.mjs", "default": "./dist/metro/index.cjs" },Steps to Reproduce
In the repro repository:
pnpm installpnpm startSnack or Repository Link
https://github.com/stevezhu/uniwind-esm-import-repro
Uniwind version
1.3.0
React Native Version
0.83.1
Platforms
iOS, Android, Web
Expo
Yes
Additional information