-
-
Save m1sta/63c9525297092df8ac78c85d31477c52 to your computer and use it in GitHub Desktop.
Using import with babel standalone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function App() { | |
return ( | |
<div> | |
<strong>app.js</strong> is loaded<br/> | |
<SubComponent /> | |
</div> | |
) | |
} | |
ReactDOM.render(<App />, document.getElementById("root-react")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
class SubComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
return ( | |
<span> SubComponent-is-working </span> | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/react@16.13.1/umd/react.production.min.js" crossorigin></script> | |
<script src="https://unpkg.com/react-dom@16.13.1/umd/react-dom.production.min.js" crossorigin="anonymous"></script> | |
<script src="https://unpkg.com/babel-standalone@6/babel.min.js" crossorigin></script> | |
<body> | |
<div id="root-react"></div> | |
</body> | |
<script type="text/babel" src="babel-module.js"></script> | |
<script type="text/babel" src="babel-app.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version will work with jsxLoader if you put the main file
babel-app.js
inline on the page and have the modules loaded from outside it. I'll reply more in the main issue that you opened.