4
votes

I developed an ember-cli addon that works fine.

When I run the command ember build, it basically creates a vendor.js file that contains my addon and all dependencies (ember, jquery etc...) which is about 3MB

I'd like to know if it's possible to export the addon as its own (my-addon.js) without any dependencies inside, as a vendor I can use?

I'm basically trying to make my ember-cli addon a bower component that I can include in another ember project. My addon and all dependencies are more than 100MB of data (including node modules, broccoli, tests...), so when I install it using npm install my-addon, it's pretty big. I don't really need that in my other project, the addon itself (dist version) is about a couple of KB and that's all I need...

Basically, this is the architecture of my projects:

Ember project:

my-project.git

/my-project
  /app
    /controllers etc...
  /node_modules
    /my-addon //My addon lives here for now and contains everything (all node_modules, bower_components, tests... about 100MB to download!)
  Brocfile.js etc..

Basic architecture for an ember-cli addon:

my-addon.git

/my-addon
  /addon
  /app
  /bower_components
  /node_modules
  /tests
  Brocfile.js etc..

package.json:

{
  "name": "my-addon",
  "version": "0.0.1",
  "directories": {
        "doc": "doc",
        "test": "tests"
  },
  "scripts": {
        "start": "ember server",
        "build": "ember build",
        "test": "ember test"
  },
  "engines": {
        "node": ">= 0.10.0"
  },
  "devDependencies": {
        "body-parser": "^1.2.0",
        "broccoli-sass": "0.3.2",
        "broccoli-asset-rev": "0.3.1",
        "broccoli-ember-hbs-template-compiler": "^1.6.1",
        "ember-cli": "0.1.2",
        "ember-cli-content-security-policy": "0.3.0",
        "ember-cli-ic-ajax": "0.1.1",
        "ember-cli-inject-live-reload": "^1.3.0",
        "ember-cli-qunit": "0.1.0",
        "ember-data": "1.0.0-beta.10",
        "ember-export-application-global": "^1.0.0",
        "express": "^4.8.5",
        "glob": "^4.0.5"
    }
    "keywords": [
        "ember-addon"
    ],

    "ember-addon": {
        "configPath": "tests/dummy/config"
    }
}

Thanks

1
Could you point us in the direction of your addon's repoPatsy Issa
I edited the post with the architecture of the projects.alexmngn
I am more interested in the package.json file that your addon has for managing dependencies and suchPatsy Issa
I added what the package.json of my addon looks like.alexmngn
Could you jump on the ember js IRC channel or the SO channelPatsy Issa

1 Answers

0
votes

So, what happened?

My answer would be, that your local repo - should have all that junk that it needs to process etc... but the final code that you set up with bower, should be a either a branch with just your /dist or something or - the github repo should only have the unbuilt code. Then... you bower install --save your-thing - which would then get registered with the ember app. then just bower install or update etc - and it will check the config - and pull in the dependencies based on the package.json and the bower.json.

It would be great if you documented your findings and answered this question here. I bet it's a pretty common workflow.