Search in sources :

Example 1 with ModuleKind

use of org.jetbrains.kotlin.serialization.js.ModuleKind in project kotlin by JetBrains.

the class K2JSCompiler method setupPlatformSpecificArgumentsAndServices.

@Override
protected void setupPlatformSpecificArgumentsAndServices(@NotNull CompilerConfiguration configuration, @NotNull K2JSCompilerArguments arguments, @NotNull Services services) {
    MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
    if (arguments.target != null) {
        assert arguments.target == "v5" : "Unsupported ECMA version: " + arguments.target;
    }
    configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.defaultVersion());
    if (arguments.sourceMap) {
        configuration.put(JSConfigurationKeys.SOURCE_MAP, true);
    }
    if (arguments.metaInfo) {
        configuration.put(JSConfigurationKeys.META_INFO, true);
    }
    List<String> libraries = new SmartList<String>();
    if (!arguments.noStdlib) {
        libraries.add(0, PathUtil.getKotlinPathsForCompiler().getJsStdLibJarPath().getAbsolutePath());
    }
    if (arguments.libraries != null) {
        ContainerUtil.addAllNotNull(libraries, arguments.libraries.split(File.pathSeparator));
    }
    configuration.put(JSConfigurationKeys.LIBRARIES, libraries);
    String moduleKindName = arguments.moduleKind;
    ModuleKind moduleKind = moduleKindName != null ? moduleKindMap.get(moduleKindName) : ModuleKind.PLAIN;
    if (moduleKind == null) {
        messageCollector.report(CompilerMessageSeverity.ERROR, "Unknown module kind: " + moduleKindName + ". " + "Valid values are: plain, amd, commonjs, umd", CompilerMessageLocation.NO_LOCATION);
    }
    configuration.put(JSConfigurationKeys.MODULE_KIND, moduleKind);
}
Also used : ModuleKind(org.jetbrains.kotlin.serialization.js.ModuleKind) MessageCollector(org.jetbrains.kotlin.cli.common.messages.MessageCollector) SmartList(com.intellij.util.SmartList)

Aggregations

SmartList (com.intellij.util.SmartList)1 MessageCollector (org.jetbrains.kotlin.cli.common.messages.MessageCollector)1 ModuleKind (org.jetbrains.kotlin.serialization.js.ModuleKind)1