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

Remove Blaze dependency from base packages #6844

Closed
Akryum opened this issue Apr 18, 2016 · 40 comments
Closed

Remove Blaze dependency from base packages #6844

Akryum opened this issue Apr 18, 2016 · 40 comments

Comments

@Akryum
Copy link

Akryum commented Apr 18, 2016

I appears that some base meteor packages still have a blaze dependency even if we don't want to use it. And because of that, we can't completly remove jquery.

Investigations shows the following dependencies for now:

  • meteor-base -> webapp -> boilerplate-generator (??) -> spacebars -> blaze
  • static-html -> templating-tools -> spacebar-compiler -> blaze

Original post

(Using Meteor 1.3.2.1)

It should be possible to use the package in a non-blaze project (for example with angular, react or vue), without the blaze dependency (and jquery). In my current project, I am only using static-html with vuejs, plus some custom login service plugged into Meteor account system, and the app still has to load blaze and jquery.

It would be great if accounts-base was ui agnostic for use in any kind of project.

@trajano
Copy link

trajano commented Apr 18, 2016

Although it has a dependency on blaze, as long as it does not have a dependency on blaze-templates we on angular land should not get affected.

@trajano
Copy link

trajano commented Apr 18, 2016

It appears to be marked as a weak dependency

https://github.com/meteor/meteor/blob/devel/packages/accounts-base/package.js

I wonder if we should change meteor's behavior to not load weak dependencies by default.

@reohjs
Copy link
Contributor

reohjs commented Apr 20, 2016

Weak dependencies are already not included by default, there is most likely another package at fault here.

@trajano
Copy link

trajano commented Apr 20, 2016

Unfortunately it's not easy to tell which one as of yet. Though personally my .meteor/packages is pretty short

meteor-base             
mobile-experience    
mongo                   
session                
jquery                  
tracker                 
es5-shim             
alanning:roles
accounts-password
netanelgilad:angular-server
anti:fake
random
twbs:bootstrap
fortawesome:fontawesome
tmeasday:publish-counts
standard-minifier-css
standard-minifier-js
modules
angular-templates
percolate:find-from-publication
matb33:collection-hooks
tmeasday:publish-with-relations
pbastowski:angular-babel
dburles:mongo-collection-instances

@Akryum
Copy link
Author

Akryum commented Apr 21, 2016

Here are my packages:
meteor-base
mobile-experience
mongo
session
tracker
static-html
check
email
accounts-base
webpack:webpack
kadira:flow-router-ssr
ccorcos:subs-cache

@abernix
Copy link
Contributor

abernix commented Apr 21, 2016

@Akryum Almost certainly static-html. I think it uses uses templating-tools, which will use spacebars-compiler which uses blaze.

@Akryum
Copy link
Author

Akryum commented Apr 21, 2016

What can I do to remove the blaze dependency then?

@trajano
Copy link

trajano commented Apr 22, 2016

I don't think you can. I created a new project and got rid of the blaze packages and I still have it. The .meteor/package I have is down to

meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
reactive-var # Reactive variable for tracker
tracker # Meteor's client-side reactive programming library

standard-minifier-css # CSS minifier run for production mode
standard-minifier-js # JS minifier run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code

@trajano
Copy link

trajano commented Apr 22, 2016

You're going to get it regardless because your app will need

meteor-base which has webapp which has boilerplate-generator (??) which has spacebars which has... blaze

@Akryum Akryum changed the title Remove Blaze dependency from accounts-base Remove Blaze dependency from base packages Apr 22, 2016
@Akryum
Copy link
Author

Akryum commented Apr 22, 2016

Maybe we could get rid of these dependencies?

@trajano
Copy link

trajano commented Apr 22, 2016

boilerplate-generator

provides https://github.com/meteor/meteor/blob/devel/packages/boilerplate-generator/boilerplate_web.browser.html which is a sparebars template that gives the main file of the application so we can't get rid of webapp->boilerplate->spacebars

spacebars

provides https://github.com/meteor/meteor/blob/devel/packages/spacebars/spacebars-runtime.js which requires blaze. However, from looking at it I wonder if we can have a non-reactive version of spacebars so we do not need to include the blaze reactivity on the boilerplate code.

@reohjs
Copy link
Contributor

reohjs commented Apr 22, 2016

boilerplate-generator can probably lose the spacebars& uidependencies since they don't seem to be in use. (and spacebars-compiler doesn't depend on Blaze)

@stubailo
Copy link
Contributor

stubailo commented May 5, 2016

Why do these dependencies matter? These only load Blaze on the server, right?

@DerekTBrown
Copy link

@stubailo I don't believe so. It seems that these packages automatically add a ton of client dependencies like JQuery (https://atmospherejs.com/meteor/blaze). Meteor needs to move in the direction of being more split up for people who want to use either React or Angular as a template tool.

@DerekTBrown
Copy link

@skirunman
Copy link
Contributor

skirunman commented Jul 29, 2016

@DerekTBrown You can certainly remove jquery from your client bundle, see #6563 and https://github.com/meteor/meteor/blob/devel/History.md#v132

You are correct that boilerplate-generator uses Blaze, but as @stubailo mentions, this is only on the server:

api.use(['underscore', 'spacebars-compiler',
'spacebars', 'htmljs', 'ui'], 'server');
api.addFiles(['boilerplate-generator.js'], 'server');

I'm all for cleaning these dependencies up though.

@DerekTBrown
Copy link

DerekTBrown commented Jul 29, 2016

@skirunman the issue you are mentioning only removed JQuery from check (https://github.com/meteor/meteor/pull/6710/files) not as a dependency from Blaze:

https://github.com/meteor/meteor/blob/devel/packages/blaze/package.js#L8

@skirunman
Copy link
Contributor

That's correct, but my understanding is that Blaze has a hard dependency today on jquery anyway. Might want to ask guys that know Blaze much better than I do like @mitar.

Anyway, my understanding of your issue is that you want to make sure libraries you are not going to use on the client, like blaze and jquery, are not included in your client bundle if you are using React. Blaze and jquery can be excluded from the client today if you are using React, just as we are doing today.

It looks like they will still be included in the server bundle, but it does look like it may be possible to remove them with some refactoring. If that is of issue for you you could try generating a PR.

@DerekTBrown
Copy link

@skirunman @mitar - I don't care if Blaze / JQuery are included in my server bundle, but I don't want them included in the client bundle. The problem, is that the following dependency chain exists:

meteor-base -> webapp -> boilerplate-generator -> spacebars -> blaze -> jquery

Even if I want to use React or Angular, I still need webapp in order to serve HTTP content, which, in turn automatically imports clientside JQuery.

@mitar
Copy link
Contributor

mitar commented Jul 31, 2016

Does webapp need jQuery on the client? Maybe we should just limit dependency on webapp for jQuery to server only?

@skirunman
Copy link
Contributor

skirunman commented Jul 31, 2016

Unless I missing something here, it looks to me that jQuery is only being included on the server from the webapp -> boilerplate-generator dependency.

https://github.com/meteor/meteor/blob/devel/packages/webapp/package.js

api.use(['logging', 'underscore', 'routepolicy', 'boilerplate-generator',
           'webapp-hashing'], 'server');
api.use(['underscore'], 'client');

and boiler-plate only looks like it runs on the server.

https://github.com/meteor/meteor/blob/devel/packages/boilerplate-generator/package.js

api.use(['underscore',  'spacebars-compiler',
           'spacebars', 'htmljs', 'ui'], 'server');
  api.addFiles(['boilerplate-generator.js'], 'server');
  api.export(['Boilerplate'], 'server');

@mitar
Copy link
Contributor

mitar commented Jul 31, 2016

So where is the jQuery dependency defined?

@Akryum
Copy link
Author

Akryum commented Aug 1, 2016

I think it's static-html

@skirunman
Copy link
Contributor

skirunman commented Aug 4, 2016

@mitar I do not see any client dependency for Blaze or jQuery in the meteor-base package so I think that is fine.

If you include the static-html package in your app then there is a dependency chain of static-html > templating-tools > spacebars-compiler > blaze-tools, html-tools, htmljs

Looking at the packages blaze-tools, html-tools and htmljs and the dependency chain I don't see any dependencies on jQuery or Blaze.

There is a Package.onTest dependency in the spacebars-compiler package for both blaze and spacebars, but my assumption is these dependencies should not be included unless you run the meteor test command or the Meteor.isTest flag is set to true (have not tested this though so maybe someone else can confirm).

Also, static-html is a build plugin and I thought build plugins were not built in to the client bundle (could be wrong). https://github.com/meteor/meteor/blob/devel/packages/static-html/package.js

Hope this helps.

@ElegantSudo
Copy link

ElegantSudo commented Aug 6, 2016

Bottom line is that I didn't include jQuery in my Meteor app at all, and it's included on the client my production apps.

NPM packages and build tools are installed as developer only because they're for development only.

I think MDG is very clear on where jQuery is used and what depends on it. I think they're intentionally ignoring it because they feel like they have bigger fish to fry.

Regardless, there's a big part of me that feels like this just shouldn't be a problem and Meteor should be architecting their development build tool like any other.

I know for sure that webpack doesn't give me these problems.

@skirunman
Copy link
Contributor

skirunman commented Aug 14, 2016

@ElegantSudo If you include Blaze you are going to get jquery as Blaze currently has a dependency on jquery. Are you using Blaze in your app or another package that has a dependency on Blaze or jquery? For instance, accounts-ui which is going to also pull in jquery through its dependency chain.

@ElegantSudo
Copy link

ElegantSudo commented Aug 14, 2016

@skirunman I'm a 100% React app with no accounts-ui, no Blaze, and no jQuery dependencies from my packages as far as I can tell. It would be great if there were a program that allowed you to track dependencies, but currently I'm at a loss. I'm going to go into my Meteor folder tonight and search the cached packages for dependencies with Atom.

@HamzaHawk
Copy link

It is a bit frustrating that we can not remove blaze dependencies from the client side, even when we are using React or Angular. It seems to affect the loading time of app on startup.
http://info.meteor.com/blog/comparing-performance-of-blaze-react-angular-meteor-and-angular-2-with-meteor

@skirunman
Copy link
Contributor

FYI, you can completely removed jquery dependency from client bundle. static-html module used to be a blocking issue, but the jquery dependency was removed in this commit a91a1cc.

You still have a server dependency on jquery because of package boilerplate-generator and the dependency chain starting with webapp package.

@hwillson
Copy link
Contributor

hwillson commented Feb 24, 2017

Hi all - it looks like we're now in a good position to close this issue, for the following reasons:

Issue Summary

  1. People want to be able to remove all client side Blaze dependencies from their apps.
  2. People want to be able to remove all client side jQuery dependencies from their apps.
  3. Having Blaze and jQuery as server side dependencies doesn't really matter.

Breakdown

  1. Blaze can be completely removed from the client side by removing the blaze-html-templates package. If you then want to use the static-html package, that's okay - Blaze is still kept out of your client side bundle; static-html does not have a dependency on Blaze. It uses some of Blaze's internal packages like caching-html-compiler and templating-tools, but these packages are not brought into your client bundle. You can verify this at any point using the following steps (assuming at least Meteor 1.4.3.1):
meteor create no-client-side-blaze
cd no-client-side-blaze
meteor remove blaze-html-templates
meteor add static-html
echo "<body>No Blaze</body>" > client/main.html 
rm client/main.js
meteor
cd .meteor/local/build/programs/web.browser
grep -lir "Blaze" *
  1. If you're not using Blaze, jQuery can also be completely removed from your client bundle, by removing your apps jquery package. Quick example to verify:
meteor create no-client-side-jquery
cd no-client-side-jquery
meteor remove jquery
meteor remove blaze-html-templates
meteor add static-html
echo "<body>No jQuery</body>" > client/main.html 
rm client/main.js
meteor
cd .meteor/local/build/programs/web.browser/packages
find . | grep jquery

One quick thing to note - after removing the jquery package, some people think jQuery is still available via their client side app as they're testing the $ function within their browser console, and it works. Don't be fooled by this (really confusing and unfortunate side affect) of certain browsers deciding to use the $ symbol themselves. See the $(selector) section of the Chrome console CLI docs for an example of this.

  1. Blaze is definitely still needed/used on the server side, by the boilerplate-generator. As discussed in this issue thread however, this really isn't much of an issue for people.

Conclusion

Given the above, I'll close this issue. Thanks for opening this originally, and thanks everyone for participating in the discussion!

@skirunman
Copy link
Contributor

For completeness, I opened this issue to remove jquery from the server bundle as well. #8232

@stubailo
Copy link
Contributor

One issue is that it's not easy to identify which code is being loaded on the client - so it's hard to verify that Blaze is only being loaded on the server.

@hwillson
Copy link
Contributor

Great point @skirunman, thanks for doing that!

Also a great point @stubailo - I think that would be best tracked in a new issue / feature request (if anyone wants to open / champion one).

@abernix
Copy link
Contributor

abernix commented Feb 24, 2017

Presumably, #8073 will identify which packages were are bundled, when it's done.

@jmaguirrei
Copy link

@hwillson I removed Blaze but I could not remove Jquery.

Just commented the line jquery@1.11.10 # Helpful client-side library at .meteor/packages, but jquery is still in my client bundle:

<script type="text/javascript" src="/packages/jquery.js?hash=c57b3cfa0ca9c66400d4456b6f6f1e486ee10aad"></script>

Besides standard packages, I use this:

aldeed:collection2
accounts-password@1.3.4
kadira:flow-router
rocketchat:streamer
mizzao:user-status
mdg:validated-method
space:tracker-mobx-autorun
reywood:publish-composite
kadira:dochead

Also noticed in your comment, Breakdown 2, you say:

meteor remove blaze-html-templates
meteor add static-html

Should be remove jquery?

I also removed jquery.js manually, but the building process generated it again.

What could be wrong?

Thanks

@hwillson
Copy link
Contributor

@jmaguirrei - mizzao:user-status has a client side dependency on jquery; see https://github.com/mizzao/meteor-user-status/blob/master/package.js#L16

Regarding breakdown 2, I mentioned removing the jquery package earlier, but you're right - it should be added to the steps (I've added it now). Thanks!

@jmaguirrei
Copy link

@hwillson OK! I just commented on that package. Thanks.

@s7dhansh
Copy link
Contributor

These are my packages

meteor-base@1.0.4             # Packages every Meteor app needs to have
mobile-experience@1.0.4       # Packages for a great mobile UX
mongo@1.1.16                   # The database Meteor supports right now
reactive-var@1.0.11            # Reactive variable for tracker
jquery@1.11.10                  # Helpful client-side library
tracker@1.1.2                 # Meteor's client-side reactive programming library

standard-minifier-css@1.3.4   # CSS minifier run for production mode
standard-minifier-js@1.2.3    # JS minifier run for production mode
es5-shim@4.6.15                # ECMAScript 5 compatibility for older browsers.
ecmascript@0.6.3              # Enable ECMAScript2015+ syntax in app code

service-configuration@1.0.11
react-meteor-data
materialize:materialize
accounts-google@1.1.1
email@1.1.18
http@1.2.12
reywood:publish-composite
fourseven:scss
static-html
settlin:meteor-maintenance-mode
ground:db@2.0.0-rc.7

but I still have blaze. versions file shows

blaze@2.1.9
blaze-tools@1.0.10

I tried figuring out the package which causes this indirect dependency, but was unable to? Can someone help?

@abernix
Copy link
Contributor

abernix commented Mar 20, 2017

@s7dhansh Try removing each package one by one from the .meteor/packages file until nothing is left. Somewhere in that process, you should observe on the server console that blaze has been removed.

@s7dhansh
Copy link
Contributor

@abernix I had done that already, to no avail. That is why I posted here to get some help :).

I just debugged on a bare app, and realised a few things that were already written above in this issue. Silly me, for not reading it properly earlier. The versions file will have blaze because of the meteor-base package itself, which loads it only on the server. So, I should live with it without worrying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests