Closed Rdmkr closed 8 months ago
@bennymeg I sent you a donation, could I have your input on this? Any clarification appreciated.
The error state that you are trying to use require in an ES module.
I am not sure where in the main.ts I used @angular/core, did you added it? if so, did you require or imported it? Anyway, please try running this test project first.
BTW, thank you for the contribution, but I would have tried to help anyhow...
"I am not sure where in the main.ts I used @angular/core, did you added it? if so, did you require or imported it?"
I did not add the require statement, that was generated by the build script.
I forked the test project here and tried to add a v16 angular app for testing: https://github.com/Rdmkr/nx-electron-boilerplate/tree/feature/angular-boilerplate
Currently running into a different problem when trying to serve:
TypeError: ws.readExecutor is not a function
at readTargetOptions (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/@nx/devkit/src/executors/read-target-options.js:19:27)
at startBuild_1 (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/nx-electron/src/executors/execute/executor.js:119:61)
at startBuild_1.next (<anonymous>)
at resume (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/tslib/tslib.js:279:48)
at /home/nrade/git/nx-ng-electron-boilerplate/node_modules/tslib/tslib.js:278:125
at new Promise (<anonymous>)
at i.<computed> [as next] (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/tslib/tslib.js:278:67)
at executor_1 (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/nx-electron/src/executors/execute/executor.js:31:125)
at executor_1.next (<anonymous>)
at resume (/home/nrade/git/nx-ng-electron-boilerplate/node_modules/tslib/tslib.js:279:48)
It seems to have trouble instantiating the Workspace class:
function readTargetOptions({ project, target, configuration }, context) {
var _a;
const projectConfiguration = (context.workspace || context.projectsConfigurations).projects[project];
const targetConfiguration = projectConfiguration.targets[target];
const ws = new Workspaces(context.root);
const [nodeModule, executorName] = targetConfiguration.executor.split(':');
const { schema } = ws.readExecutor(nodeModule, executorName);
const defaultProject = ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
return (0, params_1.combineOptionsForExecutor)({}, (_a = configuration !== null && configuration !== void 0 ? configuration : targetConfiguration.defaultConfiguration) !== null && _a !== void 0 ? _a : '', targetConfiguration, schema, defaultProject, ws.relativeCwd(context.cwd));
}
Solved that one... I didn't have an explicit version of @nx/devkit specified, so it probably defaulted to an old one.
Angular v16 app is running in Electron in the test project...
Great!
Something dawned on me today... The Electron app is not supposed to be depending on @angular/core... that's the web app's purview. The problem is likely just that the dependencies of my project aren't properly divided between the electron and the angular side... I spent some time moving the angular stuff into a "shared-ui" module that the electron app doesn't touch and the process is getting a lot farther than it did before... still not there yet but I think I'm across this hurdle.
Apologies if this is not 100% nx-electron related, but my best guess is that the 16.0.0-beta1 package of this software is at fault.
Getting the following error when trying to serve electron app:
Line number in main.js refers to:
Slightly more info and link to repo can be found here: https://stackoverflow.com/questions/77276313/require-of-es-module-not-supported-in-built-electron-app-code