Skip to content
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

Omit dynamic imported module from require, import statement #6232

Merged
merged 9 commits into from
May 1, 2023
Merged
Changes from 1 commit
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
Next Next commit
add tests
mununki committed May 1, 2023
commit 72363611150ef24549b4a472b51aa4ff0afce519
4 changes: 3 additions & 1 deletion jscomp/test/build.ninja

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions jscomp/test/import_lazy_component.js

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

1 change: 1 addition & 0 deletions jscomp/test/import_lazy_component.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let a = Belt.Array.map([1], x => x)
11 changes: 11 additions & 0 deletions jscomp/test/import_unnecessary.js

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

3 changes: 3 additions & 0 deletions jscomp/test/import_unnecessary.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Import_lazy_component is not a pure module
// It is supposed not to be required by dynamic import
let a = Js.import(Import_lazy_component.a)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is tested in this example?

Copy link
Member Author

@mununki mununki May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// import_lazy_component.res
let a = Belt.Array.map([1], x => x)

import_lazy_component.res has side effect. So, import_unnecessary.res module's JS output also had unnecessary require("./import_lazy_component.js"); before this PR changes. See the test output before this PR changes affect: dface2b