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 issues with Websocket in tests #7972

Open
sbland opened this issue Sep 27, 2023 · 1 comment
Open

Webpack issues with Websocket in tests #7972

sbland opened this issue Sep 27, 2023 · 1 comment

Comments

@sbland
Copy link

sbland commented Sep 27, 2023

Description

Since upgrading bit and my envs I now get an issue with ws_1.WebSocketServer being undefined.

Relevant code:

import { WebSocket, RawData, WebSocketServer } from 'ws';

const wss: WebSocketServer = new WebSocketServer({
  port,
  server,
});

Seems to be related to this issue: websockets/ws#1538 but no steps here resolve my setup. I've added the webpack overrides to my environment webpack transformers as below:

export const modifyOutputTransformer = (configMutator) => {
  const newWebpackConfig = {
    resolve: {
      mainFields: ['main', 'browser'],
    },
  };


  configMutator.merge([newWebpackConfig]);
  return configMutator;
};
...
 /**
  * generates the component previews during development and during build
  */
 preview(): EnvHandler<Preview> {
   /**
    * @see https://bit.dev/docs/react-env/component-previews
    */
   return ReactPreview.from({
     mounter: this.previewMounter,
     hostDependencies,
     transformers: [modifyOutputTransformer],
   });
 }
...

Specifications

  • Bit version: 1.0.0
  • Workspace type: harmony
  • Node version: 16
  • npm / yarn version:(npm v8.19.4)
  • Platform: ubuntu
@GiladShoham
Copy link
Member

Can you please console.log(configMutator.raw) and see that the final webpack config is as expected?
Also, I'm not sure how this config will affect other libraries used by the preview. it might break it completely.

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

No branches or pull requests

2 participants