Ember-cli-build, exclude components ember addon












2















I'm using a "core" ember addon in a boilerplate, with



npm link core-addon


This addon contains generic components, helpers, routes...



Is there a way to exclude some of these components in the boilerplate's ember-cli-build file?



I already tried the following in the ember-build-cli in my boilerplate project, which is probably wrong:



const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const environment = EmberApp.env();
module.exports = function (defaults) {
let app = new EmberApp(defaults, {
funnel: {
enabled:true,
exclude:['core-addon/pods/components/pages/**/*']
},
});
return app.toTree();
};


Ember version: 3.5.0
Ember cli version 3.5.0 node version 8.11.3










share|improve this question



























    2















    I'm using a "core" ember addon in a boilerplate, with



    npm link core-addon


    This addon contains generic components, helpers, routes...



    Is there a way to exclude some of these components in the boilerplate's ember-cli-build file?



    I already tried the following in the ember-build-cli in my boilerplate project, which is probably wrong:



    const EmberApp = require('ember-cli/lib/broccoli/ember-app');
    const environment = EmberApp.env();
    module.exports = function (defaults) {
    let app = new EmberApp(defaults, {
    funnel: {
    enabled:true,
    exclude:['core-addon/pods/components/pages/**/*']
    },
    });
    return app.toTree();
    };


    Ember version: 3.5.0
    Ember cli version 3.5.0 node version 8.11.3










    share|improve this question

























      2












      2








      2








      I'm using a "core" ember addon in a boilerplate, with



      npm link core-addon


      This addon contains generic components, helpers, routes...



      Is there a way to exclude some of these components in the boilerplate's ember-cli-build file?



      I already tried the following in the ember-build-cli in my boilerplate project, which is probably wrong:



      const EmberApp = require('ember-cli/lib/broccoli/ember-app');
      const environment = EmberApp.env();
      module.exports = function (defaults) {
      let app = new EmberApp(defaults, {
      funnel: {
      enabled:true,
      exclude:['core-addon/pods/components/pages/**/*']
      },
      });
      return app.toTree();
      };


      Ember version: 3.5.0
      Ember cli version 3.5.0 node version 8.11.3










      share|improve this question














      I'm using a "core" ember addon in a boilerplate, with



      npm link core-addon


      This addon contains generic components, helpers, routes...



      Is there a way to exclude some of these components in the boilerplate's ember-cli-build file?



      I already tried the following in the ember-build-cli in my boilerplate project, which is probably wrong:



      const EmberApp = require('ember-cli/lib/broccoli/ember-app');
      const environment = EmberApp.env();
      module.exports = function (defaults) {
      let app = new EmberApp(defaults, {
      funnel: {
      enabled:true,
      exclude:['core-addon/pods/components/pages/**/*']
      },
      });
      return app.toTree();
      };


      Ember version: 3.5.0
      Ember cli version 3.5.0 node version 8.11.3







      ember.js ember-cli ember-addon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 13:38









      Bert HuysBert Huys

      386




      386
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Addons generally take the reverse approach of this: The addon manages what gets merged into the consuming app via configuration in the consuming app.



          At the highest level, each addon has an entry point that is the index.js file sitting in the root directory of the addon. The addon provides certain configuration options that it reads from config/environment.js of the consuming app when installing.



          I think a really good case study for you would be ember-bootstrap. Look at their configuration options and more specifically the blacklist option. They allow the consuming application to only install a subset of the bootstrap components. Furthermore, the project supports bootstrap 3 or bootstrap 4, but the consuming app isn't getting both! The work is done in index.js



          Let's look just at how they blacklist (ie exclude) certain components from being added to the consuming app:



          treeForApp(tree) {
          tree = this.filterComponents(tree);
          return this._super.treeForApp.call(this, tree);
          },
          filterComponents(tree) {
          let whitelist = this.generateWhitelist(this.bootstrapOptions.whitelist);
          let blacklist = this.bootstrapOptions.blacklist || ;

          // exit early if no opts defined
          if (whitelist.length === 0 && blacklist.length === 0) {
          return tree;
          }

          return new Funnel(tree, {
          exclude: [(name) => this.excludeComponent(name, whitelist, blacklist)]
          });
          }


          where this.excludeComponent at it's core is a boolean returning filter function that returns true if the blacklist contains it in the blacklist case (there for excluding it). The treeForApp function returns the tree for all app files, ie what will be merged from the addon's app dir into the consuming app:



          The consuming app's ember-cli-build would look something like this:



          //your-bootstrap-app/ember-cli-build.js

          module.exports = function(defaults) {
          let app = new EmberApp(defaults, {
          'ember-bootstrap': {
          blacklist: ['bs-popover', 'bs-accordion']
          }
          });

          return app.toTree();
          };


          and the result would be no bs-popover and no bs-accordion available in the consuming apps app tree. These options are obtained in the index.js file like so:



          let options =Object.assign({}, defaultOptions, app.options['ember-bootstrap']);
          this.bootstrapOptions = options;


          Check this general guide to building addons and the more advanced api for more info.






          share|improve this answer
























          • Thanks a lot for this detailed answer,your explanation is a big help.

            – Bert Huys
            Nov 22 '18 at 12:36






          • 1





            I managed to get it working with some minor adjustments to the "excludeComponent" function.

            – Bert Huys
            Nov 22 '18 at 14:44











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413322%2fember-cli-build-exclude-components-ember-addon%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Addons generally take the reverse approach of this: The addon manages what gets merged into the consuming app via configuration in the consuming app.



          At the highest level, each addon has an entry point that is the index.js file sitting in the root directory of the addon. The addon provides certain configuration options that it reads from config/environment.js of the consuming app when installing.



          I think a really good case study for you would be ember-bootstrap. Look at their configuration options and more specifically the blacklist option. They allow the consuming application to only install a subset of the bootstrap components. Furthermore, the project supports bootstrap 3 or bootstrap 4, but the consuming app isn't getting both! The work is done in index.js



          Let's look just at how they blacklist (ie exclude) certain components from being added to the consuming app:



          treeForApp(tree) {
          tree = this.filterComponents(tree);
          return this._super.treeForApp.call(this, tree);
          },
          filterComponents(tree) {
          let whitelist = this.generateWhitelist(this.bootstrapOptions.whitelist);
          let blacklist = this.bootstrapOptions.blacklist || ;

          // exit early if no opts defined
          if (whitelist.length === 0 && blacklist.length === 0) {
          return tree;
          }

          return new Funnel(tree, {
          exclude: [(name) => this.excludeComponent(name, whitelist, blacklist)]
          });
          }


          where this.excludeComponent at it's core is a boolean returning filter function that returns true if the blacklist contains it in the blacklist case (there for excluding it). The treeForApp function returns the tree for all app files, ie what will be merged from the addon's app dir into the consuming app:



          The consuming app's ember-cli-build would look something like this:



          //your-bootstrap-app/ember-cli-build.js

          module.exports = function(defaults) {
          let app = new EmberApp(defaults, {
          'ember-bootstrap': {
          blacklist: ['bs-popover', 'bs-accordion']
          }
          });

          return app.toTree();
          };


          and the result would be no bs-popover and no bs-accordion available in the consuming apps app tree. These options are obtained in the index.js file like so:



          let options =Object.assign({}, defaultOptions, app.options['ember-bootstrap']);
          this.bootstrapOptions = options;


          Check this general guide to building addons and the more advanced api for more info.






          share|improve this answer
























          • Thanks a lot for this detailed answer,your explanation is a big help.

            – Bert Huys
            Nov 22 '18 at 12:36






          • 1





            I managed to get it working with some minor adjustments to the "excludeComponent" function.

            – Bert Huys
            Nov 22 '18 at 14:44
















          1














          Addons generally take the reverse approach of this: The addon manages what gets merged into the consuming app via configuration in the consuming app.



          At the highest level, each addon has an entry point that is the index.js file sitting in the root directory of the addon. The addon provides certain configuration options that it reads from config/environment.js of the consuming app when installing.



          I think a really good case study for you would be ember-bootstrap. Look at their configuration options and more specifically the blacklist option. They allow the consuming application to only install a subset of the bootstrap components. Furthermore, the project supports bootstrap 3 or bootstrap 4, but the consuming app isn't getting both! The work is done in index.js



          Let's look just at how they blacklist (ie exclude) certain components from being added to the consuming app:



          treeForApp(tree) {
          tree = this.filterComponents(tree);
          return this._super.treeForApp.call(this, tree);
          },
          filterComponents(tree) {
          let whitelist = this.generateWhitelist(this.bootstrapOptions.whitelist);
          let blacklist = this.bootstrapOptions.blacklist || ;

          // exit early if no opts defined
          if (whitelist.length === 0 && blacklist.length === 0) {
          return tree;
          }

          return new Funnel(tree, {
          exclude: [(name) => this.excludeComponent(name, whitelist, blacklist)]
          });
          }


          where this.excludeComponent at it's core is a boolean returning filter function that returns true if the blacklist contains it in the blacklist case (there for excluding it). The treeForApp function returns the tree for all app files, ie what will be merged from the addon's app dir into the consuming app:



          The consuming app's ember-cli-build would look something like this:



          //your-bootstrap-app/ember-cli-build.js

          module.exports = function(defaults) {
          let app = new EmberApp(defaults, {
          'ember-bootstrap': {
          blacklist: ['bs-popover', 'bs-accordion']
          }
          });

          return app.toTree();
          };


          and the result would be no bs-popover and no bs-accordion available in the consuming apps app tree. These options are obtained in the index.js file like so:



          let options =Object.assign({}, defaultOptions, app.options['ember-bootstrap']);
          this.bootstrapOptions = options;


          Check this general guide to building addons and the more advanced api for more info.






          share|improve this answer
























          • Thanks a lot for this detailed answer,your explanation is a big help.

            – Bert Huys
            Nov 22 '18 at 12:36






          • 1





            I managed to get it working with some minor adjustments to the "excludeComponent" function.

            – Bert Huys
            Nov 22 '18 at 14:44














          1












          1








          1







          Addons generally take the reverse approach of this: The addon manages what gets merged into the consuming app via configuration in the consuming app.



          At the highest level, each addon has an entry point that is the index.js file sitting in the root directory of the addon. The addon provides certain configuration options that it reads from config/environment.js of the consuming app when installing.



          I think a really good case study for you would be ember-bootstrap. Look at their configuration options and more specifically the blacklist option. They allow the consuming application to only install a subset of the bootstrap components. Furthermore, the project supports bootstrap 3 or bootstrap 4, but the consuming app isn't getting both! The work is done in index.js



          Let's look just at how they blacklist (ie exclude) certain components from being added to the consuming app:



          treeForApp(tree) {
          tree = this.filterComponents(tree);
          return this._super.treeForApp.call(this, tree);
          },
          filterComponents(tree) {
          let whitelist = this.generateWhitelist(this.bootstrapOptions.whitelist);
          let blacklist = this.bootstrapOptions.blacklist || ;

          // exit early if no opts defined
          if (whitelist.length === 0 && blacklist.length === 0) {
          return tree;
          }

          return new Funnel(tree, {
          exclude: [(name) => this.excludeComponent(name, whitelist, blacklist)]
          });
          }


          where this.excludeComponent at it's core is a boolean returning filter function that returns true if the blacklist contains it in the blacklist case (there for excluding it). The treeForApp function returns the tree for all app files, ie what will be merged from the addon's app dir into the consuming app:



          The consuming app's ember-cli-build would look something like this:



          //your-bootstrap-app/ember-cli-build.js

          module.exports = function(defaults) {
          let app = new EmberApp(defaults, {
          'ember-bootstrap': {
          blacklist: ['bs-popover', 'bs-accordion']
          }
          });

          return app.toTree();
          };


          and the result would be no bs-popover and no bs-accordion available in the consuming apps app tree. These options are obtained in the index.js file like so:



          let options =Object.assign({}, defaultOptions, app.options['ember-bootstrap']);
          this.bootstrapOptions = options;


          Check this general guide to building addons and the more advanced api for more info.






          share|improve this answer













          Addons generally take the reverse approach of this: The addon manages what gets merged into the consuming app via configuration in the consuming app.



          At the highest level, each addon has an entry point that is the index.js file sitting in the root directory of the addon. The addon provides certain configuration options that it reads from config/environment.js of the consuming app when installing.



          I think a really good case study for you would be ember-bootstrap. Look at their configuration options and more specifically the blacklist option. They allow the consuming application to only install a subset of the bootstrap components. Furthermore, the project supports bootstrap 3 or bootstrap 4, but the consuming app isn't getting both! The work is done in index.js



          Let's look just at how they blacklist (ie exclude) certain components from being added to the consuming app:



          treeForApp(tree) {
          tree = this.filterComponents(tree);
          return this._super.treeForApp.call(this, tree);
          },
          filterComponents(tree) {
          let whitelist = this.generateWhitelist(this.bootstrapOptions.whitelist);
          let blacklist = this.bootstrapOptions.blacklist || ;

          // exit early if no opts defined
          if (whitelist.length === 0 && blacklist.length === 0) {
          return tree;
          }

          return new Funnel(tree, {
          exclude: [(name) => this.excludeComponent(name, whitelist, blacklist)]
          });
          }


          where this.excludeComponent at it's core is a boolean returning filter function that returns true if the blacklist contains it in the blacklist case (there for excluding it). The treeForApp function returns the tree for all app files, ie what will be merged from the addon's app dir into the consuming app:



          The consuming app's ember-cli-build would look something like this:



          //your-bootstrap-app/ember-cli-build.js

          module.exports = function(defaults) {
          let app = new EmberApp(defaults, {
          'ember-bootstrap': {
          blacklist: ['bs-popover', 'bs-accordion']
          }
          });

          return app.toTree();
          };


          and the result would be no bs-popover and no bs-accordion available in the consuming apps app tree. These options are obtained in the index.js file like so:



          let options =Object.assign({}, defaultOptions, app.options['ember-bootstrap']);
          this.bootstrapOptions = options;


          Check this general guide to building addons and the more advanced api for more info.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 10:11









          mistahenrymistahenry

          5,74931829




          5,74931829













          • Thanks a lot for this detailed answer,your explanation is a big help.

            – Bert Huys
            Nov 22 '18 at 12:36






          • 1





            I managed to get it working with some minor adjustments to the "excludeComponent" function.

            – Bert Huys
            Nov 22 '18 at 14:44



















          • Thanks a lot for this detailed answer,your explanation is a big help.

            – Bert Huys
            Nov 22 '18 at 12:36






          • 1





            I managed to get it working with some minor adjustments to the "excludeComponent" function.

            – Bert Huys
            Nov 22 '18 at 14:44

















          Thanks a lot for this detailed answer,your explanation is a big help.

          – Bert Huys
          Nov 22 '18 at 12:36





          Thanks a lot for this detailed answer,your explanation is a big help.

          – Bert Huys
          Nov 22 '18 at 12:36




          1




          1





          I managed to get it working with some minor adjustments to the "excludeComponent" function.

          – Bert Huys
          Nov 22 '18 at 14:44





          I managed to get it working with some minor adjustments to the "excludeComponent" function.

          – Bert Huys
          Nov 22 '18 at 14:44




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413322%2fember-cli-build-exclude-components-ember-addon%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter