SDK 37: cjs bundler error with superstruct library

SDK Version: 37
Platforms: All

Hi there,
I’m trying to use the module superstruct. (superstruct - npm)

I installed it with yarn add superstruct then tried to use it.
The cli tool won’t build my code, and it prints the following error:

InternalError Metro Bundler has encountered an error: While trying to resolve module `superstruct` from file `/Users/laurent/dev/singulargarden/logbook-mobile/src/stores/PostStore.ts`, the package `/Users/laurent/dev/singulargarden/logbook-mobile/node_modules/superstruct/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/laurent/dev/singulargarden/logbook-mobile/node_modules/superstruct/lib/index.cjs`. Indeed, none of these files exist:

  * /Users/laurent/dev/singulargarden/logbook-mobile/node_modules/superstruct/lib/index.cjs(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)
  * /Users/laurent/dev/singulargarden/logbook-mobile/node_modules/superstruct/lib/index.cjs/index(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)

It seems to work when I copy the .cjs file to a cjs.js file. Is this a bundler issue? Should I reconfigure the bundler to accept .cjs file somehow?

Bests,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.