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

Does not work without webpack polyfills in renderer mode #28

Closed
chaliy opened this issue Aug 10, 2022 · 2 comments
Closed

Does not work without webpack polyfills in renderer mode #28

chaliy opened this issue Aug 10, 2022 · 2 comments

Comments

@chaliy
Copy link

chaliy commented Aug 10, 2022

Error message:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }
resolve 'path' in '/Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron'
  Parsed request is a module
  using description file: /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules
        single file module
          using description file: /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/package.json (relative path: ./node_modules/path)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path.ts doesn't exist
            .jsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path.jsx doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path.tsx doesn't exist
            .css
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path.css doesn't exist
        /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/electron/node_modules/path doesn't exist
      /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules
        single file module
          using description file: /Users/mchalyi/Projects/uu3jrd/file-messenger/package.json (relative path: ./node_modules/path)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path.ts doesn't exist
            .jsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path.jsx doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path.tsx doesn't exist
            .css
              Field 'browser' doesn't contain a valid alias configuration
              /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path.css doesn't exist
        /Users/mchalyi/Projects/uu3jrd/file-messenger/node_modules/path doesn't exist
      /Users/mchalyi/Projects/uu3jrd/node_modules doesn't exist or is not a directory
      /Users/mchalyi/Projects/node_modules doesn't exist or is not a directory
      /Users/mchalyi/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
 @ ./node_modules/electron-unhandled/index.js 2:33-52 15:23-42 35:19-38
 @ ./src/renderer/index.tsx 18:45-74

So basically the problem here is that node APIs are not polyfilled any more. I guess recommended way to fix this, would be to extract part which is intended for rendrer, to something like unhandledRenderer and do not import what is not needed.

Would you accept PR on such change? This is super breaking change.

@sindresorhus
Copy link
Owner

The problem is your Webpack config.

@chaliy
Copy link
Author

chaliy commented Aug 11, 2022

Well this is "problem" with every new electron development. I guess nobody would like to introduce polyfills in their code just because library references something and then do not use. But okay. Anyways, it seems like it faster to implement just in application.

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

No branches or pull requests

2 participants