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 template has not been updated to the new plugins syntax #2992

Closed
3 tasks done
dev-javid opened this issue Oct 26, 2022 · 7 comments
Closed
3 tasks done

Webpack template has not been updated to the new plugins syntax #2992

dev-javid opened this issue Oct 26, 2022 · 7 comments

Comments

@dev-javid
Copy link

Pre-flight checklist

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

Electron Forge version

6.0.0-beta.68

Electron version

v21.2.0

Operating system

Windows 10

Last known working Electron Forge version

No response

Expected behavior

npm start should launch the application

Actual behavior

Getting error:

An unhandled rejection has occurred inside Forge:
Error: Expected plugin to either be a plugin instance or a { name, config } object but found @electron-forge/plugin-webpack,[object Object]

Electron Forge was terminated. Location:
{}

image

Steps to reproduce

I am trying to create a fresh TypeScript + Webpack application using electron-forge

Go to https://www.electronforge.io/templates/typescript-+-webpack-template

Copy the command to create new project:
npx create-electron-app my-new-app --template=typescript-webpack

Without changing any code run the application using npm start

Additional information

No response

@rinqtmith
Copy link

I have fixed this by changing plugins in package.json to below according to this link.

      "plugins": [
        {
          "name": "@electron-forge/plugin-webpack",
          "config": {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.ts",
                  "name": "main_window"
                }
              ]
            }
          }
        }
      ]

@MarshallOfSound
Copy link
Member

Ah yes good catch, @rinqtmith is correct. We recently changed the syntax for plugins to more closer align with the syntax for makers / publishers. Looks like we forgot to update the webpack template to use the new syntax 😅

@MarshallOfSound MarshallOfSound changed the title Error: Expected plugin to either be a plugin instance or a { name, config } object but found @electron-forge/plugin-webpack,[object Object] Webpack template has not been updated to the new plugins syntax Oct 26, 2022
@MarshallOfSound
Copy link
Member

Fixed in #2990

@raphael10-collab
Copy link

raphael10-collab commented Oct 27, 2022

@rinqtmith @MarshallOfSound I'm sorry. I do not understand what should I do in order to fix this issue that suddenly came up

This is my electron forge config in package.json :

      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "devServer": {
              "client": {
                "logging": "info",
                "overlay": {
                  "errors": true,
                  "warnings": false
                }
              },
              "allowedHosts": [
                "all"
              ],
              "devMiddleware": {
                "index": false
              }
            },
            "mainConfig": "./webpack.main.config.js",
            "devContentSecurityPolicy": "default-src 'unsafe-eval' 'self'; script-src-elem 'self' 'unsafe-inline'; img-src *; style-src 'self' 'unsafe-inline'; font-src 'self' https://static2.sharepointonline.com; connect-src 'self' https: http:",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/app/index.html",
                  "js": "./src/app/renderer.ts",
                  "preload": {
                    "js": "./src/main/preload/preload.ts"
                  },
                  "name": "main_window"
                },
                {
                  "html": "./src/app_A/index_A.html",
                  "js": "./src/app_A/renderer_A.ts",
                  "preload": {
                    "js": "./src/main/preload/preload.ts"
                  },
                  "name": "window_type_a"
                },
                {
                  "html": "./src/app_S/index_S.html",
                  "js": "./src/app_S/renderer_S.ts",
                  "css": "./src/app_S/components/style.css",
                  "preload": {
                    "js": "./src/main/preload/preload.ts"
                  },
                  "name": "search_window"
                },
                {
                  "html": "./src/app_F/index_F.html",
                  "js": "./src/app_F/renderer_F.ts",
                  "preload": {
                    "js": "./src/main/preload/preload.ts"
                  },
                  "name": "window_type_f"
                },
                {
                  "html": "./src/app_C/index_C.html",
                  "js": "./src/app_C/renderer_C.ts",
                  "preload": {
                    "js": "./src/main/preload/preload.ts"
                  },
                  "name": "window_type_c"
                }
              ]
            }
          }
        ]
      ]
    }

electron-forge installed :

    "@electron-forge/cli": "^6.0.0-beta.63",
    "@electron-forge/maker-deb": "^6.0.0-beta.63",
    "@electron-forge/maker-flatpak": "^6.0.0-beta.63",
    "@electron-forge/maker-rpm": "^6.0.0-beta.63",
    "@electron-forge/maker-snap": "^6.0.0-beta.63",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.63",
    "@electron-forge/maker-zip": "^6.0.0-beta.63",
    "@electron-forge/plugin-electronegativity": "^6.0.0-beta.63",
    "@electron-forge/plugin-webpack": "^6.0.0-beta.68",

@rinqtmith
Copy link

I think it is not fixed in #2990. I tried a new project and it still makes old version package.json .

You need to pass an object {name, config} to plugins. For example,

 "plugins": [
        {
          "name": "@electron-forge/plugin-webpack",
          "config": {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.ts",
                  "name": "main_window",
                  "preload": {
                    "js": "./src/preload.ts"
                  }
                }
              ]
            }
          }
        }
      ]

@MarshallOfSound
Copy link
Member

@raphael10-collab per the comment above you need to change this syntax.

"plugins": [
  [
    "@electron-forge/plugin-webpack",
    { ... }
  ]
]

into this syntax

"plugins": [
  {
    "name": "@electron-forge/plugin-webpack",
    "config": { ... }
  }
]

@rinqtmith the fix has not been published yet, we're aiming to get that out tomorrow PST

@raphael10-collab

This comment was marked as resolved.

puppis pushed a commit to bojanczyk/slajdomat that referenced this issue Mar 1, 2023
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

4 participants