I'm a maintainer for https://www.npmjs.com/package/@dfinity/agent, and a developer called out that our packages weren't working with default settings for React Native, so I dove into it to reproduce.
It turns out that using Module Namespacing in our ESM packages is breaking the build process when I compile it using the Expo tool. The error output looks like this:
Failed to compile.Module parse failed: Unexpected token (11:9)You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders| export * from '@dfinity/agent/lib/esm/request_id';| export * from '@dfinity/agent/lib/esm/utils/bls';> export * as polling from '@dfinity/agent/lib/esm/polling';| export * as Cbor from '@dfinity/agent/lib/esm/cbor';| //# sourceMappingURL=index.js.map
As you can see, the first few lines are correctly interpreting export * from
clauses, but it crashes anywhere that I use export * as
. I'd ideally like to find a way to support the package by changing a .tsconfig
setting or something, but I'm not sure if that's possible without breaking the current namespace setup.
Here are the tsconfig options we are using:
{"compilerOptions": {"target": "es2017","module": "commonjs","esModuleInterop": true,"lib": ["dom","es6","es2017" ],"rootDir": "./" }, ...}