Accepted practice for an ES6 module imported just for side-effects?

后端 未结 2 1355
长发绾君心
长发绾君心 2021-01-13 05:20

I like to keep my code modular, so I put this kind of code in a separate file (overrides/extra.js):

import Ember from \'ember\';

Ember.RSVP.con         


        
2条回答
  •  梦毁少年i
    2021-01-13 06:03

    Yes this is accepted if your module doesn't need to export any data, but there's no need to export anything from a module if it's not required:

    import Ember from 'ember';
    
    Ember.RSVP.configure('onerror', function(error) {
        ....
    });
    

    app.js:

    import './overrides/extra';
    

提交回复
热议问题