aboutsummaryrefslogtreecommitdiff
path: root/lux-js/source
diff options
context:
space:
mode:
authorEduardo Julian2021-01-11 02:05:30 -0400
committerEduardo Julian2021-01-11 02:05:30 -0400
commit8aac0c573c29d2829242d66539a9e027d03ff8ec (patch)
tree5b4b37d33b90ff24b3d9d019e31770d6d0b8dc9d /lux-js/source
parent706ce9e4916b65c4df5101bd3cc1b4da3b2057af (diff)
Encapsulate JS definitions produced by the JS compiler in a local scope to avoid interacting with the global scope.
Diffstat (limited to 'lux-js/source')
-rw-r--r--lux-js/source/program.lux7
1 files changed, 6 insertions, 1 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux
index 80e53eade..c923aace5 100644
--- a/lux-js/source/program.lux
+++ b/lux-js/source/program.lux
@@ -613,6 +613,11 @@
(-> Any (Promise Any))
(promise.future (\ world/program.default exit +0)))
+(def: (scope body)
+ (-> _.Statement _.Statement)
+ (_.statement (_.apply/* (_.closure (list) body)
+ (list))))
+
(program: [{service /cli.service}]
(exec (do promise.monad
[_ (/.compiler {#/static.host @.js
@@ -628,7 +633,7 @@
[(& Register Text) _.Expression _.Statement]
..extender
service
- [(packager.package _.use_strict _.code _.then)
+ [(packager.package _.use_strict _.code _.then ..scope)
(format (/cli.target service) (\ file.default separator) "program.js")])]
(..declare_success! []))
(io.io [])))