Skip to main content

detect_module

Function detect_module 

Source
pub fn detect_module(src: &str, script_err: &str) -> bool
Expand description

Node’s syntax detection, given the error the CommonJS (script-goal) compile of src failed with: the source is an ES module when module syntax explains that error and the module-goal parse succeeds.

A top-level await is recognised by its token rather than by V8’s exact message, because where an await operand sits decides which message a script parse reports (f(await x) is “missing ) after argument list”).