@jspsych/config 2.0.2 → 3.0.1
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.
- package/CHANGELOG.md +14 -0
- package/jest.cjs +1 -0
- package/package.json +6 -16
- package/rollup.js +82 -81
- package/tsconfig.contrib.json +1 -1
- package/tsconfig.core.json +0 -3
- package/tsconfig.json +3 -14
- package/babel.cjs +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @jspsych/config
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3401](https://github.com/jspsych/jsPsych/pull/3401) [`db7bcf82`](https://github.com/jspsych/jsPsych/commit/db7bcf82f6491ac8d02c7c4cf89e42d4ddcde1d9) Thanks [@jadeddelta](https://github.com/jadeddelta)! - allow JSON resolution in contrib repository for usage of package.json in versioning
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#2858](https://github.com/jspsych/jsPsych/pull/2858) [`76e75080`](https://github.com/jspsych/jsPsych/commit/76e75080247e936c6ae8a8227517fb95ce74974b) Thanks [@bjoluc](https://github.com/bjoluc)! - Activate TypeScript's `isolatedModules` flag in the root `tsconfig.json` file. If you are facing any TypeScript errors due to `isolatedModules`, please update your code according to the error messages.
|
|
14
|
+
|
|
15
|
+
- [#2858](https://github.com/jspsych/jsPsych/pull/2858) [`810ed7a3`](https://github.com/jspsych/jsPsych/commit/810ed7a3d1d9181cf25a9cb11ddd37914cd97483) Thanks [@bjoluc](https://github.com/bjoluc)! - Migrate the build chain from TypeScript, Babel, and Terser to [esbuild](https://esbuild.github.io/). Babel and Terser are no longer included as dependencies and the Babel configuration at `@jspsych/config/babel` has been removed. The minified browser builds are only transpiled down to [ES2015](https://caniuse.com/es6) now.
|
|
16
|
+
|
|
3
17
|
## 2.0.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/jest.cjs
CHANGED
|
@@ -8,6 +8,7 @@ module.exports.makePackageConfig = (dirname) => {
|
|
|
8
8
|
return {
|
|
9
9
|
transform: { "\\.(js|jsx|ts|tsx)$": "@sucrase/jest-plugin" },
|
|
10
10
|
moduleNameMapper: hq.load(dirname + "/tsconfig.json").get("jest"),
|
|
11
|
+
|
|
11
12
|
testEnvironment: "jsdom",
|
|
12
13
|
testEnvironmentOptions: {
|
|
13
14
|
fetchExternalResources: true,
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspsych/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Shared (build) configuration for jsPsych packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
"./babel": {
|
|
8
|
-
"import": null,
|
|
9
|
-
"require": "./babel.cjs"
|
|
10
|
-
},
|
|
11
7
|
"./gulp": {
|
|
12
8
|
"import": "./gulp.js",
|
|
13
9
|
"require": null
|
|
@@ -39,33 +35,27 @@
|
|
|
39
35
|
},
|
|
40
36
|
"homepage": "https://www.jspsych.org/latest/developers/configuration",
|
|
41
37
|
"dependencies": {
|
|
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
38
|
"@rollup/plugin-commonjs": "25.0.7",
|
|
47
|
-
"@rollup/plugin-json": "6.0.1",
|
|
48
39
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
49
|
-
"@rollup/plugin-replace": "5.0.5",
|
|
50
|
-
"@rollup/plugin-terser": "0.4.4",
|
|
51
40
|
"@sucrase/jest-plugin": "3.0.0",
|
|
52
41
|
"@types/gulp": "4.0.17",
|
|
53
42
|
"@types/jest": "29.5.8",
|
|
54
43
|
"alias-hq": "6.2.3",
|
|
55
|
-
"babel-preset-minify": "0.5.2",
|
|
56
44
|
"canvas": "^2.11.2",
|
|
45
|
+
"esbuild": "0.15.14",
|
|
57
46
|
"gulp": "4.0.2",
|
|
58
47
|
"gulp-cli": "2.3.0",
|
|
59
|
-
"gulp-file": "
|
|
48
|
+
"gulp-file": "0.4.0",
|
|
60
49
|
"gulp-rename": "2.0.0",
|
|
61
50
|
"gulp-replace": "1.1.4",
|
|
62
51
|
"gulp-zip": "6.0.0",
|
|
63
52
|
"jest": "29.7.0",
|
|
64
53
|
"jest-environment-jsdom": "29.7.0",
|
|
65
54
|
"merge-stream": "2.0.0",
|
|
66
|
-
"regenerator-runtime": "0.14.0",
|
|
67
55
|
"rollup": "4.3.0",
|
|
68
|
-
"rollup-plugin-
|
|
56
|
+
"rollup-plugin-dts": "5.0.0",
|
|
57
|
+
"rollup-plugin-esbuild": "5.0.0",
|
|
58
|
+
"rollup-plugin-node-externals": "5.0.2",
|
|
69
59
|
"sucrase": "3.34.0",
|
|
70
60
|
"tslib": "2.6.2",
|
|
71
61
|
"typescript": "^5.2.2"
|
package/rollup.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "path";
|
|
2
3
|
|
|
3
|
-
import { DEFAULT_EXTENSIONS as babelDefaultExtensions } from "@babel/core";
|
|
4
|
-
import { babel } from "@rollup/plugin-babel";
|
|
5
4
|
import commonjs from "@rollup/plugin-commonjs";
|
|
6
|
-
import json from "@rollup/plugin-json";
|
|
7
5
|
import resolve from "@rollup/plugin-node-resolve";
|
|
8
|
-
import replace from "@rollup/plugin-replace";
|
|
9
|
-
import terser from "@rollup/plugin-terser";
|
|
10
6
|
import { defineConfig } from "rollup";
|
|
11
|
-
import
|
|
7
|
+
import dts from "rollup-plugin-dts";
|
|
8
|
+
import esbuild from "rollup-plugin-esbuild";
|
|
9
|
+
import externals from "rollup-plugin-node-externals";
|
|
12
10
|
import ts from "typescript";
|
|
13
11
|
|
|
12
|
+
const getTsCompilerOptions = () => {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
return ts.parseJsonConfigFileContent(
|
|
15
|
+
ts.readConfigFile(path.join(cwd, "tsconfig.json"), ts.sys.readFile).config,
|
|
16
|
+
ts.sys,
|
|
17
|
+
cwd
|
|
18
|
+
).options;
|
|
19
|
+
};
|
|
20
|
+
|
|
14
21
|
const getPackageInfo = () => {
|
|
15
22
|
const { name, version } = JSON.parse(readFileSync("./package.json"));
|
|
16
23
|
return { name, version };
|
|
@@ -22,7 +29,7 @@ const makeConfig = ({
|
|
|
22
29
|
iifeOutputOptions = {},
|
|
23
30
|
isNodeOnlyBuild = false,
|
|
24
31
|
}) => {
|
|
25
|
-
const
|
|
32
|
+
const input = "src/index.ts";
|
|
26
33
|
const destinationDirectory = "dist";
|
|
27
34
|
const destination = `${destinationDirectory}/index`;
|
|
28
35
|
|
|
@@ -31,100 +38,94 @@ const makeConfig = ({
|
|
|
31
38
|
...outputOptions,
|
|
32
39
|
};
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/** @type{import("rollup-plugin-esbuild").Options} */
|
|
42
|
+
const esBuildPluginOptions = {
|
|
43
|
+
loaders: { ".json": "json" },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** @type{import("@rollup/plugin-commonjs").RollupCommonJSOptions} */
|
|
47
|
+
const commonjsPluginOptions = {
|
|
48
|
+
extensions: [".js", ".json"],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Non-babel builds
|
|
52
|
+
const config = defineConfig([
|
|
53
|
+
// Type definitions (bundled as a single .d.ts file)
|
|
54
|
+
{
|
|
55
|
+
input,
|
|
56
|
+
output: [{ file: `${destination}.d.ts`, format: "es" }],
|
|
57
|
+
plugins: [
|
|
58
|
+
dts({
|
|
44
59
|
compilerOptions: {
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
...getTsCompilerOptions(),
|
|
61
|
+
noEmit: false,
|
|
47
62
|
paths: {}, // Do not include files referenced via `paths`
|
|
48
63
|
},
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
json(),
|
|
52
|
-
commonjs(),
|
|
53
|
-
],
|
|
54
|
-
...globalOptions,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
/** @type {import("rollup").OutputOptions} */
|
|
58
|
-
const output = [
|
|
59
|
-
{
|
|
60
|
-
// Build file to be used as an ES import
|
|
61
|
-
file: `${destination}.js`,
|
|
62
|
-
format: "esm",
|
|
63
|
-
...outputOptions,
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
64
66
|
},
|
|
67
|
+
|
|
68
|
+
// Module builds
|
|
65
69
|
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
...globalOptions,
|
|
71
|
+
input,
|
|
72
|
+
plugins: [
|
|
73
|
+
externals(),
|
|
74
|
+
esbuild({ ...esBuildPluginOptions, target: "node18" }),
|
|
75
|
+
commonjs(commonjsPluginOptions),
|
|
76
|
+
],
|
|
77
|
+
output: [
|
|
78
|
+
{ file: `${destination}.js`, format: "esm", ...outputOptions },
|
|
79
|
+
{ file: `${destination}.cjs`, format: "cjs", ...outputOptions },
|
|
80
|
+
],
|
|
70
81
|
},
|
|
71
|
-
];
|
|
82
|
+
]);
|
|
72
83
|
|
|
73
|
-
let sourcemapBaseUrl;
|
|
74
84
|
if (!isNodeOnlyBuild) {
|
|
75
85
|
// In builds that are published to NPM (potentially every CI build), point to sourcemaps via the
|
|
76
86
|
// package's canonical unpkg URL
|
|
87
|
+
let sourcemapBaseUrl;
|
|
77
88
|
if (process.env.CI) {
|
|
78
89
|
const { name, version } = getPackageInfo();
|
|
79
90
|
sourcemapBaseUrl = `https://unpkg.com/${name}@${version}/${destinationDirectory}/`;
|
|
80
91
|
}
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
// IIFE build for tinkering in modern browsers
|
|
94
|
+
config.push({
|
|
95
|
+
...globalOptions,
|
|
96
|
+
input,
|
|
97
|
+
plugins: [
|
|
98
|
+
externals({ deps: false }),
|
|
99
|
+
resolve({ preferBuiltins: false }),
|
|
100
|
+
esbuild({ ...esBuildPluginOptions, target: "esnext" }),
|
|
101
|
+
commonjs(commonjsPluginOptions),
|
|
102
|
+
],
|
|
103
|
+
output: {
|
|
104
|
+
file: `${destination}.browser.js`,
|
|
105
|
+
format: "iife",
|
|
106
|
+
sourcemapBaseUrl,
|
|
107
|
+
...outputOptions,
|
|
108
|
+
...iifeOutputOptions,
|
|
109
|
+
},
|
|
89
110
|
});
|
|
90
|
-
}
|
|
91
111
|
|
|
92
|
-
|
|
93
|
-
const config = defineConfig([{ ...commonConfig, output }]);
|
|
94
|
-
|
|
95
|
-
if (!isNodeOnlyBuild) {
|
|
96
|
-
// Babel build
|
|
112
|
+
// Minified production IIFE build
|
|
97
113
|
config.push({
|
|
98
|
-
...
|
|
114
|
+
...globalOptions,
|
|
115
|
+
input,
|
|
99
116
|
plugins: [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
'import "regenerator-runtime/runtime.js";',
|
|
105
|
-
},
|
|
106
|
-
delimiters: ["", ""],
|
|
107
|
-
preventAssignment: true,
|
|
108
|
-
}),
|
|
109
|
-
...commonConfig.plugins,
|
|
110
|
-
babel({
|
|
111
|
-
babelHelpers: "bundled",
|
|
112
|
-
extends: "@jspsych/config/babel",
|
|
113
|
-
// https://github.com/ezolenko/rollup-plugin-typescript2#rollupplugin-babel
|
|
114
|
-
extensions: [...babelDefaultExtensions, ".ts"],
|
|
115
|
-
}),
|
|
116
|
-
],
|
|
117
|
-
output: [
|
|
118
|
-
{
|
|
119
|
-
// Minified production build file
|
|
120
|
-
file: `${destination}.browser.min.js`,
|
|
121
|
-
format: "iife",
|
|
122
|
-
plugins: [terser()],
|
|
123
|
-
sourcemapBaseUrl,
|
|
124
|
-
...outputOptions,
|
|
125
|
-
...iifeOutputOptions,
|
|
126
|
-
},
|
|
117
|
+
externals({ deps: false }),
|
|
118
|
+
resolve({ preferBuiltins: false }),
|
|
119
|
+
esbuild({ ...esBuildPluginOptions, target: "es2015", minify: true }),
|
|
120
|
+
commonjs(commonjsPluginOptions),
|
|
127
121
|
],
|
|
122
|
+
output: {
|
|
123
|
+
file: `${destination}.browser.min.js`,
|
|
124
|
+
format: "iife",
|
|
125
|
+
sourcemapBaseUrl,
|
|
126
|
+
...outputOptions,
|
|
127
|
+
...iifeOutputOptions,
|
|
128
|
+
},
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
131
|
|
package/tsconfig.contrib.json
CHANGED
package/tsconfig.core.json
CHANGED
|
@@ -7,8 +7,5 @@
|
|
|
7
7
|
"jspsych": ["../jspsych/src"],
|
|
8
8
|
"@jspsych/*": ["../*/src"]
|
|
9
9
|
},
|
|
10
|
-
// allow resolving json modules in tests (needed for transitive imports of jspsych in tests;
|
|
11
|
-
// the jspsych package itself uses https://stackoverflow.com/a/61426303 instead)
|
|
12
|
-
"resolveJsonModule": true
|
|
13
10
|
}
|
|
14
11
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
// shared base tsconfig for all jsPsych packages
|
|
3
|
-
// based on https://github.com/formium/tsdx/blob/462af2d002987f985695b98400e0344b8f2754b7/templates/basic/tsconfig.json
|
|
4
|
-
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
|
|
5
2
|
"compilerOptions": {
|
|
6
3
|
"target": "ES6",
|
|
7
4
|
"module": "ESNext",
|
|
8
5
|
"lib": ["dom", "esnext"],
|
|
9
6
|
"importHelpers": true,
|
|
10
|
-
// output .d.ts declaration files for consumers
|
|
11
7
|
"declaration": true,
|
|
12
|
-
// output .js.map sourcemap files for consumers
|
|
13
8
|
"sourceMap": true,
|
|
14
|
-
// stricter type-checking for stronger correctness. Recommended by TS
|
|
15
9
|
"strict": false, // should be enabled one lucky day
|
|
16
|
-
// linter checks for common issues
|
|
17
10
|
"noImplicitReturns": true,
|
|
18
11
|
"noFallthroughCasesInSwitch": true,
|
|
19
|
-
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
|
|
20
12
|
"noUnusedLocals": false, // should be enabled one lucky day
|
|
21
13
|
"noUnusedParameters": false, // should be enabled one lucky day
|
|
22
|
-
// use Node's module resolution algorithm, instead of the legacy TS one
|
|
23
14
|
"moduleResolution": "node",
|
|
24
|
-
// interop between ESM and CJS modules. Recommended by TS
|
|
25
15
|
"esModuleInterop": true,
|
|
26
|
-
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
|
|
27
16
|
"skipLibCheck": true,
|
|
28
|
-
// error out if import and file system have a casing mismatch. Recommended by TS
|
|
29
17
|
"forceConsistentCasingInFileNames": true,
|
|
30
|
-
|
|
31
|
-
"
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"isolatedModules": true, // required by Sucrase
|
|
20
|
+
"resolveJsonModule": true, // required for automatic package versioning and needed for transitive imports of jspsych
|
|
32
21
|
}
|
|
33
22
|
}
|
package/babel.cjs
DELETED