njs icon indicating copy to clipboard operation
njs copied to clipboard

run main file as ES6 module

Open drsm opened this issue 6 years ago • 1 comments

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.

drsm avatar Mar 24 '19 14:03 drsm

get rid of global this

done in (behavior is optional to pass test262 tests)https://github.com/nginx/njs/commit/3a5298339383e5c85a80d20bc23365e918b2d8e7

xeioex avatar Apr 18 '19 15:04 xeioex