-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
Error: cannot find module undefinedbuild/... after HMR #2412
Comments
Also ran into this hot reload issue with a native module. I made a quick example: https://github.com/ldevalliere/temp-electron-forge where if you run it and then make a small change to trigger a hot reload you'll get the issue |
I had the same issue with the node-keytar native module on |
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,
}),
]; |
Seems like this is related to webpack 5 caching, and should be fixable like this. We should consider adding that as a default parameter during |
@MynockSpit it seems to work. Thank you a lot. |
@MynockSpit @atheck Could you please provide more details how to fix this? |
Nevermind, just missed to configure the path correctly. For anyone else const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const relocateLoader = require('@vercel/webpack-asset-relocator-loader');
module.exports = [
new ForkTsCheckerWebpackPlugin(),
new NodePolyfillPlugin(),
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /a\.js|node_modules/,
// include specific files based on a RegExp
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
}),
// modification below
{
apply(compiler) {
compiler.hooks.compilation.tap('webpack-asset-relocator-loader', (compilation) => {
relocateLoader.initAssetCache(compilation, 'native_modules');
});
},
},
]; |
with this webpack.plugins.js it works! |
* Add docs site * Add barebones typescript * Attempt to catch out databases that end up in the wrong directory * Add basic docs * Ignore datagrip's files * Add typeorm config, models and migrations * Fix json file typo * Document testing tools * Add e131 to global scope * Update createMainWindow.ts * Add author * Move migrations * Update .gitignore * Remove cache to fix electron/forge#2412 * Get a working build * Swap tailwind for mantine * Tweak nav * Experiment with buttons * Adda bout * Add dark background * Expose webpack build in development * Add admin site to webpack * Fix migrations * Clear out v1 files * Add QR Code package * Ignore all databases * Fix icon path * Fix icon path * Add a second nav class * Add prettier and lint * Fix docusaurus error * Bump docusaurus * Add API via both contextbridge and sockets * Demonstrate working refresh function with redux * Build out admin interface and include CPU & Ram usage * Tidy up visuals of control page * Migrate to some new, more sensible, models. Includes migrations tested against dramasoc, lounge & blank db * Move to our own fork of the e131 lib * Add E131 fading (#21) * Add basic e131 fade function * Change function to allow multiple fades at once * Add preset management * Fix crash bug * Populate list of presets * Bump codeql version * Move markdown docs amongst the code * Move docs around, and add mermaid * Fix repo path * Style tweaks * Tweak into an npm monorepo * Simplify docs offering again * Add winston * Refactor use of get presets route to rely on redux * Add connection lost and screensaver messages * Fix sorting * Add bundle size analyser * Add list of socket clients * Fix paths * Fix capitalisation * Add clients list to admin interface * Reduce huge fontawesome bundle size * Disable analyzer mode as it's breaking github actions * Add clients list * Add working general config * Remove file backup because it fails if no database exists * Get E1.31 output working * Add warning about saving risk of config * OSC output (#22) * Add V1 osc code as ts * Add inheritance for osc * Tidy osc a bit Co-authored-by: James Bithell <[email protected]> * Run prettier * Finish OSC Config and E1.31 Config Co-Authored-By: John Cherry <[email protected]> * Force LF line endings * Fix case sensitivity issue * Add route for OSC Messages * Check alternative ports when booting * Catch being unable to test ports * Change to a lib with TS support * Document environment variables * Set custom port in display * Few fixes * Get debugger working * Add folder admin * Fix folder sorting * Add basics of preset settings + add folder help text * Add input for e1.31 * Implement HTTP & Macro presets * Add e131 sampler (#25) * Convert sampler code to typescript * Broken sampling code but has a nice button * Move e131 to TS + tidy bits * Fix restart issue * Fix IP info * Add a screen * Fix breaking changes Co-authored-by: James Bithell <[email protected]> * Tweak text * Add reboot & quit functionality + add e131 sampling socket connection Co-Authored-By: John Cherry <[email protected]> * Config page tweaks for saving * Add restore from backup function * Improve new db upload UI * Add live logging into admin * Only open dev tools if running in dev * Send a 200 for the backup restore * Add v1 history page * Update index.ts * Fix upload path * Get file uploads working * Add edit handling for new databases * Add basic docs outline * Add * OSC Admin Page (#27) * Add default preset states * Add form fields * Tweak for saving * Make osc presets work * get current console Co-authored-by: John Cherry <[email protected]> Co-authored-by: John Cherry <[email protected]> * Add LX Keypad to V2 (#28) * Add keypad and attempt to make communicate * setintensity * Correct api and add interface * remove useRef * Fix clear logic * Fix routing and make linking macros * Add Channel Check mode (#29) * Tweak menu bar selection system (use url not a state tracked) * Update reviewdog.yml * Update Preset.tsx * Update Help.tsx * Tweak fader setup to not just restrict to channels * Rename Preset Folders to Folders because they're now a big core part of the project (not just a little bolt on) * Fix plural * Update 1656679151854-AddFaderType.ts * New table styling, add fader editing, bugfix of invalid json causing crash Co-Authored-By: John Cherry <[email protected]> * Pull OSC mixer directly from the reducer * Add spellings and update packages * Fix usage rings bug * Fix OSC edit midas bug * Improve editing experience in admin * Remove class as it prevented dbToPercentage being used * Add fader display + rough in datastore that powers it and metering * Add fader channel values & metering * Add fader control * Fix "Payload not sent" error because a 0 value is falsy * Remove local port to get dynamically allocated one Co-Authored-By: John Cherry <[email protected]> * Remove DCAs as their paths are odd * Working faders! * Update faders when a preset is recalled * V2 Error Boundary (#34) * Add a simple error boundary * Remove logger * comment component * Get fader positions when preset triggered * Document V2 (#31) Add control panel info * Add QR code to error boundary * Bump docusaurus * Change modal to tooltip * Add a message if audio disconnected and faders can't be shown * V2 fix osc editor and command encoding (#36) * check if we have a value before adding to address * convert to command-based second options * Add reload button to error boundary * Spelling * show JSON editor when our osc editor errors * use JSON editor as soon as Schema invalid * support simple OSC messages * Add logo screensaver functionality * Lint * Add fullscreen checkbox Co-authored-by: John Cherry <[email protected]> Co-authored-by: John Cherry <[email protected]>
closed with electron-forge/electron-forge-docs#76 |
@georgexu99 how should this be approached in typescript? |
Using an explicit any for now {
apply(compiler: any) {
compiler.hooks.compilation.tap('webpack-asset-relocator-loader', (compilation: any) => {
relocateLoader.initAssetCache(compilation, 'native_modules')
})
},
} |
* bump * TS Docs aren't actually provided as far as I can see * Bump * Add database structure * Add edit page * Add config option to macro preset * Allow presets to be recalled over http * Bump version * Improve locked message, and fix logic error in web server * Basic work on time clock triggers * Remove time clock triggers * Lint * Remove stats file * Lint * Update folder.ts * Add badge showing preset type * Add parent name to folders * Add duplicate preset button * Refactor folder icons to allow them to be used with other buttons * Add preset icons, and make icons searchable * Add more icons * Improve admin pin entry * Update settings.json * Start UI * Bump * Fix imports * Add more ui * Remove webpack cache to fix database error in electron/forge#2412 (comment) * Radically simplify icon file * Basic UI * UI tweaks * Edit functionality complete * Build out function * Update NavbarItem.tsx * Fix bugs * Time clock trigger bugfixes * Clarify skip behaviour * Lint * Closes #164 by removing effect mode * Update index.ts * Add error handling to sampling mode * Add docs
Preflight Checklist
Issue Details
Durig development after hot reloading the app, the following error occurs:
better_sqlite3 is a native module and is built with electron-rebuild during install with a script in package.json:
For HMR I'm using
react-hot-loader
.Expected Behavior
The app should reload correctly.
Actual Behavior
The error appears in the console and the screen keeps blank.
To Reproduce
Additional Information
The text was updated successfully, but these errors were encountered: