4 Star 1 Fork 0

wmlgl / babel-require

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

#babel-require

通过同步AJAX请求实现,性能低下,请只用于开发调试,生产环境请使用webpack等静态编译工具。
Implement by Synchronous AJAX, low performance, we use it in development and debug, not use it in production environment.

##Supported:

支持Babel版本: Babel5.x

##Config:

加载模块时,如果配置了jsx,并且该模块属于jsx项配置的目录下,则加载".jsx"文件,否则加载".js"文件。 Config exmaple:

<script type="text/javascript">
require.config({
    jsx: ["app"]
});
</script>
<script type="text/babel">
    // 会加载"app/app.jsx"
    // Will be load "app/app.jsx"
    import App from "app/app";

    // 会加载"lib/hello.js"
    // Will be load "lib/hello.js"
    import Hello from "lib/hello";
</script>

##Example:

Online: http://wmlgl.github.io/babel-require/examples/


<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Examples</title>
		<script src="lib/react/react.js"></script>
		<script src="lib/react/react-dom.js"></script>
		<script src="lib/babel-core/browser.js"></script>
		<script src="lib/babel-core/browser-polyfill.js"></script>
		<script src="dest/babel-require.js"></script>
	</head>
	<body>
		<div id="container">loading...</div>
	</body>
</html>
<script type="text/javascript">
	require.config({
		jsx: [
			"app"
		]
	});
</script>
<script type="text/babel">
	import App from "app/app"; 			// load jsx file
	import Hello from "lib/hello";		//load normal CMD module
	
	alert(Hello.say);
	ReactDOM.render(<App/>, document.getElementById('container'));
</script>

// file: app/app.jsx
import Test1 from './loadtest1/test1'
import Test2 from './loadtest2/test2'

export default class App extends React.Component {
	render () {
		return (
			<div>
				Hello App!
				<Test1 />
				<Test2 />
			</div>
		);
	}
}
Copyright (c) 2016, wmlgl All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the {organization} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

一个类似NodeJS的"require()"函数,用来帮助Babel在浏览器上直接使用import关键字。A "require()" function like NodeJS, let Babel's browser version support "import" keyword. 展开 收起
JavaScript
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/wmlgl/babel-require.git
git@gitee.com:wmlgl/babel-require.git
wmlgl
babel-require
babel-require
master

搜索帮助