Skip to content

Commit

Permalink
[flow] Flip default of `module.system.haste.module_ref_prefix.standar…
Browse files Browse the repository at this point in the history
…d_cjs_esm_interop` and remove ability to set it to false

Summary: Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D67867385

fbshipit-source-id: 8033601db9ea3eff9a99816b9d801a7f75a75f9b
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Jan 7, 2025
1 parent 5f0fb3c commit ddcde52
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 38 deletions.
2 changes: 0 additions & 2 deletions src/commands/commandUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,6 @@ let make_options
|| FlowConfig.include_warnings flowconfig;
opt_max_header_tokens = FlowConfig.max_header_tokens flowconfig;
opt_haste_module_ref_prefix = FlowConfig.haste_module_ref_prefix flowconfig;
opt_haste_module_ref_prefix_standard_cjs_esm_interop =
FlowConfig.haste_module_ref_prefix_standard_cjs_esm_interop flowconfig;
opt_haste_module_ref_prefix_LEGACY_INTEROP =
FlowConfig.haste_module_ref_prefix_LEGACY_INTEROP flowconfig;
opt_haste_name_reducers = FlowConfig.haste_name_reducers flowconfig;
Expand Down
13 changes: 7 additions & 6 deletions src/commands/config/flowConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ module Opts = struct
gc_worker_space_overhead: int option; (** Gc.control's space_overhead *)
gc_worker_window_size: int option; (** Gc.control's window_size *)
haste_module_ref_prefix: string option;
haste_module_ref_prefix_standard_cjs_esm_interop: bool;
haste_module_ref_prefix_LEGACY_INTEROP: string option;
haste_name_reducers: (Str.regexp * string) list;
haste_namespaces: string list;
Expand Down Expand Up @@ -218,7 +217,6 @@ module Opts = struct
gc_worker_space_overhead = None;
gc_worker_window_size = None;
haste_module_ref_prefix = None;
haste_module_ref_prefix_standard_cjs_esm_interop = false;
haste_module_ref_prefix_LEGACY_INTEROP = None;
haste_name_reducers =
[(Str.regexp "^\\(.*/\\)?\\([a-zA-Z0-9$_.-]+\\)\\.js\\(\\.flow\\)?$", "\\2")];
Expand Down Expand Up @@ -1057,7 +1055,13 @@ module Opts = struct
("module.system", module_system_parser);
("module.system.haste.module_ref_prefix", haste_module_ref_prefix_parser);
( "module.system.haste.module_ref_prefix.standard_cjs_esm_interop",
boolean (fun opts v -> Ok { opts with haste_module_ref_prefix_standard_cjs_esm_interop = v })
boolean (fun opts v ->
if v then
Ok opts
else
Error
"module.system.haste.module_ref_prefix.standard_cjs_esm_interop cannot be disabled."
)
);
( "module.system.haste.module_ref_prefix_LEGACY_INTEROP",
haste_module_ref_prefix_LEGACY_INTEROP_parser
Expand Down Expand Up @@ -1732,9 +1736,6 @@ let gc_worker_window_size c = c.options.Opts.gc_worker_window_size

let haste_module_ref_prefix c = c.options.Opts.haste_module_ref_prefix

let haste_module_ref_prefix_standard_cjs_esm_interop c =
c.options.Opts.haste_module_ref_prefix_standard_cjs_esm_interop

let haste_module_ref_prefix_LEGACY_INTEROP c = c.options.Opts.haste_module_ref_prefix_LEGACY_INTEROP

let haste_name_reducers c = c.options.Opts.haste_name_reducers
Expand Down
2 changes: 0 additions & 2 deletions src/commands/config/flowConfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ val gc_worker_window_size : config -> int option

val haste_module_ref_prefix : config -> string option

val haste_module_ref_prefix_standard_cjs_esm_interop : config -> bool

val haste_module_ref_prefix_LEGACY_INTEROP : config -> string option

val haste_name_reducers : config -> (Str.regexp * string) list
Expand Down
4 changes: 0 additions & 4 deletions src/common/options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ type t = {
opt_format: format;
opt_gc_worker: gc_control;
opt_haste_module_ref_prefix: string option;
opt_haste_module_ref_prefix_standard_cjs_esm_interop: bool;
opt_haste_module_ref_prefix_LEGACY_INTEROP: string option;
opt_haste_name_reducers: (Str.regexp * string) list;
opt_haste_namespaces_options: Haste_namespaces.options;
Expand Down Expand Up @@ -256,9 +255,6 @@ let gc_worker opts = opts.opt_gc_worker

let haste_module_ref_prefix opts = opts.opt_haste_module_ref_prefix

let haste_module_ref_prefix_standard_cjs_esm_interop opts =
opts.opt_haste_module_ref_prefix_standard_cjs_esm_interop

let haste_module_ref_prefix_LEGACY_INTEROP opts = opts.opt_haste_module_ref_prefix_LEGACY_INTEROP

let haste_name_reducers opts = opts.opt_haste_name_reducers
Expand Down
1 change: 0 additions & 1 deletion src/flow_dot_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ let stub_metadata ~root ~checked =
facebook_fbt = None;
facebook_module_interop = false;
file_options = Files.default_options;
haste_module_ref_prefix_standard_cjs_esm_interop = false;
ignore_non_literal_requires = false;
max_literal_length = 100;
max_workers = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ let stub_metadata ~root ~checked =
facebook_fbt = None;
facebook_module_interop = false;
file_options;
haste_module_ref_prefix_standard_cjs_esm_interop = false;
ignore_non_literal_requires = false;
max_literal_length = 100;
max_workers = 0;
Expand Down
1 change: 0 additions & 1 deletion src/typing/__tests__/type_hint_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let metadata =
facebook_fbt = None;
facebook_module_interop = false;
file_options = Files.default_options;
haste_module_ref_prefix_standard_cjs_esm_interop = false;
ignore_non_literal_requires = false;
max_literal_length = 100;
max_workers = 0;
Expand Down
1 change: 0 additions & 1 deletion src/typing/__tests__/typed_ast_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ let metadata =
facebook_fbt = None;
facebook_module_interop = false;
file_options = Files.default_options;
haste_module_ref_prefix_standard_cjs_esm_interop = false;
ignore_non_literal_requires = false;
max_literal_length = 100;
max_workers = 0;
Expand Down
6 changes: 0 additions & 6 deletions src/typing/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type metadata = {
facebook_fbt: string option;
facebook_module_interop: bool;
file_options: Files.options;
haste_module_ref_prefix_standard_cjs_esm_interop: bool;
ignore_non_literal_requires: bool;
max_literal_length: int;
max_workers: int;
Expand Down Expand Up @@ -280,8 +279,6 @@ let metadata_of_options options =
facebook_fbt = Options.facebook_fbt options;
facebook_module_interop = Options.facebook_module_interop options;
file_options = Options.file_options options;
haste_module_ref_prefix_standard_cjs_esm_interop =
Options.haste_module_ref_prefix_standard_cjs_esm_interop options;
ignore_non_literal_requires = Options.should_ignore_non_literal_requires options;
max_literal_length = Options.max_literal_length options;
max_workers = Options.max_workers options;
Expand Down Expand Up @@ -634,9 +631,6 @@ let verbose cx = cx.metadata.verbose

let slow_to_check_logging cx = cx.metadata.slow_to_check_logging

let haste_module_ref_prefix_standard_cjs_esm_interop cx =
cx.metadata.haste_module_ref_prefix_standard_cjs_esm_interop

let max_workers cx = cx.metadata.max_workers

let missing_module_generators cx = cx.metadata.missing_module_generators
Expand Down
3 changes: 0 additions & 3 deletions src/typing/context.mli
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ type metadata = {
facebook_fbt: string option;
facebook_module_interop: bool;
file_options: Files.options;
haste_module_ref_prefix_standard_cjs_esm_interop: bool;
ignore_non_literal_requires: bool;
max_literal_length: int;
max_workers: int;
Expand Down Expand Up @@ -297,8 +296,6 @@ val verbose : t -> Verbose.t option

val slow_to_check_logging : t -> Slow_to_check_logging.t

val haste_module_ref_prefix_standard_cjs_esm_interop : t -> bool

val max_workers : t -> int

val missing_module_generators : t -> (Str.regexp * string) list
Expand Down
2 changes: 1 addition & 1 deletion src/typing/flow_js_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ module CJSRequireTKit = struct
NamespaceT { namespace_symbol = module_symbol; values_type; types_tmap }
in
let t =
if standard_cjs_esm_interop then
if standard_cjs_esm_interop && not legacy_interop then
lookup_builtin_typeapp
cx
reason
Expand Down
2 changes: 1 addition & 1 deletion src/typing/statement.ml
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ module Make
cx
(mk_reason (RModule mref) loc)
~namespace_symbol:(mk_module_symbol ~name:mref ~def_loc:loc)
~standard_cjs_esm_interop:(Context.haste_module_ref_prefix_standard_cjs_esm_interop cx)
~standard_cjs_esm_interop:true
~legacy_interop
module_t
in
Expand Down
9 changes: 1 addition & 8 deletions src/typing/type_sig_merge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,7 @@ let rec merge ?(hooklike = false) ?(as_const = false) ?(const_decl = false) env
let t = Flow_js_utils.lookup_builtin_typeapp file.cx reason "Promise" [ns_t] in
make_hooklike file hooklike t
| Pack.ModuleRef { loc; index; legacy_interop } ->
let t =
require
file
loc
index
~standard_cjs_esm_interop:(Context.haste_module_ref_prefix_standard_cjs_esm_interop file.cx)
~legacy_interop
in
let t = require file loc index ~standard_cjs_esm_interop:true ~legacy_interop in
let reason = Reason.(mk_reason (RCustom "module reference") loc) in
let t = Flow_js_utils.lookup_builtin_typeapp file.cx reason "$Flow$ModuleRef" [t] in
make_hooklike file hooklike t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
all=true
module.system=haste
module.system.haste.module_ref_prefix=m#
module.system.haste.module_ref_prefix.standard_cjs_esm_interop=true

0 comments on commit ddcde52

Please sign in to comment.