You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to integrate this npm package with my Node + React.js + Webpack app.
When I try to import the package in React with import OSTSDK from '@ostdotcom/ost-sdk-js, I get the error Error: Cannot find module ".".
This error is caused by Webpack not supporting dynamic requires, as stated in their documentation https://webpack.js.org/guides/dependency-management/#require-with-expression. So an expression like serviceV0ManifestKlass = require(rootPrefix + '/services/v0/manifest') in the index.js file causes an error with Webpack, because it does not allow any dynamic variables (in this case rootPrefix) in the require function.
Hi @vliegenthart ,
Thanks for reporting the issue.
We had considered making the SDK work on browser in the past.
But, we always ended-up coming to a conclusion that prevented us from proceeding further.
The Conclusion:
If you are using sdk from client-side (browser), you are exposing your API key and secret.
Having said that, we would like to understand more about your needs.
Thanks for your response. I completely understand your reasoning about server-side vs client-side.
I was just experimenting with some testing setups, so it was more an issue out of interest why it does not work with client-side. By now I have integrated the OST SDK JS in my Express API server, so there is no need for any fixes from my side. Thank you :)
I'm trying to integrate this npm package with my Node + React.js + Webpack app.
When I try to import the package in React with
import OSTSDK from '@ostdotcom/ost-sdk-js
, I get the errorError: Cannot find module "."
.This error is caused by Webpack not supporting dynamic requires, as stated in their documentation https://webpack.js.org/guides/dependency-management/#require-with-expression. So an expression like
serviceV0ManifestKlass = require(rootPrefix + '/services/v0/manifest')
in the index.js file causes an error with Webpack, because it does not allow any dynamic variables (in this caserootPrefix
) in the require function.Another example of this issue can be seen here: webpack/webpack#5680.
Would be amazing if this issue could be fixed soon, so we can use the package with a Webpack configuration :)
The text was updated successfully, but these errors were encountered: