diff options
author | 2023-05-31 13:58:38 -0700 | |
---|---|---|
committer | 2023-05-31 13:58:38 -0700 | |
commit | 68c15680753c7cc3ab9a7d9d6e42dfbeafb529df (patch) | |
tree | 1556a7e1619df9a615996a5fd06928cb30e00771 | |
parent | 4b34a7ce2ab233e51fc0bc5ee5b1ddc0e40b438b (diff) | |
download | bun-68c15680753c7cc3ab9a7d9d6e42dfbeafb529df.tar.gz bun-68c15680753c7cc3ab9a7d9d6e42dfbeafb529df.tar.zst bun-68c15680753c7cc3ab9a7d9d6e42dfbeafb529df.zip |
Update macro doc
-rw-r--r-- | docs/bundler/macros.md | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/docs/bundler/macros.md b/docs/bundler/macros.md index e2693de71..3c6be7097 100644 --- a/docs/bundler/macros.md +++ b/docs/bundler/macros.md @@ -29,7 +29,7 @@ $ bun build ./cli.tsx console.log(`Your random number is ${0.6805550949689833}`); ``` -As you can see, the source code of the `random` function occurs nowhere in the bundle. Instead, it is executed _during bundling_ and function call (`random()`) is replaced with the result of the function. +As you can see, the source code of the `random` function occurs nowhere in the bundle. Instead, it is executed _during bundling_ and function call (`random()`) is replaced with the result of the function. Since the source code will never be included in the bundle, macros can safely perform privileged operations like reading from a database. ## When to use macros @@ -72,12 +72,6 @@ if (returnFalse()) { } ``` -## Security - -Macros are only executed on your source files, not on files imported from packages in `node_modules`. - -The source code of a macro will never be included in the bundled; as such, macros can safely perform privileged operations like reading from a database. - ## Serializablility Bun's transpiler needs to be able to serialize the result of the macro so it can be inlined into the AST. All JSON-compatible data structures are supported: |