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

Importing SDK into webpack 5 app requires extra library configuration #3842

Open
tomBarkerSwitchTelecom opened this issue Sep 18, 2024 · 4 comments
Labels
bug Bug

Comments

@tomBarkerSwitchTelecom
Copy link

Describe the bug
When importing the SDK into a webpack 5 application there are underlying libraries that are no longer included as standard (for browser) which need require modifying the links to the libraries.

Is this expected?

libraries affected:

  • crypto
  • os
  • querystring
  • stream
  • vm

To Reproduce
Steps to reproduce the behavior:

  1. npx create-react-app webex-test --template typescript
  2. cd webex-test
  3. npm install --save webex
  4. Add <script crossorigin src="https://unpkg.com/webex/umd/webex.min.js"></script> to index.html
  5. Add const Webex = require("webex"); to App.tsx
  6. npm start

Expected behavior
SDK to import the underlying libraries it requires.

Workaround
Installing a browser version of the library and then "linking" it in the package.json seems to solve these issues.
see this example app https://github.com/tomBarkerSwitchTelecom/webex-test.

Screenshots
image

Platform (please complete the following information):

  • OS: [iOS]
  • Browser [chrome]
  • Version [3.4.0]
  • Device Type [Desktop]

Additional context

@sreenara
Copy link
Contributor

Thanks for raising this bug @tomBarkerSwitchTelecom. We'll take a look at this shortly. I see both the issues #3841 and this one are related.

@Shreyas281299
Copy link
Contributor

Shreyas281299 commented Sep 20, 2024

@tomBarkerSwitchTelecom, webpack > 5 removed the ability to automatically polyfill node APIs, because of this we have to install each polyfill and add them as resolve.fallback in webpack.config.js.

So if we have to use os,

Changes in package.json
"os-browserify": "0.3.0" //devDependency

Changes in webpack.config

resolve:{
      fallback:{
             os: require.resolve('os-browserify'),

This might be a helpful article - https://gist.github.com/ef4/d2cf5672a93cf241fd47c020b9b3066a

@tomBarkerSwitchTelecom
Copy link
Author

Thanks for the reply.
I originally went through that article and that was how i found the work around I suggested in the ticket.
The problem with the solution in the ticket is that it requires "ejecting" the create react app which is a pretty nuclear solution, (but admittedly, ejecting isn't required for the solution I found).

Given that webe-js-sdk is designed for use in the browser is there an appetite to move to consuming the browser based versions of these dependencies and explicitly auto add them to the package lock so that this work around (and ejecting) isn't required?

@Shreyas281299
Copy link
Contributor

@tomBarkerSwitchTelecom - we have created an internal ticket and the team will pick it up in the coming month.

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

No branches or pull requests

3 participants