Skip to content

Conversation

@xeioex
Copy link
Contributor

@xeioex xeioex commented Dec 6, 2025

No description provided.

When an imported module has a .so extension, it is treated as a native
module extension. After dlopen(), njs looks up a symbol with this signature:

    JSModuleDef *js_init_module(JSContext *ctx, const char *module_name)

This function must:
- Return a valid JSModuleDef pointer on success, or NULL on failure
- Register module exports using the QuickJS module API
- Be declared with C linkage (use extern "C" if implementing in C++)

See quickjs.h for the complete QuickJS API reference and
nginx/t/js_native_module.t for a working example.

This closes nginx#968 feature request on Github.
This introduces ngx_js_merge_conftime_loc_conf() to handle merging
of configuration-time properties.

Normally ngx_js_merge_conf() does all the default value initialization
for child location configurations.

There is a special case for global "http" or "stream" configuration
where the parent configuration needs to be initialized (so it can be
reused by server configurations if no additional directives were
defined in them). But parent configurations are not initialized by
ngx_js_merge_conf().

Most of the ngx_js_loc_conf_t values are only used at runtime, so
only configuration-time values need to be merged in the parent.
The runtime values will be provided from the appropriate
ngx_js_loc_conf_t during request processing.

Previously, configuration-time merging was done inline. Extracting
it into a dedicated function simplifies adding new configuration-time
properties.
@xeioex xeioex requested a review from VadimZhestikov December 6, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant