Skip to content
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

WIP: Use nw-builder v4.0.7 #122

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrericardo
Copy link
Contributor

@andrericardo andrericardo commented Dec 30, 2024

I'm no Javascript expert but would you be interested in a PR that tries to upgrade nw-builder to the latest version 4.13.7 and possibly NW.js to v0.94.0?

Tried to follow the migration path for nw-builder described here:

https://github.com/nwutils/nw-builder/tree/v4.0.3?tab=readme-ov-file#migration-to-v4

Couple of questions:

  1. Since the latest versions of nw-builder require platform property, would you consider removing the dependency on nw-builder get platform name from the gulp task? Or am I seeing things wrong?

https://github.com/nwutils/nw-builder?tab=readme-ov-file#api-reference

nw-builder first moved the file again to src/util/platform.js
nwutils/nw-builder@v3.8.10...v4.0.7#diff-4dbd0a6d4d2f9999a53e0fe28c45f303bac69dbfb3aba774962443725234cf9d

I've tried to import it with

const { getPlatform } = require("nw-builder/src/util/platform");
const currentPlatform = () => { return getPlatform(process.platform) };

But I'm getting an error that I don't know if it's possible to solve, since the function is not exported.

$ gulp build  --platforms osx64
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/util/platform' is not defined by "exports" in /Users/andre/code/opensubtitles-uploader/node_modules/nw-builder/package.json
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:366:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:713:9)
    at resolveExports (node:internal/modules/cjs/loader:584:36)
    at Module._findPath (node:internal/modules/cjs/loader:658:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1120:27)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/Users/andre/code/opensubtitles-uploader/gulpfile.js:31:25) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Could copy the file to the vendor folder and move on, which I did in order to progress the build.

nw-builder moved platform.js again in
https://github.com/nwutils/nw-builder/pull/910/files#diff-ded7d82adc6eea35c2e80c2cf91ea002bd00db3073decc2812add012d5872efcR33

  1. I'm not sure about the described usage of CJS modules with nwbuild, opened a question on nw-builder side:

nwutils/nw-builder#1331

My end goal is to build opensubtitles-uploader with https://dl.nwjs.io/v0.94.0/nwjs-v0.94.0-osx-arm64.zip

@vankasteelj
Copy link
Owner

Hello. You cannot use nwbuilder latest versions as they moved away from CommonJS into ESM. And they both are incompatible. I'm actually stuck with many project because some people decide to move to ESM (got, nwbuilder and webtorrent are an example). The thing is NW.js is incompatible with ESM, and it seems it will never be compatible.

However, you can upgrade NW.js to the latest version without any issue (maybe there will be CSS tweaks to apply, that sometimes happen with newer NW.js version but nothing should break, I believe. And if it does, it should be simple enough to fix.

What you could also do is manually build your ARM version for MacOS by copying node_modules and all the files in this repository next to the ARM binary, and launch that binary. This should work, even if it's a manual workaround for now. I don't see why it wouldnt at this stage.

I cannot help you more as I do not own any Apple product to test with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants