4

I am developing a reusable component (module) for AngularJS which can be used to enable offline features of applications built with AngularJS.

To achieve client side storage features without re-inventing the wheel, I decided to use this good library provided by Google called Lovefield, which works as,

A cross-browser, SQL-like, relational query engine for Web in pure JavaScript.

I know how to wrap this library with angularjs by creating custom directives, services etc. inside my module. But my question is,

When distributing my module, do I need to include the Javascript code for lovefiled inside my own module code Or Should I ask the developer to include it by himself using <script> tags inside his html? What is the recommended way to do this? (It is apparent that both methods can be used)

I went through some of the 3rd party angular modules here, but cannot figure out what is the recommended way of doing this.

Terrance
  • 11,764
  • 4
  • 54
  • 80
Chaya Sandamali
  • 657
  • 9
  • 22
  • 1
    It also depends on how you have configured your project. Best way is to create a bower package and distribute it. check http://bower.io/docs/creating-packages/ You can create your directive and have the lovefield package as a dependency. IMO that is the best way to create and distribute angularjs components. On installing the component/directive in any project will also download and install lovefield package. – anit Sep 09 '15 at 08:11

2 Answers2

1

you should ask the developer to add the <script> tag you should have a package.json file which indicates what depenedencies you have like that -

{
  "name": "angular-lovefield",
  "version": "1.0.0",  
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "youre-name",
  "license": "ISC",
  "dependencies": {
    "lovefield": 1.0.0.1 
  }

}

you can create this file using the npm init command

good luck.

Ran Sasportas
  • 2,256
  • 1
  • 14
  • 21
-2

I know that this is not exactly what you've meant, but.. I've already done the same thing "wrap this library with angularjs by creating custom directives, services etc."

I used bower to distribute the module (called ng-lovefield) and added lovefield as a dependency in the bower.json file, I suggest that if you wish to create a new module you do the same (no matter what kind of package manager you choose - npm \ bower)

Including the actual <script> in the html is the task runner responsibility such as grunt or gulp, you can use grunt-wiredep to inject all your bower dependencies automaticly to your html. If you do not wish to use task runner for some reason I guess that you have to do it manually.

kutomer
  • 734
  • 8
  • 17
  • Please include the relevant portion of your code that answers the question directly in your answer. Posting an answer that only contains an external link is not useful, as links can die. – Kelly Keller-Heikkila Jan 19 '16 at 13:34
  • You probably want to review [How to offer personal open-source libraries?](https://meta.stackexchange.com/q/229085) before posting about your project here. – Martijn Pieters Jan 19 '16 at 14:41