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

Allow custom ignore for webpack plugin users #1444

Closed
3 tasks done
NaridaL opened this issue Jan 28, 2020 · 8 comments · Fixed by #1447
Closed
3 tasks done

Allow custom ignore for webpack plugin users #1444

NaridaL opened this issue Jan 28, 2020 · 8 comments · Fixed by #1447
Labels
bug plugin/webpack Issues or pull requests related to first-party webpack plugins/templates

Comments

@NaridaL
Copy link

NaridaL commented Jan 28, 2020

Preflight Checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version:

6.0.0-beta.47

  • Electron Version:

v7.1.10

  • Operating System:
  • Last Known Working Electron Forge version::

image

Expected Behavior

webpack plugin should respect the externals property of the webpack config

Actual Behavior

It doesn't

To Reproduce

I'm using selenium-webdriver in my app (no, not for testing...), which doesn't compile with webpack (see SeleniumHQ/selenium#7726 ). I've added it to webpack's externals, which work fine during development:

module.exports = {
  // Put your normal webpack config below here
  resolve: {
    // Add `.ts` and `.tsx` as a resolvable extension.
    extensions: ['.ts', '.tsx', '.js'],
  },
  module: {
    rules,
  },
  externals: [
    function(context, request, callback) {
      if (
        [
          'selenium-webdriver',
          'selenium-webdriver/chrome',
        ].includes(request)
      ) {
        return callback(null, 'commonjs ' + request)
      }
      callback()
    },
  ],
}

Unfortunately, when I package it, all the node_modules are removed, and the app doesn't start...

The webpack plugin should either understand the externals configuration, or it should include an option to manually whitelist particular dependencies.

Additional Information

@NaridaL NaridaL added the bug label Jan 28, 2020
@malept malept added duplicate plugin/webpack Issues or pull requests related to first-party webpack plugins/templates labels Jan 28, 2020
@malept
Copy link
Member

malept commented Jan 28, 2020

This sounds like a duplicate of #1250.

@malept malept closed this as completed Jan 28, 2020
@NaridaL
Copy link
Author

NaridaL commented Jan 28, 2020

@malept

This is specifically about a module which won't work with webpack.

The other issue seems to have found a workaround by not externalizing it?

@malept malept removed the duplicate label Jan 28, 2020
@malept malept changed the title Webpack-plugin doesn't support externals Allow custom ignore for webpack plugin users Jan 28, 2020
@malept malept reopened this Jan 28, 2020
@malept
Copy link
Member

malept commented Jan 28, 2020

From #1447 (comment):

I've starting trying to work around my issue by moving all of the dependencies, except the one I want bundled, into devDependencies and overriding electronPackager.ignore. This makes sense because the dependencies really are used only during development as "sources" for webpack.

Maybe this approach should be considered as the "official" way of doing it? It would require less magic in the webpack plugin and therefore much more intuitive.

I don't think the approach to put everything bundled by webpack into devDependencies, mostly because it goes against what most people learn about how dependencies vs devDependencies works.

I propose to add a config option to WebpackPluginConfig, includeExternals, which would be an array of glob patterns that would get copied over during packaging.

@malept malept reopened this Jan 28, 2020
@NaridaL
Copy link
Author

NaridaL commented Jan 29, 2020

@malept What do people learn about dev/Dependencies?

I think there are two main use cases for webpack. Webapps, where usually you only deploy the generated bundle, and don't care about the package. And packages where webpack is used to compile only the package sources and not dependencies, in which case you do want dependencies as non-dev dependencies.

Electron packages don't seem to fit in either category.

In any case, manually specifying the packages which should get copied is problematic, as you also need to manually specify all the dependencies which need to get copied. For example, selenium-webdriver has 4 dependencies, which also have their own deps, which would all need to be manually added to the includeExternals option.

Electron-Packager already seems to have logic which resolves the required dependencies tree from package.dependencies

@tsvetilian-ty
Copy link

tsvetilian-ty commented Jun 26, 2020

Is there progress with this issue? At the moment we are facing the same problem... Do you @NaridaL and @malept have any workarounds?

@NaridaL
Copy link
Author

NaridaL commented Jun 26, 2020

@tsvetilian-ty #1451 (comment)

@barbalex
Copy link

barbalex commented Jul 13, 2020

@malept I personally would not care how I have to place my dependencies in package.json, as long as this hard problem is solved. This problem is a real blocker for webpack noobs like me

@malept
Copy link
Member

malept commented Aug 6, 2021

Fixed in #2424

@malept malept closed this as completed Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug plugin/webpack Issues or pull requests related to first-party webpack plugins/templates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants