deno_core

Macro include_js_files

Source
macro_rules! include_js_files {
    ($name:ident $( dir $dir:literal, )? $(
    $s1:literal
    $(with_specifier $s2:literal)?
    $(= $config:tt)?
  ),* $(,)?) => { ... };
}
Expand description

Helps embed JS files in an extension. Returns a vector of ExtensionFileSource, that represents the filename and source code.

// Example (for "my_extension"):
let files = include_js_files!(
  my_extension
  "01_hello.js",
  "02_goodbye.js",
);

// Produces following specifiers:
// - "ext:my_extension/01_hello.js"
// - "ext:my_extension/02_goodbye.js"

An optional “dir” option can be specified to prefix all files with a directory name.

// Example with "dir" option (for "my_extension"):
include_js_files!(
  my_extension
  dir "js",
  "01_hello.js",
  "02_goodbye.js",
);
// Produces following specifiers:
// - "ext:my_extension/js/01_hello.js"
// - "ext:my_extension/js/02_goodbye.js"

You may also override the specifiers for each file like so:

// Example with "dir" option (for "my_extension"):
include_js_files!(
  my_extension
  "module:hello" = "01_hello.js",
  "module:goodbye" = "02_goodbye.js",
);
// Produces following specifiers:
// - "module:hello"
// - "module:goodbye"