Closed leafac closed 1 year ago
.mjs
files can't be imported without an await
, which is a problem since babel visitors are sync.
I'm working on a project called cst-tokens
, a native-JS virtual machine for syntax and semantics that is heavily inspired by the babel and eslint internals but uses a generator-based visitor architecture. I expect it to be able to solve problems like this.
@conartist6 Thank you for the information.
Would it be feasible for babel-plugin-macros itself to work around this with the trick that it recommends to macro authors?
I don't think so? Kind of the point of a macro is that it exposes babel's APIs, but those objects and functions wouldn't be available in a child process.
@conartist6
I don't think so? Kind of the point of a macro is that it exposes babel's APIs, but those objects and functions wouldn't be available in a child process.
Hmmm, yeah, right. I suppose it could still work by serializing the whole AST to JSON. But that sounds very clunky. It’s too bad, really, given that the ecosystem is moving from CommonJS to ESM… 🤷
Thank you again for the information.
I’m closing this issue for now. If anything changes or someone comes up with a better idea we can reopen it.
Sounds good. To reiterate: I am fairly confident that I have the solution to this and other critical problems with babel. I am working full time on developing that solution.
Want to breathe a new life into this issue. https://github.com/babel/babel/issues/16860
Currently babel-plugin-macros requires macros to be defined in files that match
/[./]macro(\.c?js)?$/
. What if that was/[./]macro(\.[cm]?js)?$/
?