micro-mod
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

MOD

npm version GitHub license GitHub tag Publish workflow Join the chat at https://gitter.im/rapiop-mod/community

安装

npm install micro-mod

引用

import mod from 'micro-mod';
// 导入 amd 支持
import amdResolver from 'micro-mod/lib/resolver/amd';
// 注册模块类型解析器
mod.registerModuleResolver(amdResolver);

使用

// 添加模块配置
mod.config({
    modules: {
        react: {
            type: 'amd',
            js: 'https://cdn.jsdelivr.net/npm/react@16.13.1/umd/react.production.min.js'
        },
        'react-dom': {
            type: 'amd',
            js: 'https://cdn.jsdelivr.net/npm/react-dom@16.13.1/umd/react-dom.production.min.js',
            dep: 'react'
        }
    }
});

(async () => {
    // 加载模块
    const [React, ReactDOM] = await mod.import(['react', 'react-dom']);
    // 使用模块
    ReactDOM.render(React.createElement('button', {}, 'test'), document.getElementById('app'));
})();

使用教程

Package Sidebar

Install

npm i micro-mod

Weekly Downloads

1

Version

1.3.1

License

MIT

Unpacked Size

2.97 MB

Total Files

238

Last publish

Collaborators

  • zxbing0066