Merge pull request #3122 from jspsych/update-config-package

Update `@jspsych/config` dependencies
This commit is contained in:
bjoluc 2023-11-10 21:15:13 +01:00 committed by GitHub
commit 76fca2712f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 4840 additions and 16812 deletions

View File

@ -0,0 +1,5 @@
---
"@jspsych/config": patch
---
Remove erroneous browser builds from the rollup configuration returned by `makeNodeRollupConfig()`

View File

@ -0,0 +1,9 @@
---
"@jspsych/config": major
---
Upgrade build tools to their latest versions. This doesn't introduce breaking changes to the artifacts built using `@jspsych/config`, but it requires some minor changes to projects using `@jspsych/config`:
- The minimum required Node.js version is now 18.0.0
- Jest has been upgraded from v28 to v29 and ts-jest has been replaced with the more performant Sucrase Jest plugin to avoid significant memory leaks. As a consequence, Jest does no longer type-check code. If you are facing any issues, please check Jest's [upgrade guide](https://jestjs.io/docs/upgrading-to-jest29) for instructions on updating your tests.
- TypeScript has been upgraded from version 4 to version 5. This is very unlikely to break anything in your code though.

View File

@ -9,26 +9,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node: [14, 16] node: [18, 20]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node }} - name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: npm cache: npm
- name: Install npm@v7
run: npm install -g npm@7
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
# Running this after `npm ci` because `npm ci` removes `node_modules`: # Running this after `npm ci` because `npm ci` removes `node_modules`:
- name: Download Turborepo cache - name: Download Turborepo cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: node_modules/.cache/turbo path: node_modules/.cache/turbo
key: ${{ runner.os }}-node-${{ matrix.node }}-turbo-${{ hashFiles('node_modules/.cache/turbo') }} key: ${{ runner.os }}-node-${{ matrix.node }}-turbo-${{ hashFiles('node_modules/.cache/turbo') }}
@ -38,14 +35,7 @@ jobs:
- name: Build packages - name: Build packages
run: npm run build run: npm run build
# TODO setup linting
# - name: Lint
# run: npm run lint
- name: Run tests - name: Run tests
run: npm run test -- --ci --coverage --maxWorkers=2 run: npm run test -- --ci --coverage --maxWorkers=2
env: env:
NODE_OPTIONS: "--max-old-space-size=4096" # Increase heap size for jest NODE_OPTIONS: "--max-old-space-size=4096" # Increase heap size for jest
# TODO setup codecov or coveralls
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1

View File

@ -16,24 +16,24 @@ jobs:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Setup Node.js 16 - name: Setup Node.js
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 20
cache: npm cache: npm
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Download Turborepo cache - name: Download Turborepo cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: node_modules/.cache/turbo path: node_modules/.cache/turbo
key: ${{ runner.os }}-node-16-turbo-${{ hashFiles('node_modules/.cache/turbo') }} key: ${{ runner.os }}-node-20-turbo-${{ hashFiles('node_modules/.cache/turbo') }}
restore-keys: | restore-keys: |
${{ runner.os }}-node-16-turbo- ${{ runner.os }}-node-20-turbo-
- name: Run tests - name: Run tests
run: npm run test -- --ci --maxWorkers=2 run: npm run test -- --ci --maxWorkers=2

21520
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,21 +20,21 @@
"docs:serve": "poetry install && poetry run mike serve" "docs:serve": "poetry install && poetry run mike serve"
}, },
"engines": { "engines": {
"node": ">=14.0.0", "node": ">=18.0.0",
"npm": ">=7.0.0" "npm": ">=9.0.0"
}, },
"packageManager": "npm@8.3.1", "packageManager": "npm@8.3.1",
"devDependencies": { "devDependencies": {
"@changesets/changelog-github": "^0.4.4", "@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0", "@changesets/cli": "^2.22.0",
"alias-hq": "github:bjoluc/alias-hq#tsconfig-parsing-quickfix",
"husky": "^8.0.1", "husky": "^8.0.1",
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"jest": "*",
"lint-staged": "^12.4.1", "lint-staged": "^12.4.1",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"prettier-plugin-import-sort": "^0.0.7", "prettier-plugin-import-sort": "^0.0.7",
"turbo": "^1.2.9", "turbo": "^1.2.9"
"jest": "*",
"ts-jest": "*"
}, },
"prettier": { "prettier": {
"printWidth": 100 "printWidth": 100

View File

@ -1,21 +1,13 @@
const ts = require("typescript"); const hq = require("alias-hq");
const { pathsToModuleNameMapper } = require("ts-jest");
/** @type { (dirname: string) => import('@jest/types').Config.InitialOptions } */ /** @type { (dirname: string) => import('@jest/types').Config.InitialOptions } */
module.exports.makePackageConfig = (dirname) => { module.exports.makePackageConfig = (dirname) => {
const packageJson = require(dirname + "/package.json"); const packageJson = require(dirname + "/package.json");
const packageBaseName = packageJson.name.replace("@jspsych/", ""); const packageBaseName = packageJson.name.replace("@jspsych/", "");
// based on https://github.com/formium/tsdx/blob/462af2d002987f985695b98400e0344b8f2754b7/src/createRollupConfig.ts#L51-L57
const tsCompilerOptions = ts.parseJsonConfigFileContent(
ts.readConfigFile(dirname + "/tsconfig.json", ts.sys.readFile).config,
ts.sys,
dirname
).options;
return { return {
preset: "ts-jest", transform: { "\\.(js|jsx|ts|tsx)$": "@sucrase/jest-plugin" },
moduleNameMapper: pathsToModuleNameMapper(tsCompilerOptions.paths, { prefix: "<rootDir>/" }), moduleNameMapper: hq.load(dirname + "/tsconfig.json").get("jest"),
testEnvironment: "jsdom", testEnvironment: "jsdom",
testEnvironmentOptions: { testEnvironmentOptions: {
fetchExternalResources: true, fetchExternalResources: true,

View File

@ -25,7 +25,7 @@
"./tsconfig.contrib.json": "./tsconfig.contrib.json" "./tsconfig.contrib.json": "./tsconfig.contrib.json"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=18.0.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -39,33 +39,35 @@
}, },
"homepage": "https://www.jspsych.org/latest/developers/configuration", "homepage": "https://www.jspsych.org/latest/developers/configuration",
"dependencies": { "dependencies": {
"@babel/cli": "7.17.10", "@babel/cli": "7.23.0",
"@babel/core": "7.17.10", "@babel/core": "7.23.3",
"@babel/preset-env": "7.17.10", "@babel/preset-env": "7.23.3",
"@rollup/plugin-babel": "5.3.1", "@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "22.0.0", "@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "4.1.0", "@rollup/plugin-json": "6.0.1",
"@rollup/plugin-node-resolve": "13.3.0", "@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "4.0.0", "@rollup/plugin-replace": "5.0.5",
"@types/gulp": "4.0.9", "@rollup/plugin-terser": "0.4.4",
"@types/jest": "27.5.1", "@sucrase/jest-plugin": "3.0.0",
"@types/gulp": "4.0.17",
"@types/jest": "29.5.8",
"alias-hq": "6.2.3",
"babel-preset-minify": "0.5.2", "babel-preset-minify": "0.5.2",
"canvas": "2.11.2", "canvas": "^2.11.2",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-cli": "2.3.0", "gulp-cli": "2.3.0",
"gulp-file": "^0.4.0", "gulp-file": "^0.4.0",
"gulp-rename": "2.0.0", "gulp-rename": "2.0.0",
"gulp-replace": "1.1.3", "gulp-replace": "1.1.4",
"gulp-zip": "5.1.0", "gulp-zip": "6.0.0",
"jest": "28.1.0", "jest": "29.7.0",
"jest-environment-jsdom": "28.1.0", "jest-environment-jsdom": "29.7.0",
"merge-stream": "2.0.0", "merge-stream": "2.0.0",
"regenerator-runtime": "0.13.9", "regenerator-runtime": "0.14.0",
"rollup": "2.73.0", "rollup": "4.3.0",
"rollup-plugin-terser": "7.0.2", "rollup-plugin-typescript2": "0.36.0",
"rollup-plugin-typescript2": "0.31.2", "sucrase": "3.34.0",
"ts-jest": "28.0.2", "tslib": "2.6.2",
"tslib": "2.4.0", "typescript": "^5.2.2"
"typescript": "^4.6.4"
} }
} }

View File

@ -4,8 +4,8 @@ import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json"; import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve"; import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace"; import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import { defineConfig } from "rollup"; import { defineConfig } from "rollup";
import { terser } from "rollup-plugin-terser";
import typescript from "rollup-plugin-typescript2"; import typescript from "rollup-plugin-typescript2";
import ts from "typescript"; import ts from "typescript";
@ -148,5 +148,5 @@ export const makeCoreRollupConfig = () =>
export const makeNodeRollupConfig = () => export const makeNodeRollupConfig = () =>
makeConfig({ makeConfig({
globalOptions: { external: ["jspsych"] }, globalOptions: { external: ["jspsych"] },
nodeOnly: true, isNodeOnlyBuild: true,
}); });

View File

@ -1,7 +1,7 @@
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response"; import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import { pressKey, startTimeline } from "@jspsych/test-utils"; import { pressKey, startTimeline } from "@jspsych/test-utils";
jest.useFakeTimers("modern"); jest.useFakeTimers();
describe("minimum_valid_rt parameter", () => { describe("minimum_valid_rt parameter", () => {
test("has a default value of 0", async () => { test("has a default value of 0", async () => {

View File

@ -14,7 +14,7 @@ describe("survey-html-form plugin", () => {
]); ]);
expect( expect(
displayElement.querySelectorAll('#jspsych-survey-html-form input:not([type="submit"]').length displayElement.querySelectorAll('#jspsych-survey-html-form input:not([type="submit"])').length
).toBe(3); ).toBe(3);
// Provide some test input // Provide some test input

View File

@ -62,7 +62,7 @@ describe("survey-likert plugin simulation", () => {
await expectFinished(); await expectFinished();
const surveyData = getData().values()[0].response; const surveyData = getData().values()[0].response as Record<string, number>;
const all_valid = Object.entries(surveyData).every((x) => { const all_valid = Object.entries(surveyData).every((x) => {
return x[1] <= 4 && x[1] >= 0; return x[1] <= 4 && x[1] >= 0;
}); });
@ -94,7 +94,7 @@ describe("survey-likert plugin simulation", () => {
await expectFinished(); await expectFinished();
const surveyData = getData().values()[0].response; const surveyData = getData().values()[0].response as Record<string, number>;
const all_valid = Object.entries(surveyData).every((x) => { const all_valid = Object.entries(surveyData).every((x) => {
return x[1] <= 4 && x[1] >= 0; return x[1] <= 4 && x[1] >= 0;
}); });