njs
njs copied to clipboard
run main file as ES6 module
10.2 Types of Source Code
15.1 Scripts
15.2 Modules
according to the specs above, the import statement is restricted to module code only.
so, if we want to use it in js_include file.js or njs file.js, then the file should be executed as ES6 module too.
changes required:
- get rid of global
this - run main file in separate scope to prevent pollution of other module's namespaces.
PS. IMO the "Scripts" is a compatibility/legacy stuff from ES6 point of view.
get rid of global this
done in (behavior is optional to pass test262 tests)https://github.com/nginx/njs/commit/3a5298339383e5c85a80d20bc23365e918b2d8e7