Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Dec 5, 2024
1 parent 98efe9b commit 8591e00
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 10 deletions.
2 changes: 1 addition & 1 deletion karma-browserstack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const customLaunchers = [
}, {});

module.exports = async config => {
const karmaConfig = (await import("./tools/lib/karmaConfig.js")).default;
const karmaConfig = (await import("./tools/lib/karmaConfig.ts")).default;

config.set({
...karmaConfig,
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = async config => {
const karmaConfig = (await import("./tools/lib/karmaConfig.js")).default;
const karmaConfig = (await import("./tools/lib/karmaConfig.ts")).default;

config.set({
...karmaConfig,
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"pre-test": "node --experimental-strip-types --disable-warning=ExperimentalWarning tools/pre-test.ts",
"prettier": "prettier --write \"*.{mjs,cjs,js,json,scss,ts,tsx}\" \"public/**/*.{mjs,cjs,js,json,scss,ts,tsx}\" \"src/**/*.{mjs,cjs,js,json,scss,ts,tsx}\" \"tools/**/*.{mjs,cjs,js,json,scss,ts,tsx}\"",
"test": "node --run pre-test && cross-env SPORT=basketball jest --testPathIgnorePatterns football && cross-env SPORT=football jest --testRegex \"football.*\\.test\\.c?[jt]sx?\"",
"test-e2e": "node --run pre-test && karma start karma.conf.js",
"test-e2e-watch": "node --run pre-test && karma start karma.conf.js --auto-watch --no-single-run",
"test-e2e-browserstack": "node --run pre-test && karma start karma-browserstack.conf.js",
"test-e2e": "node --run pre-test && node --experimental-strip-types --disable-warning=ExperimentalWarning node_modules/karma/bin/karma start karma.conf.js",
"test-e2e-watch": "node --run pre-test && node --experimental-strip-types --disable-warning=ExperimentalWarning node_modules/karma/bin/karma start karma.conf.js --auto-watch --no-single-run",
"test-e2e-browserstack": "node --run pre-test && node --experimental-strip-types --disable-warning=ExperimentalWarning node_modules/karma/bin/karma start karma-browserstack.conf.js",
"prepare": "husky"
},
"lint-staged": {
Expand Down Expand Up @@ -117,6 +117,11 @@
"@types/gtag.js": "^0.0.20",
"@types/html-minifier-terser": "^7.0.2",
"@types/jest": "^29.5.14",
"@types/karma-browserstack-launcher": "^1.6.5",
"@types/karma-chrome-launcher": "^3.1.4",
"@types/karma-firefox-launcher": "^2.1.4",
"@types/karma-mocha": "^1.3.4",
"@types/karma-rollup-preprocessor": "^7.0.3",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.10.1",
"@types/react": "^18.3.13",
Expand Down
71 changes: 71 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/lib/buildJSWorker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as rollup from "rollup";
import rollupConfig from "./rollupConfig.js";
import rollupConfig from "./rollupConfig.ts";
import { parentPort, workerData } from "node:worker_threads";

const LODASH_BLACKLIST = [
Expand Down
3 changes: 2 additions & 1 deletion tools/lib/karmaConfig.js → tools/lib/karmaConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import alias from "@rollup/plugin-alias";
import rollupConfig from "./rollupConfig.js";
import rollupConfig from "./rollupConfig.ts";
import browserstackLauncher from "karma-browserstack-launcher";
import chromeLauncher from "karma-chrome-launcher";
import firefoxLauncher from "karma-firefox-launcher";
import mocha from "karma-mocha";
import rollupPreprocessor from "karma-rollup-preprocessor";
// @ts-expect-error
import sourceMapSupport from "karma-source-map-support";

const files = ["src/test/mocha.ts", "src/test/smoke.ts"];
Expand Down
17 changes: 14 additions & 3 deletions tools/lib/rollupConfig.js → tools/lib/rollupConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import alias from "@rollup/plugin-alias";
import { babel } from "@rollup/plugin-babel";
// @ts-expect-error
import blacklist from "rollup-plugin-blacklist";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
Expand All @@ -12,7 +13,18 @@ import { getSport } from "./buildFuncs.ts";

const extensions = [".mjs", ".js", ".json", ".node", ".ts", ".tsx"];

export default (nodeEnv, { blacklistOptions, statsFilename, legacy } = {}) => {
export default (
nodeEnv: "development" | "production" | "test",
{
blacklistOptions,
statsFilename,
legacy,
}: {
blacklistOptions?: RegExp[];
statsFilename?: string;
legacy?: boolean;
} = {},
) => {
const sport = getSport();

// This gets used in babel.config.js, except we don't want it set to "test" in karma because then it will activate @babel/plugin-transform-modules-commonjs
Expand All @@ -24,7 +36,6 @@ export default (nodeEnv, { blacklistOptions, statsFilename, legacy } = {}) => {

const plugins = [
alias({
resolve: [".json"],
entries: {
// This is assumed to be generated prior to rollup being started
"league-schema": path.resolve(root, "build/files/league-schema.json"),
Expand Down Expand Up @@ -99,7 +110,7 @@ export default (nodeEnv, { blacklistOptions, statsFilename, legacy } = {}) => {

return {
plugins,
onwarn(warning, rollupWarn) {
onwarn(warning: any, rollupWarn: any) {
// I don't like this, but there's too much damn baggage
if (warning.code === "CIRCULAR_DEPENDENCY") {
return;
Expand Down

0 comments on commit 8591e00

Please sign in to comment.