RReverser / esmod

Fast in-place import/export transpiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace TODO:{import,export} with proper implementations

RReverser opened this issue · comments

@jdalton Assigning you as I think that one won't require any parser-specific help from me.

Currently, this WIP acorn plugin takes code like:

import 'smth';
while (1) {
  /* looks like block, but it's not: {
  } */
  smth
}
export const answer = 42;

and transforms it into:

<TODO:import>
while (1) {
  /* looks like block, but it's not: {
  } */
  smth
}
<TODO:export>

My plan was to base the transform off of transform-es2015-modules-commonjs and add-module-exports. I'm not super proficient with AST transforms so if anyone else wants to jump in, please be my guest.

We should make the transform customizable so it can be tailored for folks like Webpack.
Pinging in @TheLarkInn.

use babel/babel#4964 if you want a closer to real implementation (but still not proper w/ cache, URL pathing, and some other behavior)

@bmeck Thanks for the reference! I'm cool with it being more simple, hand wavy, and loose at the moment. This project started out of a gist yesterday so I trying not to kill it with complexity right off the bat. Webpack will likely have a transform in mind, as I have. Being a spec perfect clone isn't on my radar right now.

Moving to #3.