yavorsky / riot-brunch

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

require and export in CommonJS style #11

Closed robinplace closed 7 years ago

robinplace commented 8 years ago

riot-brunch assumes that we have the riot global available, meaning I have to add riot.js as a vendor script. This is unnecessary as we're downloading it from the NPM anyway and it can be included with a simple require. This way also means polluting the global scope.

This change does things in what I feel is the "CommonJS way". The code comes from https://github.com/jhthorsen/riotify/blob/master/index.js#L16 . We eliminate the vendor script and the global.

Hopefully this helps cut down on configuration clutter for everyone :grinning: .

yavorsky commented 8 years ago

@robbiewxyz Thanks for your interest! But modules and riot scope is a brunch part. Plugins is just compilers.

You can specify riot as dependency in package.json and then get access using var riot = require('riot'); in any of your modules. Moreover, you can use:

npm: { globals: {
  riot: "riot"
}}

in your brunch config.

If you are using riot from separate vendor file, brunch docs says: All files from vendor directory are by default concatenated before all files from app directory