question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@zeit/webpack-asset-relocator-loader does not work

See original GitHub issue

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.46
  • Electron Version:
    • v7.1.3
  • Operating System:
    • Ubuntu 18.04 x64
  • Last Known Working Electron Forge version:
    • ?

Expected Behavior

When I install @zeit/webpack-asset-relocator-loader I expect it it do what it’s supposed to do. Not sure exactly what, but not to break the build for sure.

Actual Behavior

yarn start writes the following to .webpack/renderer/main_window/index.html (instead of the real content):

Html Webpack Plugin:
<pre>
  Error: /x/src/index.html:82
  /******/  __webpack_require__.ab = __dirname + "/native_modules/";
                                     ^
  ReferenceError: __dirname is not defined
  
  - index.html:82 
    /x/src/index.html:82:36
  
  - index.html:89 
    /x/src/index.html:89:10
  
  - index.js:247 HtmlWebpackPlugin.evaluateCompilationResult
    [x-app]/[html-webpack-plugin]/index.js:247:28
  
  - index.js:161 
    [x-app]/[html-webpack-plugin]/index.js:161:23
  
  - task_queues.js:93 processTicksAndRejections
    internal/process/task_queues.js:93:5
  
</pre>

To Reproduce

Take a look at this repo: https://github.com/MOZGIII/electron-webpack-asset-relocator-loader-issue

It has just two commits in the master branch, first for the yarn create electron-app ... --template=webpack, and the second to reproduce the bug.

Additional Information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
MarshallOfSoundcommented, Dec 7, 2019

// Add support for native node modules

Historically most people really don’t care why they need a thing (some do) but most just want to be given the thing, told that it “makes the thing work” and then they move on. 😄

The asset relocator is required as you can’t bundle a native module into a JS bundle (it’s native compiled code not JS). So it scans your dependencies, finds the native modules, and copies them to the appropriate place in the bundled application so that when you ship your app your native modules actually loads.

Apparently, when I google @marshallofsound/webpack-asset-relocator-loader the link to the fork at github is nowhere to be found. Just a note on why it ended up so problematic.

Yeah I was hopeful that fork wouldn’t live long and upstream would take the change 🤷‍♂ looks like that didn’t happen 😆

You can see my fork on GH --> https://github.com/MarshallOfSound/webpack-asset-relocator-loader it just has a single additional commit to support electron apps loading native modules where __dirname is not a thing

0reactions
MOZGIIIcommented, Dec 8, 2019

Thanks a lot for your help and for your work @MarshallOfSound.

Read more comments on GitHub >

github_iconTop Results From Across the Web

zeit/webpack-asset-relocator-loader does not work · Issue #1327
The asset relocator is required as you can't bundle a native module into a JS bundle (it's native compiled code not JS). So...
Read more >
@zeit/webpack-asset-relocator-loader - npm
Asset relocation loader used in ncc for performing Node.js builds while emitting and relocating any asset references.
Read more >
@zeit/webpack-asset-relocator-loader vulnerabilities | Snyk
Asset relocation loader used in ncc for performing Node.js builds while emitting and relocating any asset references. · latest version.
Read more >
@zeit/webpack-asset-relocator-loader: Popularity and Maintenance ...
zeit /webpack-asset-relocator-loader downloads and star history, commits and versions frequency, issues and pull request stats, maintainer info, ...
Read more >
@zeit/ncc v0.22.3 Bundlephobia
Size of @zeit/ncc v0.22.3 is 1.2 kB (minified), and 630.0 B when ... This package does not export ES6 modules. ... @zeit/webpack-asset-relocator-loader.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found