如何将Scala.js应用程序转换为CommonJS模块? [英] How to convert Scala.js application to CommonJS module?

查看:63
本文介绍了如何将Scala.js应用程序转换为CommonJS模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CommonJS环境中,是否有任何标准方法可以将Scala.js应用程序用作库?如果没有,我可以为此目的修补生成的js文件吗?

Is there any standard way to use Scala.js application as a libriary in CommonJS environment? And if not, can I patch generated js file for that purpose?

推荐答案

Scala.js 0.6.13及更高版本



将此内容放入构建文件中:

Scala.js 0.6.13 and onward

Put this in your build file:

scalaJSModuleKind := ModuleKind.CommonJSModule



Scala.js 0.6.5至0.6.12



将其放入您的构建文件中(解释见下文):

Scala.js 0.6.5 to 0.6.12

Put this in your build file (explanation see below):

scalaJSOutputWrapper := ("var __ScalaJSEnv = { exportsNamespace: exports };", "")



Scala.js 0.5.4至0.6.4



您可以告诉Scala.js将其导出的内容发送到哪里。要制作CommonJS模块,只需在其前添加:

Scala.js 0.5.4 to 0.6.4

You can tell Scala.js where to send the stuff it exports. To make a CommonJS module, simply prepend this:

var __ScalaJSEnv = {
   exportsNamespace: exports
};

到<产生的 .js 文件code> fastOptJS / fullOptJS

to the .js file produced by fastOptJS/fullOptJS.

请升级:)

这篇关于如何将Scala.js应用程序转换为CommonJS模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆