Closed yantakus closed 7 years ago
I would need a lot more information than that to know why webpack is blowing up.
Off the top of my head: are you configuring webpack to expect an ES module? Or a common JS module?
our main
file is in common JS. If webpack is configured to look for a jsnext:main
, we have an es module there.
If you wanna be super explicit you can import whichever of the following works:
shopify-buy/index
-> commonjs
shopify-buy/index.es
-> es module
shopify-buy/index.amd
-> amd module
shopify-buy/index.umd
-> umd module
Hopefully this help!
This is what I see inside node_modules/shopify-buy
:
There's no files you mention.
The version I use: "shopify-buy": "^0.7.1",
. Did you expect me to use v1alpha
?
I'm using ES imports. As you can see above I'm using import shopifyBuy from 'shopify-buy';
and I have "modules": false
option in .babelrc
file.
Using import shopifyBuy from 'shopify-buy/dist/shopify-buy.umd';
helped to solve the issue, thanks.
Why isn't the UMD build exported as default?
Sorry, I was assuming this was the alpha. Glad you found a solution!
The UMD is not the default, because NPM convention is to support commonjs, and the UMD file is larger, so there's not a ton of advantage.
Just this one line
import shopifyBuy from 'shopify-buy';
(I mean even without using it anywhere further) is enough forwebpack -p
to fail with the following error:Any ideas on how to fix this?