diff --git a/.changeset/node.md b/.changeset/node.md new file mode 100644 index 00000000..5eef65fa --- /dev/null +++ b/.changeset/node.md @@ -0,0 +1,5 @@ +--- +"@jspsych/config": major +--- + +Require at least Node.js v18 and npm v8 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08130ca7..c72d39c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,26 +9,23 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14, 16] + node: [18] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Node.js ${{ matrix.node }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} cache: npm - - name: Install npm@v7 - run: npm install -g npm@7 - - name: Install dependencies run: npm ci # Running this after `npm ci` because `npm ci` removes `node_modules`: - name: Download Turborepo cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: node_modules/.cache/turbo key: ${{ runner.os }}-node-${{ matrix.node }}-turbo-${{ hashFiles('node_modules/.cache/turbo') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49eac7de..66215350 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,29 +16,30 @@ jobs: name: Release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Setup Node.js 16 - uses: actions/setup-node@v2 + - name: Setup Node.js + uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: npm - name: Install dependencies run: npm ci - name: Download Turborepo cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: node_modules/.cache/turbo - key: ${{ runner.os }}-node-16-turbo-${{ hashFiles('node_modules/.cache/turbo') }} + key: ${{ runner.os }}-node-18-turbo-${{ hashFiles('node_modules/.cache/turbo') }} restore-keys: | - ${{ runner.os }}-node-16-turbo- + ${{ runner.os }}-node-18-turbo- + + - name: Check types + run: npm run tsc - name: Run tests run: npm run test -- --ci --maxWorkers=2 - env: - NODE_OPTIONS: "--max-old-space-size=4096" # Increase heap size for jest - name: Create Release Pull Request or Publish Packages id: changesets diff --git a/docs/developers/configuration.md b/docs/developers/configuration.md index 01565f7c..78f85e3b 100644 --- a/docs/developers/configuration.md +++ b/docs/developers/configuration.md @@ -9,9 +9,7 @@ In order to work on code in the jsPsych or the jspsych-contrib repository, it is ### Install Node.js -The jsPsych development setup requires Node.js >= v14 to be installed on your machine. -We recommend that you [install version 16](https://nodejs.org/en/) since it includes version 7 of NPM (required for the workspaces feature that the jsPsych repositories use). -If you are bound to Node.js v14, make sure to install NPM v7 manually (via `npm install -g npm@7`). +The jsPsych development setup requires [Node.js](https://nodejs.org/en/) >= v18 to be installed on your machine. ### Clone the repository and install the dependencies @@ -26,25 +24,22 @@ or ```sh git clone https://github.com/jspsych/jspsych-contrib.git && cd jspsych-contrib ``` + in a terminal. Then run `npm install`. This will create a `node_modules` directory and install all the dependencies into it that are required to build and test jsPsych. -!!! attention - It is important that `npm install` is only run in the root directory of the repository (due to the NPM workspaces feature). - If you accidentally ran `npm install` anywhere else, remove the `node_modules` directory and the `package-lock.json` file that were created at that location and run `npm install` in the root directory again. - !!! info - If you are running `npm install` in the core jsPsych repository, this will also execute the build chain for all packages in the jsPsych repository. - This step may take a few minutes. - If you would like to use that time efficiently, consider reading the following two sections to know what's happening. +If you are running `npm install` in the core jsPsych repository, this will also execute the build chain for all packages in the jsPsych repository. +This step may take a few minutes. +If you would like to use that time efficiently, consider reading the following two sections to know what's happening. ## Repository structure A Node.js package is a directory that contains a `package.json` file describing it. Most importantly, a `package.json` file lists other packages that the package depends on. -The jsPsych and jspsych-contrib repositories use NPM *workspaces*. +The jsPsych and jspsych-contrib repositories use NPM _workspaces_. That means, running `npm install` in the repository root will install the dependencies for all packages in the `packages` directory. The core jsPsych library and every jsPsych plugin or extension is laid out as an individual package. These packages are published to the [NPM registry](https://www.npmjs.com/) where they can be downloaded by NPM or any CDN (such as [unpkg](https://unpkg.com/)). @@ -54,40 +49,39 @@ These packages are published to the [NPM registry](https://www.npmjs.com/) where JsPsych comes with a build chain (specified in the `@jspsych/config` package) that can be executed by running `npm run build` in a package's directory. The build chain will read the package (starting at its `src/index.ts` file) and create the following build artifacts in the package's `dist` directory: -* **`index.js`** +- **`index.js`** This file contains everything from `index.ts`, but as plain JavaScript and bundled in a single file (i.e. without `import`ing files from the same package). It is used by bundlers like [webpack](https://webpack.js.org/). -* **`index.cjs`** - Like `index.js`, but using the old CommonJS standard to support backwards-compatible tools like the [Jest](https://jestjs.io/) testing framework. +- **`index.cjs`** + Like `index.js`, but using the old CommonJS standard to support tools like the [Jest](https://jestjs.io/) testing framework. -* **`index.browser.js`** +- **`index.browser.js`** This file, like `index.js`, contains the entire package as plain JavaScript, but this time wrapped in a function so that it can be included directly by browsers using the `