meteor-feature-requests icon indicating copy to clipboard operation
meteor-feature-requests copied to clipboard

Allows to have a Meteor app that is server only

Open theodorDiaconu opened this issue 7 years ago • 20 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 ?

theodorDiaconu avatar Sep 19 '18 11:09 theodorDiaconu

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.

aogaili avatar Sep 20 '18 05:09 aogaili

@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.

theodorDiaconu avatar Sep 21 '18 10:09 theodorDiaconu

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.

stale[bot] avatar Dec 10 '19 21:12 stale[bot]

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

stale[bot] avatar Dec 18 '19 22:12 stale[bot]

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

theodorDiaconu avatar Dec 19 '19 04:12 theodorDiaconu

@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:[email protected]', 'server')

This will more or less achieve what you want.

sebakerckhof avatar Jan 07 '20 16:01 sebakerckhof

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.

stale[bot] avatar Feb 08 '20 17:02 stale[bot]

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...

marcusyoda avatar Feb 11 '20 16:02 marcusyoda

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.

stale[bot] avatar Mar 14 '20 17:03 stale[bot]

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.

aogaili avatar Mar 20 '20 08:03 aogaili

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.

stale[bot] avatar Apr 21 '20 09:04 stale[bot]

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

stale[bot] avatar Apr 29 '20 09:04 stale[bot]

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.

stale[bot] avatar Oct 31 '20 22:10 stale[bot]

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

stale[bot] avatar Nov 09 '20 01:11 stale[bot]

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.

filipenevola avatar Nov 11 '20 22:11 filipenevola

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

dr-dimitru avatar Nov 12 '20 10:11 dr-dimitru

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

[email protected]             # Packages every Meteor app needs to have
[email protected]                   # The database Meteor supports right now
[email protected]    # JS minifier run for production mode
[email protected]              # 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 :heart:

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.

jankapunkt avatar May 29 '21 07:05 jankapunkt

@jankapunkt Does this help?

harryadel avatar May 30 '21 11:05 harryadel

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

StorytellerCZ avatar Jun 04 '21 19:06 StorytellerCZ

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

jankapunkt avatar Jun 05 '21 06:06 jankapunkt