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

Installing and initializing the live-plugin-manager breaks the module build #1929

Closed
3 tasks done
karlitos opened this issue Aug 24, 2020 · 17 comments · Fixed by #2149
Closed
3 tasks done

Installing and initializing the live-plugin-manager breaks the module build #1929

karlitos opened this issue Aug 24, 2020 · 17 comments · Fixed by #2149
Labels
bug plugin/webpack Issues or pull requests related to first-party webpack plugins/templates

Comments

@karlitos
Copy link

karlitos commented Aug 24, 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.52
  • Electron Version:
    • v9.1.2
  • Operating System:
    • macOs 10.13.6 (
  • Last Known Working Electron Forge version::
    • 6.0.0-beta.52

Expected Behavior

I followed the instructions at live-plugin-manager

Actual Behavior

After installing the live-plugin-manager and initializing the manager as:

import { PluginManager } from 'live-plugin-manager';

const manager = new PluginManager();

the npm start results in App throwing following error:

App threw an error during load
Error: Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (85:14)
    at Object.module.exports.pp$4.raise (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20834:13)
    at Object.module.exports.pp.unexpected (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18680:8)
    at Object.module.exports.pp$1.parseTryStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19069:49)
    at Object.module.exports.pp$1.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834:32)
    at Object.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539:118)
    at Object.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314:22)
    at Object.module.exports.pp$1.parseBlock (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157:23)
    at Object.module.exports.pp$1.parseTryStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19073:24)
    at Object.module.exports.pp$1.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834:32)
    at Object.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539:118)
    at Object.parseStatement (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314:22)
    at Object.module.exports.pp$1.parseBlock (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157:23)
    at Object.module.exports.pp$3.parseFunctionBody (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20675:22)
    at Object.module.exports.pp$3.parseArrowExpression (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20638:8)
    at Object.module.exports.pp$3.parseExprAtom (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20227:21)
    at Object.parseExprAtom (/Users/kmacha/Dev/kiss-my-resume/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4551:117)
    at Object../node_modules/fs-extra/lib/mkdirs/make-dir.js (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:9642:7)
    at __webpack_require__ (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/mkdirs/index.js (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:9619:44)
    at __webpack_require__ (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/copy-sync/copy-sync.js (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:8559:20)
    at __webpack_require__ (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/copy-sync/index.js (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:8736:13)
    at __webpack_require__ (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:21:30)
    at Object../node_modules/fs-extra/lib/index.js (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:9485:6)
    at __webpack_require__ (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:21:30)

To Reproduce

Pull the electron-app branch of my app, install the live-plugin-manager and initialize the manager.

Additional Information

Generally this bug might be caused by the live-plugin-manager. I am seraching for solution allowing users locally install npm packages without needing to depend on npm installation. I tried to fetch those packages via HTTP, but then their dependencies are not installed. Maybe there is another way of achieving this without needing to use the live-plugin-manager

Full log with DEBUG=*

https://pastebin.com/zkBdNQfr

@barbalex
Copy link

barbalex commented Aug 26, 2020

I get the same issue when updating @electron-forge above version 6.0.0-beta.50. Tested with 6.0.0-beta.52, 6.0.0-beta.53, 6.0.0-beta.54

@barbalex
Copy link

similar issue: #1726

@karlitos
Copy link
Author

Many thanks, I tries to downgrade @electron_forge to version 6.0.0-beta.50 but this did not help

$ npm list | grep @electron-forge*
├─┬ @electron-forge/[email protected]
│ ├─┬ @electron-forge/[email protected]
│ ├─┬ @electron-forge/[email protected]
│ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ └── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ └─┬ @electron-forge/[email protected]
│ │ │   ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├─┬ @electron-forge/[email protected]
│ │ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ └── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├── @electron-forge/[email protected] deduped
│ │ ├── @electron-forge/[email protected] deduped
│ │ ├── @electron-forge/[email protected]
│ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ ├─┬ @electron-forge/[email protected]
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ │ │ ├── @electron-forge/[email protected] deduped
│ ├─┬ @electron-forge/[email protected]
│ │ ├── @electron-forge/[email protected] deduped
├─┬ @electron-forge/[email protected]
│ ├─┬ @electron-forge/[email protected]
│ │ ├── @electron-forge/[email protected] deduped
│ ├── @electron-forge/[email protected] deduped
├─┬ @electron-forge/[email protected]
│ ├── @electron-forge/[email protected] deduped
│ ├── @electron-forge/[email protected] deduped
├─┬ @electron-forge/[email protected]
│ ├── @electron-forge/[email protected] deduped
│ ├── @electron-forge/[email protected] deduped
├─┬ @electron-forge/[email protected]
│ ├── @electron-forge/[email protected] deduped
│ ├── @electron-forge/[email protected] deduped
├─┬ @electron-forge/[email protected]
│ ├── @electron-forge/[email protected] deduped
│ ├─┬ @electron-forge/[email protected]
│ │ └── @electron-forge/[email protected] deduped
│ ├── @electron-forge/[email protected] deduped
│ ├─┬ @electron-forge/[email protected]

@barbalex
Copy link

Sorry to hear. Seems that webpack combined with native modules is a hard nut to crack: #621 (comment)

@linonetwo
Copy link

linonetwo commented Aug 30, 2020

Import fs-extra will cause this bug too.

This is caused by @marshallofsound/webpack-asset-relocator-loader, you can simply comment it out in the :

module.exports = [
  // Add support for native node modules
  {
    test: /\.node$/,
    use: 'node-loader',
  },
  // {
  //   test: /\.(m?js|node)$/,
  //   parser: { amd: true },
  //   use: {
  //     loader: '@zeit/webpack-asset-relocator-loader',
  //     options: {
  //       outputAssetBase: 'native_modules',
  //       emitDirnameAll: true,
  //     },
  //   },
  // },
  {
    test: /\.tsx?$/,

...

I can't understand why we need this plugin, it seems useless according to its readme...

And I try replace it with @zeit/webpack-asset-relocator-loader, then there will be Uncaught ReferenceError: __dirname is not defined bug vercel/webpack-asset-relocator-loader#97

So currently just comment it out, and it is fixed.

@karlitos
Copy link
Author

karlitos commented Sep 1, 2020

Many thanks @linonetwo, I commented the rule out and this fixed the build errors. I also wonder what the webpack-asset-relocator-loader is good for. I have to test the app further and see if I can build and package my app without any further problems.

@timfish
Copy link
Contributor

timfish commented Jan 6, 2021

webpack-asset-relocator-loader finds and relocates assets. Most importantly in the electron-forge context, it relocates binaries for node native modules when bundling with Webpack.

electron-forge uses a patched version which hasn't been updated for a while.

@linonetwo
Copy link

well, why electron-forge works fine without it?

@timfish
Copy link
Contributor

timfish commented Jan 7, 2021

Unless you're using a native node module, you are unlikely to need webpack-asset-relocator-loader...

@dianlight
Copy link

I don't know but in my project if I use the original @vercel/webpack-asset-relocator-loader work fine also with native modules.

@malept malept added the plugin/webpack Issues or pull requests related to first-party webpack plugins/templates label Aug 6, 2021
@barbalex
Copy link

Still getting this with v6.0.0-beta.59. Hoping for #2149 to solve it 🙏

@barbalex
Copy link

barbalex commented Sep 9, 2021

v6.0.0-beta.60 finally solved this for us 🚀

@barbalex
Copy link

barbalex commented Sep 9, 2021

Nope, on next yarn dev I got:

App threw an error during load
Error: Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (13:10)
    at Object.module.exports.pp$4.raise (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:20834:13)
    at Object.module.exports.pp.unexpected (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:18680:8)
    at Object.module.exports.pp$1.parseTryStatement (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:19069:49)
    at Object.module.exports.pp$1.parseStatement (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:18834:32)
    at Object.parseStatement (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:4539:118)
    at Object.parseStatement (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:42314:22)
    at Object.module.exports.pp$1.parseBlock (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:19157:23)
    at Object.module.exports.pp$3.parseFunctionBody (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:20675:22)
    at Object.module.exports.pp$1.parseFunction (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:19273:8)
    at Object.module.exports.pp$3.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:20219:21)
    at Object.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:4551:117)
    at Object.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:42293:75)
    at Object.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:35894:26)
    at Object.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:15975:26)
    at Object.parseExprAtom (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:380:26)
    at Object.module.exports.pp$3.parseExprSubscripts (C:\Users\alexa\kapla4\node_modules\@marshallofsound\webpack-asset-relocator-loader\dist\index.js:20116:19)
    at Object../node_modules/fs-extra/lib/empty/index.js (C:\Users\alexa\kapla4\.webpack\main\index.js:10474:7)
    at __webpack_require__ (C:\Users\alexa\kapla4\.webpack\main\index.js:13400:41)
    at Object../node_modules/fs-extra/lib/index.js (C:\Users\alexa\kapla4\.webpack\main\index.js:10687:6)
    at __webpack_require__ (C:\Users\alexa\kapla4\.webpack\main\index.js:13400:41)
    at C:\Users\alexa\kapla4\.webpack\main\index.js:13425:10
    at C:\Users\alexa\kapla4\.webpack\main\index.js:13690:3
    at Object.<anonymous> (C:\Users\alexa\kapla4\.webpack\main\index.js:13693:12)
    at Module._compile (internal/modules/cjs/loader.js:1083:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1113:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
| Compiling Renderer Code
An unhandled rejection has occurred inside Forge:
[Error: EISDIR: illegal operation on a directory, read] {
  errno: -4068,
  code: 'EISDIR',
  syscall: 'read'
}

Electron Forge was terminated. Location:
{}
error Command failed with exit code 1.

Weird that that did not happen on the first run of yarn dev after upgrading.

@barbalex
Copy link

barbalex commented Sep 9, 2021

So this issue should be re-opened

@malept
Copy link
Member

malept commented Sep 9, 2021

So this issue should be re-opened

No, see https://www.electronforge.io/config/plugins/webpack#native-modules

@barbalex
Copy link

barbalex commented Sep 9, 2021

@malept Thanks a lot. I did not realize that the docs had changed. Following that advice I now run into #2361

@barbalex
Copy link

O.k., so after lots of experimenting I completely changed the way to use externals. I am now following https://www.electronforge.io/config/plugins/webpack#native-modules closely, using @vercel/webpack-asset-relocator-loader. And it works.

What broke it for me was the fact that my project had quite some history, struggling with the native library. So it used a lot of tips and tricks found in a number of other issues. Which seem not to work anymore for newer versions of electron-forge. Add to that my not understanding what is going on here, and you get quite a confusing mess.

Thanks a lot for this great tool, @malept

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.

6 participants