-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.ejs
More file actions
30 lines (25 loc) · 794 Bytes
/
bundle.ejs
File metadata and controls
30 lines (25 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(function(modules){
const require=(id)=>{
const [fn,mapping] = modules[id]
const module = {
exports:{}
}
function localRequire(filePath){
const id = mapping[filePath]
return require(id)
}
fn(localRequire,module,module.exports)//相当于在执行foojs、mainjs
return module.exports
}
require(0)
// require,module,exports 传进来的特性?
// exports 是输出
})({
<% data.forEach((item)=>{%>
"<%-item["id"]%>":[function (require,module,exports){
<%- item["code"]%>
},<%- JSON.stringify(item["mapping"]) %> ],
<%}) %>
})
// ()立即执行
// 使用commonJS规范里面的require 代替import