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

BlindTargetErrors when building @tanker and subscriptions-transport-ws #77

Open
qpre opened this issue Jul 24, 2020 · 2 comments
Open

Comments

@qpre
Copy link

qpre commented Jul 24, 2020

Hello !

First of all thanks a lot for your efforts on this particular matter that is differential loading,
the ecosystem shall be thankful !

I'm trying to convert a webpack configuration from a project using react / Apollo and a bunch of other tools to use this plugin. I've been in luck so far but just came across an issue that I do not know how to solve.

plugin revision: 2.5.0-next.2

webpack configuration:

// The base webpack config
const config = {
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  entry: path.resolve(__dirname, '../src/index.js'),
  output: {
    path: path.resolve(__dirname, '../dist/'),
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [BabelMultiTargetPlugin.loader(), 'eslint-loader'],
      },
    ],
  },
  resolve: {
    mainFields: ['es2015', 'module', 'main'],
  },
  plugins: [
    new BabelMultiTargetPlugin({
      doNotTarget: [
        /node_modules\/@tanker/,
        /node_modules\/subscriptions-transport-ws/,
      ],
      babel: {
        presets: ['@babel/preset-react'],
      },
    }),
  ],
  node: {
    fs: 'empty',
  },
};

Error output (stripped warnings for readability but there's a lot of Can't resolve 'xxx'):

ERROR in ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js
Module not found: Error: Can't resolve 'net' in '/Users/qpre/connected_physics/platform-web-stack/app/client-web/node_modules/subscriptions-transport-ws/node_modules/ws/lib'
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js 7:12-26
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/index.js
 @ ./node_modules/subscriptions-transport-ws/dist/server.js
 @ ./node_modules/subscriptions-transport-ws/dist?babel-target=legacy
 @ ./node_modules/apollo-link-ws/lib/bundle.esm.js?babel-target=legacy
 @ ./src/services/apollo-graphql.js?babel-target=legacy
 @ ./src/pages/_app/App.js?babel-target=legacy
 @ ./src?babel-target=legacy

ERROR in ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js
Module not found: Error: Can't resolve 'tls' in '/Users/qpre/connected_physics/platform-web-stack/app/client-web/node_modules/subscriptions-transport-ws/node_modules/ws/lib'
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js 8:12-26
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/index.js
 @ ./node_modules/subscriptions-transport-ws/dist/server.js
 @ ./node_modules/subscriptions-transport-ws/dist?babel-target=legacy
 @ ./node_modules/apollo-link-ws/lib/bundle.esm.js?babel-target=legacy
 @ ./src/services/apollo-graphql.js?babel-target=legacy
 @ ./src/pages/_app/App.js?babel-target=legacy
 @ ./src?babel-target=legacy

ERROR in ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js
Module not found: Error: Encountered unexpected blind targeting request for /Users/qpre/connected_physics/platform-web-stack/app/client-web/node_modules/babel-loader/lib/index.js??ref--4-0!/Users/qpre/connected_physics/platform-web-stack/app/client-web/node_modules/eslint-loader/dist/cjs.js!/Users/qpre/connected_physics/platform-web-stack/app/client-web/node_modules/crypto-browserify/index.js.Please see http://github.com/DanielSchaffer/webpack-babel-multi-target-plugin#blind-targeting for more information.
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js 4:15-32
 @ ./node_modules/subscriptions-transport-ws/node_modules/ws/index.js
 @ ./node_modules/subscriptions-transport-ws/dist/server.js
 @ ./node_modules/subscriptions-transport-ws/dist?babel-target=legacy
 @ ./node_modules/apollo-link-ws/lib/bundle.esm.js?babel-target=legacy
 @ ./src/services/apollo-graphql.js?babel-target=legacy
 @ ./src/pages/_app/App.js?babel-target=legacy
 @ ./src?babel-target=legacy

How can I move forward from this point of how could I help solving this ?

Thanks !

@DanielSchaffer
Copy link
Owner

@qpre Hello, and thanks for the report! If you remove the plugin from the configuration, does it work as expected? I ask because two of those errors you mention appear to be trying to import from NodeJS modules, which shouldn't really be happening for a web bundle.

It's also possible that due to the mainFields configuration, Webpack might be looking at the wrong entry point for subscriptions-transport-ws, if it has more than one.

@qpre
Copy link
Author

qpre commented Aug 20, 2020

Hello @DanielSchaffer sorry for the late reply I was on vacation.

If the plugin is removed, everything builds smoothly

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