Skip to content

Commit 1615975

Browse files
authored
Don't export $$default (#6328)
* don't export 2235default * handle that 2235default is now gone * changelog
1 parent 43e1175 commit 1615975

13 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
- GenType: Propagate comments from record fields to emitted TypeScript types. https://github.com/rescript-lang/rescript-compiler/pull/6333
1818

19+
#### :boom: Breaking Change
20+
21+
- `$$default` is no longer exported from the generated JavaScript when using default exports. https://github.com/rescript-lang/rescript-compiler/pull/6328
22+
1923
# 11.0.0-beta.4
2024

2125
#### :rocket: New Feature

jscomp/core/js_dump.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ and vident cxt f (v : J.vident) =
500500
| Qualified ({ id; kind = Ml | Runtime }, Some name) ->
501501
let cxt = Ext_pp_scope.ident cxt f id in
502502
P.string f L.dot;
503-
P.string f (Ext_ident.convert name);
503+
P.string f
504+
(if name = Js_dump_import_export.default_export then name
505+
else Ext_ident.convert name);
504506
cxt
505507
| Qualified ({ id; kind = External _ }, Some name) ->
506508
let cxt = Ext_pp_scope.ident cxt f id in

jscomp/core/js_dump_import_export.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let exports cxt f (idents : Ident.t list) =
5050
( cxt,
5151
if id_name = default_export then
5252
(* TODO check how it will affect AMDJS*)
53-
esModule :: (default_export, str) :: (s, str) :: acc
53+
esModule :: (default_export, str) :: acc
5454
else (s, str) :: acc ))
5555
in
5656
P.at_least_two_lines f;
@@ -77,7 +77,7 @@ let es6_export cxt f (idents : Ident.t list) =
7777
let str, cxt = Ext_pp_scope.str_of_ident cxt id in
7878
( cxt,
7979
if id_name = default_export then
80-
(default_export, str) :: (s, str) :: acc
80+
(default_export, str) :: acc
8181
else (s, str) :: acc ))
8282
in
8383
P.at_least_two_lines f;

jscomp/core/js_dump_import_export.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25+
val default_export : string
26+
2527
val exports : Ext_pp_scope.t -> Ext_pp.t -> Ident.t list -> Ext_pp_scope.t
2628

2729
val es6_export : Ext_pp_scope.t -> Ext_pp.t -> Ident.t list -> Ext_pp_scope.t

jscomp/test/default_export_test.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/es6_export.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/es6_export.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var $$default = 3;
55

66
export {
7-
$$default ,
87
$$default as default,
98
}
109
/* No side effect */

jscomp/test/es6_import.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/es6_import.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as Es6_export from "./es6_export.mjs";
44

5-
console.log(Es6_export.$$default);
5+
console.log(Es6_export.default);
66

77
export {
88

jscomp/test/escape_esmodule.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/key_word_property.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/es6/js_option.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export {
9696
andThen ,
9797
map ,
9898
getWithDefault ,
99-
$$default ,
10099
$$default as default,
101100
filter ,
102101
firstSome ,

lib/js/js_option.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ exports.equal = equal;
9595
exports.andThen = andThen;
9696
exports.map = map;
9797
exports.getWithDefault = getWithDefault;
98-
exports.$$default = $$default;
9998
exports.default = $$default;
10099
exports.__esModule = true;
101100
exports.filter = filter;

0 commit comments

Comments
 (0)