[Gradle, JS] Adopt Gradle plugin to webpack 5

^KT-42921 fixed
This commit is contained in:
Ilya Goncharov
2020-11-14 21:00:53 +03:00
committed by TeamCityServer
parent a06feaf819
commit 1b8c74337e
10 changed files with 42 additions and 30 deletions
@@ -11,21 +11,21 @@ package org.jetbrains.kotlin.gradle.targets.js
// DO NOT MODIFY DIRECTLY! Use org.jetbrains.kotlin.generators.gradle.targets.js.MainKt
class NpmVersions {
val dukat = NpmPackageVersion("dukat", "0.5.8-rc.4")
val webpack = NpmPackageVersion("webpack", "4.44.1")
val webpackCli = NpmPackageVersion("webpack-cli", "3.3.12")
val webpackBundleAnalyzer = NpmPackageVersion("webpack-bundle-analyzer", "3.8.0")
val webpack = NpmPackageVersion("webpack", "5.4.0")
val webpackCli = NpmPackageVersion("webpack-cli", "4.2.0")
val webpackBundleAnalyzer = NpmPackageVersion("webpack-bundle-analyzer", "4.1.0")
val webpackDevServer = NpmPackageVersion("webpack-dev-server", "3.11.0")
val sourceMapLoader = NpmPackageVersion("source-map-loader", "1.1.0")
val sourceMapLoader = NpmPackageVersion("source-map-loader", "1.1.2")
val sourceMapSupport = NpmPackageVersion("source-map-support", "0.5.19")
val cssLoader = NpmPackageVersion("css-loader", "4.3.0")
val styleLoader = NpmPackageVersion("style-loader", "1.2.1")
val cssLoader = NpmPackageVersion("css-loader", "5.0.1")
val styleLoader = NpmPackageVersion("style-loader", "2.0.0")
val toStringLoader = NpmPackageVersion("to-string-loader", "1.1.6")
val miniCssExtractPlugin = NpmPackageVersion("mini-css-extract-plugin", "0.11.1")
val mocha = NpmPackageVersion("mocha", "8.1.3")
val karma = NpmPackageVersion("karma", "5.2.2")
val miniCssExtractPlugin = NpmPackageVersion("mini-css-extract-plugin", "1.3.1")
val mocha = NpmPackageVersion("mocha", "8.2.1")
val karma = NpmPackageVersion("karma", "5.2.3")
val karmaChromeLauncher = NpmPackageVersion("karma-chrome-launcher", "3.1.0")
val karmaPhantomjsLauncher = NpmPackageVersion("karma-phantomjs-launcher", "1.0.4")
val karmaFirefoxLauncher = NpmPackageVersion("karma-firefox-launcher", "1.3.0")
val karmaFirefoxLauncher = NpmPackageVersion("karma-firefox-launcher", "2.1.0")
val karmaOperaLauncher = NpmPackageVersion("karma-opera-launcher", "1.0.0")
val karmaIeLauncher = NpmPackageVersion("karma-ie-launcher", "1.0.0")
val karmaSafariLauncher = NpmPackageVersion("karma-safari-launcher", "1.0.0")
@@ -35,4 +35,4 @@ class NpmVersions {
val karmaSourcemapLoader = NpmPackageVersion("karma-sourcemap-loader", "0.3.8")
val kotlinJsTestRunner = KotlinGradleNpmPackage("test-js-runner")
}
}
@@ -268,10 +268,7 @@ data class KotlinWebpackConfig(
enforce: "pre"
});
config.devtool = ${devtool?.let { "'$it'" } ?: false};
config.stats = config.stats || {}
Object.assign(config.stats, config.stats, {
warningsFilter: [/Failed to parse source map/]
})
config.ignoreWarnings = [/Failed to parse source map/]
""".trimIndent()
)
@@ -8,11 +8,12 @@ import {runWithFilteringAndConsoleAdapters} from "./src/Adapter";
const kotlin_test = require('kotlin-test');
process.exit = (exitCode) => {
throw new Error(`Exit with ${exitCode}`)
};
const parser = new CliArgsParser(getDefaultCliDescription());
const parser = new CliArgsParser(
getDefaultCliDescription(),
(exitCode) => {
throw new Error(`Exit with ${exitCode}`)
}
);
const untypedArgs = parser.parse(window.__karma__.config.args);
const initialAdapter = kotlin_test.kotlin.test.detectAdapter_8be2vx$();
@@ -3,7 +3,10 @@ import {runWithFilteringAndConsoleAdapters} from "./src/Adapter";
const kotlin_test = require('kotlin-test');
const parser = new CliArgsParser(getDefaultCliDescription());
const parser = new CliArgsParser(
getDefaultCliDescription(),
process.exit
);
const untypedArgs = parser.parse(process.argv);
const initialAdapter = kotlin_test.kotlin.test.detectAdapter_8be2vx$();
@@ -24,6 +24,7 @@
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.25.2",
"rollup-plugin-terser": "^5.1.2",
"typescript": "^3.7.2"
"typescript": "^3.7.2",
"format-util": "^1.0.5"
}
}
@@ -27,7 +27,10 @@ export type CliArgDescription = {
}
export class CliArgsParser {
constructor(private description: CliDescription) {
constructor(
private description: CliDescription,
private onFail: (n: number) => never
) {
}
printUsage() {
@@ -59,7 +62,7 @@ export class CliArgsParser {
println(message);
println();
this.printUsage();
process.exit(1)
this.onFail(1)
}
parse(args: string[]): CliArgValues {
@@ -5,7 +5,7 @@
import {KotlinTestRunner} from "./KotlinTestRunner";
import {TeamCityMessageData, TeamCityMessagesFlow} from "./TeamCityMessagesFlow";
import {format} from "util";
const format = require("format-util");
// don't use enum as it is not minified by uglify
export type IgnoredTestSuitesReporting
@@ -26,7 +26,7 @@ export const TYPED_MESSAGE = `##teamcity[message text='%s' type='%s']`
* @see https://confluence.jetbrains.com/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-servMsgsServiceMessages
*/
const util = require('util');
const format = require('format-util');
export function tcEscape(str) {
if (!str) {
@@ -56,5 +56,5 @@ export function formatMessage() {
formattedArguments.push(tcEscape(param));
});
formattedArguments.unshift(tcMessage);
return util.format.apply(util, formattedArguments);
return format(formattedArguments);
}
@@ -33,13 +33,15 @@ class TeamCityErrorPlugin {
apply(compiler) {
compiler.hooks.done.tap('TeamCityErrorPlugin', (stats) => {
const warningsFilters = this.warningsFilter(stats.compilation.options.stats.warningsFilter);
const warningsFilters = this.warningsFilter(stats.compilation.options.ignoreWarnings);
stats.compilation.errors.forEach(error => {
const type = 'error';
if (error instanceof ModuleNotFoundError) {
error.dependencies.forEach(dependency => {
console[type](formatMessage(TYPED_MESSAGE, `Module '${dependency.request}' not found`, type));
const module = error.module;
module.dependencies.forEach(dependency => {
console[type](
formatMessage(TYPED_MESSAGE, `Module '${dependency.request}' not found in '${module.resource}'`, type));
});
return
}
@@ -158,6 +158,11 @@ find-up@^4.0.0:
locate-path "^5.0.0"
path-exists "^4.0.0"
format-util@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==
fs-extra@8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"