esnext / es6-module-transpiler

Tomorrow’s JavaScript module syntax today
http://esnext.github.io/es6-module-transpiler/
Other
1.21k stars 85 forks source link

Allow transpilation of source string not just filename from library usage #159

Closed hojberg closed 10 years ago

hojberg commented 10 years ago

This might already be possible, but would be awesome if I could just give the container a source string instead of a filename. My current usecase is a series of transpilations happening on a file and want to perform all operations without having to go to a tmp disk in between transpilations.

caridy commented 10 years ago

You can simply parse the source, and set mod.ast:

var recast = require('recast');
var ast = recast.parse(src); // src is the source string
hojberg commented 10 years ago

@caridy not sure how that answers my question.

Im looking to transpile a source string instead of a file - I know that es6-module-transpiler uses recast, but not sure how that helps me getting it to accept a string instead of a file?

eventualbuddha commented 10 years ago

See my comment on the gulp project for an avenue for fixing this using a custom resolver. If this does not work or requires changes to the transpiler come back and comment here and I'll reopen.

rkusa commented 10 years ago

@hojberg I've solved your issue by creating Module objects directly and adding them to the container manually (see gulpe-es6mt/index.js#L37)