Melchior.jsJavaScript 模块加载器

联合创作 · 2023-09-22

Melchior.js 是一个模式加载器,提供通过链式模块定义的API,让你可以远离那些长长的AMD定义和重复的模块名。它起步非常容易,定制方便,而且压缩版只有3KB。

在线演示

示例代码:

// create modulemelchiorjs.module('yourModule')// define dependencies.require('dependencyUno')
.require('dependencyDuo', 'duo')// define module body.body(function () {    // `dependencyUno` is available here!
    dependencyUno.doSomething();    // aliased `dependencyDuo` is available as `duo`!
    duo.doSomething();    // return methods for other modules
    return {
        method: function () { ... },
        anotherMethod: function () { ... }
    };
});

配置:

melchiorjs.config({
    paths: {        'jQuery': 'path/to/jquery',        'underscore': 'path/to/underscore',        'myModule': 'path/to/myModule'
    },    // provide shim to non-melchior modules if needed
    // declare globals returned by libraries and deps
    shim: {
        underscore: {
            exports: '_'
        }
    }
});

支持的浏览器:

Firefox IE Opera
1+ ✔ 2+ ✔ 8+ ✔ 10+ ✔ 3+ ✔

 

浏览 5
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报