Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support named imports in Node.js #78

Open
johnboxall opened this issue Feb 24, 2022 · 0 comments
Open

Support named imports in Node.js #78

johnboxall opened this issue Feb 24, 2022 · 0 comments
Labels
ack Acknowledged

Comments

@johnboxall
Copy link
Contributor

johnboxall commented Feb 24, 2022

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
@joeluong-sfcc joeluong-sfcc added the ack Acknowledged label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Acknowledged
Projects
None yet
Development

No branches or pull requests

2 participants