@jspsych/config 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/jest.cjs +3 -11
  3. package/package.json +26 -24
  4. package/rollup.js +21 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @jspsych/config
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#3122](https://github.com/jspsych/jsPsych/pull/3122) [`715a9d13`](https://github.com/jspsych/jsPsych/commit/715a9d130ec1d4772ce0b61956d8c19be5348fca) Thanks [@bjoluc](https://github.com/bjoluc)! - 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`:
8
+
9
+ - The minimum required Node.js version is now 18.0.0
10
+ - 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.
11
+ - TypeScript has been upgraded from version 4 to version 5. This is very unlikely to break anything in your code though.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#3122](https://github.com/jspsych/jsPsych/pull/3122) [`535e5d90`](https://github.com/jspsych/jsPsych/commit/535e5d903c4a5d6c71f3eecb73bc62b51e044a1f) Thanks [@bjoluc](https://github.com/bjoluc)! - Remove erroneous browser builds from the rollup configuration returned by `makeNodeRollupConfig()`
16
+
17
+ - [#3184](https://github.com/jspsych/jsPsych/pull/3184) [`9acfa29c`](https://github.com/jspsych/jsPsych/commit/9acfa29c8db1d7a8816c53ac49651f15493f2cf4) Thanks [@bjoluc](https://github.com/bjoluc)! - Point to source maps via canonical unpkg URLs in NPM-published browser builds. This prevents 404 errors when using redirecting CDN URLs (as described in #3043).
18
+
19
+ ## 1.3.3
20
+
21
+ ### Patch Changes
22
+
23
+ - [#3073](https://github.com/jspsych/jsPsych/pull/3073) [`caef8713`](https://github.com/jspsych/jsPsych/commit/caef8713e28fd0c4ed85ba86c27254ee8418087a) Thanks [@jodeleeuw](https://github.com/jodeleeuw)! - Update `canvas` package dependency version to fix missing binaries issues with newer node/npm versions
24
+
3
25
  ## 1.3.2
4
26
 
5
27
  ### Patch Changes
package/jest.cjs CHANGED
@@ -1,21 +1,13 @@
1
- const ts = require("typescript");
2
- const { pathsToModuleNameMapper } = require("ts-jest");
1
+ const hq = require("alias-hq");
3
2
 
4
3
  /** @type { (dirname: string) => import('@jest/types').Config.InitialOptions } */
5
4
  module.exports.makePackageConfig = (dirname) => {
6
5
  const packageJson = require(dirname + "/package.json");
7
6
  const packageBaseName = packageJson.name.replace("@jspsych/", "");
8
7
 
9
- // based on https://github.com/formium/tsdx/blob/462af2d002987f985695b98400e0344b8f2754b7/src/createRollupConfig.ts#L51-L57
10
- const tsCompilerOptions = ts.parseJsonConfigFileContent(
11
- ts.readConfigFile(dirname + "/tsconfig.json", ts.sys.readFile).config,
12
- ts.sys,
13
- dirname
14
- ).options;
15
-
16
8
  return {
17
- preset: "ts-jest",
18
- moduleNameMapper: pathsToModuleNameMapper(tsCompilerOptions.paths, { prefix: "<rootDir>/" }),
9
+ transform: { "\\.(js|jsx|ts|tsx)$": "@sucrase/jest-plugin" },
10
+ moduleNameMapper: hq.load(dirname + "/tsconfig.json").get("jest"),
19
11
  testEnvironment: "jsdom",
20
12
  testEnvironmentOptions: {
21
13
  fetchExternalResources: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jspsych/config",
3
- "version": "1.3.2",
3
+ "version": "2.0.0",
4
4
  "description": "Shared (build) configuration for jsPsych packages",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,7 +25,7 @@
25
25
  "./tsconfig.contrib.json": "./tsconfig.contrib.json"
26
26
  },
27
27
  "engines": {
28
- "node": ">=14.0.0"
28
+ "node": ">=18.0.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
@@ -39,33 +39,35 @@
39
39
  },
40
40
  "homepage": "https://www.jspsych.org/latest/developers/configuration",
41
41
  "dependencies": {
42
- "@babel/cli": "7.17.10",
43
- "@babel/core": "7.17.10",
44
- "@babel/preset-env": "7.17.10",
45
- "@rollup/plugin-babel": "5.3.1",
46
- "@rollup/plugin-commonjs": "22.0.0",
47
- "@rollup/plugin-json": "4.1.0",
48
- "@rollup/plugin-node-resolve": "13.3.0",
49
- "@rollup/plugin-replace": "4.0.0",
50
- "@types/gulp": "4.0.9",
51
- "@types/jest": "27.5.1",
42
+ "@babel/cli": "7.23.0",
43
+ "@babel/core": "7.23.3",
44
+ "@babel/preset-env": "7.23.3",
45
+ "@rollup/plugin-babel": "6.0.4",
46
+ "@rollup/plugin-commonjs": "25.0.7",
47
+ "@rollup/plugin-json": "6.0.1",
48
+ "@rollup/plugin-node-resolve": "15.2.3",
49
+ "@rollup/plugin-replace": "5.0.5",
50
+ "@rollup/plugin-terser": "0.4.4",
51
+ "@sucrase/jest-plugin": "3.0.0",
52
+ "@types/gulp": "4.0.17",
53
+ "@types/jest": "29.5.8",
54
+ "alias-hq": "6.2.3",
52
55
  "babel-preset-minify": "0.5.2",
53
- "canvas": "2.9.1",
56
+ "canvas": "^2.11.2",
54
57
  "gulp": "4.0.2",
55
58
  "gulp-cli": "2.3.0",
56
59
  "gulp-file": "^0.4.0",
57
60
  "gulp-rename": "2.0.0",
58
- "gulp-replace": "1.1.3",
59
- "gulp-zip": "5.1.0",
60
- "jest": "28.1.0",
61
- "jest-environment-jsdom": "28.1.0",
61
+ "gulp-replace": "1.1.4",
62
+ "gulp-zip": "6.0.0",
63
+ "jest": "29.7.0",
64
+ "jest-environment-jsdom": "29.7.0",
62
65
  "merge-stream": "2.0.0",
63
- "regenerator-runtime": "0.13.9",
64
- "rollup": "2.73.0",
65
- "rollup-plugin-terser": "7.0.2",
66
- "rollup-plugin-typescript2": "0.31.2",
67
- "ts-jest": "28.0.2",
68
- "tslib": "2.4.0",
69
- "typescript": "^4.6.4"
66
+ "regenerator-runtime": "0.14.0",
67
+ "rollup": "4.3.0",
68
+ "rollup-plugin-typescript2": "0.36.0",
69
+ "sucrase": "3.34.0",
70
+ "tslib": "2.6.2",
71
+ "typescript": "^5.2.2"
70
72
  }
71
73
  }
package/rollup.js CHANGED
@@ -1,14 +1,21 @@
1
+ import { readFileSync } from "node:fs";
2
+
1
3
  import { DEFAULT_EXTENSIONS as babelDefaultExtensions } from "@babel/core";
2
4
  import { babel } from "@rollup/plugin-babel";
3
5
  import commonjs from "@rollup/plugin-commonjs";
4
6
  import json from "@rollup/plugin-json";
5
7
  import resolve from "@rollup/plugin-node-resolve";
6
8
  import replace from "@rollup/plugin-replace";
9
+ import terser from "@rollup/plugin-terser";
7
10
  import { defineConfig } from "rollup";
8
- import { terser } from "rollup-plugin-terser";
9
11
  import typescript from "rollup-plugin-typescript2";
10
12
  import ts from "typescript";
11
13
 
14
+ const getPackageInfo = () => {
15
+ const { name, version } = JSON.parse(readFileSync("./package.json"));
16
+ return { name, version };
17
+ };
18
+
12
19
  const makeConfig = ({
13
20
  outputOptions = {},
14
21
  globalOptions = {},
@@ -16,7 +23,8 @@ const makeConfig = ({
16
23
  isNodeOnlyBuild = false,
17
24
  }) => {
18
25
  const source = "src/index";
19
- const destination = "dist/index";
26
+ const destinationDirectory = "dist";
27
+ const destination = `${destinationDirectory}/index`;
20
28
 
21
29
  outputOptions = {
22
30
  sourcemap: true,
@@ -62,11 +70,20 @@ const makeConfig = ({
62
70
  },
63
71
  ];
64
72
 
73
+ let sourcemapBaseUrl;
65
74
  if (!isNodeOnlyBuild) {
75
+ // In builds that are published to NPM (potentially every CI build), point to sourcemaps via the
76
+ // package's canonical unpkg URL
77
+ if (process.env.CI) {
78
+ const { name, version } = getPackageInfo();
79
+ sourcemapBaseUrl = `https://unpkg.com/${name}@${version}/${destinationDirectory}/`;
80
+ }
81
+
66
82
  output.push({
67
83
  // Build file to be used for tinkering in modern browsers
68
84
  file: `${destination}.browser.js`,
69
85
  format: "iife",
86
+ sourcemapBaseUrl,
70
87
  ...outputOptions,
71
88
  ...iifeOutputOptions,
72
89
  });
@@ -103,6 +120,7 @@ const makeConfig = ({
103
120
  file: `${destination}.browser.min.js`,
104
121
  format: "iife",
105
122
  plugins: [terser()],
123
+ sourcemapBaseUrl,
106
124
  ...outputOptions,
107
125
  ...iifeOutputOptions,
108
126
  },
@@ -148,5 +166,5 @@ export const makeCoreRollupConfig = () =>
148
166
  export const makeNodeRollupConfig = () =>
149
167
  makeConfig({
150
168
  globalOptions: { external: ["jspsych"] },
151
- nodeOnly: true,
169
+ isNodeOnlyBuild: true,
152
170
  });