Skip to content
forked from seajs/seajs-wrap

A Sea.js plugin for loading CommonJS modules directly

License

Notifications You must be signed in to change notification settings

hotoo/seajs-wrap

 
 

Repository files navigation

seajs-wrap spm package Build Status

The Sea.js plugin for loading CommonJS modules directly.

It would wrap files with 'define(function(require, exports, module) {})' block so that you can load CommonJS modules without wrapping it first.

It could only load modules in the same domain, so please use it in developement environment.

Install

Install with spm@3.x:

$ spm install seajs-wrap

Usage

<script src="path/to/sea.js"></script>
<script src="path/to/seajs-wrap.js"></script>

<script>
seajs.use(['common'], function(Common) {
  var str = Common(); // 'CommonJS'
})
</script>
// common.js
// It is a CommonJS module
var example = 'CommonJS'
module.exports = function() {
  return example;
}
  • no wrap
<script>
seajs.use(['test.js?nowrap'], function() {
  // it would excute test.js without wrapping
})
</script>

For more details please visit 中文文档.

About

A Sea.js plugin for loading CommonJS modules directly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published