@@ -68,75 +68,79 @@ module S = Js_stmt_make
68
68
69
69
let (// ) = Filename. concat
70
70
71
- let string_of_module_id (module_system : Lam_module_ident.system )
71
+ let string_of_module_id
72
+ (module_system : Lam_module_ident.system )
72
73
(x : Lam_module_ident.t ) : string =
73
- match x.kind with
74
- | Runtime
75
- | Ml ->
76
- let id = x.id in
77
- let file = Printf. sprintf " %s.js" id.name in
78
- let modulename = String. uncapitalize id.name in
79
- let rebase dep =
80
- Ext_filename. node_relative_path
81
- (`Dir (Js_config. get_output_dir module_system ! Location. input_name)) dep
82
- in
83
- let dependency_pkg_info =
84
- Lam_compile_env. get_package_path_from_cmj module_system x
85
- in
86
- let current_pkg_info =
87
- Js_config. get_current_package_name_and_path module_system
88
- in
89
- begin match module_system, dependency_pkg_info, current_pkg_info with
90
- | _ , `NotFound , _ ->
91
- Ext_pervasives. failwithf ~loc: __LOC__
92
- " @[%s not found in search path - while compiling %s @] "
93
- file ! Location. input_name
94
- | `Goog , `Found (package_name , x ), _ ->
95
- package_name ^ " ." ^ String. uncapitalize id.name
96
- | `Goog , (`Empty | `Package_script _), _
97
- ->
98
- Ext_pervasives. failwithf ~loc: __LOC__
99
- " @[%s was not compiled with goog support in search path - while compiling %s @] "
100
- file ! Location. input_name
101
- | (`AmdJS | `NodeJS ),
102
- ( `Empty | `Package_script _) ,
103
- `Found _ ->
104
- Ext_pervasives. failwithf ~loc: __LOC__
105
- " @[dependency %s was compiled in script mode - while compiling %s in package mode @]"
106
- file ! Location. input_name
107
- | _ , _ , `NotFound -> assert false
108
- | (`AmdJS | `NodeJS ),
109
- `Found (package_name, x),
110
- `Found (current_package, path) ->
111
- if current_package = package_name then
112
- rebase (`File (
113
- Lazy. force Ext_filename. package_dir // x // modulename))
114
- else
115
- package_name // x // modulename
116
- | (`AmdJS | `NodeJS ), `Found (package_name, x),
117
- `Package_script (current_package)
118
- ->
119
- if current_package = package_name then
120
- rebase (`File (
121
- Lazy. force Ext_filename. package_dir // x // modulename))
122
- else
123
- package_name // x // modulename
124
- | (`AmdJS | `NodeJS ), `Found (package_name, x), `Empty
125
- -> package_name // x // modulename
126
- | (`AmdJS | `NodeJS ),
127
- (`Empty | `Package_script _) ,
128
- (`Empty | `Package_script _)
129
- ->
130
- begin match Config_util. find file with
131
- | file ->
132
- rebase (`File file)
133
- | exception Not_found ->
74
+ let result =
75
+ match x.kind with
76
+ | Runtime
77
+ | Ml ->
78
+ let id = x.id in
79
+ let file = Printf. sprintf " %s.js" id.name in
80
+ let modulename = String. uncapitalize id.name in
81
+ let rebase dep =
82
+ Ext_filename. node_relative_path
83
+ (`Dir (Js_config. get_output_dir module_system ! Location. input_name)) dep
84
+ in
85
+ let dependency_pkg_info =
86
+ Lam_compile_env. get_package_path_from_cmj module_system x
87
+ in
88
+ let current_pkg_info =
89
+ Js_config. get_current_package_name_and_path module_system
90
+ in
91
+ begin match module_system, dependency_pkg_info, current_pkg_info with
92
+ | _ , `NotFound , _ ->
134
93
Ext_pervasives. failwithf ~loc: __LOC__
135
- " @[%s was not found in search path - while compiling %s @] "
94
+ " @[%s not found in search path - while compiling %s @] "
136
95
file ! Location. input_name
137
- end
138
- end
139
- | External name -> name
96
+ | `Goog , `Found (package_name , x ), _ ->
97
+ package_name ^ " ." ^ String. uncapitalize id.name
98
+ | `Goog , (`Empty | `Package_script _), _
99
+ ->
100
+ Ext_pervasives. failwithf ~loc: __LOC__
101
+ " @[%s was not compiled with goog support in search path - while compiling %s @] "
102
+ file ! Location. input_name
103
+ | (`AmdJS | `NodeJS ),
104
+ ( `Empty | `Package_script _) ,
105
+ `Found _ ->
106
+ Ext_pervasives. failwithf ~loc: __LOC__
107
+ " @[dependency %s was compiled in script mode - while compiling %s in package mode @]"
108
+ file ! Location. input_name
109
+ | _ , _ , `NotFound -> assert false
110
+ | (`AmdJS | `NodeJS ),
111
+ `Found (package_name, x),
112
+ `Found (current_package, path) ->
113
+ if current_package = package_name then
114
+ rebase (`File (
115
+ Lazy. force Ext_filename. package_dir // x // modulename))
116
+ else
117
+ package_name // x // modulename
118
+ | (`AmdJS | `NodeJS ), `Found (package_name, x),
119
+ `Package_script (current_package)
120
+ ->
121
+ if current_package = package_name then
122
+ rebase (`File (
123
+ Lazy. force Ext_filename. package_dir // x // modulename))
124
+ else
125
+ package_name // x // modulename
126
+ | (`AmdJS | `NodeJS ), `Found (package_name, x), `Empty
127
+ -> package_name // x // modulename
128
+ | (`AmdJS | `NodeJS ),
129
+ (`Empty | `Package_script _) ,
130
+ (`Empty | `Package_script _)
131
+ ->
132
+ begin match Config_util. find file with
133
+ | file ->
134
+ rebase (`File file)
135
+ | exception Not_found ->
136
+ Ext_pervasives. failwithf ~loc: __LOC__
137
+ " @[%s was not found in search path - while compiling %s @] "
138
+ file ! Location. input_name
139
+ end
140
+ end
141
+ | External name -> name in
142
+ if Js_config. is_windows then Ext_filename. replace_backward_slash result
143
+ else result
140
144
141
145
142
146
0 commit comments