Comments (5)
This is a bit problematic.
The first issue is fs.readdirSync
. I'm not familiar with webpack but with browserify you can use the brfs
transform and get the list of resources as expected in the bundle. I guess the same can be achieved in webpack.
The second issue is that resources are required and instantiated lazily. This will not work with bundlers because AFAIK they can only read require()
calls that are statically analyzable.
So I think that right now there is no way to use the lib in the browser unless we remove the lazy require feature.
from shopify-api-node.
Actually it seems that webpack supports dynamic requires. I'll see if I can find a way to make it work.
from shopify-api-node.
I managed to make it work with webpack. Here is the configuration and the required dependencies:
'use strict';
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
libraryTarget: 'umd',
library: 'Shopify'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.js$/,
loader: 'transform?brfs'
}
]
}
};
babel-core
babel-loader
babel-preset-es2015
brfs
json-loader
transform-loader
webpack
It seems to work but the generated bundle is ~750 KB 😄 (~180 KB when minimized).
As said above, I'm not a webpack expert so maybe it can be improved.
from shopify-api-node.
With 5f83632 the size of the generated bundle is ~380 KB (~130 KB minimized). We can reduce it further by removing the lodash
dependency and using some lightweight alternatives for _.pick
and _.omit
, but I don't know if it makes sense as the library has not been designed for the browser.
from shopify-api-node.
Thanks for this!
from shopify-api-node.
Related Issues (20)
- Unable to make any calls with the API - Always getting HTML in the body HOT 2
- collectionListing is not working HOT 2
- Unable to add properties to line_items HOT 1
- Error build incorretly extends interface HOT 1
- deprecated API and custom app warning HOT 7
- IOrder type missing some properties HOT 1
- Uncatchable exception thrown HOT 2
- customerRecover
- fulfillmentOrder.list calls `/assigned_fulfillment_orders` instead of `/orders/:id/fulfillment_orders` HOT 2
- can i have example of update customer metafileds
- Discount Code lookup redirects HOT 1
- Error: Missing or invalid options HOT 2
- When using shopify order list api it gives data but shopify api helath-check give unsupported warning HOT 9
- shopify.order.cancel({ id }), name: "HTTPError", code: "ERR_NON_2XX_3XX_RESPONSE" HOT 1
- only able to create single order HOT 1
- ERR_NON_2XX_3XX_RESPONSE - shopify.location.list
- Update for breaking Shopify API changes
- Get Shopify shop name from object with correct type HOT 2
- Shopify Deprecating Rest API HOT 1
- Shedule request based on query costs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify-api-node.