Skip to content

Commit 79b8b58

Browse files
committed
parse moduleResolution field from gentypeconfig
1 parent 8167b3d commit 79b8b58

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

jscomp/gentype/GenTypeConfig.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module ModuleNameMap = Map.Make (ModuleName)
22

33
type module_ = CommonJS | ES6
4+
type moduleResolution = Node | Node16 | Bundler
45
type bsVersion = int * int * int
56

67
type t = {
@@ -13,6 +14,7 @@ type t = {
1314
exportInterfaces: bool;
1415
generatedFileExtension: string option;
1516
module_: module_;
17+
moduleResolution: moduleResolution;
1618
namespace: string option;
1719
platformLib: string;
1820
mutable projectRoot: string;
@@ -32,6 +34,7 @@ let default =
3234
exportInterfaces = false;
3335
generatedFileExtension = None;
3436
module_ = ES6;
37+
moduleResolution = Node;
3538
namespace = None;
3639
platformLib = "";
3740
projectRoot = "";
@@ -112,6 +115,7 @@ let readConfig ~getBsConfigFile ~namespace =
112115
in
113116
let parseConfig ~bsconf ~gtconf =
114117
let moduleString = gtconf |> getStringOption "module" in
118+
let moduleResolutionString = gtconf |> getStringOption "moduleResolution" in
115119
let exportInterfacesBool = gtconf |> getBool "exportInterfaces" in
116120
let generatedFileExtensionStringOption =
117121
gtconf |> getStringOption "generatedFileExtension"
@@ -143,6 +147,13 @@ let readConfig ~getBsConfigFile ~namespace =
143147
| None, Some ("es6" | "es6-global") -> ES6
144148
| _ -> default.module_
145149
in
150+
let moduleResolution =
151+
match moduleResolutionString with
152+
| Some "node" -> Node
153+
| Some "node16" -> Node16
154+
| Some "bundler" -> Bundler
155+
| _ -> default.moduleResolution
156+
in
146157
let exportInterfaces =
147158
match exportInterfacesBool with
148159
| None -> default.exportInterfaces
@@ -204,6 +215,7 @@ let readConfig ~getBsConfigFile ~namespace =
204215
exportInterfaces;
205216
generatedFileExtension;
206217
module_;
218+
moduleResolution;
207219
namespace;
208220
platformLib;
209221
projectRoot;

0 commit comments

Comments
 (0)