Create a separate package for Session Storage Adapters
Overview
Move the existing Session Storage Adapters to a separate package. Managing Sessions is not the Core Functionality of this Library.
It makes sense to provide Memory Session Storage for testing purposes and an extendable API for other Databases to use in production.
Type
- [x] Changes to existing features
Motivation
What inspired this feature request? What problems were you facing? We faced issues with the build due to compatibility with the packages used for Session Storage. Reducing the number of unused dependencies resolves many Build Issues reported here.
We would also like this feature. We have our own solution for this and do not want to have an additional parallel system.
Our build is failing because of a node-gyp error, and it's because shopify-api is installing sqlite, which we don't need. At the very least, the database drivers should be devDeps or peerDeps... to make them actually dependencies is not efficient at all, and causes a lot of trouble.
"dependencies": {
"@shopify/network": "^1.5.1",
"@types/jsonwebtoken": "^8.5.0",
"@types/node-fetch": "^2.5.7",
"@types/supertest": "^2.0.10",
"cookies": "^0.8.0",
"jsonwebtoken": "^8.5.1",
"mongodb": "^4.5.0", // ===========> to remove
"mysql2": "^2.3.3", // ===========> to remove
"node-fetch": "^2.6.1",
"pg": "^8.7.3", // ===========> to remove
"redis": "^4.1.0", // ===========> to remove
"sqlite3": "^5.0.8", // ===========> to remove
"tslib": "^2.0.3",
"uuid": "^8.3.1"
},
+1 for us too. These dependencies should be opt-in, not mandatory. Some of them require special configuration to build properly in certain situations. Users shouldn't have to be forced to do that for something they're not even using.
For anyone like us bundling their server code with Webpack (NestJs actually) and don't mind keeping node_modules around, we are able to build v5 of this package with the help of webpack-node-externals on Node 16:
// webpack.config.js
const nodeExternals = require("webpack-node-externals");
const webpackConfig = {
externals: [
nodeExternals(),
{
"@shopify/shopify-api": "commonjs2 @shopify/shopify-api",
},
],
};
module.exports = webpackConfig;
This is available in this monorepo : in particular all the session storage implementation are individual packages that implement the same interface defined by the session-storage package