From 8aac0c573c29d2829242d66539a9e027d03ff8ec Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 11 Jan 2021 02:05:30 -0400 Subject: Encapsulate JS definitions produced by the JS compiler in a local scope to avoid interacting with the global scope. --- lux-js/source/program.lux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lux-js/source') 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 []))) -- cgit v1.2.3