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

Module build failed with Webpack / Typescript boilerplate & fs-extra #1643

Closed
delewis13 opened this issue Apr 25, 2020 · 8 comments
Closed
Labels

Comments

@delewis13
Copy link

Issue Details

Electron Forge Version: 6.0.0-beta.47
OS: macOS 10.14.6

Expected Behavior

Ability to bundle app and use fs-extra module

Actual Behavior

Upon attempting to use any methods within fs-extra module hit a 'module build failed' error.

To Reproduce

yarn create electron-app my-new-app --template=typescript-webpack
yarn add fs-extra

Then update the typescript loader config in webpack.rules.js to the following [else webpack build fails, seems like template is currently broken]:

  {
    test: /\.tsx?$/,
    exclude: /(node_modules|\.webpack)/,
    use: {
      loader: 'ts-loader',
      options: {
        transpileOnly: true
      }
    }

Then enable node-integration in browser window, update renderer.ts to:

import "./index.css"
import fse from "fs-extra"

fse.access("./test")

console.log(
  '👋 This message is being logged by "renderer.js", included via webpack'
)

and finally: yarn start

Additional Information

`index.js:14 Uncaught Error: Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (86:14)
    at Object.module.exports.pp$4.raise (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20834)
    at Object.module.exports.pp.unexpected (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18680)
    at Object.module.exports.pp$1.parseTryStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19069)
    at Object.module.exports.pp$1.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834)
    at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539)
    at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314)
    at Object.module.exports.pp$1.parseBlock (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157)
    at Object.module.exports.pp$1.parseTryStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19073)
    at Object.module.exports.pp$1.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834)
    at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539)
    at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314)
    at Object.module.exports.pp$1.parseBlock (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157)
    at Object.module.exports.pp$3.parseFunctionBody (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20675)
    at Object.module.exports.pp$3.parseArrowExpression (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20638)
    at Object.module.exports.pp$3.parseExprAtom (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20227)
    at Object.parseExprAtom (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4551)
    at Object../node_modules/fs-extra/lib/mkdirs/make-dir.js (index.js:14)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:100)
    at Object../node_modules/fs-extra/lib/mkdirs/index.js (index.js:3)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:100)
    at Object../node_modules/fs-extra/lib/copy-sync/copy-sync.js (copy-sync.js:5)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:100)
    at Object../node_modules/fs-extra/lib/copy-sync/index.js (index.js:4)
@delewis13 delewis13 added the bug label Apr 25, 2020
@b-zurg
Copy link
Contributor

b-zurg commented Jun 1, 2020

I'm also seeing some issues with this. I found that the following configuration helps but it actually doesn't solve the problem completely:

  resolve: {
    extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".json"],
    modules: ["node_modules"],
  },

@rheimus
Copy link

rheimus commented Aug 3, 2020

Rolling back fs-extra to 8.1.0 resolved the issue for me, I have not tracked down exactly what is causing the issue with 9.x.x. Though it may be a good plan to raise an issue on the fs-extra project.

@b-zurg
Copy link
Contributor

b-zurg commented Aug 3, 2020

Oh wow. I guess in the meantime for those using yarn you can use a yarn resolution to ensure all usages of fs-extra are at 8.1.0 - though I wonder what the breaking changes are between the versions.

@karlitos
Copy link

Hi, I stumbled upon this issue and it seems, that it's related to #1929 I just checked, and the live-plugin-manager depends on "fs-extra": "^9.0.0" I now tries to downgrade the live-plugin-manager to version, which depends on fs-extra@8.1.0 but this does not solve my problem.

I checked, but multiple packages depends on fs-extra@9.0.1 and I did not have any problems till I installed live-plugin-manager

$ npm list fs-extra
kiss-my-resume@0.9.0 /Users/kmacha/Dev/kiss-my-resume
├─┬ @electron-forge/cli@6.0.0-beta.52
│ ├─┬ @electron-forge/core@6.0.0-beta.52
│ │ ├─┬ @electron-forge/installer-dmg@6.0.0-beta.52
│ │ │ ├─┬ @electron-forge/installer-darwin@6.0.0-beta.52
│ │ │ │ └── fs-extra@9.0.1  deduped
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ @electron-forge/installer-zip@6.0.0-beta.52
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ @electron-forge/template-base@6.0.0-beta.52
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ @electron-forge/template-typescript@6.0.0-beta.52
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ @electron-forge/template-typescript-webpack@6.0.0-beta.52
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ @electron-forge/template-webpack@6.0.0-beta.52
│ │ │ └── fs-extra@9.0.1  deduped
│ │ ├─┬ electron-packager@15.0.0
│ │ │ ├─┬ electron-notarize@1.0.0
│ │ │ │ └── fs-extra@9.0.1  deduped
│ │ │ ├── fs-extra@9.0.1  deduped
│ │ │ └─┬ galactus@0.2.1
│ │ │   ├─┬ flora-colossus@1.0.1
│ │ │   │ └── fs-extra@7.0.1
│ │ │   └── fs-extra@4.0.3
│ │ ├─┬ electron-rebuild@1.11.0
│ │ │ └── fs-extra@8.1.0
│ │ └── fs-extra@9.0.1  deduped
│ ├─┬ @electron/get@1.12.2
│ │ └── fs-extra@8.1.0
│ └── fs-extra@9.0.1
├─┬ @electron-forge/maker-deb@6.0.0-beta.52
│ ├─┬ @electron-forge/maker-base@6.0.0-beta.52
│ │ └── fs-extra@9.0.1  deduped
│ └─┬ electron-installer-debian@3.1.0
│   ├─┬ electron-installer-common@0.10.2
│   │ └── fs-extra@9.0.1  deduped
│   └── fs-extra@9.0.1  deduped
├─┬ @electron-forge/maker-rpm@6.0.0-beta.52
│ └─┬ electron-installer-redhat@3.2.0
│   └── fs-extra@9.0.1  deduped
├─┬ @electron-forge/maker-squirrel@6.0.0-beta.52
│ ├─┬ electron-winstaller@4.0.1
│ │ └── fs-extra@7.0.1
│ └── fs-extra@9.0.1  deduped
├─┬ @electron-forge/maker-zip@6.0.0-beta.52
│ └── fs-extra@9.0.1  deduped
├─┬ @electron-forge/plugin-webpack@6.0.0-beta.52
│ └── fs-extra@9.0.1  deduped
└─┬ live-plugin-manager@0.14.0
  └── fs-extra@8.1.0

@aidangoettsch
Copy link

Any update on this issue? It seems like graphql-tools is the culprit for my project and ends up failing to load both fs-extra and fast-glob with similarly weird errors. Pinning fs-extra to 8.1.0 works to resolve that error, but still leaves me with issues with fast-glob.

@nawbc
Copy link

nawbc commented Jan 15, 2021

the same issue when import electron-updater the fs-extra throw the error

ERROR in ./node_modules/fs-extra/lib/ensure/symlink-type.js
Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (22:10)
at Object.module.exports.pp$4.raise (C:\Users\Admin\Desktop\bilibili-up\node_modules@marshallofsound\webpack-asset-relocator-loader\dist\index.js:20834:13)
at Object.module.exports.pp.unexpected (C:\Users\Admin\Desktop\

@karlitos
Copy link

karlitos commented Jan 15, 2021

Everyone affected by this isue might try to remove webpack-asset-relocator-loader from their project and use something like copy-webpack-plugin in case some assets need to to be relocated. For further reference see #1929
Electron forge needs to update their patched version of the webpack-asset-relocator-loader. Loking at the related commit, it may be not that hard.

@malept
Copy link
Member

malept commented Aug 2, 2021

Electron forge needs to update their patched version of the webpack-asset-relocator-loader.

This was fixed in beta 58.

Loking at the related commit, it may be not that hard.

If you look at the related PR, it was indeed difficult to do.

@malept malept closed this as completed Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants