From c95c350d6b95f93609dea568772bf24631915402 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 3 Jan 2024 09:37:46 -0800 Subject: [PATCH] formatting --- gulp/argv.js | 23 +-- gulp/bundle-task.js | 151 +++++++++-------- gulp/clean-task.js | 13 +- gulp/closure-task.js | 235 ++++++++++++++------------ gulp/compile-task.js | 19 ++- gulp/copy-main-task.js | 52 ++++-- gulp/memoize-task.js | 20 +-- gulp/package-task.js | 110 ++++++------ gulp/test-task.js | 43 ++--- gulp/typescript-task.js | 69 +++++--- gulp/util.js | 166 ++++++++++++------ gulpfile.js | 111 ++++++------ jest.config.js | 55 +++--- jest.coverage.config.js | 14 +- jestconfigs/jest.es2015.cjs.config.js | 20 +-- jestconfigs/jest.es2015.esm.config.js | 22 +-- jestconfigs/jest.es2015.umd.config.js | 27 +-- jestconfigs/jest.es5.cjs.config.js | 20 +-- jestconfigs/jest.es5.esm.config.js | 22 +-- jestconfigs/jest.es5.umd.config.js | 27 +-- jestconfigs/jest.esnext.cjs.config.js | 20 +-- jestconfigs/jest.esnext.esm.config.js | 22 +-- jestconfigs/jest.esnext.umd.config.js | 27 +-- jestconfigs/jest.ix.config.js | 20 +-- jestconfigs/jest.src.config.js | 24 +-- jestconfigs/jest.ts.config.js | 24 +-- 26 files changed, 742 insertions(+), 614 deletions(-) diff --git a/gulp/argv.js b/gulp/argv.js index 30576c27..cb2ff2a0 100644 --- a/gulp/argv.js +++ b/gulp/argv.js @@ -16,16 +16,19 @@ // under the License. import args from 'command-line-args'; -const argv = args([ - { name: `all`, type: Boolean }, - { name: 'verbose', alias: 'v', type: Boolean }, - { name: `target`, type: String, defaultValue: `` }, - { name: `module`, type: String, defaultValue: `` }, - { name: `coverage`, type: Boolean, defaultValue: false }, - { name: `tests`, type: String, multiple: true, defaultValue: [`spec/*`] }, - { name: `targets`, alias: `t`, type: String, multiple: true, defaultValue: [] }, - { name: `modules`, alias: `m`, type: String, multiple: true, defaultValue: [] }, -], { partial: true }); +const argv = args( + [ + { name: `all`, type: Boolean }, + { name: 'verbose', alias: 'v', type: Boolean }, + { name: `target`, type: String, defaultValue: `` }, + { name: `module`, type: String, defaultValue: `` }, + { name: `coverage`, type: Boolean, defaultValue: false }, + { name: `tests`, type: String, multiple: true, defaultValue: [`spec/*`] }, + { name: `targets`, alias: `t`, type: String, multiple: true, defaultValue: [] }, + { name: `modules`, alias: `m`, type: String, multiple: true, defaultValue: [] }, + ], + { partial: true } +); const { targets, modules } = argv; diff --git a/gulp/bundle-task.js b/gulp/bundle-task.js index 04060e08..9ef22577 100644 --- a/gulp/bundle-task.js +++ b/gulp/bundle-task.js @@ -46,91 +46,96 @@ const __dirname = dirname(__filename); const bundleDir = resolve(__dirname, '../spec/bundle'); const fileNames = readdirSync(bundleDir) - .filter(fileName => fileName.endsWith('.js')) - .map(fileName => fileName.replace(/\.js$/, '')); + .filter((fileName) => fileName.endsWith('.js')) + .map((fileName) => fileName.replace(/\.js$/, '')); const bundlesGlob = join(bundleDir, '**.js'); const esbuildDir = join(bundleDir, 'esbuild'); -export const esbuildTask = (minify = true) => () => observableFromStreams( - gulp.src(bundlesGlob), - gulpEsbuild({ - bundle: true, - minify, - treeShaking: true, - plugins: [ - esbuildAlias({ - [npmPkgName]: resolve(__dirname, `../targets/${npmPkgName}/${mainExport}.dom.mjs`), - }), - ], - }), - gulpRename((p) => { p.basename += '-bundle'; }), - gulp.dest(esbuildDir), - size({ gzip: true }) -); - -const rollupDir = join(bundleDir, 'rollup'); -export const rollupTask = (minify = true) => () => ObservableForkJoin( - fileNames.map(fileName => observableFromStreams( - rollupStream({ - input: join(bundleDir, `${fileName}.js`), - output: { format: 'commonjs' }, +export const esbuildTask = (minify = true) => () => + observableFromStreams( + gulp.src(bundlesGlob), + gulpEsbuild({ + bundle: true, + minify, + treeShaking: true, plugins: [ - rollupAlias({ - entries: { [npmPkgName]: resolve(__dirname, `../targets/es2015/esm/`) } + esbuildAlias({ + [npmPkgName]: resolve(__dirname, `../targets/${npmPkgName}/${mainExport}.dom.mjs`), }), - nodeResolve() ], - onwarn: (message) => { - if (message.code === 'CIRCULAR_DEPENDENCY') return - console.error(message); - } }), - source(`${fileName}-bundle.js`), - buffer(), - ...(minify ? [terser()] : []), - gulp.dest(rollupDir), + gulpRename((p) => { + p.basename += '-bundle'; + }), + gulp.dest(esbuildDir), size({ gzip: true }) - )) -) + ); + +const rollupDir = join(bundleDir, 'rollup'); +export const rollupTask = (minify = true) => () => + ObservableForkJoin( + fileNames.map((fileName) => + observableFromStreams( + rollupStream({ + input: join(bundleDir, `${fileName}.js`), + output: { format: 'commonjs' }, + plugins: [ + rollupAlias({ + entries: { [npmPkgName]: resolve(__dirname, `../targets/es2015/esm/`) }, + }), + nodeResolve(), + ], + onwarn: (message) => { + if (message.code === 'CIRCULAR_DEPENDENCY') return; + console.error(message); + }, + }), + source(`${fileName}-bundle.js`), + buffer(), + ...(minify ? [terser()] : []), + gulp.dest(rollupDir), + size({ gzip: true }) + ) + ) + ); const webpackDir = join(bundleDir, 'webpack'); -export const webpackTask = (opts = { minify: true, analyze: false }) => () => observableFromStreams( - gulp.src(bundlesGlob), - named(), - webpack({ - mode: opts?.minify == false ? 'development' : 'production', - optimization: { - usedExports: true - }, - output: { - filename: '[name]-bundle.js' - }, - module: { - rules: [ - { - resolve: { - fullySpecified: false, - mainFields: ['module', 'main'] - } - } - ] - }, - resolve: { - alias: { [npmPkgName]: resolve(__dirname, `../targets/es2015/esm/`) } - }, - stats: 'errors-only', - plugins: opts?.analyze ? [new BundleAnalyzerPlugin()] : [] - }), - gulp.dest(webpackDir), - size({ gzip: true }) -); +export const webpackTask = (opts = { minify: true, analyze: false }) => () => + observableFromStreams( + gulp.src(bundlesGlob), + named(), + webpack({ + mode: opts?.minify == false ? 'development' : 'production', + optimization: { + usedExports: true, + }, + output: { + filename: '[name]-bundle.js', + }, + module: { + rules: [ + { + resolve: { + fullySpecified: false, + mainFields: ['module', 'main'], + }, + }, + ], + }, + resolve: { + alias: { [npmPkgName]: resolve(__dirname, `../targets/es2015/esm/`) }, + }, + stats: 'errors-only', + plugins: opts?.analyze ? [new BundleAnalyzerPlugin()] : [], + }), + gulp.dest(webpackDir), + size({ gzip: true }) + ); -export const execBundleTask = () => () => observableFromStreams( - gulp.src(join(bundleDir, '**/**-bundle.js')), - async (generator) => { +export const execBundleTask = () => () => + observableFromStreams(gulp.src(join(bundleDir, '**/**-bundle.js')), async (generator) => { for await (const file of generator) { console.log(`executing ${file.path}`); execSync(`node ${file.path}`); } - } -); + }); diff --git a/gulp/clean-task.js b/gulp/clean-task.js index 1dd290f8..bccb1b88 100644 --- a/gulp/clean-task.js +++ b/gulp/clean-task.js @@ -19,15 +19,12 @@ import del from 'del'; import { targetDir } from './util.js'; import memoizeTask from './memoize-task.js'; import { catchError } from 'rxjs/operators/index.js'; -import { - from as ObservableFrom, - empty as ObservableEmpty, -} from 'rxjs'; +import { from as ObservableFrom, empty as ObservableEmpty } from 'rxjs'; -export const cleanTask = ((cache) => memoizeTask(cache, function clean(target, format) { +export const cleanTask = ((cache) => + memoizeTask(cache, function clean(target, format) { const dir = targetDir(target, format); - return ObservableFrom(del(dir)) - .pipe(catchError((e) => ObservableEmpty())); -}))({}); + return ObservableFrom(del(dir)).pipe(catchError((e) => ObservableEmpty())); + }))({}); export default cleanTask; diff --git a/gulp/closure-task.js b/gulp/closure-task.js index a5951ea6..99cd7d47 100644 --- a/gulp/closure-task.js +++ b/gulp/closure-task.js @@ -16,14 +16,14 @@ // under the License. import { - targetDir, - mainExport, - esmRequire, - getUMDExportName, - gCCLanguageNames, - observableFromStreams, - shouldRunInChildProcess, - spawnGulpCommandInChildProcess, + targetDir, + mainExport, + esmRequire, + getUMDExportName, + gCCLanguageNames, + observableFromStreams, + shouldRunInChildProcess, + spawnGulpCommandInChildProcess, } from './util.js'; import fs from 'fs'; @@ -33,12 +33,12 @@ import mkdirp from 'mkdirp'; import sourcemaps from 'gulp-sourcemaps'; import { memoizeTask } from './memoize-task.js'; import cc from 'google-closure-compiler'; -const closureCompiler = cc.gulp() - -export const closureTask = ((cache) => memoizeTask(cache, async function closure(target, format) { +const closureCompiler = cc.gulp(); +export const closureTask = ((cache) => + memoizeTask(cache, async function closure(target, format) { if (shouldRunInChildProcess(target, format)) { - return spawnGulpCommandInChildProcess('compile', target, format); + return spawnGulpCommandInChildProcess('compile', target, format); } const src = targetDir(target, `cls`); @@ -46,73 +46,83 @@ export const closureTask = ((cache) => memoizeTask(cache, async function closure await mkdirp(out); - await Promise.all([ + await Promise.all( + [ `${mainExport}.dom`, `${mainExport}.dom.iterable`, `${mainExport}.dom.asynciterable`, `${mainExport}.dom.iterable.operators`, - `${mainExport}.dom.asynciterable.operators` - ].map(closureCompile)); + `${mainExport}.dom.asynciterable.operators`, + ].map(closureCompile) + ); async function closureCompile(entry) { - - const entry_point = path.join(src, `${entry}.dom.cls.js`); - const externsPath = path.join(out, `${entry}.externs.js`); - - await Promise.all([ - fs.promises.writeFile(entry_point, generateUMDExportAssignment(entry)), - fs.promises.writeFile(externsPath, generateExternsFile(path.resolve(`${src}/${entry}.js`))) - ]); - - return await observableFromStreams( - gulp.src([ - /* external libs first */ - `node_modules/tslib/package.json`, - `node_modules/tslib/tslib.es6.js`, - `node_modules/rxjs/package.json`, - `node_modules/rxjs/util/root.js`, - `node_modules/rxjs/internal/symbol/observable.js`, - `${src}/**/*.js` /* <-- then sources globs */ - ], { base: `./` }), - sourcemaps.init(), - 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 entry_point = path.join(src, `${entry}.dom.cls.js`); + const externsPath = path.join(out, `${entry}.externs.js`); + + await Promise.all([ + fs.promises.writeFile(entry_point, generateUMDExportAssignment(entry)), + fs.promises.writeFile(externsPath, generateExternsFile(path.resolve(`${src}/${entry}.js`))), + ]); + + return await observableFromStreams( + gulp.src( + [ + /* external libs first */ + `node_modules/tslib/package.json`, + `node_modules/tslib/tslib.es6.js`, + `node_modules/rxjs/package.json`, + `node_modules/rxjs/util/root.js`, + `node_modules/rxjs/internal/symbol/observable.js`, + `${src}/**/*.js` /* <-- then sources globs */, + ], + { base: `./` } + ), + sourcemaps.init(), + 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 = (target, entry_point, output, externs, libraryName) => ({ - externs, - entry_point, - third_party: true, - warning_level: `QUIET`, - dependency_mode: `PRUNE`, - rewrite_polyfills: false, - module_resolution: `NODE`, - // formatting: `PRETTY_PRINT`, - // debug: true, - compilation_level: `ADVANCED`, - process_common_js_modules: true, - package_json_entry_names: `module,jsnext:main,main`, - assume_function_wrapper: true, - js_output_file: `${output}.js`, - language_in: gCCLanguageNames[`esnext`], - language_out: gCCLanguageNames[target], - output_wrapper: `(function (global, factory) { + externs, + entry_point, + third_party: true, + warning_level: `QUIET`, + dependency_mode: `PRUNE`, + rewrite_polyfills: false, + module_resolution: `NODE`, + // formatting: `PRETTY_PRINT`, + // debug: true, + compilation_level: `ADVANCED`, + process_common_js_modules: true, + package_json_entry_names: `module,jsnext:main,main`, + assume_function_wrapper: true, + js_output_file: `${output}.js`, + 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) : (factory(global.${libraryName} = global.${libraryName} || {})); -}(this, (function (exports) {%output%}.bind(this))));` +}(this, (function (exports) {%output%}.bind(this))));`, }); export default closureTask; function generateUMDExportAssignment(entry) { - return [` + return [ + ` import { __await } from 'tslib'; __await.prototype[Symbol.toStringTag] = '__await'; Object.defineProperty(__await, Symbol.hasInstance, { @@ -120,36 +130,43 @@ Object.defineProperty(__await, Symbol.hasInstance, { return !!(inst && inst[Symbol.toStringTag] === '__await'); } });`, - `import * as exports0 from './${entry}';`, - 'Object.assign(arguments[0], exports0);' - ].join('\n'); + `import * as exports0 from './${entry}';`, + 'Object.assign(arguments[0], exports0);', + ].join('\n'); } function generateExternsFile(entryModulePath) { - const entryModule = esmRequire(entryModulePath, { warnings: false }); - return [ - externsHeader(), - ...getPublicExportedNames(entryModule) - .map(externBody).filter(Boolean) - ].join('\n'); + const entryModule = esmRequire(entryModulePath, { warnings: false }); + return [ + externsHeader(), + ...getPublicExportedNames(entryModule).map(externBody).filter(Boolean), + ].join('\n'); } function externBody({ exportName, staticNames, instanceNames }) { - return [ - `var ${exportName} = function() {};`, - staticNames.map((staticName) => (isNaN(+staticName) - ? `/** @type {?} */\n${exportName}.${staticName} = function() {};` - : `/** @type {?} */\n${exportName}[${staticName}] = function() {};` - )).join('\n'), - instanceNames.map((instanceName) => (isNaN(+instanceName) - ? `/** @type {?} */\n${exportName}.prototype.${instanceName};` - : `/** @type {?} */\n${exportName}.prototype[${instanceName}];` - )).join('\n') - ].filter(Boolean).join('\n'); + return [ + `var ${exportName} = function() {};`, + staticNames + .map((staticName) => + isNaN(+staticName) + ? `/** @type {?} */\n${exportName}.${staticName} = function() {};` + : `/** @type {?} */\n${exportName}[${staticName}] = function() {};` + ) + .join('\n'), + instanceNames + .map((instanceName) => + isNaN(+instanceName) + ? `/** @type {?} */\n${exportName}.prototype.${instanceName};` + : `/** @type {?} */\n${exportName}.prototype[${instanceName}];` + ) + .join('\n'), + ] + .filter(Boolean) + .join('\n'); } function externsHeader() { - return (` + return ` // @ts-nocheck /** * @fileoverview Closure Compiler externs for Ix @@ -164,37 +181,35 @@ Symbol.observable; Symbol.asyncIterator; /** @type {symbol} */ var symbolObservable = function() {}; -`); +`; } // Reflect on the Ix entrypoint module to build the closure externs file. // Assume all the non-inherited static and prototype members of the Ix entrypoint // and its direct exports are public, and should be preserved through minification. function getPublicExportedNames(entryModule) { - const fn = function() {}; - const isStaticOrProtoName = (x) => ( - !(x in fn) && - (x !== `default`) && - (x !== `undefined`) && - (x !== `__esModule`) && - (x !== `constructor`) - ); - return Object - .getOwnPropertyNames(entryModule) - .filter((name) => name !== 'default') - .filter((name) => ( - typeof entryModule[name] === `object` || - typeof entryModule[name] === `function` - )) - .map((name) => [name, entryModule[name]]) - .reduce((reserved, [name, value]) => { - - const staticNames = value && - typeof value === 'object' ? Object.getOwnPropertyNames(value).filter(isStaticOrProtoName) : - typeof value === 'function' ? Object.getOwnPropertyNames(value).filter(isStaticOrProtoName) : []; - - const instanceNames = (typeof value === `function` && Object.getOwnPropertyNames(value.prototype || {}) || []).filter(isStaticOrProtoName); - - return [...reserved, { exportName: name, staticNames, instanceNames }]; - }, []); + const fn = function () {}; + const isStaticOrProtoName = (x) => + !(x in fn) && x !== `default` && x !== `undefined` && x !== `__esModule` && x !== `constructor`; + return Object.getOwnPropertyNames(entryModule) + .filter((name) => name !== 'default') + .filter( + (name) => typeof entryModule[name] === `object` || typeof entryModule[name] === `function` + ) + .map((name) => [name, entryModule[name]]) + .reduce((reserved, [name, value]) => { + const staticNames = + value && typeof value === 'object' + ? Object.getOwnPropertyNames(value).filter(isStaticOrProtoName) + : typeof value === 'function' + ? Object.getOwnPropertyNames(value).filter(isStaticOrProtoName) + : []; + + const instanceNames = ( + (typeof value === `function` && Object.getOwnPropertyNames(value.prototype || {})) || + [] + ).filter(isStaticOrProtoName); + + return [...reserved, { exportName: name, staticNames, instanceNames }]; + }, []); } diff --git a/gulp/compile-task.js b/gulp/compile-task.js index 075b37d6..fdf65722 100644 --- a/gulp/compile-task.js +++ b/gulp/compile-task.js @@ -23,12 +23,17 @@ import closureTask from './closure-task.js'; import typescriptTask from './typescript-task.js'; import { copyMainTask, copyTSTask } from './copy-main-task.js'; -export 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` ? closureTask(target, format, ...args)() - : typescriptTask(target, format, ...args)(); -}))({}); +export 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` + ? closureTask(target, format, ...args)() + : typescriptTask(target, format, ...args)(); + }))({}); export default compileTask; diff --git a/gulp/copy-main-task.js b/gulp/copy-main-task.js index 9ddabed6..14fa3278 100644 --- a/gulp/copy-main-task.js +++ b/gulp/copy-main-task.js @@ -15,9 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { - targetDir, observableFromStreams -} from './util.js'; +import { targetDir, observableFromStreams } from './util.js'; import del from 'del'; import gulp from 'gulp'; @@ -31,7 +29,8 @@ import { publish, refCount } from 'rxjs/operators/index.js'; const exec = promisify(childProcess.exec); -export const copyMainTask = ((cache) => memoizeTask(cache, function copyMain(target) { +export const copyMainTask = ((cache) => + memoizeTask(cache, function copyMain(target) { const out = targetDir(target); const dtsGlob = `${targetDir(`es2015`, `cjs`)}/**/*.ts`; const cjsGlob = `${targetDir(`es2015`, `cjs`)}/**/*.js`; @@ -43,24 +42,43 @@ export const copyMainTask = ((cache) => memoizeTask(cache, function copyMain(tar const es2015UmdSourceMapsGlob = `${targetDir(`es2015`, `umd`)}/*.map`; const esnextUmdSourceMapsGlob = `${targetDir(`esnext`, `umd`)}/*.map`; return ObservableForkJoin( - observableFromStreams(gulp.src(dtsGlob), gulp.dest(out)), // copy d.ts files - observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy es2015 cjs files - observableFromStreams(gulp.src(cjsSourceMapsGlob), gulp.dest(out)), // copy es2015 cjs sourcemaps - observableFromStreams(gulp.src(esmSourceMapsGlob), gulp.dest(out)), // copy es2015 esm sourcemaps - observableFromStreams(gulp.src(es2015UmdSourceMapsGlob), gulp.dest(out)), // copy es2015 umd sourcemap files, but don't rename - observableFromStreams(gulp.src(esnextUmdSourceMapsGlob), gulp.dest(out)), // copy es2015 umd sourcemap files, but don't rename - observableFromStreams(gulp.src(esmGlob), gulpRename((p) => { p.extname = '.mjs'; }), gulpReplace(`.js'`, `.mjs'`), gulp.dest(out)), // copy es2015 esm files and rename to `.mjs` - observableFromStreams(gulp.src(es2015UmdGlob), gulpRename((p) => { p.basename += `.es2015.min`; }), gulp.dest(out)), // copy es2015 umd files and add `.min` - observableFromStreams(gulp.src(esnextUmdGlob), gulpRename((p) => { p.basename += `.esnext.min`; }), gulp.dest(out)), // copy esnext umd files and add `.esnext.min` + observableFromStreams(gulp.src(dtsGlob), gulp.dest(out)), // copy d.ts files + observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy es2015 cjs files + observableFromStreams(gulp.src(cjsSourceMapsGlob), gulp.dest(out)), // copy es2015 cjs sourcemaps + observableFromStreams(gulp.src(esmSourceMapsGlob), gulp.dest(out)), // copy es2015 esm sourcemaps + observableFromStreams(gulp.src(es2015UmdSourceMapsGlob), gulp.dest(out)), // copy es2015 umd sourcemap files, but don't rename + observableFromStreams(gulp.src(esnextUmdSourceMapsGlob), gulp.dest(out)), // copy es2015 umd sourcemap files, but don't rename + observableFromStreams( + gulp.src(esmGlob), + gulpRename((p) => { + p.extname = '.mjs'; + }), + gulpReplace(`.js'`, `.mjs'`), + gulp.dest(out) + ), // copy es2015 esm files and rename to `.mjs` + observableFromStreams( + gulp.src(es2015UmdGlob), + gulpRename((p) => { + p.basename += `.es2015.min`; + }), + gulp.dest(out) + ), // copy es2015 umd files and add `.min` + observableFromStreams( + gulp.src(esnextUmdGlob), + gulpRename((p) => { + p.basename += `.esnext.min`; + }), + gulp.dest(out) + ) // copy esnext umd files and add `.esnext.min` ).pipe(publish(new ReplaySubject()), refCount()); -}))({}); + }))({}); -export const copyTSTask = ((cache) => memoizeTask(cache, async function copyTS(target, format) { +export const copyTSTask = ((cache) => + memoizeTask(cache, async function copyTS(target, format) { const out = targetDir(target, format); await exec(`mkdirp ${out}`); await exec(`shx cp -r src/* ${out}`); await del(`${out}/**/*.js`); -}))({}); - + }))({}); export default copyMainTask; diff --git a/gulp/memoize-task.js b/gulp/memoize-task.js index bb522934..bc5502f2 100644 --- a/gulp/memoize-task.js +++ b/gulp/memoize-task.js @@ -17,20 +17,20 @@ import { taskName } from './util.js'; -export const createTask = ((taskFn) => ((target, format, ...args) => { +export const createTask = (taskFn) => (target, format, ...args) => { // Give the memoized fn a displayName so gulp's output is easier to follow. const fn = () => taskFn(target, format, ...args); fn.displayName = `${taskFn.name || ``}:${taskName(target, format, ...args)}:task`; return fn; -})); +}; -export const memoizeTask = ((cache, taskFn) => ((target, format, ...args) => { - // Give the memoized fn a displayName so gulp's output is easier to follow. - const fn = () => ( - cache[taskName(target, format)] || ( - cache[taskName(target, format)] = taskFn(target, format, ...args))); - fn.displayName = `${taskFn.name || ``}:${taskName(target, format, ...args)}:task`; - return fn; -})); +export const memoizeTask = (cache, taskFn) => (target, format, ...args) => { + // Give the memoized fn a displayName so gulp's output is easier to follow. + const fn = () => + cache[taskName(target, format)] || + (cache[taskName(target, format)] = taskFn(target, format, ...args)); + fn.displayName = `${taskFn.name || ``}:${taskName(target, format, ...args)}:task`; + return fn; +}; export default memoizeTask; diff --git a/gulp/package-task.js b/gulp/package-task.js index ee22c681..15f7913f 100644 --- a/gulp/package-task.js +++ b/gulp/package-task.js @@ -16,34 +16,40 @@ // under the License. import { - metadataFiles, packageJSONFields, - mainExport, npmPkgName, npmOrgName, - targetDir, packageName, observableFromStreams + metadataFiles, + packageJSONFields, + mainExport, + npmPkgName, + npmOrgName, + targetDir, + packageName, + observableFromStreams, } from './util.js'; import gulp from 'gulp'; import { memoizeTask } from './memoize-task.js'; import gulpJsonTransform from 'gulp-json-transform'; -import { - ReplaySubject, - empty as ObservableEmpty, - forkJoin as ObservableForkJoin, -} from 'rxjs'; +import { ReplaySubject, empty as ObservableEmpty, forkJoin as ObservableForkJoin } from 'rxjs'; import { publish, refCount } from 'rxjs/operators/index.js'; -export const packageTask = ((cache) => memoizeTask(cache, function bundle(target, format) { - if (target === `src`) return ObservableEmpty(); - const out = targetDir(target, format); - const jsonTransform = gulpJsonTransform(target === npmPkgName ? createMainPackageJson(target, format) : - target === `ts` ? createTypeScriptPackageJson(target, format) - : createScopedPackageJSON(target, format), - 2); - return ObservableForkJoin( - observableFromStreams(gulp.src(metadataFiles), gulp.dest(out)), // copy metadata files - observableFromStreams(gulp.src(`package.json`), jsonTransform, gulp.dest(out)) // write packageJSONs - ).pipe(publish(new ReplaySubject()), refCount()); -}))({}); +export const packageTask = ((cache) => + memoizeTask(cache, function bundle(target, format) { + if (target === `src`) return ObservableEmpty(); + const out = targetDir(target, format); + const jsonTransform = gulpJsonTransform( + target === npmPkgName + ? createMainPackageJson(target, format) + : target === `ts` + ? createTypeScriptPackageJson(target, format) + : createScopedPackageJSON(target, format), + 2 + ); + return ObservableForkJoin( + observableFromStreams(gulp.src(metadataFiles), gulp.dest(out)), // copy metadata files + observableFromStreams(gulp.src(`package.json`), jsonTransform, gulp.dest(out)) // write packageJSONs + ).pipe(publish(new ReplaySubject()), refCount()); + }))({}); export default packageTask; @@ -56,7 +62,7 @@ const createMainPackageJson = (target, format) => (orig) => ({ module: `${mainExport}.node.mjs`, browser: { [`./${mainExport}.node.js`]: `./${mainExport}.dom.js`, - [`./${mainExport}.node.mjs`]: `./${mainExport}.dom.mjs` + [`./${mainExport}.node.mjs`]: `./${mainExport}.dom.mjs`, }, exports: { '.': { @@ -69,14 +75,14 @@ const createMainPackageJson = (target, format) => (orig) => ({ }, './*': { import: `./*.mjs`, - require: `./*.js` - } + require: `./*.js`, + }, }, types: `${mainExport}.node.d.ts`, unpkg: `${mainExport}.dom.es2015.min.js`, jsdelivr: `${mainExport}.dom.es2015.min.js`, sideEffects: false, - esm: { mode: `all`, sourceMap: true } + esm: { mode: `all`, sourceMap: true }, }); const createTypeScriptPackageJson = (target, format) => (orig) => ({ @@ -89,35 +95,31 @@ const createTypeScriptPackageJson = (target, format) => (orig) => ({ type: 'module', dependencies: { '@types/node': '*', - ...orig.dependencies - } + ...orig.dependencies, + }, }); -const createScopedPackageJSON = (target, format) => (({ name, ...orig }) => - packageJSONFields.reduce( - (xs, key) => ({ ...xs, [key]: xs[key] || orig[key] }), - { - // un-set version, since it's automatically applied during the release process - version: undefined, - // set the scoped package name (e.g. "@apache-arrow/esnext-esm") - name: `${npmOrgName}/${npmPkgName}-${packageName(target, format)}`, - // set "unpkg"/"jsdeliver" if building scoped UMD target - unpkg: format === 'umd' ? `${mainExport}.dom.js` : undefined, - jsdelivr: format === 'umd' ? `${mainExport}.dom.js` : undefined, - // set "browser" if building scoped UMD target, otherwise "Arrow.dom" - browser: format === 'umd' ? `${mainExport}.dom.js` : `${mainExport}.dom.js`, - // set "main" to "Arrow" if building scoped UMD target, otherwise "Arrow.node" - main: format === 'umd' ? `${mainExport}.dom.js` : `${mainExport}.node.js`, - // set "type" to `module` or `commonjs` (https://nodejs.org/api/packages.html#packages_type) - type: format === 'esm' ? `module` : `commonjs`, - // set "module" (for https://www.npmjs.com/package/@pika/pack) if building scoped ESM target - module: format === 'esm' ? `${mainExport}.dom.js` : undefined, - // set "sideEffects" to false as a hint to Webpack that it's safe to tree-shake the ESM target - sideEffects: format === 'esm' ? false : undefined, - // include "esm" settings for https://www.npmjs.com/package/esm if building scoped ESM target - esm: format === `esm` ? { mode: `auto`, sourceMap: true } : undefined, - // set "types" (for TypeScript/VSCode) - types: format === 'umd' ? undefined : `${mainExport}.node.d.ts`, - } - ) -); +const createScopedPackageJSON = (target, format) => ({ name, ...orig }) => + packageJSONFields.reduce((xs, key) => ({ ...xs, [key]: xs[key] || orig[key] }), { + // un-set version, since it's automatically applied during the release process + version: undefined, + // set the scoped package name (e.g. "@apache-arrow/esnext-esm") + name: `${npmOrgName}/${npmPkgName}-${packageName(target, format)}`, + // set "unpkg"/"jsdeliver" if building scoped UMD target + unpkg: format === 'umd' ? `${mainExport}.dom.js` : undefined, + jsdelivr: format === 'umd' ? `${mainExport}.dom.js` : undefined, + // set "browser" if building scoped UMD target, otherwise "Arrow.dom" + browser: format === 'umd' ? `${mainExport}.dom.js` : `${mainExport}.dom.js`, + // set "main" to "Arrow" if building scoped UMD target, otherwise "Arrow.node" + main: format === 'umd' ? `${mainExport}.dom.js` : `${mainExport}.node.js`, + // set "type" to `module` or `commonjs` (https://nodejs.org/api/packages.html#packages_type) + type: format === 'esm' ? `module` : `commonjs`, + // set "module" (for https://www.npmjs.com/package/@pika/pack) if building scoped ESM target + module: format === 'esm' ? `${mainExport}.dom.js` : undefined, + // set "sideEffects" to false as a hint to Webpack that it's safe to tree-shake the ESM target + sideEffects: format === 'esm' ? false : undefined, + // include "esm" settings for https://www.npmjs.com/package/esm if building scoped ESM target + esm: format === `esm` ? { mode: `auto`, sourceMap: true } : undefined, + // set "types" (for TypeScript/VSCode) + types: format === 'umd' ? undefined : `${mainExport}.node.d.ts`, + }); diff --git a/gulp/test-task.js b/gulp/test-task.js index 57a17cc2..89ce6c98 100644 --- a/gulp/test-task.js +++ b/gulp/test-task.js @@ -20,7 +20,7 @@ import { argv } from './argv.js'; import child_process from 'child_process'; import { memoizeTask } from './memoize-task.js'; import { npmPkgName, targetAndModuleCombinations } from './util.js'; -import {promisify} from 'util'; +import { promisify } from 'util'; import asyncDone_ from 'async-done'; const asyncDone = promisify(asyncDone_); @@ -48,25 +48,26 @@ const testOptions = { }, }; -export const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format) { - const args = [...execArgv]; - const opts = { ...testOptions }; - if (format === 'esm' || target === 'ts' || target === 'src' || target === npmPkgName) { - args.unshift(`--experimental-vm-modules`); - } - if (argv.coverage) { - args.push(`-c`, `jest.coverage.config.js`, `--coverage`); - } else { - const cfgname = [target, format].filter(Boolean).join('.'); - // args.push(`--verbose`, `--no-cache`, `-i`); - args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, ...argv.tests); - } - opts.env = { - ...opts.env, - TEST_DOM_STREAMS: (target === 'src' || format === 'umd').toString(), - TEST_NODE_STREAMS: (target === 'src' || format !== 'umd').toString(), - }; - return asyncDone(() => child_process.spawn(`node`, args, opts)); -}))({}, [jest, ...jestArgv], testOptions); +export const testTask = ((cache, execArgv, testOptions) => + memoizeTask(cache, function test(target, format) { + const args = [...execArgv]; + const opts = { ...testOptions }; + if (format === 'esm' || target === 'ts' || target === 'src' || target === npmPkgName) { + args.unshift(`--experimental-vm-modules`); + } + if (argv.coverage) { + args.push(`-c`, `jest.coverage.config.js`, `--coverage`); + } else { + const cfgname = [target, format].filter(Boolean).join('.'); + // args.push(`--verbose`, `--no-cache`, `-i`); + args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, ...argv.tests); + } + opts.env = { + ...opts.env, + TEST_DOM_STREAMS: (target === 'src' || format === 'umd').toString(), + TEST_NODE_STREAMS: (target === 'src' || format !== 'umd').toString(), + }; + return asyncDone(() => child_process.spawn(`node`, args, opts)); + }))({}, [jest, ...jestArgv], testOptions); export default testTask; diff --git a/gulp/typescript-task.js b/gulp/typescript-task.js index e1e7e69d..ef52dd84 100644 --- a/gulp/typescript-task.js +++ b/gulp/typescript-task.js @@ -16,11 +16,11 @@ // under the License. import { - targetDir, - tsconfigName, - observableFromStreams, - shouldRunInChildProcess, - spawnGulpCommandInChildProcess, + targetDir, + tsconfigName, + observableFromStreams, + shouldRunInChildProcess, + spawnGulpCommandInChildProcess, } from './util.js'; import gulp from 'gulp'; @@ -29,39 +29,54 @@ import tsc from 'typescript'; import ts from 'gulp-typescript'; import sourcemaps from 'gulp-sourcemaps'; import { memoizeTask } from './memoize-task.js'; -import { - ReplaySubject, - forkJoin as ObservableForkJoin, -} from 'rxjs'; +import { ReplaySubject, forkJoin as ObservableForkJoin } from 'rxjs'; import { takeLast, publish, refCount } from 'rxjs/operators/index.js'; -export const typescriptTask = ((cache) => memoizeTask(cache, function typescript(target, format) { - +export const typescriptTask = ((cache) => + memoizeTask(cache, function typescript(target, format) { if (shouldRunInChildProcess(target, format)) { - return spawnGulpCommandInChildProcess('compile', target, format); + return spawnGulpCommandInChildProcess('compile', target, format); } const out = targetDir(target, format); const tsconfigPath = path.join(`tsconfig`, `tsconfig.${tsconfigName(target, format)}.json`); - return compileTypescript(out, tsconfigPath) - .pipe(takeLast(1), publish(new ReplaySubject()), refCount()) -}))({}); + return compileTypescript(out, tsconfigPath).pipe( + takeLast(1), + publish(new ReplaySubject()), + refCount() + ); + }))({}); function compileTypescript(out, tsconfigPath, tsconfigOverrides) { - const tsProject = ts.createProject(tsconfigPath, { typescript: tsc, ...tsconfigOverrides }); - const { stream: { js, dts } } = observableFromStreams( - tsProject.src(), sourcemaps.init(), - tsProject(ts.reporter.defaultReporter()) - ); - const writeSources = observableFromStreams(tsProject.src(), gulp.dest(path.join(out, 'src'))); - const writeDTypes = observableFromStreams(dts, sourcemaps.write('./', { includeContent: false, sourceRoot: './src' }), gulp.dest(out)); - const mapFile = tsProject.options.module === tsc.ModuleKind.ES2015 ? esmMapFile : cjsMapFile; - const writeJS = observableFromStreams(js, sourcemaps.write('./', { mapFile, includeContent: false, sourceRoot: './src' }), gulp.dest(out)); - return ObservableForkJoin(writeSources, writeDTypes, writeJS); + const tsProject = ts.createProject(tsconfigPath, { typescript: tsc, ...tsconfigOverrides }); + const { + stream: { js, dts }, + } = observableFromStreams( + tsProject.src(), + sourcemaps.init(), + tsProject(ts.reporter.defaultReporter()) + ); + const writeSources = observableFromStreams(tsProject.src(), gulp.dest(path.join(out, 'src'))); + const writeDTypes = observableFromStreams( + dts, + sourcemaps.write('./', { includeContent: false, sourceRoot: './src' }), + gulp.dest(out) + ); + const mapFile = tsProject.options.module === tsc.ModuleKind.ES2015 ? esmMapFile : cjsMapFile; + const writeJS = observableFromStreams( + js, + sourcemaps.write('./', { mapFile, includeContent: false, sourceRoot: './src' }), + gulp.dest(out) + ); + return ObservableForkJoin(writeSources, writeDTypes, writeJS); } -function cjsMapFile(mapFilePath) { return mapFilePath; } -function esmMapFile(mapFilePath) { return mapFilePath.replace('.js.map', '.mjs.map'); } +function cjsMapFile(mapFilePath) { + return mapFilePath; +} +function esmMapFile(mapFilePath) { + return mapFilePath.replace('.js.map', '.mjs.map'); +} export default typescriptTask; diff --git a/gulp/util.js b/gulp/util.js index ca3cf126..6b36cc16 100644 --- a/gulp/util.js +++ b/gulp/util.js @@ -24,7 +24,7 @@ import { ReplaySubject, empty as ObservableEmpty, throwError as ObservableThrow, - fromEvent as ObservableFromEvent + fromEvent as ObservableFromEvent, } from 'rxjs'; import { merge, @@ -35,7 +35,7 @@ import { refCount, } from 'rxjs/operators/index.js'; -import {promisify} from 'util'; +import { promisify } from 'util'; import asyncDone_ from 'async-done'; import { createRequire } from 'module'; @@ -54,20 +54,29 @@ const knownTargets = [`es5`, `es2015`, `esnext`]; const knownModules = [`cjs`, `esm`, `cls`, `umd`]; const tasksToSkipPerTargetOrFormat = { src: { clean: true, build: true }, - cls: { test: true, package: true } + cls: { test: true, package: true }, }; const packageJSONFields = [ - `version`, `license`, `description`, - `author`, `homepage`, `repository`, - `bugs`, `keywords`, `dependencies` + `version`, + `license`, + `description`, + `author`, + `homepage`, + `repository`, + `bugs`, + `keywords`, + `dependencies`, ]; const metadataFiles = [`LICENSE`, `readme.md`, `CHANGELOG.md`].map((filename) => { - let err = false, prefixes = [`./`, `../`]; + let err = false, + prefixes = [`./`, `../`]; let p = prefixes.find((prefix) => { try { fs.statSync(path.resolve(path.join(prefix, filename))); - } catch (e) { return false; } + } catch (e) { + return false; + } return true; }); if (!p) { @@ -82,7 +91,7 @@ const gCCLanguageNames = { es2015: `ECMASCRIPT_2015`, es2016: `ECMASCRIPT_2016`, es2017: `ECMASCRIPT_2017`, - esnext: `ECMASCRIPT_NEXT` + esnext: `ECMASCRIPT_NEXT`, }; const UMDSourceTargets = { @@ -90,13 +99,15 @@ const UMDSourceTargets = { es2015: `es2015`, es2016: `es2015`, es2017: `es2015`, - esnext: `esnext` + esnext: `esnext`, }; const terserLanguageNames = { - es5: 5, es2015: 6, - es2016: 7, es2017: 8, - esnext: 8 // <--- ? + es5: 5, + es2015: 6, + es2016: 7, + es2017: 8, + esnext: 8, // <--- ? }; // ES7+ keywords Terser shouldn't mangle @@ -106,17 +117,35 @@ const ESKeywords = [ // GroupedIterable/GroupedAsyncIterable `key`, // PropertyDescriptors - `configurable`, `enumerable`, + `configurable`, + `enumerable`, // IteratorResult, Symbol.asyncIterator - `done`, `value`, `Symbol.asyncIterator`, `asyncIterator`, + `done`, + `value`, + `Symbol.asyncIterator`, + `asyncIterator`, // AsyncObserver - `values`, `hasError`, `hasCompleted`, `errorValue`, `closed`, + `values`, + `hasError`, + `hasCompleted`, + `errorValue`, + `closed`, // Observable/Subscription/Scheduler - `next`, `error`, `complete`, `subscribe`, `unsubscribe`, `isUnsubscribed`, + `next`, + `error`, + `complete`, + `subscribe`, + `unsubscribe`, + `isUnsubscribed`, // EventTarget - `addListener`, `removeListener`, `addEventListener`, `removeEventListener`, + `addListener`, + `removeListener`, + `addEventListener`, + `removeEventListener`, // AbortController - `AbortController`, `AbortSignal`, `AbortError` + `AbortController`, + `AbortSignal`, + `AbortError`, ]; function taskName(target, format) { @@ -137,9 +166,13 @@ function targetDir(target, format) { function shouldRunInChildProcess(target, format) { // If we're building more than one module/target, then yes run this task in a child process - if (targets.length > 1 || modules.length > 1) { return true; } + if (targets.length > 1 || modules.length > 1) { + return true; + } // If the target we're building *isn't* the target the gulp command was configured to run, then yes run that in a child process - if (targets[0] !== target || modules[0] !== format) { return true; } + if (targets[0] !== target || modules[0] !== format) { + return true; + } // Otherwise no need -- either gulp was run for just one target, or we've been spawned as the child of a multi-target parent gulp return false; } @@ -148,22 +181,29 @@ const gulp = path.join(path.parse(require.resolve(`gulp`)).dir, `bin/gulp.js`); function spawnGulpCommandInChildProcess(command, target, format) { 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` } - }); + 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.`)); + }).catch(() => + Promise.reject( + err.length > 0 ? err.join('\n') : `Error in "${command}:${taskName(target, format)}" task.` + ) + ); } -const logAndDie = (e) => { if (e) { console.error(e); process.exit(1) } }; +const logAndDie = (e) => { + if (e) { + console.error(e); + process.exit(1); + } +}; function observableFromStreams(...streams) { - if (streams.length <= 0) { return ObservableEmpty(); } + if (streams.length <= 0) { + return ObservableEmpty(); + } const pumped = streams.length <= 1 ? streams[0] : pump(...streams, logAndDie); const fromEvent = ObservableFromEvent.bind(null, pumped); const streamObs = fromEvent(`data`).pipe( @@ -171,14 +211,14 @@ function observableFromStreams(...streams) { takeUntil(fromEvent(`end`).pipe(merge(fromEvent(`close`)))), defaultIfEmpty(`empty stream`), multicast(new ReplaySubject()), - refCount()); + refCount() + ); streamObs.stream = pumped; streamObs.observable = streamObs; return streamObs; } function* combinations(_targets, _modules) { - const targets = known(knownTargets, _targets || [`all`]); const modules = known(knownModules, _modules || [`all`]); @@ -200,32 +240,50 @@ function* combinations(_targets, _modules) { } function known(known, values) { - return ~values.indexOf(`all`) ? known - : ~values.indexOf(`src`) ? [`src`] - : Object.keys( - values.reduce((map, arg) => (( - (known.indexOf(arg) !== -1) && - (map[arg.toLowerCase()] = true) - || true) && map - ), {}) + return ~values.indexOf(`all`) + ? known + : ~values.indexOf(`src`) + ? [`src`] + : Object.keys( + values.reduce( + (map, arg) => + ((known.indexOf(arg) !== -1 && (map[arg.toLowerCase()] = true)) || true) && map, + {} + ) ).sort((a, b) => known.indexOf(a) - known.indexOf(b)); } } -const getUMDExportName = (umdEntryFileName) => umdEntryFileName - .split('.') - .filter((x) => x != 'dom') - .map((x) => x[0].toUpperCase() + x.slice(1)) - .join(''); +const getUMDExportName = (umdEntryFileName) => + umdEntryFileName + .split('.') + .filter((x) => x != 'dom') + .map((x) => x[0].toUpperCase() + x.slice(1)) + .join(''); export { - mainExport, npmPkgName, npmOrgName, metadataFiles, packageJSONFields, - - knownTargets, knownModules, tasksToSkipPerTargetOrFormat, - gCCLanguageNames, UMDSourceTargets, terserLanguageNames, - - taskName, packageName, tsconfigName, targetDir, combinations, observableFromStreams, - ESKeywords, esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess, getUMDExportName, + mainExport, + npmPkgName, + npmOrgName, + metadataFiles, + packageJSONFields, + knownTargets, + knownModules, + tasksToSkipPerTargetOrFormat, + gCCLanguageNames, + UMDSourceTargets, + terserLanguageNames, + taskName, + packageName, + tsconfigName, + targetDir, + combinations, + observableFromStreams, + ESKeywords, + esmRequire, + shouldRunInChildProcess, + spawnGulpCommandInChildProcess, + getUMDExportName, }; export const targetAndModuleCombinations = [...combinations(targets, modules)]; diff --git a/gulpfile.js b/gulpfile.js index 95c75b34..895d8742 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,10 +18,7 @@ import * as os from 'os'; import del from 'del'; import gulp from 'gulp'; -import { - from as ObservableFrom, - bindNodeCallback as ObservableBindNodeCallback -} from 'rxjs'; +import { from as ObservableFrom, bindNodeCallback as ObservableBindNodeCallback } from 'rxjs'; import { flatMap } from 'rxjs/operators/index.js'; import cleanTask from './gulp/clean-task.js'; import { testTask } from './gulp/test-task.js'; @@ -30,53 +27,60 @@ import packageTask from './gulp/package-task.js'; import { targets, modules } from './gulp/argv.js'; import { esbuildTask, rollupTask, webpackTask, execBundleTask } from './gulp/bundle-task.js'; import { - taskName, combinations, - targetDir, knownTargets, - npmPkgName, UMDSourceTargets, - tasksToSkipPerTargetOrFormat + taskName, + combinations, + targetDir, + knownTargets, + npmPkgName, + UMDSourceTargets, + tasksToSkipPerTargetOrFormat, } from './gulp/util.js'; for (const [target, format] of combinations([`all`], [`all`])) { - const task = taskName(target, format); - gulp.task(`clean:${task}`, cleanTask(target, format)); - gulp.task( `test:${task}`, testTask(target, format)); - gulp.task(`compile:${task}`, compileTask(target, format)); - gulp.task(`package:${task}`, packageTask(target, format)); - gulp.task(`build:${task}`, gulp.series( - `clean:${task}`, `compile:${task}`, `package:${task}` - )); + const task = taskName(target, format); + gulp.task(`clean:${task}`, cleanTask(target, format)); + gulp.task(`test:${task}`, testTask(target, format)); + gulp.task(`compile:${task}`, compileTask(target, format)); + gulp.task(`package:${task}`, packageTask(target, format)); + gulp.task(`build:${task}`, gulp.series(`clean:${task}`, `compile:${task}`, `package:${task}`)); } // The UMD bundles build temporary es5/6/next targets via TS, // then run the TS source through either closure-compiler or // a minifier, so we special case that here. knownTargets.forEach((target) => { - const umd = taskName(target, `umd`); - const cls = taskName(UMDSourceTargets[target], `cls`); - gulp.task(`build:${umd}`, gulp.series( - `build:${cls}`, - `clean:${umd}`, `compile:${umd}`, `package:${umd}`, - function remove_closure_tmp_files() { - return del(targetDir(target, `cls`)) - } - )); + const umd = taskName(target, `umd`); + const cls = taskName(UMDSourceTargets[target], `cls`); + gulp.task( + `build:${umd}`, + gulp.series( + `build:${cls}`, + `clean:${umd}`, + `compile:${umd}`, + `package:${umd}`, + function remove_closure_tmp_files() { + return del(targetDir(target, `cls`)); + } + ) + ); }); // The main "ix" module builds the es5/umd, es2015/cjs, // es2015/esm, and es2015/umd targets, then copies and renames the // compiled output into the ix folder -gulp.task(`build:${npmPkgName}`, - gulp.series( - gulp.parallel( - `build:${taskName(`es5`, `umd`)}`, - `build:${taskName(`esnext`, `cjs`)}`, - `build:${taskName(`esnext`, `esm`)}`, - `build:${taskName(`esnext`, `umd`)}` - ), - `clean:${npmPkgName}`, - `compile:${npmPkgName}`, - `package:${npmPkgName}` - ) +gulp.task( + `build:${npmPkgName}`, + gulp.series( + gulp.parallel( + `build:${taskName(`es5`, `umd`)}`, + `build:${taskName(`esnext`, `cjs`)}`, + `build:${taskName(`esnext`, `esm`)}`, + `build:${taskName(`esnext`, `umd`)}` + ), + `clean:${npmPkgName}`, + `compile:${npmPkgName}`, + `package:${npmPkgName}` + ) ); gulp.task(`bundle:esbuild`, esbuildTask()); @@ -86,7 +90,10 @@ gulp.task(`bundle:webpack:analyze`, webpackTask({ analyze: true })); gulp.task(`bundle:clean`, () => del(`test/bundle/**/*-bundle.js`)); gulp.task(`bundle:exec`, execBundleTask()); -gulp.task(`bundle`, gulp.series(`bundle:clean`, `bundle:esbuild`, `bundle:rollup`, `bundle:webpack`, `bundle:exec`)); +gulp.task( + `bundle`, + gulp.series(`bundle:clean`, `bundle:esbuild`, `bundle:rollup`, `bundle:webpack`, `bundle:exec`) +); // And finally the global composite tasks gulp.task(`test`, gulpConcurrent(getTasks(`test`))); @@ -94,21 +101,25 @@ gulp.task(`clean`, gulp.parallel(getTasks(`clean`))); gulp.task(`build`, gulpConcurrent(getTasks(`build`))); gulp.task(`compile`, gulpConcurrent(getTasks(`compile`))); gulp.task(`package`, gulpConcurrent(getTasks(`package`))); -gulp.task(`default`, gulp.series(`clean`, `build`, `test`)); +gulp.task(`default`, gulp.series(`clean`, `build`, `test`)); function gulpConcurrent(tasks, numCPUs = Math.max(1, os.cpus().length * 0.5) | 0) { - return () => ObservableFrom(tasks.map((task) => gulp.series(task))) - .pipe(flatMap((task) => ObservableBindNodeCallback(task)(), numCPUs || 1)); + return () => + ObservableFrom(tasks.map((task) => gulp.series(task))).pipe( + flatMap((task) => ObservableBindNodeCallback(task)(), numCPUs || 1) + ); } function getTasks(name) { - const tasks = []; - if (targets.indexOf(`ts`) !== -1) tasks.push(`${name}:ts`); - if (targets.indexOf(npmPkgName) !== -1) tasks.push(`${name}:${npmPkgName}`); - for (const [target, format] of combinations(targets, modules)) { - if (tasksToSkipPerTargetOrFormat[target] && tasksToSkipPerTargetOrFormat[target][name]) continue; - if (tasksToSkipPerTargetOrFormat[format] && tasksToSkipPerTargetOrFormat[format][name]) continue; - tasks.push(`${name}:${taskName(target, format)}`); - } - return tasks.length && tasks || [(done) => done()]; + const tasks = []; + if (targets.indexOf(`ts`) !== -1) tasks.push(`${name}:ts`); + if (targets.indexOf(npmPkgName) !== -1) tasks.push(`${name}:${npmPkgName}`); + for (const [target, format] of combinations(targets, modules)) { + if (tasksToSkipPerTargetOrFormat[target] && tasksToSkipPerTargetOrFormat[target][name]) + continue; + if (tasksToSkipPerTargetOrFormat[format] && tasksToSkipPerTargetOrFormat[format][name]) + continue; + tasks.push(`${name}:${taskName(target, format)}`); + } + return (tasks.length && tasks) || [(done) => done()]; } diff --git a/jest.config.js b/jest.config.js index 34b5feb9..a3c04f78 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,45 +17,40 @@ export default { verbose: false, - testEnvironment: "node", - rootDir: ".", - roots: [ - "/spec/" - ], - cacheDirectory: ".jest-cache", - extensionsToTreatAsEsm: [".ts"], - moduleFileExtensions: ["js", "mjs", "ts"], - coverageReporters: ["lcov"], - coveragePathIgnorePatterns: [ - "spec\\/.*\\.(ts|tsx|js)$", - "/node_modules/" - ], + testEnvironment: 'node', + rootDir: '.', + roots: ['/spec/'], + cacheDirectory: '.jest-cache', + extensionsToTreatAsEsm: ['.ts'], + moduleFileExtensions: ['js', 'mjs', 'ts'], + coverageReporters: ['lcov'], + coveragePathIgnorePatterns: ['spec\\/.*\\.(ts|tsx|js)$', '/node_modules/'], moduleNameMapper: { - "^ix$": "/src/Ix.node", - "^ix(.*)": "/src$1", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix$': '/src/Ix.node', + '^ix(.*)': '/src$1', + '^(\\.{1,2}/.*)\\.js$': '$1', }, - testRegex: "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$", + testRegex: '(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$', transform: { - "^.+\\.jsx?$": [ - "ts-jest", + '^.+\\.jsx?$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "spec/tsconfig.json", - useESM: true - } + tsconfig: 'spec/tsconfig.json', + useESM: true, + }, ], - "^.+\\.tsx?$": [ - "ts-jest", + '^.+\\.tsx?$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "spec/tsconfig.json", - useESM: true - } - ] + tsconfig: 'spec/tsconfig.json', + useESM: true, + }, + ], }, transformIgnorePatterns: [ - "/targets/(es5|es2015|esnext|ix)/", - "/node_modules/(?!@openpgp/web-stream-tools)/", + '/targets/(es5|es2015|esnext|ix)/', + '/node_modules/(?!@openpgp/web-stream-tools)/', ], }; diff --git a/jest.coverage.config.js b/jest.coverage.config.js index 0853366b..8aec960f 100644 --- a/jest.coverage.config.js +++ b/jest.coverage.config.js @@ -16,11 +16,11 @@ // under the License. module.exports = { - ...require('./jest.config'), - "globals": { - "ts-jest": { - "diagnostics": false, - "tsConfig": "spec/tsconfig.coverage.json" - } - } + ...require('./jest.config'), + globals: { + 'ts-jest': { + diagnostics: false, + tsConfig: 'spec/tsconfig.coverage.json', + }, + }, }; diff --git a/jestconfigs/jest.es2015.cjs.config.js b/jestconfigs/jest.es2015.cjs.config.js index 3f6cbdab..cdb833a8 100644 --- a/jestconfigs/jest.es2015.cjs.config.js +++ b/jestconfigs/jest.es2015.cjs.config.js @@ -2,26 +2,26 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/es2015/cjs$1", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/es2015/cjs$1', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.cjs.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.cjs.json', }, ], }, diff --git a/jestconfigs/jest.es2015.esm.config.js b/jestconfigs/jest.es2015.esm.config.js index d31d462f..3a2a9785 100644 --- a/jestconfigs/jest.es2015.esm.config.js +++ b/jestconfigs/jest.es2015.esm.config.js @@ -2,28 +2,28 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/es2015/esm$1", - "tslib": "tslib/tslib.es6.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/es2015/esm$1', + tslib: 'tslib/tslib.es6.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.esm.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.esm.json', useESM: true, }, ], diff --git a/jestconfigs/jest.es2015.umd.config.js b/jestconfigs/jest.es2015.umd.config.js index 8d383a7f..d19efdea 100644 --- a/jestconfigs/jest.es2015.umd.config.js +++ b/jestconfigs/jest.es2015.umd.config.js @@ -2,29 +2,30 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", + rootDir: '../', moduleNameMapper: { - "^ix/asynciterable/operators(.*)": "/targets/es2015/umd/Ix.dom.asynciterable.operators.js", - "^ix/asynciterable(.*)": "/targets/es2015/umd/Ix.dom.asynciterable.js", - "^ix/iterable/operators(.*)": "/targets/es2015/umd/Ix.dom.iterable.operators.js", - "^ix/iterable(.*)": "/targets/es2015/umd/Ix.dom.iterable.js", - "^ix(.*)": "/targets/es2015/umd/Ix.dom.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix/asynciterable/operators(.*)': + '/targets/es2015/umd/Ix.dom.asynciterable.operators.js', + '^ix/asynciterable(.*)': '/targets/es2015/umd/Ix.dom.asynciterable.js', + '^ix/iterable/operators(.*)': '/targets/es2015/umd/Ix.dom.iterable.operators.js', + '^ix/iterable(.*)': '/targets/es2015/umd/Ix.dom.iterable.js', + '^ix(.*)': '/targets/es2015/umd/Ix.dom.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.umd.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es2015.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.es2015.umd.json', }, ], }, diff --git a/jestconfigs/jest.es5.cjs.config.js b/jestconfigs/jest.es5.cjs.config.js index 80a14e39..8c79431a 100644 --- a/jestconfigs/jest.es5.cjs.config.js +++ b/jestconfigs/jest.es5.cjs.config.js @@ -2,26 +2,26 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/es5/cjs$1", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/es5/cjs$1', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.cjs.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.cjs.json', }, ], }, diff --git a/jestconfigs/jest.es5.esm.config.js b/jestconfigs/jest.es5.esm.config.js index ed8b00b5..2e3b78ab 100644 --- a/jestconfigs/jest.es5.esm.config.js +++ b/jestconfigs/jest.es5.esm.config.js @@ -2,28 +2,28 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/es5/esm$1", - "tslib": "tslib/tslib.es6.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/es5/esm$1', + tslib: 'tslib/tslib.es6.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.esm.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.esm.json', useESM: true, }, ], diff --git a/jestconfigs/jest.es5.umd.config.js b/jestconfigs/jest.es5.umd.config.js index 24ec2c14..ef3e8426 100644 --- a/jestconfigs/jest.es5.umd.config.js +++ b/jestconfigs/jest.es5.umd.config.js @@ -2,29 +2,30 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", + rootDir: '../', moduleNameMapper: { - "^ix/asynciterable/operators(.*)": "/targets/es5/umd/Ix.dom.asynciterable.operators.js", - "^ix/asynciterable(.*)": "/targets/es5/umd/Ix.dom.asynciterable.js", - "^ix/iterable/operators(.*)": "/targets/es5/umd/Ix.dom.iterable.operators.js", - "^ix/iterable(.*)": "/targets/es5/umd/Ix.dom.iterable.js", - "^ix(.*)": "/targets/es5/umd/Ix.dom.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix/asynciterable/operators(.*)': + '/targets/es5/umd/Ix.dom.asynciterable.operators.js', + '^ix/asynciterable(.*)': '/targets/es5/umd/Ix.dom.asynciterable.js', + '^ix/iterable/operators(.*)': '/targets/es5/umd/Ix.dom.iterable.operators.js', + '^ix/iterable(.*)': '/targets/es5/umd/Ix.dom.iterable.js', + '^ix(.*)': '/targets/es5/umd/Ix.dom.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.umd.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.es5.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.es5.umd.json', }, ], }, diff --git a/jestconfigs/jest.esnext.cjs.config.js b/jestconfigs/jest.esnext.cjs.config.js index cca1b727..0ca9de54 100644 --- a/jestconfigs/jest.esnext.cjs.config.js +++ b/jestconfigs/jest.esnext.cjs.config.js @@ -2,26 +2,26 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/esnext/cjs$1", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/esnext/cjs$1', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.cjs.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.cjs.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.cjs.json', }, ], }, diff --git a/jestconfigs/jest.esnext.esm.config.js b/jestconfigs/jest.esnext.esm.config.js index 2ba58f88..d7ec7e5f 100644 --- a/jestconfigs/jest.esnext.esm.config.js +++ b/jestconfigs/jest.esnext.esm.config.js @@ -2,28 +2,28 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/esnext/esm$1", - "tslib": "tslib/tslib.es6.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/esnext/esm$1', + tslib: 'tslib/tslib.es6.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.esm.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.esm.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.esm.json', useESM: true, }, ], diff --git a/jestconfigs/jest.esnext.umd.config.js b/jestconfigs/jest.esnext.umd.config.js index b9fb044c..47d97f44 100644 --- a/jestconfigs/jest.esnext.umd.config.js +++ b/jestconfigs/jest.esnext.umd.config.js @@ -2,29 +2,30 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", + rootDir: '../', moduleNameMapper: { - "^ix/asynciterable/operators(.*)": "/targets/esnext/umd/Ix.dom.asynciterable.operators.js", - "^ix/asynciterable(.*)": "/targets/esnext/umd/Ix.dom.asynciterable.js", - "^ix/iterable/operators(.*)": "/targets/esnext/umd/Ix.dom.iterable.operators.js", - "^ix/iterable(.*)": "/targets/esnext/umd/Ix.dom.iterable.js", - "^ix(.*)": "/targets/esnext/umd/Ix.dom.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix/asynciterable/operators(.*)': + '/targets/esnext/umd/Ix.dom.asynciterable.operators.js', + '^ix/asynciterable(.*)': '/targets/esnext/umd/Ix.dom.asynciterable.js', + '^ix/iterable/operators(.*)': '/targets/esnext/umd/Ix.dom.iterable.operators.js', + '^ix/iterable(.*)': '/targets/esnext/umd/Ix.dom.iterable.js', + '^ix(.*)': '/targets/esnext/umd/Ix.dom.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.umd.json', }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.esnext.umd.json", + tsconfig: '/spec/tsconfig/tsconfig.esnext.umd.json', }, ], }, diff --git a/jestconfigs/jest.ix.config.js b/jestconfigs/jest.ix.config.js index da2e9c6c..09767c87 100644 --- a/jestconfigs/jest.ix.config.js +++ b/jestconfigs/jest.ix.config.js @@ -2,27 +2,27 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix(.*)": "/targets/ix$1", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix(.*)': '/targets/ix$1', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.ix.json", + tsconfig: '/spec/tsconfig/tsconfig.ix.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.ix.json", + tsconfig: '/spec/tsconfig/tsconfig.ix.json', useESM: true, }, ], diff --git a/jestconfigs/jest.src.config.js b/jestconfigs/jest.src.config.js index 27e0e605..d9b2fd69 100644 --- a/jestconfigs/jest.src.config.js +++ b/jestconfigs/jest.src.config.js @@ -2,29 +2,29 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix": "/src/Ix.node.ts", - "^ix(.*)\\.js": "/src$1.ts", - "tslib": "tslib/tslib.es6.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix': '/src/Ix.node.ts', + '^ix(.*)\\.js': '/src$1.ts', + tslib: 'tslib/tslib.es6.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.src.json", + tsconfig: '/spec/tsconfig/tsconfig.src.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.src.json", + tsconfig: '/spec/tsconfig/tsconfig.src.json', useESM: true, }, ], diff --git a/jestconfigs/jest.ts.config.js b/jestconfigs/jest.ts.config.js index e618640d..d86b9a5b 100644 --- a/jestconfigs/jest.ts.config.js +++ b/jestconfigs/jest.ts.config.js @@ -2,29 +2,29 @@ import config from '../jest.config.js'; export default { ...config, - rootDir: "../", - moduleFileExtensions: ["js", "ts"], + rootDir: '../', + moduleFileExtensions: ['js', 'ts'], moduleNameMapper: { - "^ix": "/targets/ts/Ix.node", - "^ix(.*)": "/targets/ts$1", - "tslib": "tslib/tslib.es6.js", - "^(\\.{1,2}/.*)\\.js$": "$1", + '^ix': '/targets/ts/Ix.node', + '^ix(.*)': '/targets/ts$1', + tslib: 'tslib/tslib.es6.js', + '^(\\.{1,2}/.*)\\.js$': '$1', }, transform: { ...config.transform, - "^.+\\.js$": [ - "ts-jest", + '^.+\\.js$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.ts.json", + tsconfig: '/spec/tsconfig/tsconfig.ts.json', useESM: true, }, ], - "^.+\\.ts$": [ - "ts-jest", + '^.+\\.ts$': [ + 'ts-jest', { diagnostics: false, - tsconfig: "/spec/tsconfig/tsconfig.ts.json", + tsconfig: '/spec/tsconfig/tsconfig.ts.json', useESM: true, }, ],