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

Publish the JS package #155

Closed
lucafaggianelli opened this issue Aug 23, 2022 · 16 comments
Closed

Publish the JS package #155

lucafaggianelli opened this issue Aug 23, 2022 · 16 comments

Comments

@lucafaggianelli
Copy link

It's such a great library, why don't you publish it on NPM so we can install it with npm install qrcodegen?

Happy to help if you want!

@nayuki
Copy link
Owner

nayuki commented Aug 24, 2022

I don't know how to publish a package on NPM. It takes time to figure out build tools and packaging standards.

Cargo (Rust) was pretty straightforward. PyPI (Python) took more steps and had some ambiguity. Maven Central (Java) was an absolute nightmare to learn and configure and took me several days to figure out, not to mention writing and auditing that opaque pom.xml file.

Also, I come from the oldschool style of development of manually downloading source files and dropping them into a project...

@lucafaggianelli
Copy link
Author

Yeah, I see its never a straightforward thing!
NPM is quite painless though, I’d come up with a PR if you want, otherwise nothing 😊 I’ll just manually download the TS source

@zamicol
Copy link

zamicol commented Sep 14, 2022

Alternatively to NPM, we've been using the JS files. We added the UMD module for supporting modules and not module importing: https://github.com/Cyphrme/qrgen

See this line: https://github.com/Cyphrme/qrgen/blob/7776160432f435779c29a4c9cdd617cd52643cff/qrgen.js#L1084

@nayuki
Copy link
Owner

nayuki commented Sep 14, 2022

@zamicol: I see that your copy of qrgen.js comes from my old code. It is the hand-written JavaScript port that existed up until 2019-07-16, before being deleted and superseded by the TypeScript port. Any reason why you chose to package the old JavaScript code?

@zamicol
Copy link

zamicol commented Sep 14, 2022

Nayuki , thank you for your work!

That's when I forked it and have not updated it since. I will update using the Typescript port, and include a Javascript minified distributable, when I get a chance. I'd love to help out with the Javascript process if you'd find that useful.

I was thinking about doing it soon and wanted to see if this repo had done that yet, so I searched for an issue and found this by happenstance. What's your Javascript pipeline look like?We typically use esbuild, but the module stuff has to be done manually for now because of a bug. (As a matter of preference, we like having an option of a pipeline that has no dependency on Node.)

@nayuki
Copy link
Owner

nayuki commented Sep 15, 2022

@zamicol: Thanks. For your reference, you can grab my officially compiled JavaScript code at https://github.com/nayuki/QR-Code-generator/tags , for example https://github.com/nayuki/QR-Code-generator/releases/tag/v1.8.0 .

My JavaScript build pipeline is: tsc --strict --target ES2015 *.ts 😂

@zamicol
Copy link

zamicol commented Sep 15, 2022

Thanks Nayuki,

TL;DR:

May I suggest the following addition?

tsc --strict --lib DOM,DOM.Iterable,ES6 --target ES6 *.ts
esbuild qrcodegen.js --minify --outfile=qrcodegen.min.js && cat module_append.txt >> qrcodegen.min.js

Long:

There's a few more things: build instructions for a stand alone qrcodegen file, minification, UMD modules, and a working out-of-the-box demo with JS files included with the release/distributable. Below is detailed suggestions.

Looks like build instructions and modules have been mentioned in a previous open issue. I left a comment there as well to link the issues.

Modules

Modules help integrating with other Javascript applications more expressive,
easier to debug, and the UMD modules allows universal module/not module usage.

See this file as a suggested way to add UMD module support. Here's an example of it integrated into code here. (Note, this has to be added after esbuild because of a not-yet-fixed bug.)

Minification

Using this command on the release

esbuild qrcodegen-v1.8.0-es6.js --minify --outfile=qrcodegen-v1.8.0-es6.min.js

The file size is reduced from 45.3 kB to 11.6kB (link).

Building/Compiling

The existing build.sh does not have build instructions for the main qrcodegen.js. A one line addition makes this clear.

tsc --strict --lib DOM,DOM.Iterable,ES6 --target ES6 qrcodegen.ts
tsc --strict --lib DOM,DOM.Iterable,ES6 --target ES6 qrcodegen.ts qrcodegen-input-demo.ts
tsc --strict --lib DOM,DOM.Iterable,ES6 --target ES6 qrcodegen.ts qrcodegen-output-demo.ts

Or alternatively as you just suggested:

tsc --strict --lib DOM,DOM.Iterable,ES6 --target ES6 *.ts

See also #159

The output files can be included in the release and demo (see below).

Demo

As far as the release, (QR-Code-generator-1.8.0.tar.gz or
QR-Code-generator-1.8.0.zip), it is missing the referred files:

  • qrcodegen.js
  • qrcodegen-input-demo.js
  • qrcodegen-output-demo.js

It seems like a good idea to include these in the release so that the demo works out-of-the-box. Here's an example of included those files so it works out-of-the-box.

Thank you again for all your hard work.

@piotr-cz
Copy link

There is already PR for this: #25.
It's not complete (references author's repo) but may help

@zamicol
Copy link

zamicol commented Dec 16, 2022

Hello again! I was also wondering if #159 had been considered?

@gfortaine
Copy link

I don't know how to publish a package on NPM. It takes time to figure out build tools and packaging standards.

Cargo (Rust) was pretty straightforward. PyPI (Python) took more steps and had some ambiguity. Maven Central (Java) was an absolute nightmare to learn and configure and took me several days to figure out, not to mention writing and auditing that opaque pom.xml file.

Also, I come from the oldschool style of development of manually downloading source files and dropping them into a project...

Please find our PR : #168

A few comments :

  • we tried to stay as close as possible to the Makefile philosophy leveraging everything possible to reduce the need of 3rd party packages (mv & rm Unix commands, npm "pre" scripts)
  • we moved some utils functions (drawCanvas & toSvgString) to a dedicated submodule (/utils)
  • we used the latest functionalities of the npm/JS/TS ecosystem (exports & typesVersions in package.json, as well as npx & npm argument parser w/ npm_config_ for launching the demo)

@toyobayashi
Copy link

I published WebAssembly version on npm

https://github.com/toyobayashi/qrcodegen

@laterdayi
Copy link

@nayuki Is there a plan?

@toyobayashi
Copy link

@laterdayi Have you tried my published wasm version?

@LeoDog896
Copy link

LeoDog896 commented Nov 6, 2023

I've also published a fully refactored non-WASM version with premade renderers for both the terminal and canvas/svg.

@nayuki nayuki closed this as completed Aug 29, 2024
@atezet
Copy link

atezet commented Aug 30, 2024

@nayuki did you close this because you published it yourself? There's little guarantee that the versions published by others are updated

@LeoDog896
Copy link

@nayuki did you close this because you published it yourself? There's little guarantee that the versions published by others are updated

There hasn't been any change not reflected on my published version. Though, it is also absolutely not 1:1 of this repository's source code.

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

No branches or pull requests

9 participants