Skip to content

Question on CJS example in README #1331

Closed
@andrericardo

Description

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);
});

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions