Open
Description
Although ES6 imports work with React Native bundlers, Jest does not support it natively.
Recently I introduced this package to our library. It works perfectly in RN integration test but
- it breaks our unit test using Jest and:
- all the consumers that does NOT mock our library.
/home/runner/work/amplify-ui/amplify-ui/node_modules/react-native-url-polyfill/auto.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import {setupURLPolyfill} from './index';
^^^^^^
SyntaxError: Cannot use import statement outside a module
I have (aws-amplify/amplify-js#11411) to workaround it by vendoring a bundle that transpiles this package to CommonJS module.
According to the Node.js doc on the dual module packages, historically the main
is entry point for the CommonJS module and module
is the entrypoint for the ES6 modules.
I think this repo should use the CommonJS require, or at least change the main
to point to a CommonJS module version of it.
I can contribute a PR if we agree this is the right direction.
Metadata
Metadata
Assignees
Labels
No labels