lapis icon indicating copy to clipboard operation
lapis copied to clipboard

.moon to .lua compiler map would be a nice-to-have

Open jessegreathouse opened this issue 8 years ago • 1 comments

This might be a feature that's better suited for the moonc compliler but I figured I'd start the discussion here and see where it went.

I just started using lapis a few days ago because I've been extremely enthusiastic about openresty and I wanted to explore the ecosystem a little bit. I really like lapis and so far my only complaint is that stack traces are more difficult to decipher than they should be.

I'm used to Javascript transpilers and Sass where you can create a map that coordinates the javascript/css artifacts to their pre-compiled source. I don't know how you would implement that with moonscript and I'm no expert on the subject, but if the stack trace could be mapped to the original .moon source file then it would make adoption easier and development more intuitive.

To be clear, this is not only my first venture into lapis, but I also am very inexperienced with lua (prior to this I was just hacking lua blocks inside my openresty nginx.conf for some utility). I decided to try moonscript because lua seems like kind of a quirky language and the moonscript sugar makes it feel a lot like python which I am more familiar with. I think people like me, who are less interested in lua, and more interested in moon, would benefit a lot from mapping.

Cheers, and thanks for doing such a great job with lapis and moonscript.

jessegreathouse avatar Jan 02 '16 03:01 jessegreathouse

moonscript has pretty extensive source map support, with -X. Example output:

$ moonc -X app.moon                                                                                                                                            
Pos     Lua     >>      Moon
17       1:[ local lapis = require("lapis") ] >> 3:[ lapis = require "lapis" ]
59       3:[ Model = require("lapis.db.model").Model ] >> 5:[ import Model from require "lapis.db.model" ]
123      6:[ local _obj_0 = require("lapis.application") ] >> 6:[ import respond_to, capture_errors from require "lapis.application" ]
173      10:[ from_json = require("lapis.util").from_json ] >> 7:[ import from_json from require "lapis.util" ]
213      12:[ cached = require("lapis.cache").cached ] >> 8:[ import cached from require "lapis.cache" ]
237      13:[ local db = require("lapis.db") ] >> 10:[ db = require "lapis.db" ]
261      14:[ local csrf = require("lapis.csrf") ] >> 11:[ csrf = require "lapis.csrf" ]
289      15:[ local config = require("lapis.config").get() ] >> 12:[ config = require("lapis.config").get! ]

AFAIK only ZeroBrane has a debugger than can process this.

turbo avatar Nov 14 '18 13:11 turbo