screepers / screeps-server-mockup

Private server package for unit tests
MIT License
55 stars 13 forks source link

Peer Dependencies on @screeps projects #24

Open brisberg opened 4 years ago

brisberg commented 4 years ago

Does anyone know why this project has peer dependencies on the various @screeps component?

  "peerDependencies": {
    "@screeps/common": "^2.12.1",
    "@screeps/driver": "^5.0.0",
    "@screeps/engine": "^4.0.4"
  },

https://nodejs.org/es/blog/npm/peer-dependencies/

As far as I know, the point of peer dependencies is for "plugins" which all use a core library but don't want to version lock the consumer into a specific version of that dependency. This is particularly relevant if the consumer would also want to directly use that core library.

We already have a direct dependency on screeps itself, which has a direct dependency on all of the same components. I don't see any benefit to including these peer dependencies.

pyrodogg commented 4 years ago

Here's my reasoning. https://github.com/screepers/screeps-server-mockup/commit/24e3a47dfe9d361a6fb8d23dff2feb73ae67bceb

Linter complained about extraneous dependencies for modules like @screeps/common not being referenced in package.json. These packages are implicitly included by the @screeps package. Adding them to this project as a direct dependency would require strict coordination with the screeps package. Adding as peer dependencies simply notes that they are required but not provided by this package.

brisberg commented 4 years ago

Ok that makes sense, but I still feel it is masking the problem.

And that isn't actually true: @screeps/common is indeed directly referenced by this package so it should be a true dependency, and it is in fact provided by this this package (transitively through @screeps/screeps).

I think the real issue is "what is the purpose of @screeps/screeps?". It is supposed to be a standalone wrapper around all of the screeps components, including the launcher and UI, for launching a private server.

But that isn't quite what we are doing, we are picking up the components from @screeps/screeps, and rebuilding them ourselves into a custom runner (screepsServer.js) which can be controlled on a per tick granularity.

This kind of thing is actually exactly what the separate of the screeps components is for. You can pick and choose your components and glue them together yourself.

Thesefor, I propose the following:

We will need to keep these in sync with the latest versions (just like now #23 )

--

Consumers of this project will not need to provide any other screeps components, as they will all be included in here.

--

Totally separate topic, feel free to move. But since we have @screeps and all it's components, would it be possible to launch a UI to view the state of the mockup server? that would really help with visual debugging of integration tests.