yavorsky / riot-brunch

Adds Riot.js support to brunch
14 stars 15 forks source link

imports in tags #18

Open ghstahl opened 7 years ago

ghstahl commented 7 years ago

I can import a tag from a js file, but my tags that contain imports are having issues.

import './components/header.tag';
import './components/sidebar.tag';
import './components/loading-indicator.tag';
<app>
</app>

get transpiled to

import './components/header.tag';
import './components/sidebar.tag';
import './components/loading-indicator.tag';

riot.tag2('app', '<loading-indicator></loading-indicator> <header></header> <div class="container"> <div class="row"> <div class="col-sm-3 col-md-2 sidebar"> <div class="list-group table-of-contents"> <sidebar></sidebar> </div> </div> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <div id="riot-app"></div> </div> </div> </div>', '', '', function(opts) {
    var self = this;

  self.on('before-mount', () => {
      console.log('before-mount');
    });
    self.on('mount', () => {
      console.log(riot.EVT.app.out.appMount);
      riot.control.on(riot.EVT.app.out.appMount,self.onAppMount);
      riot.control.trigger('riot-dispatch',riot.EVT.app.out.appMount);
    });

  self.on('unmount', () => {
      console.log(riot.EVT.app.out.appUnmount)
      riot.control.trigger('riot-dispatch',riot.EVT.app.out.appUnmount);
      riot.control.off(riot.EVT.app.out.appMount,self.onAppMount);
    });

  self.onAppMount = () =>{
      console.log('app '+ riot.EVT.appMount)
    }

});
exports.plugins = {
 riot: {
      extension: 'tag',
      pattern: /\.tag$/ 
    },
    babel: {
        presets: [ 'latest', 'stage-0']
    },
    uglify: {
      mangle: false,
      compress: {
        global_defs: {
          DEBUG: false
        }
      }
    }
};
yavorsky commented 7 years ago

@ghstahl Thanks for the issue. Going to fix today.