cabbagejs / cabbage

A CLI for building conventional web applications with Broccoli
MIT License
5 stars 0 forks source link

Allow config/* files to be on Coffeescript #28

Closed TravisTheTechie closed 9 years ago

searls commented 9 years ago

Really, this doesn't work? I figured this would already work with coffeescript registered

TravisTheTechie commented 9 years ago
 |system| mememe in ~/src/cabbagejs/blueprint-simple
± |master ✗| → rm config/files.js && echo "modules.export = ->" >> config/files.coffee

 |system| mememe in ~/src/cabbagejs/blueprint-simple
± |master ✗| → cabbage run
Error: Cannot find module './config/files' from '/Users/tsmith/src/cabbagejs/blueprint-simple'
  at Function.module.exports [as sync] (/Users/tsmith/src/cabbagejs/cabbage/node_modules/resolve/lib/sync.js:33:11)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/cabbage/lib/util/config.coffee:8:34)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/cabbage/lib/util/config.coffee:1:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (/Users/tsmith/src/cabbagejs/cabbage/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
  at Module.load (/Users/tsmith/src/cabbagejs/cabbage/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/cabbage/lib/trees/js.coffee:7:10)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/cabbage/lib/trees/js.coffee:1:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (/Users/tsmith/src/cabbagejs/cabbage/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
  at Module.load (/Users/tsmith/src/cabbagejs/cabbage/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at module.exports (/Users/tsmith/src/cabbagejs/cabbage/lib/build-trees.coffee:5:5)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/blueprint-simple/Brocfile.js:2:18)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (/Users/tsmith/src/cabbagejs/cabbage/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.loadBrocfile (/Users/tsmith/src/cabbagejs/blueprint-simple/node_modules/broccoli/lib/builder.js:147:14)
  at module.exports (/Users/tsmith/src/cabbagejs/cabbage/lib/commands/run.coffee:5:43)
  at Function.module.exports [as cli] (/Users/tsmith/src/cabbagejs/cabbage/lib/cli.coffee:3:21)
  at deferToFullCabbage (/Users/tsmith/src/cabbagejs/cabbage-cli/lib/cli.coffee:18:26)
  at module.exports (/Users/tsmith/src/cabbagejs/cabbage-cli/lib/cli.coffee:7:10)
  at Object.<anonymous> (/Users/tsmith/src/cabbagejs/cabbage-cli/bin/cabbage:5:24)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:906:3

:(

searls commented 9 years ago

Hmm

Try this first, from your project:

$ npm --save-dev coffee-script

And add require('coffee-script/register') to the top of your Brocfile.

If that works, then I think it's a fair trade-off, because folks will be able to use whatever designer language at whatever version they like

TravisTheTechie commented 9 years ago

Does not appear to work for me. I'll give it a try with a fresh blueprint soon though just in case I did something to this one.

searls commented 9 years ago

I think I know the cause. Look here: https://github.com/cabbagejs/cabbage/blob/master/lib/util/config.coffee#L8-L10

I believe resolve will return strings with .js extensions regardless of whether other extensions are registered with require itself.

I just did this:

> resolve.sync('./config/files', {basedir: process.cwd()})
'/Users/justin/code/cabbagejs/blueprint-simple/config/files.js'
TravisTheTechie commented 9 years ago

Well, that's a narrow area to fix when it's time comes at least.

searls commented 9 years ago

Ah I think I have this figured out, assigning to myself