nginx / nginx/njs

run main file as ES6 module

Open
#115 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement ES6
Dominant language
C
Stars
1.6k
Forks
239
Avg merge
2d 9h
Merged PRs (30d)
10

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TC39 sections on source code, scripts, and modules, then trace the main-file execution entry point for js_include and njs file.js. The work is done when the main file accepts import statements, does not expose global this, and runs in a separate scope without polluting other module namespaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.