E4189

E4189#

Compiler diagnostic name: invalid_js_module_import.

Invalid JavaScript module import.

The #module attribute declares a JavaScript module dependency for an external JavaScript function. Module names must be module specifiers, not relative file paths.

Erroneous example#

The following example uses a relative module path:

///|
#module("./local.js")
extern "js" fn value() -> Int = "value"

///|
test {
  ignore(value)
}

MoonBit will report an error.

Suggestion#

Use a non-relative module specifier:

///|
#module("local")
extern "js" fn value() -> Int = "value"

///|
test {
  ignore(value)
}