I want to build a meteor package to wrap an existing javascript library. I would like to include the library as a git submodule. I only need 2 files from the submodule. If I only include these two in package.js will the rest of the files be ignored by meteor and not built into the package?
The only files that will end up in your package are those that will be explicitly added with api.addFiles routine (look here).
BTW, If you're planning to wrap an existing JavaScript library then you should probably start by getting familiar with autopublish project. For more details watch this video.
Related
So, my problem is that I am trying to add a couple of console.log() to a js file of an already installed package that I have in my project.
The package that I am trying to add these lines to is aldeed:autoform, since I've discovered kind of a bug in a function and I want to contribute with a solution.
In order to modify a package, I have already done the following steps:
Clone the github repo for autoform inside myProject/packages/ folder.
Modified the lines that I wanted to.
Changed the name value inside Package.describe({}) (set to
aldeed-autoform-modified)
Removed aldeed:autoform from my project (meteor remove
aldeed:autoform)
Added my modified version of autoform (meteor add
aldeed:autoform-modified)
The problem is that, since I am also using antoher packages that have aldeed:autoform as a dependency, this package gets automatically installed, and then when I run my project, it trhows an error saying that a template (related to AutoForm) is defined twice, and this makes sense since autoform package and the modified one have this templated defined, and both get included in the project.
What should I do? What is the proper way to modify a package that is a dependency for others?
If you want to modify an existing package, you can use a local version of it.
There is no need to modify its name, and if another package depends on it, changing the name will cause the dependent package not to use your modified version.
Simply clone the package repository into your projects's/packages directory or to the directory denoted by the METEOR_PACKAGE_DIRS environment variable.
You can find more details on the Meteor Guide.
I am a little new to angular-meteor and want to add an external js library to my project.
The library is Fusioncharts.js http://www.fusioncharts.com/angularjs-charts/#/demos/ex1 and it cannot be installed using any of these options
1) bower install
2) npm install
3) meteor add (from atmosphere)
So what i did is, I followed these steps How can I add third-party JavaScript libraries to a Meteor application?
and added the libraries manually under public/js directory
Created a main.js file and added all the scripts using $.getScript
Strange thing is when I add the dependency of the 'ng-fusioncharts' module in my angular.module it throws an error
" Module 'ng-fusioncharts' is not available! You either misspelled the module name or forgot to load it."
Please let me know what could be going wrong here.
P.S : When I type in FusionCharts in the console.log I do see that object.
So it means the Fusioncharts libraries were imported properly but not added to the angular dependency
Thanks in advance
Please note that $.getScript is asynchronous, so you would need a little timeout to wait for the module to be available to the rest of your code.
Another possibility to try out would be to include your script rather in client/compatibility special folder. It will be included in your JS and execute before the rest of your client JS code.
I am working on a new Meteor app that I want to structure as a set of packages.
For each package, package.js is used to specify what files to include for client and server. This is standard usage.
My question: I want to divide a package into features, and I'd like to describe each feature with a file on the same lines as what package.js does for packages. The main function of the feature file is to list the files of that feature that are required on client and server; concretely the feature file will contain api.use() calls that logically are included in the parent package.js file. In other words, I'm looking for an 'include' functionality for package.js.
Is such a thing possible, and how?
I solved this myself by generating the api.addFiles calls in the package.js. To do that I tweaked the npm meteor-package-paths module, in particular the js.coffee module to add the additional 'feature' layer of directories.
I am trying to use rajit:bootstrap3-datepicker in my project. The project page on Atmosphere list jquery as dependency of this package.
Does meteor add jquery when I run the command
meteor add rajit:bootstrap3-datepicker
or do I have to separately add jquery
meteor add jquery
Note: .meteor/packages does not show jquery as one of the added packages.
jquery is listed as a dependency in rajit:bootstrap3-datepicker package.js, this is why it will be automatically added to your app without the need to explicitly add it yourself.
.meteor/packages is only listing your app direct dependencies, not dependencies implied by the packages you're using.
You do not have to install jQuery in addition. Usually packages have their dependencies already included, so just do meteor add [package] and you are good to go.
.meteor/packages will only list dependencies specific to your app and not a package's dependency.
Tl;dr : Is there an equivalent in meteor to .gitignore?
Yes, I am aware of using a leading '.' in the directory name to get meteor to exclude it. But using leading dot is not a solution in this case. Read below to understand.
Longer:
I would like to use Bower.io to install various browser plugins.
Ideally, I run bower in the client subdirectory. Bower does its thing creating the bower_components directory and pulls down the plugin (pick a random jquery plugin for example).
Many plugins include example html, demo css files, etc. to show how to use the plugin.
Unfortunately, Meteor wants to include all that stuff in the application. Which unsurprisingly causes problems.
My current solution is to have bower.io run in the project's parent directory. This is not ideal as I have to copy js/css files over from the bower directory to the meteor client directory. (yes, I could use soft links but then the files would be missing when pushing to production).
With only a few client plugins / css packages this is becoming quite annoying.
NOTE: Renaming files/directories retrieved by bower.io to have a leading '.' or using bower in a dotted subdirectory helps only marginally. I would then have to manually include the files needed.
Is this possibly a duplicate of How to exclude directories/files from Meteor's bundler?
If you want to define the way you name your files, you could try including a certain regex to match in the meteor bundler. Otherwise, maybe it's something that needs to be implemented on a framework level.
I also found this tutorial by Tri on integrating meteor and bower: http://tridnguyen.com/articles/meteor-and-bower/. Tri defines a new meteor package to specify the exact files required on the client.
The best solution, however, is move away from Bower as Meteor offers its own package manager at a framework level. Including the front end files that you need using Meteor packages would be the more productive solution in the long run, especially as the framework changes.