Skip to content

Commit d4a533b

Browse files
authored
Use .mjs/.cjs extension for runtime files (#8207)
* Use .mjs/.cjs extension for runtime files * Fix playground build * Update artifact list
1 parent 7c68025 commit d4a533b

File tree

587 files changed

+1071
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

587 files changed

+1071
-1086
lines changed

compiler/core/js_name_of_module_id.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let string_of_module_id_in_browser (x : Lam_module_ident.t) =
3131
match x.kind with
3232
| External {name} -> name
3333
| Runtime | Ml ->
34-
"./stdlib/" ^ x.id.name ^ ".js"
34+
"./stdlib/" ^ x.id.name ^ ".mjs"
3535

3636
let string_of_module_id
3737
(id : Lam_module_ident.t)
@@ -48,6 +48,11 @@ let fix_path_for_windows : string -> string =
4848
if Ext_sys.is_windows_or_cygwin then Ext_string.replace_backward_slash
4949
else fun s -> s
5050

51+
let runtime_suffix_of_module_system (module_system : Js_packages_info.module_system)
52+
=
53+
match module_system with
54+
| Commonjs -> ".cjs"
55+
| Esmodule -> ".mjs"
5156

5257
(* dependency is runtime module *)
5358
let get_runtime_module_path
@@ -59,7 +64,7 @@ let get_runtime_module_path
5964
module_system in
6065
let js_file =
6166
Ext_namespace.js_name_of_modulename dep_module_id.id.name
62-
Upper Literals.suffix_js in
67+
Upper (runtime_suffix_of_module_system module_system) in
6368
match current_info_query with
6469
| Package_not_found -> assert false
6570
| Package_script ->

compiler/core/js_packages_info.ml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ let runtime_package_path (ms : module_system) js_file =
5151

5252
type t = {name: package_name; module_systems: package_info list}
5353

54-
let runtime_package_specs : t =
55-
{
56-
name = Pkg_runtime;
57-
module_systems =
58-
[
59-
{module_system = Esmodule; path = "lib/es6"; suffix = Literals.suffix_js};
60-
{module_system = Commonjs; path = "lib/js"; suffix = Literals.suffix_js};
61-
];
62-
}
54+
let runtime_package_specs : t = {name = Pkg_runtime; module_systems = []}
6355

6456
let same_package_by_name (x : t) (y : t) =
6557
match x.name with
@@ -201,15 +193,3 @@ let add_npm_package_path (packages_info : t) (s : string) : t =
201193
| _ -> Bsc_args.bad_arg ("invalid npm package path: " ^ s)
202194
in
203195
{packages_info with module_systems = m :: packages_info.module_systems}
204-
205-
(* support es6 modules instead
206-
TODO: enrich ast to support import export
207-
http://www.ecma-international.org/ecma-262/6.0/#sec-imports
208-
For every module, we need [Ident.t] for accessing and [filename] for import,
209-
they are not necessarily the same.
210-
211-
Es6 modules is not the same with commonjs, we use commonjs currently
212-
(play better with node)
213-
214-
FIXME: the module order matters?
215-
*)
File renamed without changes.

packages/@rescript/runtime/lib/es6/Belt_Array.js renamed to packages/@rescript/runtime/lib/es6/Belt_Array.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

3-
import * as Primitive_int from "./Primitive_int.js";
4-
import * as Primitive_option from "./Primitive_option.js";
3+
import * as Primitive_int from "./Primitive_int.mjs";
4+
import * as Primitive_option from "./Primitive_option.mjs";
55

66
function get(arr, i) {
77
if (i >= 0 && i < arr.length) {
File renamed without changes.

packages/@rescript/runtime/lib/es6/Belt_HashMap.js renamed to packages/@rescript/runtime/lib/es6/Belt_HashMap.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22

3-
import * as Primitive_option from "./Primitive_option.js";
4-
import * as Belt_internalBuckets from "./Belt_internalBuckets.js";
5-
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.js";
3+
import * as Primitive_option from "./Primitive_option.mjs";
4+
import * as Belt_internalBuckets from "./Belt_internalBuckets.mjs";
5+
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.mjs";
66

77
function size(h) {
88
return h.size;

packages/@rescript/runtime/lib/es6/Belt_HashMapInt.js renamed to packages/@rescript/runtime/lib/es6/Belt_HashMapInt.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22

3-
import * as Primitive_hash from "./Primitive_hash.js";
4-
import * as Primitive_option from "./Primitive_option.js";
5-
import * as Belt_internalBuckets from "./Belt_internalBuckets.js";
6-
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.js";
3+
import * as Primitive_hash from "./Primitive_hash.mjs";
4+
import * as Primitive_option from "./Primitive_option.mjs";
5+
import * as Belt_internalBuckets from "./Belt_internalBuckets.mjs";
6+
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.mjs";
77

88
function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) {
99
while (true) {

packages/@rescript/runtime/lib/es6/Belt_HashMapString.js renamed to packages/@rescript/runtime/lib/es6/Belt_HashMapString.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22

3-
import * as Primitive_hash from "./Primitive_hash.js";
4-
import * as Primitive_option from "./Primitive_option.js";
5-
import * as Belt_internalBuckets from "./Belt_internalBuckets.js";
6-
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.js";
3+
import * as Primitive_hash from "./Primitive_hash.mjs";
4+
import * as Primitive_option from "./Primitive_option.mjs";
5+
import * as Belt_internalBuckets from "./Belt_internalBuckets.mjs";
6+
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.mjs";
77

88
function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) {
99
while (true) {

packages/@rescript/runtime/lib/es6/Belt_HashSet.js renamed to packages/@rescript/runtime/lib/es6/Belt_HashSet.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

3-
import * as Belt_internalSetBuckets from "./Belt_internalSetBuckets.js";
4-
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.js";
3+
import * as Belt_internalSetBuckets from "./Belt_internalSetBuckets.mjs";
4+
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.mjs";
55

66
function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) {
77
while (true) {

packages/@rescript/runtime/lib/es6/Belt_HashSetInt.js renamed to packages/@rescript/runtime/lib/es6/Belt_HashSetInt.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22

3-
import * as Primitive_hash from "./Primitive_hash.js";
4-
import * as Belt_internalSetBuckets from "./Belt_internalSetBuckets.js";
5-
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.js";
3+
import * as Primitive_hash from "./Primitive_hash.mjs";
4+
import * as Belt_internalSetBuckets from "./Belt_internalSetBuckets.mjs";
5+
import * as Belt_internalBucketsType from "./Belt_internalBucketsType.mjs";
66

77
function copyBucket(h_buckets, ndata_tail, _old_bucket) {
88
while (true) {

0 commit comments

Comments
 (0)