allow a["b"] = require(...) in bundler
This commit is contained in:
parent
5552ef31b1
commit
c3d856e139
2 changed files with 27 additions and 1 deletions
|
|
@ -208,6 +208,32 @@ o.spec("bundler", function() {
|
|||
remove("c.js")
|
||||
remove("out.js")
|
||||
})
|
||||
o("works if assigned to property", function() {
|
||||
write("a.js", `var x = {}\nx.b = require("./b")\nx.c = require("./c")`)
|
||||
write("b.js", `var bb = 1\nmodule.exports = bb`)
|
||||
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
||||
bundle(ns + "a.js", ns + "out.js")
|
||||
|
||||
o(read("out.js")).equals(`new function() {\nvar x = {}\var bb = 1\nnx.b = bb\nvar cc = 1\nx.c = cc\n}`)
|
||||
|
||||
remove("a.js")
|
||||
remove("b.js")
|
||||
remove("c.js")
|
||||
remove("out.js")
|
||||
})
|
||||
o("works if assigned to property", function() {
|
||||
write("a.js", `var x = {}\nx["b"] = require("./b")\nx["c"] = require("./c")`)
|
||||
write("b.js", `var bb = 1\nmodule.exports = bb`)
|
||||
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
||||
bundle(ns + "a.js", ns + "out.js")
|
||||
|
||||
o(read("out.js")).equals(`new function() {\nvar x = {}\nvar bb = 1\nx["b"] = bb\nvar cc = 2\nx["c"] = cc\n}`)
|
||||
|
||||
remove("a.js")
|
||||
remove("b.js")
|
||||
remove("c.js")
|
||||
remove("out.js")
|
||||
})
|
||||
o("works if collision", function() {
|
||||
write("a.js", `var b = require("./b")`)
|
||||
write("b.js", `var b = 1\nmodule.exports = 2`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue