Rewriting some functions in Meteor


If I want to change snippets of the Meteor framework, I don’t want to send Meteor’s code to the client, and then rewrite it on the client. Is there a way to modify the source-code of Meteor on-the-fly before building the app the first time without modifying the original source code?

For example:

Meteor._vanillaSubscribe = Meteor.subscribe
Meteor.subscribe = function(){
  //do something

is a change I need to make to meteor for my app. I could send over the meteor app, then modify it in the client-side startup.js…

But is there a way to serve the app modified instead of doing this on the client && instead of modifying the original source files (Where are they located?) Links appreciated.


I haven’t tried this, but I believe your solution would be writing a package and loading it at top of the order

There are also examples to this pattern, such as which extends the Collection object with an attachSchema method

Hey, thanks for the reply.

Awesome. I’ve looked into writing a package, but never really figured it out because I haven’t needed to until now.

Glad to know I can do that with meteor packages.

actually, today I had to override a core function of the accounts-base package, so I did just that.