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

Make pure-knob npm publishable #9

Merged
merged 3 commits into from May 29, 2020
Merged

Make pure-knob npm publishable #9

merged 3 commits into from May 29, 2020

Conversation

ebrensi
Copy link
Contributor

@ebrensi ebrensi commented May 28, 2020

This pull request does two things:

UMD definition allows us to avoid polluting global namespace

The demo still works with no changes to the html, and pure-knob can still be used the way it was before. i.e. If inserted as a script tag in an html file, a variable pureknob will get added to the global scope.

In addition, the module definition allows it to be imported as a node, commonjs, or amd module, as in

const pureknob = require(".../path_to/pureknob.js")

pureknob.createKnob(...) 

or if imported as a bundle by parcel, webpack, browserify, etc, we can even import it into the bundle like a es6 module.

import * as pureknob from ".../path_to/pureknob.js"

pureknob.createKnob(...)

Publishable to npm repository

The package.json file defines pure-knob as a node package, which can be published to the node repository using npm-publish (see https://docs.npmjs.com/misc/developers and https://docs.npmjs.com/cli/publish). That way, developers can include it in their projects simply with npm install pure-knob, and then import it into their code with

import * as pk from "pure-knob"
pk.createKnob()

or

const pk = require("pure-knob")
pk.createKnob()

"pure-knob" without a path or .js extension indicates to the bundler that "pure-knob" is a npm package and will look for it in the node_modules folder for the active project.

I could publish it from my fork, but I would rather that @andrepxx publish the official pure-knob node package.

@andrepxx let me know if you need any more clarification about how to publish the "pure-knob" module to npm. This will make it available to many more developers!

@andrepxx
Copy link
Owner

Thank you for your contribution.

I haven't had a chance to test this yet. However, note that UMD is MIT-licensed, which requires preservation of the license note. Therefore, in order to comply with the license, we'd have to put a license note just for a bit of wrapper code. I'm not sure if that's worth it.

@ebrensi
Copy link
Contributor Author

ebrensi commented May 29, 2020

UMD stands for Universal Module Definition. It is a coding technique. It is not owned by anyone. It has been the standard way to define modules for years.

@andrepxx
Copy link
Owner

I know what it stands for.

The repositoriy has both a LICENSE file (which might be because GitHub expects you to have one) and a license note (stating "Copyright (c) the UMD contributors") in their README, which is why I got a bit sceptical.

@andrepxx andrepxx merged commit e0ed942 into andrepxx:master May 29, 2020
@ebrensi ebrensi deleted the umd branch May 29, 2020 19:38
@ebrensi
Copy link
Contributor Author

ebrensi commented May 29, 2020

Thanks a lot @andrepxx ! I really look forward to having "pure-knob" in the npm repository because that will make it easy to upgrade whenever there is a new version. By the way, the app I am using it with is https://www.heatflask.com. I use the knobs for tweaking display settings.
heatflask-screenshot

@andrepxx
Copy link
Owner

andrepxx commented Jun 5, 2020

👍

I also work on some location data visualization / exploration / analysis tool for a while, since I have a data set (in GeoJSON format) with currently more than 300 million data points and had no application which could process such huge files.

It's also available here on GitHub, but it's still pretty heavily work in progress. Already have lots of ideas for what I'd like it to be able to do, just too little time to implement them timely. ;-)

By the way, I just tried the demo, but the map layers don't seem to work for me. It just draws the tracks onto a black plane. But I know, map access is hard to do right, as maps almost always come with pretty restrictive terms of use.

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.

None yet

2 participants