Skip to content

Commit b5d8366

Browse files
committed
Lglobal_module has no side effect as expression itself
1 parent 50ec87d commit b5d8366

9 files changed

+31
-19
lines changed

jscomp/core/lam_analysis.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let not_zero_constant (x : Lam_constant.t) =
3232
let rec no_side_effects (lam : Lam.t) : bool =
3333
match lam with
3434
| Lvar _ | Lconst _ | Lfunction _ -> true
35-
| Lglobal_module (_, dynamic_import) -> not dynamic_import
35+
| Lglobal_module _ -> true
3636
(* we record side effect in the global level,
3737
this expression itself is side effect free
3838
*)

jscomp/test/build.ninja

+4-3
Large diffs are not rendered by default.

jscomp/test/import_no_side_effect.js

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/import_no_side_effect.res

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let a = await Js.import(Side_effect_free.a)

jscomp/test/import_side_effect.js

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import_lazy_component is not a pure module
22
// It is supposed not to be required by dynamic import
3-
let a = Js.import(Import_lazy_component.a)
3+
let a = Js.import(Side_effect2.a)
44

5-
module LazyC = await Import_lazy_component
5+
module M = await Side_effect

jscomp/test/import_unnecessary.js

-13
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)