🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

weg-hook-commonjs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weg-hook-commonjs

weg commonJs module

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
25
212.5%
Maintainers
1
Weekly downloads
 
Created
Source

weg-hook-commonjs

weg 已经默认自带mod.js模块化开发支持,不需要单独安装。

请配合 mod.js 一起使用。

注意:需要对目标文件设置 isMod 属性,说明这些文件是模块化代码。

fis.match('/modules/**.js', {
  isMod: true
})

这样才会被自动包装成 amd,才能在浏览器里面运行(当然还得依靠 mod.js)。

另外,所有 isModtrue 的文件都会被包裹成 AMD, 如果不想包裹,请设置 wrap 属性为 false

设置了 isMod 为 true 的文件可以在 js 里面直接通过 require('文件路径') 的方式来使用,支持相对路径和绝对路径。

var $ = require('/static/lib/jquery.js');

require('./index.js');

自定义模块ID

插件默认使用资源的绝对路径作为模块ID,如果希望更改模块ID,需要对目标文件设置 moduleId 属性

fis.match('/modules/(**).js', {
  isMod: true,
  moduleId: '$1'
})

通过上述配置,我们可以将 /modules/A.js 的模块ID由 modules/A 改变为 A

Keywords

fis3

FAQs

Package last updated on 17 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts