Closed weistn closed 10 years ago
Other solution:
Every file is wrapped in a function
(function() { ... file_1 var y }());
(function() { ... file_2 var y }());
Module global variables can be accessed via 'module.a'. Global process variables can be accessed via 'global.a'.
Implemented
Currently all files in src/ are compiled and the compiled code is concatenated. This way the files can end up with colliding imports.
Example: file1.gs import "foo" as bar var foo = 12
file2.gs import "foo"
The second import will overwrite the value 12.
Proposed solution: Instead of generating var bar = require('foo') we should generate var __module_1 = require('foo') and replace all top-level occurrences of 'bar' in file1.gs with __module_1. This way imports do not collide