Skip to content

Commit

Permalink
Don't export $$default (#6328)
Browse files Browse the repository at this point in the history
* don't export 2235default

* handle that 2235default is now gone

* changelog
  • Loading branch information
zth authored Jul 31, 2023
1 parent 43e1175 commit 1615975
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

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

#### :boom: Breaking Change

- `$$default` is no longer exported from the generated JavaScript when using default exports. https://github.com/rescript-lang/rescript-compiler/pull/6328

# 11.0.0-beta.4

#### :rocket: New Feature
Expand Down
4 changes: 3 additions & 1 deletion jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ and vident cxt f (v : J.vident) =
| Qualified ({ id; kind = Ml | Runtime }, Some name) ->
let cxt = Ext_pp_scope.ident cxt f id in
P.string f L.dot;
P.string f (Ext_ident.convert name);
P.string f
(if name = Js_dump_import_export.default_export then name
else Ext_ident.convert name);
cxt
| Qualified ({ id; kind = External _ }, Some name) ->
let cxt = Ext_pp_scope.ident cxt f id in
Expand Down
4 changes: 2 additions & 2 deletions jscomp/core/js_dump_import_export.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let exports cxt f (idents : Ident.t list) =
( cxt,
if id_name = default_export then
(* TODO check how it will affect AMDJS*)
esModule :: (default_export, str) :: (s, str) :: acc
esModule :: (default_export, str) :: acc
else (s, str) :: acc ))
in
P.at_least_two_lines f;
Expand All @@ -77,7 +77,7 @@ let es6_export cxt f (idents : Ident.t list) =
let str, cxt = Ext_pp_scope.str_of_ident cxt id in
( cxt,
if id_name = default_export then
(default_export, str) :: (s, str) :: acc
(default_export, str) :: acc
else (s, str) :: acc ))
in
P.at_least_two_lines f;
Expand Down
2 changes: 2 additions & 0 deletions jscomp/core/js_dump_import_export.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

val default_export : string

val exports : Ext_pp_scope.t -> Ext_pp.t -> Ident.t list -> Ext_pp_scope.t

val es6_export : Ext_pp_scope.t -> Ext_pp.t -> Ident.t list -> Ext_pp_scope.t
Expand Down
1 change: 0 additions & 1 deletion jscomp/test/default_export_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion jscomp/test/es6_export.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion jscomp/test/es6_export.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var $$default = 3;

export {
$$default ,
$$default as default,
}
/* No side effect */
2 changes: 1 addition & 1 deletion jscomp/test/es6_import.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/es6_import.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

console.log(Es6_export.$$default);
console.log(Es6_export.default);

export {

Expand Down
1 change: 0 additions & 1 deletion jscomp/test/escape_esmodule.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion jscomp/test/key_word_property.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/es6/js_option.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export {
andThen ,
map ,
getWithDefault ,
$$default ,
$$default as default,
filter ,
firstSome ,
Expand Down
1 change: 0 additions & 1 deletion lib/js/js_option.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ exports.equal = equal;
exports.andThen = andThen;
exports.map = map;
exports.getWithDefault = getWithDefault;
exports.$$default = $$default;
exports.default = $$default;
exports.__esModule = true;
exports.filter = filter;
Expand Down

0 comments on commit 1615975

Please sign in to comment.