Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack error with dynamic requires #24

Closed
vliegenthart opened this issue Jul 14, 2018 · 3 comments
Closed

Webpack error with dynamic requires #24

vliegenthart opened this issue Jul 14, 2018 · 3 comments

Comments

@vliegenthart
Copy link

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.

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 :)

@rachinkapoor
Copy link
Contributor

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.

@vliegenthart
Copy link
Author

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 :)

@rachinkapoor
Copy link
Contributor

Closing the issue as consensus has been reached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants