Currently, the SDK doesn't support named imports when running in a Node.js environment:
// Doesn't work!
import { ShopperLogin } from "commerce-sdk-isomorphic";
// Have to do this instead:
import capi from "commerce-sdk-isomorphic";
const { ShopperLogin } = capi;
It would be nice if named imports worked 😁
Steps to reproduce:
mkdir test-commerce-isomorphic-sdk-named-imports
cd test-commerce-isomorphic-sdk-named-imports
npm init -y
npm i commerce-sdk-isomorphic
# Set `"type": "module"` in your `package.json`.
echo 'import { ShopperLogin } from "commerce-sdk-isomorphic";' > index.js
node index.js
Observe the following error:
import { ShopperLogin } from "commerce-sdk-isomorphic";
^^^^^^^^^^^^
SyntaxError: Named export 'ShopperLogin' not found. The requested module 'commerce-sdk-isomorphic' is a CommonJS module, which may not support all module.exports as named exports
Currently, the SDK doesn't support named imports when running in a Node.js environment:
It would be nice if named imports worked 😁
Steps to reproduce:
Observe the following error: