javascriptmacrossweet.js

Sweet.js - Can macros be used in more than one file?


I've got macros defined in file 'A'. I'd like to use the macros in other files, e.g. file B.

Is this possible? I know of course that I could use the compiled results of the macro in file B, but I'd like to use the macro there too.

A

macro test {
 ...
}

test 1
test 2

B

test 3
test 4

Solution

  • Yes, you need to use the --module flag and export your macro in file A. It's documented here.