Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#### :bug: Bug fix

- Fix async context checking for module await. https://github.com/rescript-lang/rescript/pull/7271
- Fix `%external` extension. https://github.com/rescript-lang/rescript/pull/7272

# 12.0.0-alpha.8

Expand Down
2 changes: 1 addition & 1 deletion compiler/frontend/ast_exp_handle_external.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let handle_external loc (x : string) : Parsetree.expression =
Ast_compatible.app1 ~loc undefined_typeof
(Exp.ifthenelse ~loc
(Ast_compatible.app2 ~loc
(Exp.ident ~loc {loc; txt = Ldot (Lident "Pervasives", "=")})
(Exp.ident ~loc {loc; txt = Lident "=="})
(Ast_compatible.app1 ~loc typeof raw_exp)
(Ast_compatible.const_exp_string ~loc "undefined"))
empty (Some raw_exp))
Expand Down
12 changes: 12 additions & 0 deletions tests/tests/src/ExternalExtension.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Generated by ReScript, PLEASE EDIT WITH CARE


let match = typeof __DEV__ === "undefined" ? undefined : __DEV__;

if (match !== undefined) {
console.log("dev mode");
} else {
console.log("production mode");
}

/* match Not a pure module */
4 changes: 4 additions & 0 deletions tests/tests/src/ExternalExtension.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
switch %external(__DEV__) {
| Some(_) => Console.log("dev mode")
| None => Console.log("production mode")
}
Loading