atheck

atheck

Member Since 4 years ago

Halle (Saale)

Experience Points
1
follower
Lessons Completed
1
follow
Lessons Completed
4
stars
Best Reply Awards
7
repos

170 contributions in the last year

Pinned
⚡ Generate C# classes from XML Schema files
⚡ A datetime picker for your React app.
⚡ Service to show alerts and confirmations in react apps
Activity
Nov
25
2 days ago
Activity icon
issue

atheck issue comment electron-userland/electron-forge

atheck
atheck

Error: cannot find module undefinedbuild/... after HMR

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

Durig development after hot reloading the app, the following error occurs:

Uncaught Error: Cannot find module 'undefinedbuild/Release/better_sqlite3.node'
Require stack:
- electron/js2c/renderer_init
    at Module._resolveFilename (internal/modules/cjs/loader.js:887)
    at Function.o._resolveFilename (electron/js2c/renderer_init.js:33)
    at Module._load (internal/modules/cjs/loader.js:732)
    at Function.f._load (electron/js2c/asar_bundle.js:5)
    at Function.o._load (electron/js2c/renderer_init.js:33)
    at Module.require (internal/modules/cjs/loader.js:959)
    at require (internal/modules/cjs/helpers.js:88)
    at eval (database.js?4c26:9)
    at Object../node_modules/better-sqlite3/lib/database.js (index.js:66025)
    at __webpack_require__ (index.js:78100)

better_sqlite3 is a native module and is built with electron-rebuild during install with a script in package.json:

"postinstall": "electron-rebuild -f -w better-sqlite3",

For HMR I'm using react-hot-loader.

  • Electron Forge Version:
    • 6.0.0-beta.59
  • Electron Version:
    • 13.1.7
  • Operating System:
    • Windows 10
    • Ubuntu 12.04 x64
  • Last Known Working Electron Forge version::
    • 6.0.0-beta.57

Expected Behavior

The app should reload correctly.

Actual Behavior

The error appears in the console and the screen keeps blank.

To Reproduce

Additional Information

atheck
atheck

I finally found a workaround for this. I no longer use the @vercel/webpack-asset-relocator-loader in development mode.

webpack.rules.js

const nodeLoaderRule = {
    test: /native_modules\/.+\.node$/u,
    use: "node-loader",
};
const relocatorRule = {
    test: /\.(m?js|node)$/u,
    parser: { amd: false },
    use: {
        loader: "@vercel/webpack-asset-relocator-loader",
        options: {
            outputAssetBase: "native_modules",
        },
    },
};
const tsLoaderRule = {
    test: /\.tsx?$/u,
    exclude: /(node_modules|\.webpack)/u,
    use: {
        loader: "ts-loader",
        options: {
            transpileOnly: true,
        },
    },
};

if (process.env.BUILD_PRODUCTION) {
    module.exports = [nodeLoaderRule, relocatorRule, tsLoaderRule];
} else {
    module.exports = [nodeLoaderRule, tsLoaderRule];
}

webpack.plugins.js

const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");

let copyPatterns;

if (process.env.BUILD_PRODUCTION) {
    copyPatterns = [];
} else {
    copyPatterns = [
        {
            // Workaround: Copy native_modules in some directory where it's found
            from: path.resolve(__dirname, "native_modules/build"),
            to: path.resolve(__dirname, "out/"),
        },
    ];
}

module.exports = [
    new ForkTsCheckerWebpackPlugin(),
    new CopyWebpackPlugin({
        patterns: copyPatterns,
    }),
];
Nov
21
6 days ago
Nov
19
1 week ago
Nov
17
1 week ago
Nov
16
1 week ago
push

atheck push atheck/eslint-config-heck

atheck
atheck

chore: start adding unicorn rules

commit sha: eefbb73a10e255dadd3239bc90d3f47c1d59e2f7

push time in 1 week ago
Nov
10
2 weeks ago
Activity icon
created tag
createdAt 2 weeks ago
Activity icon
created tag
createdAt 2 weeks ago
Activity icon
created tag
createdAt 2 weeks ago
Activity icon
created tag
createdAt 2 weeks ago
Oct
16
1 month ago
started
started time in 1 month ago
Previous