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

Question on CJS example in README #1331

Closed
1 of 3 tasks
andrericardo opened this issue Dec 30, 2024 · 3 comments · Fixed by #1325
Closed
1 of 3 tasks

Question on CJS example in README #1331

andrericardo opened this issue Dec 30, 2024 · 3 comments · Fixed by #1325

Comments

@andrericardo
Copy link

Issue Type

  • Bug Report
  • Feature Request
  • Other

Current/Missing Behaviour

README.md mentions

let nwbuild;
import("nwbuild")
  .then((object) => {
    nwbuild = obj;
  })
  .catch((error) => {
    console.error(error);
  });

Is it really import("nwbuild")?

Also why is the parameter object, then references obj?

(object) => {
    nwbuild = obj;
  }

Expected/Proposed Behaviour

Should it be something like this?

    let nwbuild;
    import("nw-builder")
    .then((obj) => {
        nwbuild = obj;
    })
    .catch((error) => {
        console.error(error);
    });

Additional Info

  • Package version: 4.0.7
  • Operating System: OSX
  • Node version: v18.19.1
  • NW.js version: 0.76.0
  • Repro link:

I'm trying to convert from v3 to v4 this gulp task:

gulp.task('nwjs', () => {
    const nwOptions = {
        files: ['./app/**', './package.json', './README.md', './node_modules/**'],
        buildDir: releasesDir,
        appName: pkJson.name,
        appVersion: pkJson.version,
        zip: false,
        version: nwVersion,
        flavor: flavor,
        platforms: parsePlatforms()
    };

    // windows-only (or wine): replace icon & VersionInfo1.res
    if (currentPlatform().indexOf('win') !== -1) {
        nwOptions.winIco = pkJson.icon;
        nwOptions.winVersionString = {
            Comments: pkJson.description,
            CompanyName: pkJson.homepage,
            FileDescription: pkJson.releaseName,
            FileVersion: pkJson.version,
            InternalName: pkJson.name,
            OriginalFilename: pkJson.name + '.exe',
            ProductName: pkJson.releaseName,
            ProductVersion: pkJson.version
        };
    }

    const nw = new nwBuilder(nwOptions).on('log', console.log);

    return nw.build();
});

https://github.com/vankasteelj/opensubtitles-uploader/blob/d4c31f689d562f4a3fcc8bcc1585b7f64c9b748d/gulpfile.js#L147-L177

My attempt:

gulp.task('nwjs', async () => {
    const nwOptions = {
        srcDir: ['./app/**', './package.json', './README.md', './node_modules/**'],
        outDir: releasesDir,
        app: pkJson.name,
        version: nwVersion,
        zip: false,
        flavor: flavor,
        mode: "build",
        //platforms: parsePlatforms()
        platform: "osx",
        arch: "x64",
    };

    // windows-only (or wine): replace icon & VersionInfo1.res
    if (currentPlatform().indexOf('win') !== -1) {
        // nwOptions.winIco = pkJson.icon;
        nwOptions.app = {
            icon: pkJson.icon,
            comments: pkJson.description,
            company: pkJson.homepage,
            fileDescription: pkJson.releaseName,
            fileVersion: pkJson.version,
            internalName: pkJson.name,
            originalFilename: pkJson.name + '.exe',
            productName: pkJson.releaseName,
            productVersion: pkJson.version
        };
    }

    let nwbuild;
    import("nw-builder")
    .then((obj) => {
        nwbuild = obj;
    })
    .catch((error) => {
        console.error(error);
    });

    return () => nwbuild(nwOptions).on('log', console.log);
});
@ayushmanchhabra
Copy link
Collaborator

Also why is the parameter object, then references obj?
@andrericardo I have fixed the typo in the docs. If you have any other queries, please open a new issue for that specific query

@andrericardo
Copy link
Author

andrericardo commented Jan 1, 2025

Thank you @ayushmanchhabra, what about the import really is import("nwbuild") instead of import("nw-builder") ?

ayushmanchhabra added a commit that referenced this issue Jan 1, 2025
@ayushmanchhabra
Copy link
Collaborator

Oh my bad, another oversight on my part. Just pushed a fix for this

ayushmanchhabra pushed a commit that referenced this issue Jan 1, 2025
🤖 I have created a release *beep* *boop*
---


##
[4.13.8](v4.13.7...v4.13.8)
(2025-01-01)


### Bug Fixes

* **bld:** await archiver.finalize
([#1333](#1333))
([580668f](580668f)),
closes [#1328](#1328)


### Chores

* **deps:** bump the npm group across 1 directory with 11 updates
([#1332](#1332))
([b9b96ff](b9b96ff))
* **docs:** clarify CJS usage
([d673459](d673459)),
closes [#1331](#1331)
* **docs:** clarify non-usage of srcDir in CLi interface
([1b61bd1](1b61bd1)),
closes [#1330](#1330)
* **docs:** fix CJS import usage example
([5f323df](5f323df)),
closes [#1331](#1331)
* **test:** download latest NW.js version for Linux demo app
([8c09908](8c09908)),
closes [#1324](#1324)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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 a pull request may close this issue.

2 participants