The Wayback Machine - https://web.archive.org/web/20201204193403/https://github.com/melonjs/melonJS/issues/772
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

Dependency management with npm #772

Closed
parasyte opened this issue Feb 6, 2016 · 24 comments
Closed

Dependency management with npm #772

parasyte opened this issue Feb 6, 2016 · 24 comments
Projects

Comments

@parasyte
Copy link
Member

@parasyte parasyte commented Feb 6, 2016

We have a couple of third-party dependencies: https://github.com/melonjs/melonJS/tree/0b92a9c8868d63358f9ce756af620457a27ac176/src/vendors

It would be way better to maintain these through a package manager like Bower or npm. I'm slightly opposed to using npm for managing dependencies in a web framework (it's the right tool for node dependencies) regardless of the claims. I could enumerate the reasons, but suffice to say the npm ecosystem is not ready for this; the npm tool and service are. (Hint: CommonJS is dead.)

Anyway, we just choose a package manager and maintain our dependencies with a manifest. It will ease the maintenance burden for sure.

@parasyte parasyte added this to the 4.0.0 milestone Feb 6, 2016
@parasyte
Copy link
Member Author

@parasyte parasyte commented Feb 6, 2016

There are a few other dependencies spread around the repo:

@agmcleod
Copy link
Member

@agmcleod agmcleod commented Feb 6, 2016

I think the main reason for not using npm is because we don't use anything like commonjs or amd. That's where i think bower would be a bit nicer, for pulling static files. Makes complete sense in that case.

Still if we slowly transition to using es6 modules, i don't see why we shouldn't use NPM at that point.

@parasyte
Copy link
Member Author

@parasyte parasyte commented Feb 6, 2016

Most packages in npm don't support the ES6 module pattern, either. But yeah, pretty much what you said.

@agmcleod
Copy link
Member

@agmcleod agmcleod commented Feb 6, 2016

it's polyfilled through some matter. My point is we would have the ability to require npm dependencies quite easily. Given Olivier mentioned doing it at sometime, it would be the best time to switch to pulling npm vs static files via html/grunt concat ordering.

@parasyte
Copy link
Member Author

@parasyte parasyte commented Feb 6, 2016

It's been my experience that packages in npm tend to expect CommonJS+Browserify, or go all in with ES6 import. Meanwhile, we already have our dependency order expectations in line. https://github.com/melonjs/melonJS/blob/85eacab650ad596fb46d0f8290af0544a6e19265/sourceFiles.json

@obiot
Copy link
Member

@obiot obiot commented Feb 16, 2016

I like the idea, but don't we have custom code on literally each of them ? maybe a good start would be to push back all the changes we did on all respective repos ?

@parasyte
Copy link
Member Author

@parasyte parasyte commented Mar 12, 2016

I did similar work on the tutorials; they now have dependency management through npm. For example: https://github.com/melonjs/tutorial-space-invaders/blob/fd5e86b018e60dce53675c5289d9bc77d54100a2/package.json#L7

Install devDependencies with npm, then run that npm script to copy the dependencies to a location that the browser can reach. This allows us to commit only the built dependency files, and not the entire source tree for them.

$ npm install
$ npm run update:deps
@obiot obiot modified the milestones: 4.1.0, 4.0.0 Oct 18, 2016
@Ascheere
Copy link

@Ascheere Ascheere commented Oct 31, 2016

I've really enjoyed npm as the dependency manager because it can be locally managed to the solution. That might be because I've used npm a lot.

@parasyte
Copy link
Member Author

@parasyte parasyte commented Oct 31, 2016

After using npm exclusively for all dependency management (and even as the build system) it's definitely grown on me. I can't think of a good reason to use Grunt or Gulp... Or bower. :)

The one missing piece is native ES6 module support. It's being worked on right now, but there's still the problem of backward compatibility.

@krojew
Copy link

@krojew krojew commented Nov 10, 2016

+1 on using npm
-1 for bower, since it's dead

@parasyte parasyte changed the title Dependency management with Bower (or npm) Dependency management with npm Nov 11, 2016
@parasyte
Copy link
Member Author

@parasyte parasyte commented Nov 11, 2016

Agreed. Updated title.

@agmcleod
Copy link
Member

@agmcleod agmcleod commented Dec 15, 2016

@parasyte @obiot @krojew Curious on what you guys think. For building a solution here, i wonder if we need to update the build system. Whether we keep with grunt or w/e, but more importantly do we need to use modules? Or do we just have one file that has the require() vendors, and still do a concat?

@parasyte
Copy link
Member Author

@parasyte parasyte commented Dec 15, 2016

Modules will finally give us #212 😄

@agmcleod
Copy link
Member

@agmcleod agmcleod commented Dec 15, 2016

Fair point. Since we updated to use eslint, i'd love to take it the next step and start leveraging things like webpack, as i find it builds faster, easier to integrate the watch changes workflow as well. I'm more of a mocha + chai fan these days instead of jasmine, though unless updating build system demands it, i'm not rushed to change the testing framework.

@parasyte
Copy link
Member Author

@parasyte parasyte commented Dec 15, 2016

Also with ES6 module support coming soon ™️ to all major browsers, I'm not opposed to skipping CommonJS/Webpack and going straight to import/export.

@parasyte
Copy link
Member Author

@parasyte parasyte commented Dec 17, 2016

Yeah, but native support is coming to every browser already... It's one of those features you can't polyfill. The source has to be transpiled, so you lose native capability altogether.

@obiot obiot modified the milestones: 5.0.0, 4.1.0 Jan 18, 2017
@itsjavi
Copy link
Contributor

@itsjavi itsjavi commented Oct 29, 2017

Would be nice to have the library in npm (where it already is) an compatible at least with ES6 exports:

// src/scenes/MyScene.js

import {LevelDirector, ScreenObject} from "melonjs";

class MyScene extends ScreenObject {
  onResetEvent() {
    LevelDirector.loadLevel("Level_01");
  }
}

export default MyScene;

I have a workaround with webpack, babel and shim-loader which is able to treat a global variable as an export, but I can only use the me centralized object.

You can see an example in the source code of my game prototype: https://github.com/pokettomonstaa/NewBark

It is also necessary that the library does not initialize anything by its own. Right now it is doing it with the preloading screen, etc.

@obiot obiot added this to In Progress in Roadmap Dec 4, 2017
@obiot obiot moved this from In Progress to To Do in Roadmap Dec 4, 2017
obiot added a commit that referenced this issue Mar 2, 2019
this does not really use rollup as it should be, as melonjs is still not properly using package/module, but at least the new process is in place
obiot added a commit that referenced this issue Mar 3, 2019
properly include back bable transpiling, and show  bundle size upon completion
obiot added a commit that referenced this issue Mar 3, 2019
and removes all copyright per file, whihc was a pain in the *** to manage/update :)
obiot added a commit that referenced this issue Mar 4, 2019
@obiot
Copy link
Member

@obiot obiot commented Mar 4, 2019

For those of you still reading these comments here : build process has finally be changed to npm, and external dependencies managed through npm and rollup ! I realized i just broke karma with my last commit, but else its working like a charm :)

@obiot obiot closed this Mar 4, 2019
Roadmap automation moved this from New Features (Core) to Done Mar 4, 2019
@obiot obiot removed this from the 5.0.0 milestone Mar 5, 2019
@obiot
Copy link
Member

@obiot obiot commented Mar 5, 2019

all done, jasmine fixed, the new build process is a success ! I even added a dependencies badge on the README :P

obiot added a commit that referenced this issue Mar 5, 2019
this time with minpubsub; importing MinPubSub through npm and then adding link to the main functions through me.event.
obiot added a commit that referenced this issue Mar 5, 2019
- tweens is way too much customized, so move it to its own folder
- vendors is now empty and can be removed
obiot added a commit that referenced this issue Mar 6, 2019
note: the Jay export does not appears to run, but anyway once the package is imported it will always define window.Jay as previously, so "import "jay-extend" does it well enough.
@obiot
Copy link
Member

@obiot obiot commented Mar 26, 2019

@parasyte could you add me as a collaborator on npm, looks like I have no right to publish any new version there :)
https://www.npmjs.com/package/melonjs

thanks!

(my username is obiot13)

@itsjavi
Copy link
Contributor

@itsjavi itsjavi commented Mar 26, 2019

I added you @obiot

@obiot
Copy link
Member

@obiot obiot commented Mar 26, 2019

@itsjavi thanks ! finally we have an updated version of melonJS on npm :)

@parasyte
Copy link
Member Author

@parasyte parasyte commented Mar 26, 2019

Sorry about that. I would have gotten to it sooner, but I was asleep. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants
You can’t perform that action at this time.