meteor / meteor-feature-requests

A tracker for Meteor issues that are requests for new functionality, not bugs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allows to have a Meteor app that is server only

theodorDiaconu opened this issue · comments

I know that this request may be a bit weird, but I would like to simply remove all JS exported by Meteor packages from the build process for client only. I still want to keep the npm modules. Will that be possible ? Maybe using a custom compiler ?

I just want a meteor-free client but I want to have a fullstack framework.

In the same breath (a bit unrelated to main question) I would like to completely stop DDP from allowing external connections (via SockJS also) -- Is there anyway to do that too ?

commented

Hey @theodorDiaconu isn't that what the meteor --minimal flag support to produce? If not, perhaps we need an even more minimal flag, like --server-only or --barebone . This will essentially allow to run Meteor as server only. I think we could also have --apollo/graphql which default to GraphQL as a data layer/authentication.

@aliogaili the problem is that if I use packages that inject client code, I still have Meteor client when I don't need it. For example collection2 from aldeed does this.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

commented

This issue has been automatically closed it has not had recent activity.

But this is a problem that remains unsolved, unhandled and without an official response.

@theodorDiaconu one possible workaround (although not 100%) is to start from meteor create --minimal and add all your application code in a local package and then add your dependencies in the package.js file as server-only.

So in your package.js you could add:
api.use('aldeed:collection2@1.2.3', 'server')

This will more or less achieve what you want.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

the problem is that if I use packages that inject client code, I still have Meteor client when I don't need it. For example collection2 from aldeed does this.

Same issue here, meteor with DDP is a great powerfull micro service backend...

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

commented

Stepping back a bit, I think the request here it allow Meteor to act as API backend only. Perhaps we've a skeleton apps that allow bootstrapping DDP API and GraphQL API with account features (and collection/mongo server only if DDP is used).

If my understanding is correct, it is possible today to have Meteor act as backend only with minimal flag, but the issue is with third party packages injecting client code. So in API mode flag, we could have a feature to disable any client code injection.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

commented

This issue has been automatically closed it has not had recent activity.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

commented

This issue has been automatically closed it has not had recent activity.

I'm moving this to the feature requests repository so we could understand how many people would use Meteor this way.

This is definitely possible but I'm not sure how many people would use like this. Meteor is already very open to many different options but we need to be careful on adding more options, specially if we don't see enough market for it. I'm not saying that is the case, let's see.

Not directly answering your question, but might help others who is looking for:

  • Build client-only serverless bundle is possible with meteor-build-client
  • Build server-only bundle is possible with meteor build ../path --server-only command

Reviving this - We are using A server-side only application (not so micro microservice) with minimal features, based on the minimum that is available:

.meteor/packages

meteor-base@1.4.0             # Packages every Meteor app needs to have
mongo@1.11.0                   # The database Meteor supports right now
standard-minifier-js@2.6.0    # JS minifier run for production mode
ecmascript@0.15.1              # Enable ECMAScript2015+ syntax in app code
webapp

We have also removed the client entry points in the package.json:

...
  "meteor": {
    "mainModule": {
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  },
...

And yes this is a working app already ❤️

However, since we are also then adding some packages like aldeed:collection2 we are facing the same as described by @theodorDiaconu that client code is still present in the build output.

@dr-dimitru if have read the help info on the build command via meteor build --help and it says the following about --server-only:

  --server-only       Skip building mobile apps even if mobile platforms have been added.

So this command should be renamed IMO to --web-only while --server-only should make sure that no client code is covered by the build system at all.

I think this is a valid use-case when Meteor wants to evolve into the direction of being a great tool for building microservices.

@zodern we should probably get a core solution for this.

Tja package from @zodern works actually great for this. However I still think the --server-only flag confusing in what it does vs how it's named