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

NPM Package please #1

Closed
MartinMuzatko opened this issue Mar 29, 2017 · 6 comments
Closed

NPM Package please #1

MartinMuzatko opened this issue Mar 29, 2017 · 6 comments

Comments

@MartinMuzatko
Copy link

No description provided.

@photopea
Copy link
Owner

What is NPM? Do you think you can do that?

@photopea
Copy link
Owner

It seems like I have to download and install some special software, to publish UPNG.js in "npm". When I update my library, will I have to update it both at GitHub and npm, or npm can somehow connect to GitHub and download the latest version?

@MartinMuzatko
Copy link
Author

MartinMuzatko commented Mar 29, 2017

Hello! I'm sorry, I didn't know you were unaware of NodeJS/NPM. NPM is the largest package/dependency management solution on earth. The code still lives on github, developers are then enabled to download and use your code more comfortably.
Which means: install via console commands (npm install upng)
and usage via require('upng') for example. Also, you want to avoid that you are littering the global object namespace (window.upng)).

Since this code was posted to echojs.com, I thought you knew about NodeJS.

I'll see if I can find the time to create a pull request to publish it to NPM, however you should be the one publishing to NPM, since you created the library. Documentation can be found here: https://docs.npmjs.com/cli/publish

Creating the package to make it available for NPM is pretty trivial.
See more info here: https://docs.npmjs.com/cli/init

@photopea
Copy link
Owner

Do they have a web interface? I use GitHub through the web interface. It seems crazy to me to download an install some software just to send 12 kB to some server.

@erykpiast
Copy link

erykpiast commented Mar 31, 2017

No, they don't. You need to install special this package manager software (npm), which runs on and is shipped with its own virtual machine (node.js). The latter one is often used as a web server, platform for running desktop applications or even for controlling physical devices via Arduino or Raspberry Pi.

I can see you use "global export" pattern in your code, which is not recommended anymore. You need at least CommonJS module, better - UMD or ideally ES6 module transpiled to UMD by some bundler, like Webpack, Brunch or Rollup (there are a lot of more of these).

To make code readable and admired by everybody you should use the latest features of EcmaScript language and then transpile it to ES5, probably with Babel.

As the thing you build is a library, you may want to use TypeScript, which is basically superset of EcmaScript, providing type signatures and compile-time type-checks (TypeScript is compiled to JavaScript, either ES5 or ES6, so you may or may not use Babel along with that). Even people not writing TypeScript would still benefit from it as modern editors like VSCode are able to show type hints based on TypeScript types.

Separate topic is Test-Driven Development. I can see you didn't write any test for your code, which is no more acceptable in open source community. Make sure to choose some test runner like Mocha, Jasmine or Ava along with one of assertion libraries: Chai, PowerAssert or maybe built-in assert function from node.js as you already have it installed. Ideally before each deploy you would run tests cross-browser on BrowserStack or SauceLabs through Karma, to make sure your code works everywhere.

If you use Continuous Integration server for all that transpilation, building and testing stuff, you will be able to add fancy badges to README in your GitHub repository or GitHub Pages.

That's only a tip of the iceberg. Welcome to front-end development A.D. 2017.

PS
You can also ignore all of this and just continue doing awesome work as you were doing so far!

@photopea
Copy link
Owner

photopea commented Apr 2, 2017

Thank you very much for your comments. It seems like downloading, installing and learning how to use all these programs would take me more time, than I spent developing UPNG.js . I don't need them for any other purpose. Thus, I decided to leave that task to somebody else (feel free to publish UPNG.js on npm or any other "code databases" / websites).

PS I still think, than when imagining a "standard javascript environment", you should not imagine Node.js (which thousands of people have) but a web browser (which billions of people have).

@photopea photopea closed this as completed Apr 2, 2017
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

3 participants