module-descriptor-invalid: Invalid module descriptor
Cause
A descriptor in modules, or a value returned by importHook / loadHook, does not satisfy the module descriptor contract:
- The descriptor must be a non-null object containing exactly one of
source,namespace, orspecifier. sourcemust be a string or a structurally completeModuleSource.namespacemust be a non-null, non-array object. Ordinary objects are accepted.- A redirect's
specifiermust be a non-empty string.
Troubleshooting
- Use the module specifier and field name in the message to locate the
modulesentry or hook result. - Check whether the descriptor combines multiple forms or the hook returns a source string directly.
- For precompiled modules, check whether any
ModuleSourcefields were omitted or modified.
Solution
Return one of { source: code }, { namespace: exports }, or { specifier: target } according to the module source. Hooks should return a promise that resolves to the descriptor. Use the public precompileModuleSource API to generate a complete precompiled artifact and place it in source; do not manually assemble an object with missing fields.
