Skip to content

Commit

Permalink
Update to TypeScript v4.3.5 (#332)
Browse files Browse the repository at this point in the history
* chore(typescript): update to TypeScript 4.3.5

Update to TypeScript 4.3.5. Also required updating eslint and closure-compiler.

fix #331

* chore(closure-compiler): remove @export comment that breaks newest closure-compiler
  • Loading branch information
trxcllnt authored Jul 22, 2021
1 parent 01b8a46 commit 0637a25
Show file tree
Hide file tree
Showing 314 changed files with 596 additions and 1,517 deletions.
419 changes: 90 additions & 329 deletions .eslintrc.js

Large diffs are not rendered by default.

67 changes: 50 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,74 @@
"args": [
"build",
// Specify we want to debug the "src" target, which won't clean or build -- essentially a "dry-run" of the gulp build
"--target", "src"
"--target",
"src"
]
},
{
"type": "node",
"request": "launch",
"name": "Debug Unit Tests",
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"skipFiles": [
"<node_internals>/**/*.js",
"${workspaceFolder}/node_modules/**/*.js"
],
"env": {
"NODE_NO_WARNINGS": "1",
"READABLE_STREAM": "disable",
"TEST_DOM_STREAMS": "true",
"TEST_NODE_STREAMS": "true",
// Modify these environment variables to run tests on a specific compilation target + module format combo
// "TEST_TS_SOURCE": "true",
"TEST_TS_SOURCE": "false",
"TEST_TARGET": "es5",
"TEST_MODULE": "cjs"
},
"args": [
"-i",
"--verbose",
"-runInBand",
"--no-cache",
"-c", "jestconfigs/jest.src.config.js",
// "-c", "jestconfigs/jest.es5.umd.config.js",
"spec/iterable/",
"spec/asynciterable/",
"spec/iterable-operators/",
"spec/asynciterable-operators/",
// "spec/asynciterable/toobservable-spec.ts"
"-c", "jestconfigs/jest.${input:TEST_TARGET}.config.js",
"${input:TEST_FILE}"
]
}
]
}
],
"inputs": [
{
"type": "pickString",
"default": "src",
"id": "TEST_TARGET",
"options": [
"src",
"ix",
"ts",
"es5.cjs",
"es5.esm",
"es5.umd",
"es2015.cjs",
"es2015.esm",
"es2015.umd",
"esnext.cjs",
"esnext.esm",
"esnext.umd",
],
"description": "The JS version + Module format combination to test (or src to test source files)",
},
{
"type": "command",
"id": "TEST_FILE",
"command": "shellCommand.execute",
"args": {
"cwd": "${workspaceFolder}",
"description": "Select a file to debug",
"command": "./node_modules/.bin/jest --listTests | sed -r \"s@$PWD/spec/@@g\"",
}
},
{
"type": "command",
"id": "TEST_RUNTIME_ARGS",
"command": "shellCommand.execute",
"args": {
"useSingleResult": "true",
"command": "case \"${input:TEST_TARGET}\" in *cjs | *umd | ix) echo '';; *) echo '--experimental-vm-modules';; esac"
}
},
],
}
10 changes: 6 additions & 4 deletions gulp/closure-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ const closureTask = ((cache) => memoizeTask(cache, async function closure(target
`${src}/**/*.js` /* <-- then sources globs */
], { base: `./` }),
sourcemaps.init(),
closureCompiler(createClosureArgs(entry_point, entry, externsPath, getUMDExportName(entry))),
closureCompiler(createClosureArgs(target, entry_point, entry, externsPath, getUMDExportName(entry)), {
platform: ['native', 'java', 'javascript']
}),
// rename the sourcemaps from *.js.map files to *.min.js.map
sourcemaps.write(`.`, { mapFile: (mapPath) => mapPath.replace(`.js.map`, `.${target}.min.js.map`) }),
gulp.dest(out)
).toPromise();
}
}))({});

const createClosureArgs = (entry_point, output, externs, libraryName) => ({
const createClosureArgs = (target, entry_point, output, externs, libraryName) => ({
externs,
entry_point,
third_party: true,
Expand All @@ -97,8 +99,8 @@ const createClosureArgs = (entry_point, output, externs, libraryName) => ({
package_json_entry_names: `module,jsnext:main,main`,
assume_function_wrapper: true,
js_output_file: `${output}.js`,
language_in: gCCLanguageNames[`es2015`],
language_out: gCCLanguageNames[`esnext`],
language_in: gCCLanguageNames[`esnext`],
language_out: gCCLanguageNames[target],
output_wrapper: `(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['${libraryName}'], factory) :
Expand Down
12 changes: 5 additions & 7 deletions gulp/compile-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ const { npmPkgName } = require('./util');
const { memoizeTask } = require('./memoize-task');
const { empty: ObservableEmpty } = require('rxjs');

const minifyTask = require('./minify-task');
const closureTask = require('./closure-task');
const typescriptTask = require('./typescript-task');
const { copyMainTask, copyTSTask } = require('./copy-main-task');

const compileTask = ((cache) => memoizeTask(cache, function compile(target, format, ...args) {
return target === `src` ? ObservableEmpty()
: target === npmPkgName ? copyMainTask(target, format, ...args)()
: target === `ts` ? copyTSTask(target, format, ...args)()
: format === `umd` ? target === `es5` ? closureTask(target, format, ...args)()
: minifyTask(target, format, ...args)()
: typescriptTask(target, format, ...args)();
return target === `src` ? ObservableEmpty()
: target === npmPkgName ? copyMainTask(target, format, ...args)()
: target === `ts` ? copyTSTask(target, format, ...args)()
: format === `umd` ? closureTask(target, format, ...args)()
: typescriptTask(target, format, ...args)();
}))({});

module.exports = compileTask;
Expand Down
103 changes: 0 additions & 103 deletions gulp/minify-task.js

This file was deleted.

23 changes: 13 additions & 10 deletions gulp/test-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ const path = require('path');
const { argv } = require('./argv');
const child_process = require(`child_process`);
const { memoizeTask } = require('./memoize-task');
const { targetAndModuleCombinations } = require('./util');
const asyncDone = require('util').promisify(require('async-done'));

const jestArgv = [];
argv.verbose && jestArgv.push(`--verbose`);
const jestArgv = [`--reporters=jest-silent-reporter`];

if (argv.verbose) {
jestArgv.push(`--verbose`);
}

if (targetAndModuleCombinations.length > 1) {
jestArgv.push(`--detectOpenHandles`, `--no-cache`);
}

const jest = path.join(path.parse(require.resolve(`jest`)).dir, `../bin/jest.js`);
const testOptions = {
Expand All @@ -31,27 +39,22 @@ const testOptions = {
...process.env,
// hide fs.promises/stream[Symbol.asyncIterator] warnings
NODE_NO_WARNINGS: `1`,
// prevent the user-land `readable-stream` module from
// patching node's streams -- they're better now
READABLE_STREAM: `disable`
TS_JEST_DISABLE_VER_CHECKER: true
},
};

const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format) {
const args = [...execArgv];
const opts = { ...testOptions };
if (argv.coverage) {
args.push(`-c`, `jest.coverage.config.js`, `--coverage`, `--no-cache`);
args.push(`-c`, `jest.coverage.config.js`, `--coverage`);
} else {
const cfgname = [target, format].filter(Boolean).join('.');
args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `-i`, `--no-cache`, `spec/*`);
args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `spec/*`);
}
opts.env = { ...opts.env,
TEST_TARGET: target,
TEST_MODULE: format,
TEST_DOM_STREAMS: (target ==='src' || format === 'umd').toString(),
TEST_NODE_STREAMS: (target ==='src' || format !== 'umd').toString(),
TEST_TS_SOURCE: !!argv.coverage || (target === 'src') || (opts.env.TEST_TS_SOURCE === 'true')
};
return asyncDone(() => child_process.spawn(`node`, args, opts));
}))({}, [jest, ...jestArgv], testOptions);
Expand Down
24 changes: 16 additions & 8 deletions gulp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,19 @@ function shouldRunInChildProcess(target, format) {

const gulp = path.join(path.parse(require.resolve(`gulp`)).dir, `bin/gulp.js`);
function spawnGulpCommandInChildProcess(command, target, format) {
const args = [gulp, command, '-t', target, '-m', format, `--silent`];
const opts = {
stdio: [`ignore`, `inherit`, `inherit`],
env: { ...process.env, NODE_NO_WARNINGS: `1` }
};
return asyncDone(() => child_process.spawn(`node`, args, opts))
.catch((e) => { throw `Error in "${command}:${taskName(target, format)}" task`; });
const err = [];
return asyncDone(() => {
const child = child_process.spawn(
`node`,
[gulp, command, '-t', target, '-m', format, `-L`],
{
stdio: [`ignore`, `ignore`, `pipe`],
env: { ...process.env, NODE_NO_WARNINGS: `1` }
});
child.stderr.on('data', (line) => err.push(line));
return child;
}).catch(() => Promise.reject(err.length > 0 ? err.join('\n')
: `Error in "${command}:${taskName(target, format)}" task.`));
}

const logAndDie = (e) => { if (e) { process.exit(1) } };
Expand Down Expand Up @@ -230,5 +236,7 @@ module.exports = {
gCCLanguageNames, UMDSourceTargets, terserLanguageNames,

taskName, packageName, tsconfigName, targetDir, combinations, observableFromStreams,
ESKeywords, esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess, getUMDExportName
ESKeywords, esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess, getUMDExportName,

targetAndModuleCombinations: [...combinations(targets, modules)]
};
5 changes: 1 addition & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@

module.exports = {
"verbose": false,
"reporters": [
["jest-silent-reporter", { "useDots": true, "showWarnings": true }]
],
"testEnvironment": "node",
"globals": {
"ts-jest": {
"diagnostics": false,
"tsConfig": "spec/tsconfig.json"
}
},
"rootDir": "../",
"rootDir": "./",
"roots": [
"<rootDir>/spec/"
],
Expand Down
5 changes: 3 additions & 2 deletions jestconfigs/jest.es2015.cjs.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module.exports = {
...require('../jest.config'),
"rootDir": "../",
"globals": {
"ts-jest": {
"diagnostics": false,
"tsConfig": "spec/tsconfig/tsconfig.es2015.cjs.json"
"tsConfig": "<rootDir>/spec/tsconfig/tsconfig.es2015.cjs.json"
}
},
"moduleNameMapper": {
"^ix(.*)": "<rootDir>/targets/es2015/cjs$1"
}
}
};
5 changes: 3 additions & 2 deletions jestconfigs/jest.es2015.esm.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module.exports = {
...require('../jest.config'),
"rootDir": "../",
"globals": {
"ts-jest": {
"diagnostics": false,
"tsConfig": "spec/tsconfig/tsconfig.es2015.esm.json"
"tsConfig": "<rootDir>/spec/tsconfig/tsconfig.es2015.esm.json"
}
},
"moduleNameMapper": {
"^ix(.*)": "<rootDir>/targets/es2015/esm$1"
}
}
};
Loading

0 comments on commit 0637a25

Please sign in to comment.