shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

Create a separate package for Session Storage Adapters

Open Praveen2106 opened this issue 3 years ago • 2 comments

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.

Praveen2106 avatar Aug 23 '22 13:08 Praveen2106

We would also like this feature. We have our own solution for this and do not want to have an additional parallel system.

murphpdx avatar Sep 13 '22 19:09 murphpdx

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"
  },

maktouch avatar Sep 22 '22 01:09 maktouch

+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.

dxptqhtlutehvlyxcmtg avatar Oct 08 '22 02:10 dxptqhtlutehvlyxcmtg

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;

dxptqhtlutehvlyxcmtg avatar Oct 08 '22 05:10 dxptqhtlutehvlyxcmtg

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

cquemin avatar Dec 15 '22 20:12 cquemin