question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modularize, publish to npm

See original GitHub issue

In the main example there are 17 script tags: https://github.com/lo-th/Oimo.js/blob/master/index.html#L16-L32

That’s not a great way for third parties to consume this library. It’s common practice to generate a umd build so that people using module systems such as commonjs or AMD can require() this module and people not using any module system will still have their window globals as usual, but with only a single <script> tag to include.

Once the code has been modularized, you can generate a package.json file with npm, which ships by node.js by default. Just do:

npm init

And the command will walk you through filling out the right fields. You should point the "main" field at the singular entry point for this package, which could be a dist build since the internals aren’t modularized yet. A really simple way to do this with what you’ve already got is just to cat together all the files necessary and then append some exports.FOO=... statements, at least for commonjs. Once the build works, just publish to npm with:

npm publish

You can test the build with a tool like browserify.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
lo-thcommented, Jan 18, 2017

yea npm version is on way now i know how process like uil

i hope someday Saharan help me for adding creazy function

3reactions
mwthinkcommented, Aug 31, 2016

@lo-th should reconsider this for 2 reasons :

  1. Browserify. Being able to pull the package down through npm, list it as a project dependency (Just as with all my other depencendies) would be an invaluable asset. As already stated, npm is certainly no longer just for server-side packages.

  2. Server-side running. This should also be coupled with a rewrite of some code that makes Oimo depend on canvas to operate. This would be Oimo an absolute knock-out of the park for a lot of projects. I am currently working on a multiplayer browser game, but with server side features, such as collision detection (And other anti-cheat measures).

Obviously, my server has no need to be rendering graphics, but if I could run the same physics on the server that are running on the client, I wouldn’t need to be resorting to a myriad of nasty hacks I’ve implemented in the mean time.

I’m sure myself and some others who are interested could go about building the Oimo code to work in such a manner. Not a lot needs to be changed, but it would make all the difference in the world.

Read more comments on GitHub >

github_iconTop Results From Across the Web

modularize - npm
Provides AMD, CommonJS and ES6 wrapping for traditional JavaScript.. Latest version: 0.1.8, last published: 6 years ago.
Read more >
Modularizing Your Code and Publishing Node ... - Springer Link
CHAPTER 12. Modularizing Your Code and Publishing Node.js. Modules to npm. Two of the key factors that attributed to the rapid growth of...
Read more >
[ts] Modularize and publish to NPM · Issue #1381 - GitHub
What's the reason not publishing packages to npm? Is the publishing pipeline inconvenient? All reactions.
Read more >
How To Write and Publish Your Own NPM Package - Medium
It's always best practice to create a modular code where we can reuse the code instead of creating from scratch. NPM packages encourage...
Read more >
The Basics of Modular JavaScript & npm Packages - Travis Horn
With the GitHub desktop app, you will be able to easily publish any modules you make to the open source community and allow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found