xixixao / meta-coffee

OMeta for CoffeeScript in CoffeeScript
https://github.com/xixixao/meta-coffee/
MIT License
29 stars 4 forks source link

How to define environment for compiled files #4

Open Evgenus opened 10 years ago

Evgenus commented 10 years ago

I'm trying to use this in node. There is a lot of external stuff in generated files which as obviously undefined.

module, __filename, __dirname) { MultiplicativeInterpreter = subclass(OMeta, {
                                                                      ^
ReferenceError: OMeta is not defined
    at Object.<anonymous> (o:\glob-rules\grammar.js:1:100)
    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
Evgenus commented 10 years ago

found in its own sources https://github.com/xixixao/meta-coffee/blob/master/src/metacoffee/bs-semactionparser.mc#L1-L3

xixixao commented 9 years ago

In Node, you can do {runtime: {subclass, OMeta}} = require 'metacoffee'. The reason for the weird API was that I was using the compiler in both the browser and in Node. I didn't want to inline the runtime, which is pretty big. This still needs fixing.

KamilSzot commented 9 years ago

Could you add this line to the examples in Readme.md? It could help people trying out your lib.

xixixao commented 9 years ago

@KamilSzot Done. I welcome anyone to take a stab at better fixing this.