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

Run and test ESModule scripts as ES Modules #1142

Merged
merged 2 commits into from
Jun 30, 2022
Merged

Run and test ESModule scripts as ES Modules #1142

merged 2 commits into from
Jun 30, 2022

Conversation

hugo-vrijswijk
Copy link
Contributor

@hugo-vrijswijk hugo-vrijswijk commented Jun 29, 2022

Fixes #1104

Input.Script loads scripts with require, which does not work with ES modules. With this change Script.ESModule is used for es modules, as well as the file extension is changed to let Nodejs know we're working with an ES Module

This probably needs some tests, but I am not sure where to start with them

@lwronski
Copy link
Contributor

Fixes #1104

Input.Script loads scripts with require, which does not work with ES modules. With this change Script.ESModule is used for es modules, as well as the file extension is changed to let Nodejs know we're working with an ES Module

This probably needs some tests, but I am not sure where to start with them

@hugo-vrijswijk Thanks for contribution,

If you want to add some integration test, you can do it in RunTestDefiniotions.scala, here you can find another test for Scala.js

@hugo-vrijswijk
Copy link
Contributor Author

@lwronski thanks for the pointer. I've added two tests. If you could give this a review, that'd be great!

@Gedochao
Copy link
Contributor

Great contribution @hugo-vrijswijk!

Copy link
Contributor

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

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

Nice, thanks @hugo-vrijswijk!

@alexarchambault alexarchambault merged commit 4b50db8 into VirtusLab:main Jun 30, 2022
@hugo-vrijswijk
Copy link
Contributor Author

Just in time to miss the 0.1.9 release 😅

@hugo-vrijswijk hugo-vrijswijk deleted the fix/esm branch July 1, 2022 08:36
@lwronski
Copy link
Contributor

lwronski commented Jul 1, 2022

@hugo-vrijswijk You can try to run the nightly version of Scala CLI with your fix:

scala-cli --cli-version nightly hello.sc --js

about cli-version parameter you can find more detail here.

@Gedochao Gedochao added the bug Something isn't working label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jsModuleKind "es" does not work with "run" when importing a module
4 participants