aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 0fc4f794a..0c4b5dcb3 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -15361,6 +15361,18 @@ fn NewParser_(
if (p.is_control_flow_dead) {
return p.newExpr(E.Undefined{}, e_.tag.?.loc);
}
+
+ // this ordering incase someone wants ot use a macro in a node_module conditionally
+ if (p.options.features.no_macros) {
+ p.log.addError(p.source, tag.loc, "Macros are disabled") catch unreachable;
+ return p.newExpr(E.Undefined{}, e_.tag.?.loc);
+ }
+
+ if (p.source.path.isNodeModule()) {
+ p.log.addError(p.source, expr.loc, "For security reasons, macros cannot be run from node_modules.") catch unreachable;
+ return p.newExpr(E.Undefined{}, expr.loc);
+ }
+
p.macro_call_count += 1;
const record = &p.import_records.items[import_record_id];
// We must visit it to convert inline_identifiers and record usage
@@ -16510,6 +16522,17 @@ fn NewParser_(
if (p.is_control_flow_dead) {
return p.newExpr(E.Undefined{}, e_.target.loc);
}
+
+ if (p.options.features.no_macros) {
+ p.log.addError(p.source, expr.loc, "Macros are disabled") catch unreachable;
+ return p.newExpr(E.Undefined{}, expr.loc);
+ }
+
+ if (p.source.path.isNodeModule()) {
+ p.log.addError(p.source, expr.loc, "For security reasons, macros cannot be run from node_modules.") catch unreachable;
+ return p.newExpr(E.Undefined{}, expr.loc);
+ }
+
const name = p.symbols.items[ref.innerIndex()].original_name;
const record = &p.import_records.items[import_record_id];
const copied = Expr{ .loc = expr.loc, .data = .{ .e_call = e_ } };