bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
320 stars 84 forks source link

Migrate to Nx v15.1.1 #196

Closed Vorakor closed 1 year ago

Vorakor commented 1 year ago

Attempted to get this package to support Nx v15.1.1, feel free to check my work to see if it works properly.

alljinx commented 1 year ago

Really nice work, works like a charm. You should consider consider theses changes as it bump compatibility for two majors NX versions.

ErickRodrCodes commented 1 year ago

Let me review this. Remember that this might break any version below v14, so a DEPRECATION mark should definitely be used if this MR PR passes.

If you fixed the tests, and are cross-platform, so this is more than welcome. several projects that migrated to 15 are stuck atm.

bennymeg commented 1 year ago

I will do this at two stages, firstly, I will finish migrating to the latest v14 to make sure there is no breaking changes in latest v14 version like some users stated.

ErickRodrCodes commented 1 year ago

I will do this at two stages, firstly, I will finish migrating to the latest v14 to make sure there is no breaking changes in latest v14 version like some users stated.

Friendly reminder that the last version of 14 is 14.8.6, so the fix to v14 should be on the latest head of that version https://github.com/nrwl/nx/releases/tag/14.8.6

codelocksdev commented 1 year ago

This may be user error on my part, but trying to npm install the fork (both the master and also the migrate-nx-15 branches) and I'm seeing the files in my node_modules but it's not being recognized as a plugin by nx. Is there something else I need to do to pull this down for testing?

ErickRodrCodes commented 1 year ago

This may be user error on my part, but trying to npm install the fork (both the master and also the migrate-nx-15 branches) and I'm seeing the files in my node_modules but it's not being recognized as a plugin by nx. Is there something else I need to do to pull this down for testing?

I would suggest working on the branch for Nx 15 that benny is working on.

codelocksdev commented 1 year ago

I would suggest working on the branch for Nx 15 that benny is working on.

feature/v15?

codelocksdev commented 1 year ago

Ok, I pulled from that branch and still getting Unable to resolve nx-electron:app.

ekiwi111 commented 1 year ago

Ok, I pulled from that branch and still getting Unable to resolve nx-electron:app.

I was able to resolve this error with the following command: nx g nx-electron/packages/nx-electron:app desktop --frontendProject=webapp --directory=desktop --verbose.

However, I'm still getting the error The "path" argument must be of type string. Received undefined.

After many console.logs in workspaces.js and generate.js, I was able to narrow down the issue to the following: After installing nx-electron with this command: npm i -D "https://github.com/bennymeg/nx-electron.git#feature/v15" --save, the directory node_modules/nx-electron/packages/nx-electron/src/generators/nx-electron doesn't contain generator.ts, which is causing the error.

If you look at node_modules/nx/src/config/workspaces.js, around line 190 in the getImplementationFactory function, you'll find the following code:

const possibleModulePath = path.join(directory, implementationModulePath); // === "... /node_modules/nx-electron/packages/nx-electron/src/generators/nx-electron/generator"
const validImplementations = ['', '.js', '.ts'].map((x) => possibleModulePath + x); // an array of ["path_above", "path_above.js", "path_above.ts"]
const modulePath = validImplementations.find((f) => (0, fs_1.existsSync)(f)); // === undefined
if ((0, path_1.extname)(modulePath) === '.ts') { // <======== THIS THROWS
    (0, nx_plugin_1.registerPluginTSTranspiler)();
}

@bennymeg, I hope this helps! ^^^

stewones commented 1 year ago

I don't know why nx loves breaking apis without further notice or deprecation warning, this is what makes me truly sad about them. but since we have no other easy to go mono-repo options, here we are.

I was getting TypeError: (0 , typescript_1.readTsConfig) is not a function while trying to serve. workaround is to hardcode utils/config.js changing the path import.

const typescript_1 = require("@nrwl/workspace/src/utilities/ts-config");

instead of

const typescript_1 = require("@nrwl/workspace/src/utilities/typescript");
bennymeg commented 1 year ago

Tnx @stewones that was it. I found the new proper location for this function in @nrwl/js. I've published an alpha, so I will close this PR.