Skip to content

Don't export $$default #6328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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