aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
704 stars 475 forks source link

failed to parse source map from '.../node_modules/amazon-chime-sdk-js/src/websocketadapter/defaultwebsocketadapter.ts' #2594

Open manojkalpana24 opened 1 year ago

manojkalpana24 commented 1 year ago

failed to parse source map from '.../node_modules/amazon-chime-sdk-js/src/websocketadapter/defaultwebsocketadapter.ts' file: error: enoent: no such file or directory, open '.../node_modules/amazon-chime-sdk-js/src/websocketadapter/defaultwebsocketadapter.ts'

Tried upgrading the amazon-chime-sdk-js to the latest version but no use. As 'src/' directory is not published with amazon-chime-sdk-js so it's blocking us from debugging the actual source also the above error is thrown while building the react application.

xuesichao commented 1 year ago

Hi @manojkalpana24, sorry for late reply. I don't think we want to publish our src/ folder in our library because we already published compiled src/ folder - build folder.

It seems you imported defaultwebsocketadapter from wrong path. Try this instead:

node_modules/amazon-chime-sdk-js/build/websocketadapter/DefaultWebSocketAdapter.js
senthilnathan27 commented 1 year ago

how to use this path node_modules/amazon-chime-sdk-js/build/websocketadapter/DefaultWebSocketAdapter.js in create react app?

sd-hoag commented 2 months ago

Hi @manojkalpana24, sorry for late reply. I don't think we want to publish our src/ folder in our library because we already published compiled src/ folder - build folder.

It seems you imported defaultwebsocketadapter from wrong path. Try this instead:

node_modules/amazon-chime-sdk-js/build/websocketadapter/DefaultWebSocketAdapter.js

I've also been getting this error - and I am importing from the correct filepath mentioned:

Screenshot 2024-07-15 at 10 06 18 AM

Has there been any research into this?

mustafashabib commented 1 month ago

Hi @manojkalpana24 and @sd-hoag

If it's helpful, I added the filterSourceMappingUrl option to my webpack.config.js in the root of my project to skip trying to load source maps for these amazon-chime... related dependencies

See here for some details: https://webpack.js.org/loaders/source-map-loader/#filtersourcemappingurl

module: {
  strictExportPresence: true,
  rules: [
      // Handle node_modules packages that contain sourcemaps
      shouldUseSourceMap && {
          enforce: 'pre',
          exclude: /@babel(?:\/|\\{1,2})runtime/,
          test: /\.(js|mjs|jsx|ts|tsx|css)$/,
          loader: require.resolve('source-map-loader'),
          options: {
              filterSourceMappingUrl: (url, resourcePath) => {
                  const shouldSkipLoadingSourceMap =
                      /.*\/node_modules\/.*/.test(resourcePath) && /.*amazon-chime.*/.test(resourcePath);
                  return !shouldSkipLoadingSourceMap;
              },
          },
      },
jp-hoehmann commented 3 weeks ago

@xuesichao the root cause of this is the source maps published with amazon-chime-sdk-js. The final distribution contains source maps referencing sources that do not exist. The source maps should either be removed, or the sources they map to should be included.

For example the file build/websocketadapter/WebSocketReadyState.js included in the distribution currently includes the line //# sourceMappingURL=WebSocketReadyState.js.map. This causes the source map build/websocketadapter/WebSocketReadyState.js.map to be loaded, which in turn points to ../../src/websocketadapter/WebSocketReadystate.ts, which isn't included in the distribution, causing the error. To fix this, either the sources should be included in the distribution (allowing developers to step into the actual code of amazon-chime-sdk-js during debugging, but at the cost of increasing the package size), or the source maps (along with the references to them in the compiled javascript files) should be removed from the final package.