Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Add ability to handle scripts using text/babel type #15

Closed
Daniel15 opened this issue Feb 1, 2016 · 9 comments
Closed

Add ability to handle scripts using text/babel type #15

Daniel15 opened this issue Feb 1, 2016 · 9 comments

Comments

@Daniel15
Copy link
Member

Daniel15 commented Feb 1, 2016

As a simple example:

<script type="text/babel">
const foo = () => alert('Hello world!');
foo();
</script>

babel-standalone should provide some way to parse all text/babel script tags, transform the script using Babel, and evaluate their contents.

@ghost
Copy link

ghost commented Feb 2, 2016

https://github.com/danmartinez101/throw-in-the-towel/blob/master/index.js

I built this based on babel-standalone. This is basically the only addition I made on top of babel-standalone.

I'd be ecstatic to submit a PR for this and deprecate throw-in-the-towel. Let me know what you think!

@peterjuras
Copy link

That looks great! Any update on a PR?

@ghost
Copy link

ghost commented Feb 11, 2016

I'm still happy to create a PR for this if @Daniel15 would like to integrate something like it.

@Daniel15
Copy link
Member Author

Sure, I'd appreciate a pull request 😄

@gutenye
Copy link

gutenye commented Jun 19, 2016

Any updates? I believe a lot of developers need this feature since Babel 6 does not support it.

@Daniel15
Copy link
Member Author

Daniel15 commented Jun 19, 2016

Released in babel-standalone 6.10.3.

@elmehalawi
Copy link

Is it possible to do this for a page which was loaded with ajax?

@Daniel15
Copy link
Member Author

Daniel15 commented Aug 8, 2016

@dublinus How are you doing your AJAX request? Most likely you should just use Babel.transform on the scripts directly.

@elmehalawi
Copy link

@Daniel15 That's what I ended up doing. Thanks!

ssergiienko added a commit to ssergiienko/babel-standalone that referenced this issue Aug 24, 2016
According to sources `text/jsx` is supported too for auto-compilation in browser
babel#15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants