componentjs / builder2.js

builder for component
50 stars 20 forks source link

builder.use() procude "undefined" for bundled builds and is not documented #62

Closed timaschew closed 10 years ago

timaschew commented 10 years ago

use() without any param should be documented at https://github.com/component/builder2.js/blob/master/docs/builders.md#plugins

The usage of that I see in some snippets, also here: https://github.com/component/bundler.js/commit/14b12d665c40a970ced0cf17f587a14426dc83fe

which breaks the build without any error all bundles, except the boot is okay, but for the others the build output is undefined

if I replace use() with .use('scripts', build.plugins.js()) the build is fine!

jonathanong commented 10 years ago

ohhhh doing .use() was just an example. didn't expect people to actually .use() nothing.

timaschew commented 10 years ago

oops :)

nevertheless I get undefined for the css output, if there is no styles defined in the component.json. Is that desired? If yes, so then I should always check for an error and undefined return value?

build(function(err, css) {
  if (err) throw err;
  if (!css) return; // or css = "";
  fs.writeFileSync(path, css);
}
jonathanong commented 10 years ago

yeah you should check whether there's css or not