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

Support ModuleKind.ESModule #293

Open
kpritam opened this issue May 17, 2019 · 7 comments
Open

Support ModuleKind.ESModule #293

kpritam opened this issue May 17, 2019 · 7 comments
Milestone

Comments

@kpritam
Copy link

kpritam commented May 17, 2019

Latest Scala.js supports ModuleKind.ESModule, this option can not be used with ScalaJsBundler, we see this error:

java.lang.RuntimeException: scalaJSModuleKind must be set to ModuleKind.CommonJSModule in projects where ScalaJSBundler plugin is enabled
@julienrf
Copy link
Contributor

Indeed, I think checking that scalaJSModuleKind has been set to something different than ModuleKind.NoModule should work. Ideally, we could also check that the webpack version used does support ES modules.

@julienrf julienrf added this to the 1.0 milestone May 17, 2019
@vhiairrassary
Copy link
Contributor

As a POC, when deactivating moduleKind check:

diff --git a/sbt-scalajs-bundler/src/main/scala/scalajsbundler/sbtplugin/ScalaJSBundlerPlugin.scala b/sbt-scalajs-bundler/src/main/scala/scalajsbundler/sbtplugin/ScalaJSBundlerPlugin.scala
index ace7f71..a8f6a93 100644
--- a/sbt-scalajs-bundler/src/main/scala/scalajsbundler/sbtplugin/ScalaJSBundlerPlugin.scala
+++ b/sbt-scalajs-bundler/src/main/scala/scalajsbundler/sbtplugin/ScalaJSBundlerPlugin.scala
@@ -569,7 +569,7 @@ object ScalaJSBundlerPlugin extends AutoPlugin {

     ensureModuleKindIsCommonJSModule := {
       if (scalaJSLinkerConfig.value.moduleKind == ModuleKind.CommonJSModule) true
-      else sys.error(s"scalaJSModuleKind must be set to ModuleKind.CommonJSModule in projects where ScalaJSBundler plugin is enabled")
+      else true
     },

     webpackBundlingMode := BundlingMode.Default,

with default webpackBundlingMode and

webpackCliVersion := "3.3.6"
version in webpack := "4.39.1"
version in startWebpackDevServer := "3.8.0"

scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) }

it just works with Scala.js 0.6.28, Chrome 76 by loading [name]-fastopt-bundle.js. Are there other areas to check before starting a complete pull request?

@julienrf
Copy link
Contributor

Awesome, thanks for investigating!

Are there other areas to check

Maybe running tests, and running tests that use the DOM.

@KadekM
Copy link

KadekM commented Jul 24, 2021

Any news on this?

@exoego
Copy link
Contributor

exoego commented Jul 24, 2021

#336 seems inactive

@Lasering
Copy link

Lasering commented Dec 4, 2021

Is there anything I can do to help this move?

@julienrf
Copy link
Contributor

julienrf commented Dec 5, 2021

Hello! Unfortunately, this project lacks maintainers. Something you could do to help this move would be to locally test the PR that has been open, to fix the git conflicts, and finally to notify the people watching the repository that the PR is ready to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants