From af657cc0d9de78ba0507c8dba6b0cb01902897c2 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Tue, 6 Jul 2021 21:10:09 -0700 Subject: [PATCH 01/21] Replace indexOf with includes --- js/gulp/arrow-task.js | 4 ++-- js/gulp/typescript-task.js | 1 - js/gulp/util.js | 10 +++++----- js/gulpfile.js | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js index 93e9475e936..277ee745f9e 100644 --- a/js/gulp/arrow-task.js +++ b/js/gulp/arrow-task.js @@ -57,8 +57,8 @@ const arrowTSTask = ((cache) => memoizeTask(cache, async function copyTS(target, await pipeline(gulp.src(`src/**/*`), gulp.dest(out)); await del(`${out}/**/*.js`); }))({}); - - + + module.exports = arrowTask; module.exports.arrowTask = arrowTask; module.exports.arrowTSTask = arrowTSTask; diff --git a/js/gulp/typescript-task.js b/js/gulp/typescript-task.js index a56de42d381..1c488ecb769 100644 --- a/js/gulp/typescript-task.js +++ b/js/gulp/typescript-task.js @@ -31,7 +31,6 @@ const { memoizeTask } = require('./memoize-task'); const { Observable, ReplaySubject } = require('rxjs'); const typescriptTask = ((cache) => memoizeTask(cache, function typescript(target, format) { - if (shouldRunInChildProcess(target, format)) { return spawnGulpCommandInChildProcess('compile', target, format); } diff --git a/js/gulp/util.js b/js/gulp/util.js index cf53d0ef18b..673cd849799 100644 --- a/js/gulp/util.js +++ b/js/gulp/util.js @@ -121,12 +121,12 @@ function* combinations(_targets, _modules) { const targets = known(knownTargets, _targets || [`all`]); const modules = known(knownModules, _modules || [`all`]); - if (_targets.indexOf(`src`) > -1) { + if (_targets.includes(`src`)) { yield [`src`, ``]; return; } - if (_targets.indexOf(`all`) > -1 && _modules.indexOf(`all`) > -1) { + if (_targets.includes(`all`) && _modules.includes(`all`)) { yield [`ts`, ``]; yield [`src`, ``]; yield [npmPkgName, ``]; @@ -139,11 +139,11 @@ function* combinations(_targets, _modules) { } function known(known, values) { - return ~values.indexOf(`all`) ? known - : ~values.indexOf(`src`) ? [`src`] + return values.includes(`all`) ? known + : values.includes(`src`) ? [`src`] : Object.keys( values.reduce((map, arg) => (( - (known.indexOf(arg) !== -1) && + (known.includes(arg)) && (map[arg.toLowerCase()] = true) || true) && map ), {}) diff --git a/js/gulpfile.js b/js/gulpfile.js index 019f5b0e056..ad520462818 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -90,8 +90,8 @@ function gulpConcurrent(tasks) { function getTasks(name) { const tasks = []; - if (targets.indexOf(`ts`) !== -1) tasks.push(`${name}:ts`); - if (targets.indexOf(npmPkgName) !== -1) tasks.push(`${name}:${npmPkgName}`); + if (targets.includes(`ts`)) tasks.push(`${name}:ts`); + if (targets.includes(npmPkgName)) 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; From 9b4825c94decf9ae4cf97bc0b19faedd5283f5e3 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Tue, 6 Jul 2021 21:10:26 -0700 Subject: [PATCH 02/21] Compile declaration maps --- js/DEVELOP.md | 2 +- js/tsconfig/tsconfig.base.json | 1 + js/tsconfig/tsconfig.bin.cjs.json | 3 ++- js/tsconfig/tsconfig.es2015.cls.json | 1 + js/tsconfig/tsconfig.es5.cls.json | 1 + js/tsconfig/tsconfig.esnext.cls.json | 1 + 6 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/DEVELOP.md b/js/DEVELOP.md index cba4faf3aa5..66cefb08435 100644 --- a/js/DEVELOP.md +++ b/js/DEVELOP.md @@ -50,7 +50,7 @@ We use [yarn](https://yarnpkg.com/) to install dependencies and run scrips. These scripts accept argument lists of targets × modules: -* Available `targets` are `es5`, `es2015`, `esnext`, and `all` (default: `all`) +* Available `targets` are `es5`, `es2015`, `esnext`, `ts`, and `all` (default: `all`) * Available `modules` are `cjs`, `esm`, `umd`, and `all` (default: `all`) Examples: diff --git a/js/tsconfig/tsconfig.base.json b/js/tsconfig/tsconfig.base.json index 1fbd3296bf6..91f7c31bc80 100644 --- a/js/tsconfig/tsconfig.base.json +++ b/js/tsconfig/tsconfig.base.json @@ -10,6 +10,7 @@ /* Control what is emitted */ "declaration": true, + "declarationMap": true, "noEmitOnError": true, "removeComments": false, "noErrorTruncation": true, diff --git a/js/tsconfig/tsconfig.bin.cjs.json b/js/tsconfig/tsconfig.bin.cjs.json index 8a006490aef..bb40e342f9b 100644 --- a/js/tsconfig/tsconfig.bin.cjs.json +++ b/js/tsconfig/tsconfig.bin.cjs.json @@ -6,6 +6,7 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "declaration": false + "declaration": false, + "declarationMap": false } } diff --git a/js/tsconfig/tsconfig.es2015.cls.json b/js/tsconfig/tsconfig.es2015.cls.json index fe2f0b4022a..7cc364b3658 100644 --- a/js/tsconfig/tsconfig.es2015.cls.json +++ b/js/tsconfig/tsconfig.es2015.cls.json @@ -5,6 +5,7 @@ "target": "esnext", "module": "es2015", "declaration": false, + "declarationMap": false, "noEmitHelpers": true, "importHelpers": false } diff --git a/js/tsconfig/tsconfig.es5.cls.json b/js/tsconfig/tsconfig.es5.cls.json index 2c379b84759..a03808d365c 100644 --- a/js/tsconfig/tsconfig.es5.cls.json +++ b/js/tsconfig/tsconfig.es5.cls.json @@ -5,6 +5,7 @@ "target": "esnext", "module": "es2015", "declaration": false, + "declarationMap": false, "noEmitHelpers": true, "importHelpers": false } diff --git a/js/tsconfig/tsconfig.esnext.cls.json b/js/tsconfig/tsconfig.esnext.cls.json index 176a72ba614..dc35c3f8837 100644 --- a/js/tsconfig/tsconfig.esnext.cls.json +++ b/js/tsconfig/tsconfig.esnext.cls.json @@ -5,6 +5,7 @@ "target": "esnext", "module": "es2015", "declaration": false, + "declarationMap": false, "noEmitHelpers": true, "importHelpers": false } From 5a5dc31fb5513a6c8aff6280f74ac57e36e9cccb Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Tue, 6 Jul 2021 22:03:26 -0700 Subject: [PATCH 03/21] Compile declaration maps and include sources --- js/gulp/typescript-task.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/gulp/typescript-task.js b/js/gulp/typescript-task.js index 1c488ecb769..928e473141b 100644 --- a/js/gulp/typescript-task.js +++ b/js/gulp/typescript-task.js @@ -54,10 +54,11 @@ function compileTypescript(out, tsconfigPath, tsconfigOverrides) { tsProject.src(), sourcemaps.init(), tsProject(ts.reporter.defaultReporter()) ); - const writeDTypes = observableFromStreams(dts, gulp.dest(out)); + const writeSources = observableFromStreams(tsProject.src(), gulp.dest(out)); + const writeDTypes = observableFromStreams(dts, sourcemaps.write('./', { includeContent: false }), gulp.dest(out)); const mapFile = tsProject.options.module === 5 ? esmMapFile : cjsMapFile; - const writeJS = observableFromStreams(js, sourcemaps.write('./', { mapFile }), gulp.dest(out)); - return Observable.forkJoin(writeDTypes, writeJS); + const writeJS = observableFromStreams(js, sourcemaps.write('./', { mapFile, includeContent: false }), gulp.dest(out)); + return Observable.forkJoin(writeSources, writeDTypes, writeJS); } function cjsMapFile(mapFilePath) { return mapFilePath; } From f6c70db8f4adc76132882767b6bd6e720c145e3e Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 7 Jul 2021 07:43:03 -0700 Subject: [PATCH 04/21] Do not transform cjs code --- js/jest.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/jest.config.js b/js/jest.config.js index 9ebf291f701..56588ba4d12 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -45,7 +45,8 @@ module.exports = { "^.+\\.tsx?$": "ts-jest" }, "transformIgnorePatterns": [ - "/node_modules/(?!web-stream-tools).+\\.js$" + "/node_modules/(?!web-stream-tools).+\\.js$", + ".*/cjs/.*\\.js$" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$", "preset": "ts-jest", From 240226472b6fa9c80c8eddf3b0a1957de9398821 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Jul 2021 15:01:51 -0500 Subject: [PATCH 05/21] add test jest configs, path mappings to tsconfigs --- js/gulp/test-task.js | 11 +++-- js/jest.config.js | 9 ++++- js/jestconfigs/jest.apache-arrow.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es2015.cjs.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es2015.esm.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es2015.umd.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es5.cjs.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es5.esm.config.js | 29 ++++++++++++++ js/jestconfigs/jest.es5.umd.config.js | 29 ++++++++++++++ js/jestconfigs/jest.esnext.cjs.config.js | 29 ++++++++++++++ js/jestconfigs/jest.esnext.esm.config.js | 29 ++++++++++++++ js/jestconfigs/jest.esnext.umd.config.js | 29 ++++++++++++++ js/jestconfigs/jest.src.config.js | 29 ++++++++++++++ js/jestconfigs/jest.ts.config.js | 29 ++++++++++++++ js/test/Arrow.ts | 40 +++++++++++-------- js/test/tsconfig.json | 5 ++- js/test/tsconfig/tsconfig.apache-arrow.json | 13 ++++++ js/test/tsconfig/tsconfig.base.json | 17 ++++++++ js/test/tsconfig/tsconfig.es2015.cjs.json | 13 ++++++ js/test/tsconfig/tsconfig.es2015.esm.json | 13 ++++++ js/test/tsconfig/tsconfig.es2015.umd.json | 16 ++++++++ js/test/tsconfig/tsconfig.es5.cjs.json | 14 +++++++ js/test/tsconfig/tsconfig.es5.esm.json | 14 +++++++ js/test/tsconfig/tsconfig.es5.umd.json | 17 ++++++++ js/test/tsconfig/tsconfig.esnext.cjs.json | 13 ++++++ js/test/tsconfig/tsconfig.esnext.esm.json | 13 ++++++ js/test/tsconfig/tsconfig.esnext.umd.json | 16 ++++++++ js/test/tsconfig/tsconfig.src.json | 13 ++++++ js/test/tsconfig/tsconfig.ts.json | 13 ++++++ js/test/unit/bit-tests.ts | 2 +- js/test/unit/builders/builder-tests.ts | 2 +- js/test/unit/builders/date-tests.ts | 2 +- js/test/unit/builders/dictionary-tests.ts | 2 +- js/test/unit/builders/int64-tests.ts | 2 +- js/test/unit/builders/primitive-tests.ts | 2 +- js/test/unit/builders/uint64-tests.ts | 2 +- js/test/unit/builders/utf8-tests.ts | 2 +- js/test/unit/builders/utils.ts | 6 +-- js/test/unit/dataframe-tests.ts | 2 +- js/test/unit/generated-data-validators.ts | 2 +- js/test/unit/int-tests.ts | 2 +- js/test/unit/ipc/helpers.ts | 2 +- js/test/unit/ipc/message-reader-tests.ts | 2 +- js/test/unit/ipc/reader/file-reader-tests.ts | 2 +- .../unit/ipc/reader/from-inference-tests.ts | 2 +- js/test/unit/ipc/reader/json-reader-tests.ts | 2 +- .../unit/ipc/reader/stream-reader-tests.ts | 2 +- js/test/unit/ipc/reader/streams-dom-tests.ts | 2 +- js/test/unit/ipc/reader/streams-node-tests.ts | 2 +- js/test/unit/ipc/validate.ts | 2 +- js/test/unit/ipc/writer/file-writer-tests.ts | 2 +- js/test/unit/ipc/writer/json-writer-tests.ts | 2 +- .../unit/ipc/writer/stream-writer-tests.ts | 4 +- js/test/unit/ipc/writer/streams-dom-tests.ts | 2 +- js/test/unit/ipc/writer/streams-node-tests.ts | 2 +- js/test/unit/math-tests.ts | 2 +- .../unit/recordbatch/record-batch-tests.ts | 2 +- js/test/unit/table-tests.ts | 2 +- js/test/unit/table/assign-tests.ts | 2 +- js/test/unit/table/serialize-tests.ts | 2 +- js/test/unit/vector/bool-vector-tests.ts | 2 +- js/test/unit/vector/date-vector-tests.ts | 2 +- js/test/unit/vector/numeric-vector-tests.ts | 2 +- js/test/unit/vector/vector-tests.ts | 2 +- js/test/unit/visitor-tests.ts | 6 +-- js/tsconfig.json | 17 +++++++- js/tsconfig/tsconfig.base.json | 6 +++ 67 files changed, 637 insertions(+), 66 deletions(-) create mode 100644 js/jestconfigs/jest.apache-arrow.config.js create mode 100644 js/jestconfigs/jest.es2015.cjs.config.js create mode 100644 js/jestconfigs/jest.es2015.esm.config.js create mode 100644 js/jestconfigs/jest.es2015.umd.config.js create mode 100644 js/jestconfigs/jest.es5.cjs.config.js create mode 100644 js/jestconfigs/jest.es5.esm.config.js create mode 100644 js/jestconfigs/jest.es5.umd.config.js create mode 100644 js/jestconfigs/jest.esnext.cjs.config.js create mode 100644 js/jestconfigs/jest.esnext.esm.config.js create mode 100644 js/jestconfigs/jest.esnext.umd.config.js create mode 100644 js/jestconfigs/jest.src.config.js create mode 100644 js/jestconfigs/jest.ts.config.js create mode 100644 js/test/tsconfig/tsconfig.apache-arrow.json create mode 100644 js/test/tsconfig/tsconfig.base.json create mode 100644 js/test/tsconfig/tsconfig.es2015.cjs.json create mode 100644 js/test/tsconfig/tsconfig.es2015.esm.json create mode 100644 js/test/tsconfig/tsconfig.es2015.umd.json create mode 100644 js/test/tsconfig/tsconfig.es5.cjs.json create mode 100644 js/test/tsconfig/tsconfig.es5.esm.json create mode 100644 js/test/tsconfig/tsconfig.es5.umd.json create mode 100644 js/test/tsconfig/tsconfig.esnext.cjs.json create mode 100644 js/test/tsconfig/tsconfig.esnext.esm.json create mode 100644 js/test/tsconfig/tsconfig.esnext.umd.json create mode 100644 js/test/tsconfig/tsconfig.src.json create mode 100644 js/test/tsconfig/tsconfig.ts.json diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 699070a8ff4..e083efc7e0a 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -31,9 +31,6 @@ const parseXML = promisify(require('xml2js').parseString); const jestArgv = [`--reporters=jest-silent-reporter`]; argv.verbose && jestArgv.push(`--verbose`); -argv.coverage - ? jestArgv.push(`-c`, `jest.coverage.config.js`, `--coverage`, `-i`) - : jestArgv.push(`-c`, `jest.config.js`, `-i`) const jest = path.join(path.parse(require.resolve(`jest`)).dir, `../bin/jest.js`); const testOptions = { @@ -50,7 +47,13 @@ const testOptions = { const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format) { const opts = { ...testOptions }; - const args = [...execArgv, `test/unit/`]; + const args = [...execArgv]; + if (argv.coverage) { + args.push(`-c`, `jest.coverage.config.js`, `--coverage`, `-i`, `--no-cache`); + } else { + const cfgname = [target, format].filter(Boolean).join('.'); + args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `-i`, `--no-cache`, `test/unit/`); + } opts.env = { ...opts.env, TEST_TARGET: target, diff --git a/js/jest.config.js b/js/jest.config.js index 56588ba4d12..29e294e4274 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -45,10 +45,15 @@ module.exports = { "^.+\\.tsx?$": "ts-jest" }, "transformIgnorePatterns": [ + "/(es5|es2015|esnext)/umd/", + "/targets/(es5|es2015|esnext)/", "/node_modules/(?!web-stream-tools).+\\.js$", - ".*/cjs/.*\\.js$" + // ".*/cjs/.*\\.js$" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$", "preset": "ts-jest", - "testMatch": null + "testMatch": null, + "moduleNameMapper": { + "^apache-arrow(.*)": "/src/$1.js" + } }; diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js new file mode 100644 index 00000000000..6580cff084a --- /dev/null +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.apache-arrow.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/apache-arrow$1" + } +}; diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js new file mode 100644 index 00000000000..436cb3833f2 --- /dev/null +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es2015.cjs.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es2015/cjs$1" + } +}; diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js new file mode 100644 index 00000000000..909030c6788 --- /dev/null +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es2015.esm.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es2015/esm$1" + } +}; diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js new file mode 100644 index 00000000000..9e5b1c3b0be --- /dev/null +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es2015.umd.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es2015/umd/Arrow.js" + } +}; diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js new file mode 100644 index 00000000000..fbf1d2ee58a --- /dev/null +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es5.cjs.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es5/cjs$1" + } +}; diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js new file mode 100644 index 00000000000..daa86886019 --- /dev/null +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es5.esm.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es5/esm$1" + } +}; diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js new file mode 100644 index 00000000000..ef36f801de8 --- /dev/null +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.es5.umd.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/es5/umd/Arrow.js" + } +}; diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js new file mode 100644 index 00000000000..5d7c667396c --- /dev/null +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.esnext.cjs.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/esnext/cjs$1" + } +}; diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js new file mode 100644 index 00000000000..e1b97300c47 --- /dev/null +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.esnext.esm.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/esnext/esm$1" + } +}; diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js new file mode 100644 index 00000000000..169906f260f --- /dev/null +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.esnext.umd.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/esnext/umd/Arrow.js" + } +}; diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js new file mode 100644 index 00000000000..fa933f01b93 --- /dev/null +++ b/js/jestconfigs/jest.src.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "/spec/tsconfig/tsconfig.src.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/src$1" + } +}; diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js new file mode 100644 index 00000000000..b1351b8a3d8 --- /dev/null +++ b/js/jestconfigs/jest.ts.config.js @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module.exports = { + ...require('../jest.config'), + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": "spec/tsconfig/tsconfig.ts.json" + } + }, + "moduleNameMapper": { + "^apache-arrow(.*)": "/targets/ts$1" + } +}; diff --git a/js/test/Arrow.ts b/js/test/Arrow.ts index 8fe53b019d2..cb469597c53 100644 --- a/js/test/Arrow.ts +++ b/js/test/Arrow.ts @@ -17,7 +17,8 @@ // Dynamically load an Arrow target build based on command line arguments -import 'web-streams-polyfill/es6'; +import 'web-streams-polyfill'; +// import 'web-streams-polyfill/es6'; // import this before assigning window global since it does a `typeof window` check require('web-stream-tools'); @@ -32,6 +33,7 @@ Object.defineProperty(Object, Symbol.hasInstance, { return inst?.constructor && inst.constructor.name === 'Object'; } }); + Object.defineProperty(ArrayBuffer, Symbol.hasInstance, { writable: true, configurable: true, @@ -40,23 +42,29 @@ Object.defineProperty(ArrayBuffer, Symbol.hasInstance, { } }); -// these are duplicated in the gulpfile :< -const targets = [`es5`, `es2015`, `esnext`]; -const formats = [`cjs`, `esm`, `cls`, `umd`]; +// // these are duplicated in the gulpfile :< +// const targets = [`es5`, `es2015`, `esnext`]; +// const formats = [`cjs`, `esm`, `cls`, `umd`]; + +// const path = require('path'); +// const target = process.env.TEST_TARGET!; +// const format = process.env.TEST_MODULE!; +// const useSrc = process.env.TEST_TS_SOURCE === `true` || (!~targets.indexOf(target) || !~formats.indexOf(format)); + +// let modulePath = ``; -const path = require('path'); -const target = process.env.TEST_TARGET!; -const format = process.env.TEST_MODULE!; -const useSrc = process.env.TEST_TS_SOURCE === `true` || (!~targets.indexOf(target) || !~formats.indexOf(format)); +// if (useSrc) modulePath = '../src'; +// else if (target === `ts` || target === `apache-arrow`) modulePath = target; +// else modulePath = path.join(target, format); -let modulePath = ``; +// modulePath = path.resolve(`./targets`, modulePath); +// modulePath = path.join(modulePath, `Arrow${format === 'umd' ? '' : '.node'}`); +// const Arrow: typeof import('../src/Arrow') = require(modulePath); -if (useSrc) modulePath = '../src'; -else if (target === `ts` || target === `apache-arrow`) modulePath = target; -else modulePath = path.join(target, format); +// export = Arrow; -modulePath = path.resolve(`./targets`, modulePath); -modulePath = path.join(modulePath, `Arrow${format === 'umd' ? '' : '.node'}`); -const Arrow: typeof import('../src/Arrow') = require(modulePath); +// Require rxjs first so we pick up its polyfilled Symbol.observable +// eslint-disable-next-line @typescript-eslint/no-require-imports +require('rxjs/internal/symbol/observable'); -export = Arrow; +export * from 'apache-arrow'; diff --git a/js/test/tsconfig.json b/js/test/tsconfig.json index c4977d5d694..9a2b52390b6 100644 --- a/js/test/tsconfig.json +++ b/js/test/tsconfig.json @@ -1,6 +1,9 @@ { "extends": "../tsconfig.json", - "include": ["./**/*.ts"], + "include": [ + "../src/**/*.ts", + "../test/**/*.ts" + ], "compilerOptions": { "target": "esnext", "module": "commonjs", diff --git a/js/test/tsconfig/tsconfig.apache-arrow.json b/js/test/tsconfig/tsconfig.apache-arrow.json new file mode 100644 index 00000000000..47c1f4a8563 --- /dev/null +++ b/js/test/tsconfig/tsconfig.apache-arrow.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ES5 CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "paths": { + "apache-arrow/*": [ + "targets/apache-arrow" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.base.json b/js/test/tsconfig/tsconfig.base.json new file mode 100644 index 00000000000..65a752f5346 --- /dev/null +++ b/js/test/tsconfig/tsconfig.base.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "allowJs": true, + "declaration": false, + "importHelpers": false, + "noEmitHelpers": false, + "noEmitOnError": false, + "sourceMap": false, + "inlineSources": false, + "inlineSourceMap": false, + "downlevelIteration": false, + "baseUrl": "../../" + } +} diff --git a/js/test/tsconfig/tsconfig.es2015.cjs.json b/js/test/tsconfig/tsconfig.es2015.cjs.json new file mode 100644 index 00000000000..b9f67865884 --- /dev/null +++ b/js/test/tsconfig/tsconfig.es2015.cjs.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ES2015 CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES2015", + "module": "commonjs", + "paths": { + "apache-arrow/*": [ + "targets/es2015/cjs/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.es2015.esm.json b/js/test/tsconfig/tsconfig.es2015.esm.json new file mode 100644 index 00000000000..44340d7ff90 --- /dev/null +++ b/js/test/tsconfig/tsconfig.es2015.esm.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ES2015 ESModules target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES2015", + "module": "es2015", + "paths": { + "apache-arrow/*": [ + "targets/es2015/esm/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.es2015.umd.json b/js/test/tsconfig/tsconfig.es2015.umd.json new file mode 100644 index 00000000000..eac847c0cec --- /dev/null +++ b/js/test/tsconfig/tsconfig.es2015.umd.json @@ -0,0 +1,16 @@ +//Compiler configuaration to build the ES2015 Closure Compiler target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES2015", + "module": "es2015", + "declaration": false, + "noEmitHelpers": true, + "importHelpers": true, + "paths": { + "apache-arrow/*": [ + "targets/es2015/umd/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.es5.cjs.json b/js/test/tsconfig/tsconfig.es5.cjs.json new file mode 100644 index 00000000000..a6fea1449c1 --- /dev/null +++ b/js/test/tsconfig/tsconfig.es5.cjs.json @@ -0,0 +1,14 @@ +//Compiler configuaration to build the ES5 CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES5", + "module": "commonjs", + "downlevelIteration": true, + "paths": { + "apache-arrow/*": [ + "targets/es5/cjs/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.es5.esm.json b/js/test/tsconfig/tsconfig.es5.esm.json new file mode 100644 index 00000000000..63c622fb85f --- /dev/null +++ b/js/test/tsconfig/tsconfig.es5.esm.json @@ -0,0 +1,14 @@ +//Compiler configuaration to build the ES5 ESModules target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES5", + "module": "es2015", + "downlevelIteration": true, + "paths": { + "apache-arrow/*": [ + "targets/es5/esm/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.es5.umd.json b/js/test/tsconfig/tsconfig.es5.umd.json new file mode 100644 index 00000000000..e37fecc9203 --- /dev/null +++ b/js/test/tsconfig/tsconfig.es5.umd.json @@ -0,0 +1,17 @@ +//Compiler configuaration to build the ES5 Closure Compiler target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES5", + "module": "es2015", + "declaration": false, + "noEmitHelpers": true, + "importHelpers": true, + "downlevelIteration": true, + "paths": { + "apache-arrow/*": [ + "targets/es5/umd/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.esnext.cjs.json b/js/test/tsconfig/tsconfig.esnext.cjs.json new file mode 100644 index 00000000000..3289396b880 --- /dev/null +++ b/js/test/tsconfig/tsconfig.esnext.cjs.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ESNext CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ESNEXT", + "module": "commonjs", + "paths": { + "apache-arrow/*": [ + "targets/esnext/cjs/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.esnext.esm.json b/js/test/tsconfig/tsconfig.esnext.esm.json new file mode 100644 index 00000000000..3eb820d66bc --- /dev/null +++ b/js/test/tsconfig/tsconfig.esnext.esm.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ESNext ESModules target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ESNEXT", + "module": "es2015", + "paths": { + "apache-arrow/*": [ + "targets/esnext/esm/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.esnext.umd.json b/js/test/tsconfig/tsconfig.esnext.umd.json new file mode 100644 index 00000000000..838492d0443 --- /dev/null +++ b/js/test/tsconfig/tsconfig.esnext.umd.json @@ -0,0 +1,16 @@ +//Compiler configuaration to build the ESNext Closure Compiler target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ESNEXT", + "module": "es2015", + "declaration": false, + "noEmitHelpers": true, + "importHelpers": true, + "paths": { + "apache-arrow/*": [ + "targets/esnext/umd/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.src.json b/js/test/tsconfig/tsconfig.src.json new file mode 100644 index 00000000000..df3e9c15b64 --- /dev/null +++ b/js/test/tsconfig/tsconfig.src.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ES5 CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "paths": { + "apache-arrow/*": [ + "src/*" + ] + } + } +} diff --git a/js/test/tsconfig/tsconfig.ts.json b/js/test/tsconfig/tsconfig.ts.json new file mode 100644 index 00000000000..63619bb710b --- /dev/null +++ b/js/test/tsconfig/tsconfig.ts.json @@ -0,0 +1,13 @@ +//Compiler configuaration to build the ES5 CommonJS target +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "paths": { + "apache-arrow/*": [ + "targets/ts/*" + ] + } + } +} diff --git a/js/test/unit/bit-tests.ts b/js/test/unit/bit-tests.ts index de9c5ee67a7..cdfb37c1681 100644 --- a/js/test/unit/bit-tests.ts +++ b/js/test/unit/bit-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import * as Arrow from '../Arrow'; +import * as Arrow from 'apache-arrow'; const { BitIterator, getBool } = Arrow.util; describe('Bits', () => { diff --git a/js/test/unit/builders/builder-tests.ts b/js/test/unit/builders/builder-tests.ts index 6817999a034..a094fa1e976 100644 --- a/js/test/unit/builders/builder-tests.ts +++ b/js/test/unit/builders/builder-tests.ts @@ -19,7 +19,7 @@ import '../../jest-extensions'; import { AsyncIterable } from 'ix'; import { validateVector } from './utils'; import * as generate from '../../generate-test-data'; -import { Type, DataType, Chunked, util, Builder, UnionVector } from '../../Arrow'; +import { Type, DataType, Chunked, util, Builder, UnionVector } from 'apache-arrow'; const testDOMStreams = process.env.TEST_DOM_STREAMS === 'true'; const testNodeStreams = process.env.TEST_NODE_STREAMS === 'true'; diff --git a/js/test/unit/builders/date-tests.ts b/js/test/unit/builders/date-tests.ts index 812383494c1..5a9cc092b16 100644 --- a/js/test/unit/builders/date-tests.ts +++ b/js/test/unit/builders/date-tests.ts @@ -16,7 +16,7 @@ // under the License. import { validateVector } from './utils'; -import { Vector, DateDay, DateMillisecond } from '../../Arrow'; +import { Vector, DateDay, DateMillisecond } from 'apache-arrow'; import { encodeAll, encodeEach, diff --git a/js/test/unit/builders/dictionary-tests.ts b/js/test/unit/builders/dictionary-tests.ts index 9314aced047..19b3603bce1 100644 --- a/js/test/unit/builders/dictionary-tests.ts +++ b/js/test/unit/builders/dictionary-tests.ts @@ -16,7 +16,7 @@ // under the License. import { validateVector } from './utils'; -import { Dictionary, Utf8, Int32, Vector } from '../../Arrow'; +import { Dictionary, Utf8, Int32, Vector } from 'apache-arrow'; import { encodeAll, encodeEach, diff --git a/js/test/unit/builders/int64-tests.ts b/js/test/unit/builders/int64-tests.ts index 38e6cecd10e..876ce703028 100644 --- a/js/test/unit/builders/int64-tests.ts +++ b/js/test/unit/builders/int64-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { util, Vector, DataType, Int64 } from '../../Arrow'; +import { util, Vector, DataType, Int64 } from 'apache-arrow'; import { validateVector, encodeAll, encodeEach, encodeEachDOM, encodeEachNode, diff --git a/js/test/unit/builders/primitive-tests.ts b/js/test/unit/builders/primitive-tests.ts index 994d78ed052..3fd515bf406 100644 --- a/js/test/unit/builders/primitive-tests.ts +++ b/js/test/unit/builders/primitive-tests.ts @@ -18,7 +18,7 @@ import { Vector, DataType, Bool, Int8, Int16, Int32, Uint8, Uint16, Uint32, Float16, Float32, Float64 -} from '../../Arrow'; +} from 'apache-arrow'; import { validateVector, diff --git a/js/test/unit/builders/uint64-tests.ts b/js/test/unit/builders/uint64-tests.ts index 38802bca04d..e08e25b5c49 100644 --- a/js/test/unit/builders/uint64-tests.ts +++ b/js/test/unit/builders/uint64-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { util, Vector, DataType, Uint64 } from '../../Arrow'; +import { util, Vector, DataType, Uint64 } from 'apache-arrow'; import { validateVector, encodeAll, encodeEach, encodeEachDOM, encodeEachNode, diff --git a/js/test/unit/builders/utf8-tests.ts b/js/test/unit/builders/utf8-tests.ts index f6bac44e324..212879ab441 100644 --- a/js/test/unit/builders/utf8-tests.ts +++ b/js/test/unit/builders/utf8-tests.ts @@ -16,7 +16,7 @@ // under the License. import { validateVector } from './utils'; -import { Vector, Utf8 } from '../../Arrow'; +import { Vector, Utf8 } from 'apache-arrow'; import { encodeAll, encodeEach, diff --git a/js/test/unit/builders/utils.ts b/js/test/unit/builders/utils.ts index 7ec8ca714ab..0968910a96e 100644 --- a/js/test/unit/builders/utils.ts +++ b/js/test/unit/builders/utils.ts @@ -17,9 +17,9 @@ import '../../jest-extensions'; import { AsyncIterable } from 'ix'; -import { util } from '../../Arrow'; -import { Builder } from '../../Arrow'; -import { DataType, Vector, Chunked } from '../../Arrow'; +import { util } from 'apache-arrow'; +import { Builder } from 'apache-arrow'; +import { DataType, Vector, Chunked } from 'apache-arrow'; const rand = Math.random.bind(Math); const randstr = require('randomatic'); diff --git a/js/test/unit/dataframe-tests.ts b/js/test/unit/dataframe-tests.ts index 169cc6d1ae8..cb9c2323b51 100644 --- a/js/test/unit/dataframe-tests.ts +++ b/js/test/unit/dataframe-tests.ts @@ -18,7 +18,7 @@ import '../jest-extensions'; import { predicate, DataFrame, RecordBatch -} from '../Arrow'; +} from 'apache-arrow'; import { test_data } from './table-tests'; const { col, lit, custom, and, or, And, Or } = predicate; diff --git a/js/test/unit/generated-data-validators.ts b/js/test/unit/generated-data-validators.ts index 6bcc340e8ff..647932b415b 100644 --- a/js/test/unit/generated-data-validators.ts +++ b/js/test/unit/generated-data-validators.ts @@ -22,7 +22,7 @@ import { GeneratedVector } from '../generate-test-data'; -import { util } from '../Arrow'; +import { util } from 'apache-arrow'; const { createElementComparator: compare } = util; type DeferredTest = { description: string; tests?: DeferredTest[]; run: (...args: any[]) => any }; diff --git a/js/test/unit/int-tests.ts b/js/test/unit/int-tests.ts index 09c531e5432..15c75e1a11d 100644 --- a/js/test/unit/int-tests.ts +++ b/js/test/unit/int-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import * as Arrow from '../Arrow'; +import * as Arrow from 'apache-arrow'; const { Int64, Uint64, Int128 } = Arrow.util; describe(`Uint64`, () => { diff --git a/js/test/unit/ipc/helpers.ts b/js/test/unit/ipc/helpers.ts index eebf56f70a0..86cdca045d0 100644 --- a/js/test/unit/ipc/helpers.ts +++ b/js/test/unit/ipc/helpers.ts @@ -23,7 +23,7 @@ import { RecordBatchFileWriter, RecordBatchJSONWriter, RecordBatchStreamWriter, -} from '../../Arrow'; +} from 'apache-arrow'; import * as fs from 'fs'; import { fs as memfs } from 'memfs'; diff --git a/js/test/unit/ipc/message-reader-tests.ts b/js/test/unit/ipc/message-reader-tests.ts index 7320d6ea7aa..c48aa2ce156 100644 --- a/js/test/unit/ipc/message-reader-tests.ts +++ b/js/test/unit/ipc/message-reader-tests.ts @@ -22,7 +22,7 @@ import { } from '../../data/tables'; import { ArrowIOTestHelper } from './helpers'; -import { MessageReader, AsyncMessageReader } from '../../Arrow'; +import { MessageReader, AsyncMessageReader } from 'apache-arrow'; for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/test/unit/ipc/reader/file-reader-tests.ts b/js/test/unit/ipc/reader/file-reader-tests.ts index 2d784d06589..a7ddfc940a6 100644 --- a/js/test/unit/ipc/reader/file-reader-tests.ts +++ b/js/test/unit/ipc/reader/file-reader-tests.ts @@ -31,7 +31,7 @@ import { RecordBatchReader, RecordBatchFileReader, AsyncRecordBatchFileReader -} from '../../../Arrow'; +} from 'apache-arrow'; for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/test/unit/ipc/reader/from-inference-tests.ts b/js/test/unit/ipc/reader/from-inference-tests.ts index 01d15fa8003..93119c61243 100644 --- a/js/test/unit/ipc/reader/from-inference-tests.ts +++ b/js/test/unit/ipc/reader/from-inference-tests.ts @@ -27,7 +27,7 @@ import { RecordBatchStreamReader, AsyncRecordBatchFileReader, AsyncRecordBatchStreamReader -} from '../../../Arrow'; +} from 'apache-arrow'; const { parse: bignumJSONParse } = require('json-bignum'); diff --git a/js/test/unit/ipc/reader/json-reader-tests.ts b/js/test/unit/ipc/reader/json-reader-tests.ts index b41106ecfb7..0e7bab112ac 100644 --- a/js/test/unit/ipc/reader/json-reader-tests.ts +++ b/js/test/unit/ipc/reader/json-reader-tests.ts @@ -21,7 +21,7 @@ import { } from '../../../data/tables'; import { ArrowIOTestHelper } from '../helpers'; -import { RecordBatchReader } from '../../../Arrow'; +import { RecordBatchReader } from 'apache-arrow'; import { validateRecordBatchReader } from '../validate'; const { parse: bignumJSONParse } = require('json-bignum'); diff --git a/js/test/unit/ipc/reader/stream-reader-tests.ts b/js/test/unit/ipc/reader/stream-reader-tests.ts index ae7bbfbf98a..23879cf795e 100644 --- a/js/test/unit/ipc/reader/stream-reader-tests.ts +++ b/js/test/unit/ipc/reader/stream-reader-tests.ts @@ -26,7 +26,7 @@ import { } from '../validate'; import { ArrowIOTestHelper } from '../helpers'; -import { RecordBatchReader } from '../../../Arrow'; +import { RecordBatchReader } from 'apache-arrow'; for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index a338ed77e55..871c7058f77 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -24,7 +24,7 @@ import { Table, RecordBatchReader, RecordBatchStreamWriter -} from '../../../Arrow'; +} from 'apache-arrow'; import { validateRecordBatchAsyncIterator } from '../validate'; import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers'; diff --git a/js/test/unit/ipc/reader/streams-node-tests.ts b/js/test/unit/ipc/reader/streams-node-tests.ts index 080ebab73b9..07856f28645 100644 --- a/js/test/unit/ipc/reader/streams-node-tests.ts +++ b/js/test/unit/ipc/reader/streams-node-tests.ts @@ -23,7 +23,7 @@ import { Table, RecordBatchReader, RecordBatchStreamWriter -} from '../../../Arrow'; +} from 'apache-arrow'; import { ArrowIOTestHelper } from '../helpers'; import { validateRecordBatchAsyncIterator } from '../validate'; diff --git a/js/test/unit/ipc/validate.ts b/js/test/unit/ipc/validate.ts index 27e1e03e69e..aedf87a2d09 100644 --- a/js/test/unit/ipc/validate.ts +++ b/js/test/unit/ipc/validate.ts @@ -23,7 +23,7 @@ import { RecordBatchReader, RecordBatchFileReader, RecordBatchStreamReader, -} from '../../Arrow'; +} from 'apache-arrow'; export function validateRecordBatchReader(type: 'json' | 'file' | 'stream', numBatches: number, r: T) { const reader = r.open(); diff --git a/js/test/unit/ipc/writer/file-writer-tests.ts b/js/test/unit/ipc/writer/file-writer-tests.ts index 81066462304..fa639e5f672 100644 --- a/js/test/unit/ipc/writer/file-writer-tests.ts +++ b/js/test/unit/ipc/writer/file-writer-tests.ts @@ -21,7 +21,7 @@ import { } from '../../../data/tables'; import { validateRecordBatchIterator } from '../validate'; -import { Table, RecordBatchFileWriter } from '../../../Arrow'; +import { Table, RecordBatchFileWriter } from 'apache-arrow'; describe('RecordBatchFileWriter', () => { for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/test/unit/ipc/writer/json-writer-tests.ts b/js/test/unit/ipc/writer/json-writer-tests.ts index b461d0f76ce..2345483c1bb 100644 --- a/js/test/unit/ipc/writer/json-writer-tests.ts +++ b/js/test/unit/ipc/writer/json-writer-tests.ts @@ -21,7 +21,7 @@ import { } from '../../../data/tables'; import { validateRecordBatchIterator } from '../validate'; -import { Table, RecordBatchJSONWriter } from '../../../Arrow'; +import { Table, RecordBatchJSONWriter } from 'apache-arrow'; const { parse: bignumJSONParse } = require('json-bignum'); diff --git a/js/test/unit/ipc/writer/stream-writer-tests.ts b/js/test/unit/ipc/writer/stream-writer-tests.ts index 3c5cd3c06fe..939b36f8c0b 100644 --- a/js/test/unit/ipc/writer/stream-writer-tests.ts +++ b/js/test/unit/ipc/writer/stream-writer-tests.ts @@ -23,8 +23,8 @@ import { import * as generate from '../../../generate-test-data'; import { validateRecordBatchIterator } from '../validate'; import { RecordBatchStreamWriterOptions } from '../../../../src/ipc/writer'; -import { DictionaryVector, Dictionary, Uint32, Int32 } from '../../../Arrow'; -import { Table, Schema, Field, Chunked, Builder, RecordBatch, RecordBatchReader, RecordBatchStreamWriter } from '../../../Arrow'; +import { DictionaryVector, Dictionary, Uint32, Int32 } from 'apache-arrow'; +import { Table, Schema, Field, Chunked, Builder, RecordBatch, RecordBatchReader, RecordBatchStreamWriter } from 'apache-arrow'; describe('RecordBatchStreamWriter', () => { diff --git a/js/test/unit/ipc/writer/streams-dom-tests.ts b/js/test/unit/ipc/writer/streams-dom-tests.ts index 8a8060b6fb3..4e2844cb451 100644 --- a/js/test/unit/ipc/writer/streams-dom-tests.ts +++ b/js/test/unit/ipc/writer/streams-dom-tests.ts @@ -29,7 +29,7 @@ import { RecordBatchFileWriter, RecordBatchJSONWriter, RecordBatchStreamWriter, -} from '../../../Arrow'; +} from 'apache-arrow'; import { ArrowIOTestHelper, diff --git a/js/test/unit/ipc/writer/streams-node-tests.ts b/js/test/unit/ipc/writer/streams-node-tests.ts index d341e829496..15723fb17a5 100644 --- a/js/test/unit/ipc/writer/streams-node-tests.ts +++ b/js/test/unit/ipc/writer/streams-node-tests.ts @@ -29,7 +29,7 @@ import { RecordBatchFileWriter, RecordBatchJSONWriter, RecordBatchStreamWriter, -} from '../../../Arrow'; +} from 'apache-arrow'; import { ArrowIOTestHelper, diff --git a/js/test/unit/math-tests.ts b/js/test/unit/math-tests.ts index 2baaa034623..7e3ffcd8ff0 100644 --- a/js/test/unit/math-tests.ts +++ b/js/test/unit/math-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import * as Arrow from '../Arrow'; +import * as Arrow from 'apache-arrow'; const { float64ToUint16, uint16ToFloat64 } = Arrow.util; describe('Float16', () => { diff --git a/js/test/unit/recordbatch/record-batch-tests.ts b/js/test/unit/recordbatch/record-batch-tests.ts index de3090a5af7..520c04f84ed 100644 --- a/js/test/unit/recordbatch/record-batch-tests.ts +++ b/js/test/unit/recordbatch/record-batch-tests.ts @@ -19,7 +19,7 @@ import '../../jest-extensions'; import { Data, RecordBatch, Vector, Int32Vector, Float32Vector, Float32, Int32, -} from '../../Arrow'; +} from 'apache-arrow'; import { arange } from '../utils'; function numsRecordBatch(i32Len: number, f32Len: number) { diff --git a/js/test/unit/table-tests.ts b/js/test/unit/table-tests.ts index c6b0bb5f75e..2f138182bbd 100644 --- a/js/test/unit/table-tests.ts +++ b/js/test/unit/table-tests.ts @@ -20,7 +20,7 @@ import { Data, Schema, Field, Table, RecordBatch, Column, Vector, Int32Vector, Float32Vector, Utf8Vector, DictionaryVector, Struct, Float32, Int32, Dictionary, Utf8, Int8 -} from '../Arrow'; +} from 'apache-arrow'; import { arange } from './utils'; const NAMES = ['f32', 'i32', 'dictionary'] as (keyof TestDataSchema)[]; diff --git a/js/test/unit/table/assign-tests.ts b/js/test/unit/table/assign-tests.ts index a9f76dde190..fa1dacbc638 100644 --- a/js/test/unit/table/assign-tests.ts +++ b/js/test/unit/table/assign-tests.ts @@ -23,7 +23,7 @@ import * as generate from '../../generate-test-data'; import { validateTable } from '../generated-data-validators'; import { Schema, Field, DataType, Int32, Float32, Utf8 -} from '../../Arrow'; +} from 'apache-arrow'; const toSchema = (...xs: [string, DataType][]) => new Schema(xs.map((x) => new Field(...x))); const schema1 = toSchema(['a', new Int32()], ['b', new Float32()], ['c', new Utf8()]); diff --git a/js/test/unit/table/serialize-tests.ts b/js/test/unit/table/serialize-tests.ts index 961f71476a2..5eb21176362 100644 --- a/js/test/unit/table/serialize-tests.ts +++ b/js/test/unit/table/serialize-tests.ts @@ -19,7 +19,7 @@ import '../../jest-extensions'; import * as generate from '../../generate-test-data'; import { Table, Schema, Field, DataType, Dictionary, Int32, Float32, Utf8, Null, Int32Vector -} from '../../Arrow'; +} from 'apache-arrow'; const toSchema = (...xs: [string, DataType][]) => new Schema(xs.map((x) => new Field(...x))); const schema1 = toSchema(['a', new Int32()], ['b', new Float32()], ['c', new Dictionary(new Utf8(), new Int32())]); diff --git a/js/test/unit/vector/bool-vector-tests.ts b/js/test/unit/vector/bool-vector-tests.ts index 1d59a3c975c..41c53da6075 100644 --- a/js/test/unit/vector/bool-vector-tests.ts +++ b/js/test/unit/vector/bool-vector-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { Data, Bool, Vector, BoolVector } from '../../Arrow'; +import { Data, Bool, Vector, BoolVector } from 'apache-arrow'; const newBoolVector = (length: number, data: Uint8Array) => Vector.new(Data.Bool(new Bool(), 0, length, 0, null, data)); diff --git a/js/test/unit/vector/date-vector-tests.ts b/js/test/unit/vector/date-vector-tests.ts index 4f41d4f8a05..4658633ba74 100644 --- a/js/test/unit/vector/date-vector-tests.ts +++ b/js/test/unit/vector/date-vector-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { Table, DateDay, DateMillisecond } from '../../Arrow'; +import { Table, DateDay, DateMillisecond } from 'apache-arrow'; describe(`DateVector`, () => { it('returns days since the epoch as correct JS Dates', () => { diff --git a/js/test/unit/vector/numeric-vector-tests.ts b/js/test/unit/vector/numeric-vector-tests.ts index 4c3ad3a46fe..8c077e0c865 100644 --- a/js/test/unit/vector/numeric-vector-tests.ts +++ b/js/test/unit/vector/numeric-vector-tests.ts @@ -25,7 +25,7 @@ import { FloatVector, Float16Vector, Float32Vector, Float64Vector, IntVector, Int8Vector, Int16Vector, Int32Vector, Int64Vector, Uint8Vector, Uint16Vector, Uint32Vector, Uint64Vector, -} from '../../Arrow'; +} from 'apache-arrow'; const { float64ToUint16, uint16ToFloat64 } = util; import { VectorType as V } from '../../../src/interfaces'; diff --git a/js/test/unit/vector/vector-tests.ts b/js/test/unit/vector/vector-tests.ts index 91c402697f1..60bff94f8a1 100644 --- a/js/test/unit/vector/vector-tests.ts +++ b/js/test/unit/vector/vector-tests.ts @@ -18,7 +18,7 @@ import { Int32, Dictionary, DateUnit, util, Data, Vector, Utf8Vector, DateVector, DictionaryVector, -} from '../../Arrow'; +} from 'apache-arrow'; describe(`DateVector`, () => { const extras = [ diff --git a/js/test/unit/visitor-tests.ts b/js/test/unit/visitor-tests.ts index e3339b01f9a..22b3e5ced05 100644 --- a/js/test/unit/visitor-tests.ts +++ b/js/test/unit/visitor-tests.ts @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. -import { Field } from '../Arrow'; -import { Visitor } from '../Arrow'; +import { Field } from 'apache-arrow'; +import { Visitor } from 'apache-arrow'; import { DataType, Dictionary, Bool, Null, Utf8, Binary, Decimal, FixedSizeBinary, List, FixedSizeList, Map_, Struct, @@ -27,7 +27,7 @@ import { Time, TimeSecond, TimeMillisecond, TimeMicrosecond, TimeNanosecond, Timestamp, TimestampSecond, TimestampMillisecond, TimestampMicrosecond, TimestampNanosecond, Union, DenseUnion, SparseUnion, -} from '../Arrow'; +} from 'apache-arrow'; class BasicVisitor extends Visitor { public type: DataType | undefined; diff --git a/js/tsconfig.json b/js/tsconfig.json index d61218686d6..c232f209f71 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -8,7 +8,20 @@ "target": "ESNEXT", "module": "commonjs", "noEmit": true, - "esModuleInterop": true + "esModuleInterop": true, + "baseUrl": "./", + "paths": { + "apache-arrow": [ + "src/Arrow.node" + ], + "apache-arrow/*": [ + "src/*" + ] + } }, - "include": ["src/**/*.ts", "test/**/*.ts", "perf/**/*.ts"] + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "perf/**/*.ts" + ] } diff --git a/js/tsconfig/tsconfig.base.json b/js/tsconfig/tsconfig.base.json index 91f7c31bc80..dcabee543b0 100644 --- a/js/tsconfig/tsconfig.base.json +++ b/js/tsconfig/tsconfig.base.json @@ -3,6 +3,12 @@ "include": ["../src/**/*.ts"], "compileOnSave": false, "compilerOptions": { + "baseUrl": "./", + "paths": { + "apache-arrow/*": [ + "src/*" + ] + }, /* Basic stuff */ "moduleResolution": "node", From cb6ee9f3aee371f8f1ff8511dc49eb747cca6b19 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 7 Jul 2021 13:05:15 -0700 Subject: [PATCH 06/21] Remove outdated comment --- js/jest.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/jest.config.js b/js/jest.config.js index 29e294e4274..243cd5c89c7 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -47,8 +47,7 @@ module.exports = { "transformIgnorePatterns": [ "/(es5|es2015|esnext)/umd/", "/targets/(es5|es2015|esnext)/", - "/node_modules/(?!web-stream-tools).+\\.js$", - // ".*/cjs/.*\\.js$" + "/node_modules/(?!web-stream-tools).+\\.js$" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$", "preset": "ts-jest", From 0253f3aa6f5f75dfd86325ce88f7a3f0be0c9135 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 7 Jul 2021 13:16:49 -0700 Subject: [PATCH 07/21] Fix jest config paths --- js/jestconfigs/jest.apache-arrow.config.js | 2 +- js/jestconfigs/jest.es2015.cjs.config.js | 2 +- js/jestconfigs/jest.es2015.esm.config.js | 2 +- js/jestconfigs/jest.es2015.umd.config.js | 2 +- js/jestconfigs/jest.es5.cjs.config.js | 2 +- js/jestconfigs/jest.es5.esm.config.js | 2 +- js/jestconfigs/jest.es5.umd.config.js | 2 +- js/jestconfigs/jest.esnext.cjs.config.js | 2 +- js/jestconfigs/jest.esnext.esm.config.js | 2 +- js/jestconfigs/jest.esnext.umd.config.js | 2 +- js/jestconfigs/jest.src.config.js | 2 +- js/jestconfigs/jest.ts.config.js | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js index 6580cff084a..fe93f6f37d1 100644 --- a/js/jestconfigs/jest.apache-arrow.config.js +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.apache-arrow.json" + "tsConfig": "test/tsconfig/tsconfig.apache-arrow.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js index 436cb3833f2..7637a3de610 100644 --- a/js/jestconfigs/jest.es2015.cjs.config.js +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es2015.cjs.json" + "tsConfig": "test/tsconfig/tsconfig.es2015.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index 909030c6788..beb9e9734a6 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es2015.esm.json" + "tsConfig": "test/tsconfig/tsconfig.es2015.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js index 9e5b1c3b0be..2dbab39395f 100644 --- a/js/jestconfigs/jest.es2015.umd.config.js +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es2015.umd.json" + "tsConfig": "test/tsconfig/tsconfig.es2015.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js index fbf1d2ee58a..9e6bf3c9dfe 100644 --- a/js/jestconfigs/jest.es5.cjs.config.js +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es5.cjs.json" + "tsConfig": "test/tsconfig/tsconfig.es5.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index daa86886019..fd160496447 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es5.esm.json" + "tsConfig": "test/tsconfig/tsconfig.es5.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js index ef36f801de8..faf28698ce7 100644 --- a/js/jestconfigs/jest.es5.umd.config.js +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.es5.umd.json" + "tsConfig": "test/tsconfig/tsconfig.es5.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js index 5d7c667396c..6b7f3b12e81 100644 --- a/js/jestconfigs/jest.esnext.cjs.config.js +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.esnext.cjs.json" + "tsConfig": "test/tsconfig/tsconfig.esnext.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index e1b97300c47..236fca471d5 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.esnext.esm.json" + "tsConfig": "test/tsconfig/tsconfig.esnext.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js index 169906f260f..10fecdd6419 100644 --- a/js/jestconfigs/jest.esnext.umd.config.js +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.esnext.umd.json" + "tsConfig": "test/tsconfig/tsconfig.esnext.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js index fa933f01b93..308cfd66991 100644 --- a/js/jestconfigs/jest.src.config.js +++ b/js/jestconfigs/jest.src.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "/spec/tsconfig/tsconfig.src.json" + "tsConfig": "/test/tsconfig/tsconfig.src.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index b1351b8a3d8..99f21ad3ce3 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -20,7 +20,7 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "spec/tsconfig/tsconfig.ts.json" + "tsConfig": "test/tsconfig/tsconfig.ts.json" } }, "moduleNameMapper": { From 69ba8429a1c1d494874e9a741c6073f81dc57c99 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 7 Jul 2021 13:16:57 -0700 Subject: [PATCH 08/21] Add root dir for jest --- js/jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/jest.config.js b/js/jest.config.js index 243cd5c89c7..8602cb3d82f 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -24,6 +24,7 @@ module.exports = { "tsconfig": "test/tsconfig.json" } }, + "rootDir": "../", "roots": [ "/test/" ], From a637db60e43cf254e5665931f83cb5a1122fa438 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 7 Jul 2021 15:01:29 -0700 Subject: [PATCH 09/21] Simplify test setup --- js/.eslintignore | 4 ++ js/jest.config.js | 15 +++--- js/package.json | 2 +- js/test/Arrow.ts | 50 -------------------- js/test/tsconfig.json | 1 + js/test/unit/ipc/reader/streams-dom-tests.ts | 2 +- js/yarn.lock | 23 +++++++-- 7 files changed, 31 insertions(+), 66 deletions(-) diff --git a/js/.eslintignore b/js/.eslintignore index a9ba028ceea..94ef668a61c 100644 --- a/js/.eslintignore +++ b/js/.eslintignore @@ -1 +1,5 @@ .eslintrc.js +gulp +jest.config.js +jestconfigs +targets diff --git a/js/jest.config.js b/js/jest.config.js index 8602cb3d82f..bd676e9d749 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -30,27 +30,24 @@ module.exports = { ], "moduleFileExtensions": [ "js", - "ts", - "tsx" + "ts" ], "coverageReporters": [ "lcov" ], "coveragePathIgnorePatterns": [ "fb\\/(File|Message|Schema|Tensor)\\.(js|ts)$", - "test\\/.*\\.(ts|tsx|js)$", + "test\\/.*\\.(ts|js)$", "/node_modules/" ], "transform": { - "^.+\\.jsx?$": "ts-jest", - "^.+\\.tsx?$": "ts-jest" + "^.+\\.js$": "ts-jest", + "^.+\\.ts$": "ts-jest" }, "transformIgnorePatterns": [ - "/(es5|es2015|esnext)/umd/", - "/targets/(es5|es2015|esnext)/", - "/node_modules/(?!web-stream-tools).+\\.js$" + "/(es5|es2015|esnext)/umd/" ], - "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$", + "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", "preset": "ts-jest", "testMatch": null, "moduleNameMapper": { diff --git a/js/package.json b/js/package.json index 972c2caf82f..3016338cfbe 100644 --- a/js/package.json +++ b/js/package.json @@ -96,7 +96,7 @@ "ts-node": "10.0.0", "typedoc": "0.20.36", "typescript": "4.0.2", - "web-stream-tools": "0.0.1", + "@openpgp/web-stream-tools": "0.0.5", "web-streams-polyfill": "3.0.3", "xml2js": "0.4.23" }, diff --git a/js/test/Arrow.ts b/js/test/Arrow.ts index cb469597c53..de2bc58c715 100644 --- a/js/test/Arrow.ts +++ b/js/test/Arrow.ts @@ -15,56 +15,6 @@ // specific language governing permissions and limitations // under the License. -// Dynamically load an Arrow target build based on command line arguments - import 'web-streams-polyfill'; -// import 'web-streams-polyfill/es6'; - -// import this before assigning window global since it does a `typeof window` check -require('web-stream-tools'); - -( global).window = ( global).window || global; - -// Fix for Jest in node v10.x -Object.defineProperty(Object, Symbol.hasInstance, { - writable: true, - configurable: true, - value(inst: any) { - return inst?.constructor && inst.constructor.name === 'Object'; - } -}); - -Object.defineProperty(ArrayBuffer, Symbol.hasInstance, { - writable: true, - configurable: true, - value(inst: any) { - return inst?.constructor && inst.constructor.name === 'ArrayBuffer'; - } -}); - -// // these are duplicated in the gulpfile :< -// const targets = [`es5`, `es2015`, `esnext`]; -// const formats = [`cjs`, `esm`, `cls`, `umd`]; - -// const path = require('path'); -// const target = process.env.TEST_TARGET!; -// const format = process.env.TEST_MODULE!; -// const useSrc = process.env.TEST_TS_SOURCE === `true` || (!~targets.indexOf(target) || !~formats.indexOf(format)); - -// let modulePath = ``; - -// if (useSrc) modulePath = '../src'; -// else if (target === `ts` || target === `apache-arrow`) modulePath = target; -// else modulePath = path.join(target, format); - -// modulePath = path.resolve(`./targets`, modulePath); -// modulePath = path.join(modulePath, `Arrow${format === 'umd' ? '' : '.node'}`); -// const Arrow: typeof import('../src/Arrow') = require(modulePath); - -// export = Arrow; - -// Require rxjs first so we pick up its polyfilled Symbol.observable -// eslint-disable-next-line @typescript-eslint/no-require-imports -require('rxjs/internal/symbol/observable'); export * from 'apache-arrow'; diff --git a/js/test/tsconfig.json b/js/test/tsconfig.json index 9a2b52390b6..4cbb563db96 100644 --- a/js/test/tsconfig.json +++ b/js/test/tsconfig.json @@ -9,6 +9,7 @@ "module": "commonjs", "allowJs": true, "declaration": false, + "declarationMap": false, "importHelpers": false, "noEmitHelpers": false, "noEmitOnError": false, diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index 871c7058f77..5632d2c1445 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -36,7 +36,7 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' } const { parse: bignumJSONParse } = require('json-bignum'); - const { concatStream } = require('web-stream-tools').default; + const { concatStream } = require('@openpgp/web-stream-tools').default; for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/yarn.lock b/js/yarn.lock index 7b54725509b..f173495654b 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -1236,6 +1236,11 @@ npmlog "^4.1.2" write-file-atomic "^3.0.3" +"@mattiasbuelens/web-streams-adapter@0.1.0-alpha.5": + version "0.1.0-alpha.5" + resolved "https://registry.yarnpkg.com/@mattiasbuelens/web-streams-adapter/-/web-streams-adapter-0.1.0-alpha.5.tgz#091a6256fdada3d53dc0a70501bcc6f3a46add05" + integrity sha512-OIfunNt/fTjIgDtUqXhBYOKtgaxm30ZWkMWegI9iS3xUHy2/A3AXki6/k+z40+BywNMi+spON/jSE0FF9WmUKA== + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -1434,6 +1439,14 @@ dependencies: "@octokit/openapi-types" "^7.2.3" +"@openpgp/web-stream-tools@0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@openpgp/web-stream-tools/-/web-stream-tools-0.0.5.tgz#f78d73400be010dca940ec09642aaf8c35edf56d" + integrity sha512-tdUCdiMi5ogmZlAbR4cQXZDbK34QB8iEnJ434m9bj4P7sxvKg2KKKbEiB4EQb2AWhj/SNKcoNUHhT9WxTqKimQ== + dependencies: + "@mattiasbuelens/web-streams-adapter" "0.1.0-alpha.5" + web-streams-polyfill "~2.1.1" + "@sinonjs/commons@^1.7.0": version "1.8.3" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" @@ -9249,16 +9262,16 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" -web-stream-tools@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/web-stream-tools/-/web-stream-tools-0.0.1.tgz#6d2c06a6f5f46eab5e73d82285bae3c9b5ee71a0" - integrity sha512-MZUYhvTAMMy1u07OJL2pyp/tdrIu15fRJlGgnfvCQVXBS4cBNbIV1+6veYfVhTfnq0ZLispgx4nv17QxpuX+6w== - web-streams-polyfill@3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.0.3.tgz#f49e487eedeca47a207c1aee41ee5578f884b42f" integrity sha512-d2H/t0eqRNM4w2WvmTdoeIvzAUSpK7JmATB8Nr2lb7nQ9BTIJVjbQ/TRFVEh2gUH1HwclPdoPtfMoFfetXaZnA== +web-streams-polyfill@~2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-2.1.1.tgz#2c82b6193849ccb9efaa267772c28260ef68d6d2" + integrity sha512-dlNpL2aab3g8CKfGz6rl8FNmGaRWLLn2g/DtSc9IjB30mEdE6XxzPfPSig5BwGSzI+oLxHyETrQGKjrVVhbLCg== + webidl-conversions@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" From 473bd1be5ad34b21ed4b611a5f8ba26067d02841 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 8 Jul 2021 03:28:46 -0500 Subject: [PATCH 10/21] get test target jest configs working, update more test imports --- js/.npmrc | 5 + js/.vscode/launch.json | 388 ++++++++++-------- js/.vscode/settings.json | 10 + js/gulp/test-task.js | 3 - js/jest.config.js | 6 +- js/jestconfigs/jest.apache-arrow.config.js | 3 +- js/jestconfigs/jest.es2015.cjs.config.js | 3 +- js/jestconfigs/jest.es2015.esm.config.js | 3 +- js/jestconfigs/jest.es2015.umd.config.js | 3 +- js/jestconfigs/jest.es5.cjs.config.js | 3 +- js/jestconfigs/jest.es5.esm.config.js | 3 +- js/jestconfigs/jest.es5.umd.config.js | 3 +- js/jestconfigs/jest.esnext.cjs.config.js | 3 +- js/jestconfigs/jest.esnext.esm.config.js | 3 +- js/jestconfigs/jest.esnext.umd.config.js | 3 +- js/jestconfigs/jest.src.config.js | 3 +- js/jestconfigs/jest.ts.config.js | 3 +- js/test/generate-test-data.ts | 2 +- js/test/inference/column.ts | 10 +- js/test/inference/nested.ts | 10 +- js/test/inference/visitor/get.ts | 2 +- js/test/tsconfig.json | 45 +- js/test/tsconfig/tsconfig.apache-arrow.json | 7 +- js/test/tsconfig/tsconfig.base.json | 14 +- js/test/tsconfig/tsconfig.es2015.cjs.json | 7 +- js/test/tsconfig/tsconfig.es2015.esm.json | 7 +- js/test/tsconfig/tsconfig.es2015.umd.json | 7 +- js/test/tsconfig/tsconfig.es5.cjs.json | 7 +- js/test/tsconfig/tsconfig.es5.esm.json | 7 +- js/test/tsconfig/tsconfig.es5.umd.json | 7 +- js/test/tsconfig/tsconfig.esnext.cjs.json | 7 +- js/test/tsconfig/tsconfig.esnext.esm.json | 7 +- js/test/tsconfig/tsconfig.esnext.umd.json | 7 +- js/test/tsconfig/tsconfig.src.json | 5 +- js/test/tsconfig/tsconfig.ts.json | 5 +- js/test/unit/builders/builder-tests.ts | 6 +- js/test/unit/ipc/reader/streams-node-tests.ts | 15 +- .../unit/ipc/writer/stream-writer-tests.ts | 2 +- js/test/unit/utils-tests.ts | 2 +- js/test/unit/vector/numeric-vector-tests.ts | 6 +- js/tsconfig.json | 7 +- js/yarn.lock | 2 +- 42 files changed, 375 insertions(+), 276 deletions(-) diff --git a/js/.npmrc b/js/.npmrc index 5536efc09ce..e55040abad7 100644 --- a/js/.npmrc +++ b/js/.npmrc @@ -1,2 +1,7 @@ +fund=false +audit=false save-prefix= +save-exact=true engine-strict=true +update-notifier=false +registry=https://registry.npmjs.org/ diff --git a/js/.vscode/launch.json b/js/.vscode/launch.json index 43851ba5358..40fc0710ee5 100644 --- a/js/.vscode/launch.json +++ b/js/.vscode/launch.json @@ -1,182 +1,210 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Debug Gulp Build", - "program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js", - "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" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug Unit Tests", - "cwd": "${workspaceRoot}", - "program": "${workspaceFolder}/node_modules/.bin/jest", - "skipFiles": [ - "/**/*.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": "umd" - }, - "args": [ - "-i", - "test/unit/", - // "test/unit/builders/", - - // Uncomment any of these to run individual test suites - // "test/unit/builders/builder-tests.ts", - // "test/unit/builders/int64-tests.ts", - // "test/unit/builders/uint64-tests.ts", - // "test/unit/builders/date-tests.ts", - // "test/unit/builders/primitive-tests.ts", - // "test/unit/builders/dictionary-tests.ts", - // "test/unit/builders/utf8-tests.ts", - - // "test/unit/int-tests.ts", - // "test/unit/math-tests.ts", - // "test/unit/table-tests.ts", - // "test/unit/generated-data-tests.ts", - - // "test/unit/table/assign-tests.ts", - // "test/unit/table/serialize-tests.ts", - // "test/unit/recordbatch/record-batch-tests.ts", - - // "test/unit/vector/vector-tests.ts", - // "test/unit/vector/bool-vector-tests.ts", - // "test/unit/vector/date-vector-tests.ts", - // "test/unit/vector/numeric-vector-tests.ts", - - // "test/unit/visitor-tests.ts", - - // "test/unit/ipc/message-reader-tests.ts", - // "test/unit/ipc/reader/file-reader-tests.ts", - // "test/unit/ipc/reader/json-reader-tests.ts", - // "test/unit/ipc/reader/from-inference-tests.ts", - // "test/unit/ipc/reader/stream-reader-tests.ts", - // "test/unit/ipc/reader/streams-dom-tests.ts", - // "test/unit/ipc/reader/streams-node-tests.ts", - // "test/unit/ipc/writer/file-writer-tests.ts", - // "test/unit/ipc/writer/json-writer-tests.ts", - // "test/unit/ipc/writer/stream-writer-tests.ts", - // "test/unit/ipc/writer/streams-dom-tests.ts", - // "test/unit/ipc/writer/streams-node-tests.ts", - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug Integration Tests", - "cwd": "${workspaceRoot}", - "program": "${workspaceFolder}/bin/integration.js", - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "env": { - "NODE_NO_WARNINGS": "1", - "READABLE_STREAM": "disable" - }, - "args": [ - "--mode", "VALIDATE" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug bin/arrow2csv", - "env": { "ARROW_JS_DEBUG": "src", "TS_NODE_CACHE": "false" }, - "runtimeArgs": ["-r", "ts-node/register"], - "console": "integratedTerminal", - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "args": [ - "${workspaceFolder}/src/bin/arrow2csv.ts", - "-f", "./test/data/cpp/stream/simple.arrow" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug bin/file-to-stream", - "env": { "ARROW_JS_DEBUG": "src", "TS_NODE_CACHE": "false" }, - "runtimeArgs": ["-r", "ts-node/register"], - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "args": [ - "${workspaceFolder}/bin/file-to-stream.js", - "./test/data/cpp/file/struct_example.arrow", - "./struct_example-stream-out.arrow", - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug bin/stream-to-file", - "env": { "ARROW_JS_DEBUG": "src", "TS_NODE_CACHE": "false" }, - "runtimeArgs": ["-r", "ts-node/register"], - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "args": [ - "${workspaceFolder}/bin/stream-to-file.js", - "./test/data/cpp/stream/struct_example.arrow", - "./struct_example-file-out.arrow", - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug bin/json-to-arrow", - "env": { "ARROW_JS_DEBUG": "src", "TS_NODE_CACHE": "false" }, - "runtimeArgs": ["-r", "ts-node/register"], - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "args": [ - "${workspaceFolder}/bin/json-to-arrow.js", - "-j", "./test/data/json/struct_example.json", - "-a", "./struct_example-stream-out.arrow", - "-f", "stream" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Debug bin/print-buffer-alignment", - "env": { "ARROW_JS_DEBUG": "src", "TS_NODE_CACHE": "false" }, - "runtimeArgs": ["-r", "ts-node/register"], - "skipFiles": [ - "/**/*.js", - "${workspaceFolder}/node_modules/**/*.js" - ], - "args": [ - "${workspaceFolder}/bin/print-buffer-alignment.js", - "./test/data/cpp/stream/struct_example.arrow" - ] - } - ] + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug Gulp Build", + "program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js", + "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" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug Unit Tests", + "cwd": "${workspaceRoot}", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "env": { + "NODE_NO_WARNINGS": "1", + "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": "umd" + }, + "args": [ + "-i", + "test/unit/", + // "test/unit/builders/", + // Uncomment any of these to run individual test suites + // "test/unit/builders/builder-tests.ts", + // "test/unit/builders/int64-tests.ts", + // "test/unit/builders/uint64-tests.ts", + // "test/unit/builders/date-tests.ts", + // "test/unit/builders/primitive-tests.ts", + // "test/unit/builders/dictionary-tests.ts", + // "test/unit/builders/utf8-tests.ts", + // "test/unit/int-tests.ts", + // "test/unit/math-tests.ts", + // "test/unit/table-tests.ts", + // "test/unit/generated-data-tests.ts", + // "test/unit/table/assign-tests.ts", + // "test/unit/table/serialize-tests.ts", + // "test/unit/recordbatch/record-batch-tests.ts", + // "test/unit/vector/vector-tests.ts", + // "test/unit/vector/bool-vector-tests.ts", + // "test/unit/vector/date-vector-tests.ts", + // "test/unit/vector/numeric-vector-tests.ts", + // "test/unit/visitor-tests.ts", + // "test/unit/ipc/message-reader-tests.ts", + // "test/unit/ipc/reader/file-reader-tests.ts", + // "test/unit/ipc/reader/json-reader-tests.ts", + // "test/unit/ipc/reader/from-inference-tests.ts", + // "test/unit/ipc/reader/stream-reader-tests.ts", + // "test/unit/ipc/reader/streams-dom-tests.ts", + // "test/unit/ipc/reader/streams-node-tests.ts", + // "test/unit/ipc/writer/file-writer-tests.ts", + // "test/unit/ipc/writer/json-writer-tests.ts", + // "test/unit/ipc/writer/stream-writer-tests.ts", + // "test/unit/ipc/writer/streams-dom-tests.ts", + // "test/unit/ipc/writer/streams-node-tests.ts", + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug Integration Tests", + "cwd": "${workspaceRoot}", + "program": "${workspaceFolder}/bin/integration.js", + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "env": { + "NODE_NO_WARNINGS": "1", + }, + "args": [ + "--mode", + "VALIDATE" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug bin/arrow2csv", + "env": { + "ARROW_JS_DEBUG": "src", + "TS_NODE_CACHE": "false" + }, + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "console": "integratedTerminal", + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "args": [ + "${workspaceFolder}/src/bin/arrow2csv.ts", + "-f", + "./test/data/cpp/stream/simple.arrow" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug bin/file-to-stream", + "env": { + "ARROW_JS_DEBUG": "src", + "TS_NODE_CACHE": "false" + }, + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "args": [ + "${workspaceFolder}/bin/file-to-stream.js", + "./test/data/cpp/file/struct_example.arrow", + "./struct_example-stream-out.arrow", + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug bin/stream-to-file", + "env": { + "ARROW_JS_DEBUG": "src", + "TS_NODE_CACHE": "false" + }, + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "args": [ + "${workspaceFolder}/bin/stream-to-file.js", + "./test/data/cpp/stream/struct_example.arrow", + "./struct_example-file-out.arrow", + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug bin/json-to-arrow", + "env": { + "ARROW_JS_DEBUG": "src", + "TS_NODE_CACHE": "false" + }, + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "args": [ + "${workspaceFolder}/bin/json-to-arrow.js", + "-j", + "./test/data/json/struct_example.json", + "-a", + "./struct_example-stream-out.arrow", + "-f", + "stream" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Debug bin/print-buffer-alignment", + "env": { + "ARROW_JS_DEBUG": "src", + "TS_NODE_CACHE": "false" + }, + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "skipFiles": [ + "/**/*.js", + "${workspaceFolder}/node_modules/**/*.js" + ], + "args": [ + "${workspaceFolder}/bin/print-buffer-alignment.js", + "./test/data/cpp/stream/struct_example.arrow" + ] + } + ] } diff --git a/js/.vscode/settings.json b/js/.vscode/settings.json index 379ddf14d0f..0173f14c9b2 100644 --- a/js/.vscode/settings.json +++ b/js/.vscode/settings.json @@ -3,5 +3,15 @@ "editor.trimAutoWhitespace": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true + }, + "[json]": { + "editor.tabSize": 2, + "editor.wordWrap": "on", + "editor.formatOnSave": true, + }, + "[jsonc]": { + "editor.tabSize": 2, + "editor.wordWrap": "on", + "editor.formatOnSave": true, } } diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index e083efc7e0a..ec9affa5876 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -39,9 +39,6 @@ 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` }, }; diff --git a/js/jest.config.js b/js/jest.config.js index bd676e9d749..e409ed36c68 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -24,7 +24,7 @@ module.exports = { "tsconfig": "test/tsconfig.json" } }, - "rootDir": "../", + "rootDir": ".", "roots": [ "/test/" ], @@ -45,7 +45,9 @@ module.exports = { "^.+\\.ts$": "ts-jest" }, "transformIgnorePatterns": [ - "/(es5|es2015|esnext)/umd/" + "/targets/.*/.*\\.js$", + "/(es5|es2015|esnext)/umd/", + "/node_modules/(?!@openpgp/web-stream-tools).+\\.js$" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", "preset": "ts-jest", diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js index fe93f6f37d1..0e5e157fb26 100644 --- a/js/jestconfigs/jest.apache-arrow.config.js +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.apache-arrow.json" + "tsconfig": "/test/tsconfig/tsconfig.apache-arrow.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js index 7637a3de610..32c6aa4416b 100644 --- a/js/jestconfigs/jest.es2015.cjs.config.js +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es2015.cjs.json" + "tsconfig": "/test/tsconfig/tsconfig.es2015.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index beb9e9734a6..8fff0181e97 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es2015.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.es2015.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js index 2dbab39395f..3dbacf289ec 100644 --- a/js/jestconfigs/jest.es2015.umd.config.js +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es2015.umd.json" + "tsconfig": "/test/tsconfig/tsconfig.es2015.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js index 9e6bf3c9dfe..1f8d044cead 100644 --- a/js/jestconfigs/jest.es5.cjs.config.js +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es5.cjs.json" + "tsconfig": "/test/tsconfig/tsconfig.es5.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index fd160496447..40b50743b4c 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es5.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.es5.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js index faf28698ce7..e42ba21a924 100644 --- a/js/jestconfigs/jest.es5.umd.config.js +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.es5.umd.json" + "tsconfig": "/test/tsconfig/tsconfig.es5.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js index 6b7f3b12e81..b7505558b0a 100644 --- a/js/jestconfigs/jest.esnext.cjs.config.js +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.esnext.cjs.json" + "tsconfig": "/test/tsconfig/tsconfig.esnext.cjs.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index 236fca471d5..31f0d9b17fd 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.esnext.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.esnext.esm.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js index 10fecdd6419..6e38e2cc7f3 100644 --- a/js/jestconfigs/jest.esnext.umd.config.js +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.esnext.umd.json" + "tsconfig": "/test/tsconfig/tsconfig.esnext.umd.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js index 308cfd66991..0f0091bee58 100644 --- a/js/jestconfigs/jest.src.config.js +++ b/js/jestconfigs/jest.src.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "/test/tsconfig/tsconfig.src.json" + "tsconfig": "/test/tsconfig/tsconfig.src.json" } }, "moduleNameMapper": { diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index 99f21ad3ce3..0bc67da7985 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -17,10 +17,11 @@ module.exports = { ...require('../jest.config'), + "rootDir": "../", "globals": { "ts-jest": { "diagnostics": false, - "tsConfig": "test/tsconfig/tsconfig.ts.json" + "tsconfig": "/test/tsconfig/tsconfig.ts.json" } }, "moduleNameMapper": { diff --git a/js/test/generate-test-data.ts b/js/test/generate-test-data.ts index 3b83bd149f2..73c1fd2406e 100644 --- a/js/test/generate-test-data.ts +++ b/js/test/generate-test-data.ts @@ -16,7 +16,7 @@ // under the License. const randomatic = require('randomatic'); -import { VectorType as V } from '../src/interfaces'; +import { VectorType as V } from 'apache-arrow/interfaces'; import { Data, Vector, Visitor, DataType, diff --git a/js/test/inference/column.ts b/js/test/inference/column.ts index 03837612425..440116b69c9 100644 --- a/js/test/inference/column.ts +++ b/js/test/inference/column.ts @@ -17,11 +17,11 @@ /* eslint-disable jest/no-standalone-expect */ -import { Data } from '../../src/data'; -import { Field } from '../../src/schema'; -import { Column } from '../../src/column'; -import { Vector } from '../../src/vector'; -import { Bool, Int8, Utf8, List, Dictionary, Struct } from '../../src/type'; +import { Data } from 'apache-arrow/data'; +import { Field } from 'apache-arrow/schema'; +import { Column } from 'apache-arrow/column'; +import { Vector } from 'apache-arrow/vector'; +import { Bool, Int8, Utf8, List, Dictionary, Struct } from 'apache-arrow/type'; const boolType = new Bool(); const boolVector = Vector.new(Data.Bool(boolType, 0, 10, 0, null, new Uint8Array(2))); diff --git a/js/test/inference/nested.ts b/js/test/inference/nested.ts index 510da89e9f6..0e3dc95e3f4 100644 --- a/js/test/inference/nested.ts +++ b/js/test/inference/nested.ts @@ -15,11 +15,11 @@ // specific language governing permissions and limitations // under the License. -import { Data } from '../../src/data'; -import { Field } from '../../src/schema'; -import { DataType } from '../../src/type'; -import { Vector, BoolVector } from '../../src/vector/index'; -import { Bool, Int8, Utf8, List, Dictionary, Struct } from '../../src/type'; +import { Data } from 'apache-arrow/data'; +import { Field } from 'apache-arrow/schema'; +import { DataType } from 'apache-arrow/type'; +import { Vector, BoolVector } from 'apache-arrow/vector/index'; +import { Bool, Int8, Utf8, List, Dictionary, Struct } from 'apache-arrow/type'; type NamedSchema = { a: Int8; b: Utf8; c: Dictionary>; [idx: string]: DataType }; type IndexSchema = { 0: Int8; 1: Utf8; 2: Dictionary>; [idx: number]: DataType }; diff --git a/js/test/inference/visitor/get.ts b/js/test/inference/visitor/get.ts index ad7605f7e21..a983d94d19f 100644 --- a/js/test/inference/visitor/get.ts +++ b/js/test/inference/visitor/get.ts @@ -20,7 +20,7 @@ import { Bool, List, Dictionary } from '../../Arrow'; -import { instance as getVisitor } from '../../../src/visitor/get'; +import { instance as getVisitor } from 'apache-arrow/visitor/get'; const data_Bool = new Data(new Bool(), 0, 0); const data_List_Bool = new Data(new List(null as any), 0, 0); diff --git a/js/test/tsconfig.json b/js/test/tsconfig.json index 4cbb563db96..3c1da87a690 100644 --- a/js/test/tsconfig.json +++ b/js/test/tsconfig.json @@ -1,22 +1,27 @@ { - "extends": "../tsconfig.json", - "include": [ - "../src/**/*.ts", - "../test/**/*.ts" - ], - "compilerOptions": { - "target": "esnext", - "module": "commonjs", - "allowJs": true, - "declaration": false, - "declarationMap": false, - "importHelpers": false, - "noEmitHelpers": false, - "noEmitOnError": false, - - "sourceMap": false, - "inlineSources": false, - "inlineSourceMap": false, - "downlevelIteration": false - } + "extends": "../tsconfig.json", + "include": [ + "../src/**/*.ts", + "../test/**/*.ts" + ], + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "allowJs": true, + "declaration": false, + "declarationMap": false, + "importHelpers": false, + "noEmit": true, + "noEmitHelpers": false, + "noEmitOnError": false, + "sourceMap": false, + "inlineSources": false, + "inlineSourceMap": false, + "downlevelIteration": false, + "baseUrl": "../", + "paths": { + "apache-arrow": ["src/Arrow.node"], + "apache-arrow/*": ["src/*"] + } + } } diff --git a/js/test/tsconfig/tsconfig.apache-arrow.json b/js/test/tsconfig/tsconfig.apache-arrow.json index 47c1f4a8563..d91b9ca0ce8 100644 --- a/js/test/tsconfig/tsconfig.apache-arrow.json +++ b/js/test/tsconfig/tsconfig.apache-arrow.json @@ -1,12 +1,15 @@ -//Compiler configuaration to build the ES5 CommonJS target +// TypeScript configuration for the apache-arrow target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", "module": "commonjs", "paths": { + "apache-arrow": [ + "targets/apache-arrow/Arrow.node" + ], "apache-arrow/*": [ - "targets/apache-arrow" + "targets/apache-arrow/*" ] } } diff --git a/js/test/tsconfig/tsconfig.base.json b/js/test/tsconfig/tsconfig.base.json index 65a752f5346..8140c5fa756 100644 --- a/js/test/tsconfig/tsconfig.base.json +++ b/js/test/tsconfig/tsconfig.base.json @@ -1,17 +1,25 @@ +// Base TypeScript configuration for all targets' tests { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig/tsconfig.base.json", "compilerOptions": { "target": "esnext", "module": "commonjs", "allowJs": true, "declaration": false, "importHelpers": false, + "noEmit": false, "noEmitHelpers": false, "noEmitOnError": false, - "sourceMap": false, + "sourceMap": true, "inlineSources": false, "inlineSourceMap": false, "downlevelIteration": false, "baseUrl": "../../" - } + }, + "exclude": [ + "../../node_modules" + ], + "include": [ + "../../src/**/*.ts" + ], } diff --git a/js/test/tsconfig/tsconfig.es2015.cjs.json b/js/test/tsconfig/tsconfig.es2015.cjs.json index b9f67865884..5c4c3eace5e 100644 --- a/js/test/tsconfig/tsconfig.es2015.cjs.json +++ b/js/test/tsconfig/tsconfig.es2015.cjs.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ES2015 CommonJS target +// TypeScript configuration for the ES2015 CommonJS target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES2015", + "target": "esnext", "module": "commonjs", "paths": { + "apache-arrow": [ + "targets/es2015/cjs/Arrow.node" + ], "apache-arrow/*": [ "targets/es2015/cjs/*" ] diff --git a/js/test/tsconfig/tsconfig.es2015.esm.json b/js/test/tsconfig/tsconfig.es2015.esm.json index 44340d7ff90..d3424aa86bb 100644 --- a/js/test/tsconfig/tsconfig.es2015.esm.json +++ b/js/test/tsconfig/tsconfig.es2015.esm.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ES2015 ESModules target +// TypeScript configuration for the ES2015 ESModules target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES2015", + "target": "esnext", "module": "es2015", "paths": { + "apache-arrow": [ + "targets/es2015/esm/Arrow.node" + ], "apache-arrow/*": [ "targets/es2015/esm/*" ] diff --git a/js/test/tsconfig/tsconfig.es2015.umd.json b/js/test/tsconfig/tsconfig.es2015.umd.json index eac847c0cec..f6f56a4407f 100644 --- a/js/test/tsconfig/tsconfig.es2015.umd.json +++ b/js/test/tsconfig/tsconfig.es2015.umd.json @@ -1,13 +1,16 @@ -//Compiler configuaration to build the ES2015 Closure Compiler target +// TypeScript configuration for the ES2015 Closure Compiler target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES2015", + "target": "esnext", "module": "es2015", "declaration": false, "noEmitHelpers": true, "importHelpers": true, "paths": { + "apache-arrow": [ + "targets/es2015/umd/Arrow" + ], "apache-arrow/*": [ "targets/es2015/umd/*" ] diff --git a/js/test/tsconfig/tsconfig.es5.cjs.json b/js/test/tsconfig/tsconfig.es5.cjs.json index a6fea1449c1..156075c3b6c 100644 --- a/js/test/tsconfig/tsconfig.es5.cjs.json +++ b/js/test/tsconfig/tsconfig.es5.cjs.json @@ -1,11 +1,14 @@ -//Compiler configuaration to build the ES5 CommonJS target +// TypeScript configuration for the ES5 CommonJS target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES5", + "target": "esnext", "module": "commonjs", "downlevelIteration": true, "paths": { + "apache-arrow": [ + "targets/es5/cjs/Arrow.node" + ], "apache-arrow/*": [ "targets/es5/cjs/*" ] diff --git a/js/test/tsconfig/tsconfig.es5.esm.json b/js/test/tsconfig/tsconfig.es5.esm.json index 63c622fb85f..42da06dee44 100644 --- a/js/test/tsconfig/tsconfig.es5.esm.json +++ b/js/test/tsconfig/tsconfig.es5.esm.json @@ -1,11 +1,14 @@ -//Compiler configuaration to build the ES5 ESModules target +// TypeScript configuration for the ES5 ESModules target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES5", + "target": "esnext", "module": "es2015", "downlevelIteration": true, "paths": { + "apache-arrow": [ + "targets/es5/esm/Arrow.node" + ], "apache-arrow/*": [ "targets/es5/esm/*" ] diff --git a/js/test/tsconfig/tsconfig.es5.umd.json b/js/test/tsconfig/tsconfig.es5.umd.json index e37fecc9203..26a45bdf83b 100644 --- a/js/test/tsconfig/tsconfig.es5.umd.json +++ b/js/test/tsconfig/tsconfig.es5.umd.json @@ -1,14 +1,17 @@ -//Compiler configuaration to build the ES5 Closure Compiler target +// TypeScript configuration for the ES5 Closure Compiler target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ES5", + "target": "esnext", "module": "es2015", "declaration": false, "noEmitHelpers": true, "importHelpers": true, "downlevelIteration": true, "paths": { + "apache-arrow": [ + "targets/es5/umd/Arrow" + ], "apache-arrow/*": [ "targets/es5/umd/*" ] diff --git a/js/test/tsconfig/tsconfig.esnext.cjs.json b/js/test/tsconfig/tsconfig.esnext.cjs.json index 3289396b880..af4e5292eae 100644 --- a/js/test/tsconfig/tsconfig.esnext.cjs.json +++ b/js/test/tsconfig/tsconfig.esnext.cjs.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ESNext CommonJS target +// TypeScript configuration for the ESNext CommonJS target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ESNEXT", + "target": "esnext", "module": "commonjs", "paths": { + "apache-arrow": [ + "targets/esnext/cjs/Arrow.node" + ], "apache-arrow/*": [ "targets/esnext/cjs/*" ] diff --git a/js/test/tsconfig/tsconfig.esnext.esm.json b/js/test/tsconfig/tsconfig.esnext.esm.json index 3eb820d66bc..bce9dfa8d0d 100644 --- a/js/test/tsconfig/tsconfig.esnext.esm.json +++ b/js/test/tsconfig/tsconfig.esnext.esm.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ESNext ESModules target +// TypeScript configuration for the ESNext ESModules target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ESNEXT", + "target": "esnext", "module": "es2015", "paths": { + "apache-arrow": [ + "targets/esnext/esm/Arrow.node" + ], "apache-arrow/*": [ "targets/esnext/esm/*" ] diff --git a/js/test/tsconfig/tsconfig.esnext.umd.json b/js/test/tsconfig/tsconfig.esnext.umd.json index 838492d0443..c03793ddb55 100644 --- a/js/test/tsconfig/tsconfig.esnext.umd.json +++ b/js/test/tsconfig/tsconfig.esnext.umd.json @@ -1,13 +1,16 @@ -//Compiler configuaration to build the ESNext Closure Compiler target +// TypeScript configuration for the ESNext Closure Compiler target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "ESNEXT", + "target": "esnext", "module": "es2015", "declaration": false, "noEmitHelpers": true, "importHelpers": true, "paths": { + "apache-arrow": [ + "targets/esnext/umd/Arrow" + ], "apache-arrow/*": [ "targets/esnext/umd/*" ] diff --git a/js/test/tsconfig/tsconfig.src.json b/js/test/tsconfig/tsconfig.src.json index df3e9c15b64..82127502233 100644 --- a/js/test/tsconfig/tsconfig.src.json +++ b/js/test/tsconfig/tsconfig.src.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ES5 CommonJS target +// TypeScript configuration for the source target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", "module": "commonjs", "paths": { + "apache-arrow": [ + "src/Arrow.node" + ], "apache-arrow/*": [ "src/*" ] diff --git a/js/test/tsconfig/tsconfig.ts.json b/js/test/tsconfig/tsconfig.ts.json index 63619bb710b..0952dd9cec8 100644 --- a/js/test/tsconfig/tsconfig.ts.json +++ b/js/test/tsconfig/tsconfig.ts.json @@ -1,10 +1,13 @@ -//Compiler configuaration to build the ES5 CommonJS target +// TypeScript configuration for the TypeScript target's tests { "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", "module": "commonjs", "paths": { + "apache-arrow": [ + "targets/ts/Arrow.node" + ], "apache-arrow/*": [ "targets/ts/*" ] diff --git a/js/test/unit/builders/builder-tests.ts b/js/test/unit/builders/builder-tests.ts index a094fa1e976..87dbcabfcf6 100644 --- a/js/test/unit/builders/builder-tests.ts +++ b/js/test/unit/builders/builder-tests.ts @@ -227,9 +227,9 @@ function fillNADefault(values: any[], nulls: any[]): any[] { }); } -type BuilderOptions = import('../../../src/builder').BuilderOptions; -type BuilderDuplexOptions = import('../../../src/io/node/builder').BuilderDuplexOptions; -type BuilderTransformOptions = import('../../../src/io/whatwg/builder').BuilderTransformOptions; +type BuilderOptions = import('apache-arrow/builder').BuilderOptions; +type BuilderDuplexOptions = import('apache-arrow/io/node/builder').BuilderDuplexOptions; +type BuilderTransformOptions = import('apache-arrow/io/whatwg/builder').BuilderTransformOptions; async function encodeSingle(values: (T['TValue'] | TNull)[], options: BuilderOptions) { const builder = Builder.new(options); diff --git a/js/test/unit/ipc/reader/streams-node-tests.ts b/js/test/unit/ipc/reader/streams-node-tests.ts index 07856f28645..909a69a2c4c 100644 --- a/js/test/unit/ipc/reader/streams-node-tests.ts +++ b/js/test/unit/ipc/reader/streams-node-tests.ts @@ -34,11 +34,9 @@ import { validateRecordBatchAsyncIterator } from '../validate'; return test('not testing node streams because process.env.TEST_NODE_STREAMS !== "true"', () => {}); } - const { Readable, PassThrough } = require('stream'); + const { PassThrough } = require('stream'); + const MultiStream = require('multistream'); const { parse: bignumJSONParse } = require('json-bignum'); - const concatStream = ((MultiStream) => (...xs: any[]) => - new Readable().wrap(new MultiStream(...xs)) - )(require('multistream')); for (const table of generateRandomTables([10, 20, 30])) { @@ -115,7 +113,7 @@ import { validateRecordBatchAsyncIterator } from '../validate'; const tables = [...generateRandomTables([10, 20, 30])]; - const stream = concatStream(tables.map((table) => + const stream = new MultiStream(tables.map((table) => () => RecordBatchStreamWriter.writeAll(table).toNodeStream() )) as NodeJS.ReadableStream; @@ -149,7 +147,7 @@ import { validateRecordBatchAsyncIterator } from '../validate'; const tables = [...generateRandomTables([10, 20, 30])]; - const stream = concatStream(tables.map((table) => + const stream = new MultiStream(tables.map((table) => () => RecordBatchStreamWriter.writeAll(table).toNodeStream() )) as NodeJS.ReadableStream; @@ -177,7 +175,7 @@ import { validateRecordBatchAsyncIterator } from '../validate'; const tables = [...generateRandomTables([10, 20, 30])]; - const stream = concatStream(tables.map((table) => + const stream = new MultiStream(tables.map((table) => () => RecordBatchStreamWriter.writeAll(table).toNodeStream() )) as NodeJS.ReadableStream; @@ -205,8 +203,7 @@ import { validateRecordBatchAsyncIterator } from '../validate'; } } - // stream.readable should be false here - validateStreamState(reader, stream, true); + validateStreamState(reader, stream, true, true); expect(tableIndex).toBe(tables.length / 2 | 0); }); })(); diff --git a/js/test/unit/ipc/writer/stream-writer-tests.ts b/js/test/unit/ipc/writer/stream-writer-tests.ts index 939b36f8c0b..a83aa39da4c 100644 --- a/js/test/unit/ipc/writer/stream-writer-tests.ts +++ b/js/test/unit/ipc/writer/stream-writer-tests.ts @@ -22,7 +22,7 @@ import { import * as generate from '../../../generate-test-data'; import { validateRecordBatchIterator } from '../validate'; -import { RecordBatchStreamWriterOptions } from '../../../../src/ipc/writer'; +import { RecordBatchStreamWriterOptions } from 'apache-arrow/ipc/writer'; import { DictionaryVector, Dictionary, Uint32, Int32 } from 'apache-arrow'; import { Table, Schema, Field, Chunked, Builder, RecordBatch, RecordBatchReader, RecordBatchStreamWriter } from 'apache-arrow'; diff --git a/js/test/unit/utils-tests.ts b/js/test/unit/utils-tests.ts index 00553c4f1b4..560fd264c3c 100644 --- a/js/test/unit/utils-tests.ts +++ b/js/test/unit/utils-tests.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { isTypedArray } from '../../src/util/args'; +import { isTypedArray } from 'apache-arrow/util/args'; describe('isTypedArray', () => { diff --git a/js/test/unit/vector/numeric-vector-tests.ts b/js/test/unit/vector/numeric-vector-tests.ts index 8c077e0c865..41564716878 100644 --- a/js/test/unit/vector/numeric-vector-tests.ts +++ b/js/test/unit/vector/numeric-vector-tests.ts @@ -28,9 +28,9 @@ import { } from 'apache-arrow'; const { float64ToUint16, uint16ToFloat64 } = util; -import { VectorType as V } from '../../../src/interfaces'; -import { TypedArray, TypedArrayConstructor } from '../../../src/interfaces'; -import { BigIntArray, BigIntArrayConstructor } from '../../../src/interfaces'; +import { VectorType as V } from 'apache-arrow/interfaces'; +import { TypedArray, TypedArrayConstructor } from 'apache-arrow/interfaces'; +import { BigIntArray, BigIntArrayConstructor } from 'apache-arrow/interfaces'; const { joinUint8Arrays, BN } = util; const uint16ToFloat64Array = (b: ArrayBuffer) => new Float64Array([...new Uint16Array(b)].map(uint16ToFloat64)); diff --git a/js/tsconfig.json b/js/tsconfig.json index c232f209f71..1e512e8095f 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -1,14 +1,13 @@ { "extends": "./tsconfig/tsconfig.base.json", "formatCodeOptions": { - "tabSize": 4, - "indentSize": 4 + "tabSize": 2, + "indentSize": 2 }, "compilerOptions": { "target": "ESNEXT", - "module": "commonjs", + "module": "CommonJS", "noEmit": true, - "esModuleInterop": true, "baseUrl": "./", "paths": { "apache-arrow": [ diff --git a/js/yarn.lock b/js/yarn.lock index f173495654b..cf77162d673 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -6497,7 +6497,7 @@ multimatch@^5.0.0: multistream@4.1.0: version "4.1.0" - resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8" + resolved "https://registry.npmjs.org/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8" integrity sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw== dependencies: once "^1.4.0" From 6102f981edc336a180e5c26a3465a8d8c46837d5 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 8 Jul 2021 04:27:51 -0500 Subject: [PATCH 11/21] get tests working on umd targets, esm still broken --- js/gulp/package-task.js | 2 ++ js/jest.config.js | 7 ++++--- js/package.json | 2 +- js/src/Arrow.dom.ts | 1 + js/src/Arrow.ts | 2 ++ js/test/tsconfig/tsconfig.apache-arrow.json | 8 -------- js/test/tsconfig/tsconfig.base.json | 11 ++++++++++- js/test/tsconfig/tsconfig.es2015.cjs.json | 8 -------- js/test/tsconfig/tsconfig.es2015.esm.json | 8 -------- js/test/tsconfig/tsconfig.es2015.umd.json | 10 +--------- js/test/tsconfig/tsconfig.es5.cjs.json | 8 -------- js/test/tsconfig/tsconfig.es5.esm.json | 8 -------- js/test/tsconfig/tsconfig.es5.umd.json | 10 +--------- js/test/tsconfig/tsconfig.esnext.cjs.json | 8 -------- js/test/tsconfig/tsconfig.esnext.esm.json | 8 -------- js/test/tsconfig/tsconfig.esnext.umd.json | 10 +--------- js/test/tsconfig/tsconfig.src.json | 8 -------- js/test/tsconfig/tsconfig.ts.json | 8 -------- js/test/unit/ipc/reader/streams-dom-tests.ts | 2 +- js/test/unit/utils-tests.ts | 3 +-- js/tsconfig.json | 1 + js/yarn.lock | 8 ++++---- 22 files changed, 30 insertions(+), 111 deletions(-) diff --git a/js/gulp/package-task.js b/js/gulp/package-task.js index cb1d97c82dd..c320c908d3d 100644 --- a/js/gulp/package-task.js +++ b/js/gulp/package-task.js @@ -85,6 +85,8 @@ const createScopedPackageJSON = (target, format) => (({ name, ...orig }) => browser: format === 'umd' ? `${mainExport}.js` : `${mainExport}.dom.js`, // set "main" to "Arrow" if building scoped UMD target, otherwise "Arrow.node" main: format === 'umd' ? `${mainExport}.js` : `${mainExport}.node`, + // 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 diff --git a/js/jest.config.js b/js/jest.config.js index e409ed36c68..778c4c37432 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -45,9 +45,10 @@ module.exports = { "^.+\\.ts$": "ts-jest" }, "transformIgnorePatterns": [ - "/targets/.*/.*\\.js$", - "/(es5|es2015|esnext)/umd/", - "/node_modules/(?!@openpgp/web-stream-tools).+\\.js$" + "/targets/.*?/cjs/", + "/targets/.*?/(!esm)/", + "/targets/(es5|es2015|esnext)/umd/", + "/node_modules/(?!@openpgp/web-stream-tools)/" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", "preset": "ts-jest", diff --git a/js/package.json b/js/package.json index 3016338cfbe..c6bca649670 100644 --- a/js/package.json +++ b/js/package.json @@ -92,7 +92,7 @@ "npm-run-all": "4.1.5", "randomatic": "3.1.1", "rxjs": "5.5.11", - "ts-jest": "27.0.0", + "ts-jest": "27.0.3", "ts-node": "10.0.0", "typedoc": "0.20.36", "typescript": "4.0.2", diff --git a/js/src/Arrow.dom.ts b/js/src/Arrow.dom.ts index 38729797a3a..07f0c8b8e06 100644 --- a/js/src/Arrow.dom.ts +++ b/js/src/Arrow.dom.ts @@ -109,4 +109,5 @@ export { TimeBuilder, TimeSecondBuilder, TimeMillisecondBuilder, TimeMicrosecondBuilder, TimeNanosecondBuilder, UnionBuilder, DenseUnionBuilder, SparseUnionBuilder, Utf8Builder, + isTypedArray, } from './Arrow'; diff --git a/js/src/Arrow.ts b/js/src/Arrow.ts index 41408c673ae..8bf29631039 100644 --- a/js/src/Arrow.ts +++ b/js/src/Arrow.ts @@ -132,3 +132,5 @@ export const util = { compareFields, compareTypes, }; + +export { isTypedArray } from './util/args'; diff --git a/js/test/tsconfig/tsconfig.apache-arrow.json b/js/test/tsconfig/tsconfig.apache-arrow.json index d91b9ca0ce8..fdf3179f479 100644 --- a/js/test/tsconfig/tsconfig.apache-arrow.json +++ b/js/test/tsconfig/tsconfig.apache-arrow.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "paths": { - "apache-arrow": [ - "targets/apache-arrow/Arrow.node" - ], - "apache-arrow/*": [ - "targets/apache-arrow/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.base.json b/js/test/tsconfig/tsconfig.base.json index 8140c5fa756..c42a7fda366 100644 --- a/js/test/tsconfig/tsconfig.base.json +++ b/js/test/tsconfig/tsconfig.base.json @@ -14,7 +14,16 @@ "inlineSources": false, "inlineSourceMap": false, "downlevelIteration": false, - "baseUrl": "../../" + "esModuleInterop": true, + "baseUrl": "../../", + "paths": { + "apache-arrow": [ + "src/Arrow.node" + ], + "apache-arrow/*": [ + "src/*" + ] + } }, "exclude": [ "../../node_modules" diff --git a/js/test/tsconfig/tsconfig.es2015.cjs.json b/js/test/tsconfig/tsconfig.es2015.cjs.json index 5c4c3eace5e..f83a2dde910 100644 --- a/js/test/tsconfig/tsconfig.es2015.cjs.json +++ b/js/test/tsconfig/tsconfig.es2015.cjs.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "paths": { - "apache-arrow": [ - "targets/es2015/cjs/Arrow.node" - ], - "apache-arrow/*": [ - "targets/es2015/cjs/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.es2015.esm.json b/js/test/tsconfig/tsconfig.es2015.esm.json index d3424aa86bb..888d61d7813 100644 --- a/js/test/tsconfig/tsconfig.es2015.esm.json +++ b/js/test/tsconfig/tsconfig.es2015.esm.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "es2015", - "paths": { - "apache-arrow": [ - "targets/es2015/esm/Arrow.node" - ], - "apache-arrow/*": [ - "targets/es2015/esm/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.es2015.umd.json b/js/test/tsconfig/tsconfig.es2015.umd.json index f6f56a4407f..3fd3c28dc8d 100644 --- a/js/test/tsconfig/tsconfig.es2015.umd.json +++ b/js/test/tsconfig/tsconfig.es2015.umd.json @@ -3,17 +3,9 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", + "module": "umd", "declaration": false, "noEmitHelpers": true, "importHelpers": true, - "paths": { - "apache-arrow": [ - "targets/es2015/umd/Arrow" - ], - "apache-arrow/*": [ - "targets/es2015/umd/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.es5.cjs.json b/js/test/tsconfig/tsconfig.es5.cjs.json index 156075c3b6c..ab895875999 100644 --- a/js/test/tsconfig/tsconfig.es5.cjs.json +++ b/js/test/tsconfig/tsconfig.es5.cjs.json @@ -5,13 +5,5 @@ "target": "esnext", "module": "commonjs", "downlevelIteration": true, - "paths": { - "apache-arrow": [ - "targets/es5/cjs/Arrow.node" - ], - "apache-arrow/*": [ - "targets/es5/cjs/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.es5.esm.json b/js/test/tsconfig/tsconfig.es5.esm.json index 42da06dee44..f7d1c0ccaab 100644 --- a/js/test/tsconfig/tsconfig.es5.esm.json +++ b/js/test/tsconfig/tsconfig.es5.esm.json @@ -5,13 +5,5 @@ "target": "esnext", "module": "es2015", "downlevelIteration": true, - "paths": { - "apache-arrow": [ - "targets/es5/esm/Arrow.node" - ], - "apache-arrow/*": [ - "targets/es5/esm/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.es5.umd.json b/js/test/tsconfig/tsconfig.es5.umd.json index 26a45bdf83b..5769fb352c6 100644 --- a/js/test/tsconfig/tsconfig.es5.umd.json +++ b/js/test/tsconfig/tsconfig.es5.umd.json @@ -3,18 +3,10 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", + "module": "umd", "declaration": false, "noEmitHelpers": true, "importHelpers": true, "downlevelIteration": true, - "paths": { - "apache-arrow": [ - "targets/es5/umd/Arrow" - ], - "apache-arrow/*": [ - "targets/es5/umd/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.esnext.cjs.json b/js/test/tsconfig/tsconfig.esnext.cjs.json index af4e5292eae..41c221ec64d 100644 --- a/js/test/tsconfig/tsconfig.esnext.cjs.json +++ b/js/test/tsconfig/tsconfig.esnext.cjs.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "paths": { - "apache-arrow": [ - "targets/esnext/cjs/Arrow.node" - ], - "apache-arrow/*": [ - "targets/esnext/cjs/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.esnext.esm.json b/js/test/tsconfig/tsconfig.esnext.esm.json index bce9dfa8d0d..01d0f2b1c1c 100644 --- a/js/test/tsconfig/tsconfig.esnext.esm.json +++ b/js/test/tsconfig/tsconfig.esnext.esm.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "es2015", - "paths": { - "apache-arrow": [ - "targets/esnext/esm/Arrow.node" - ], - "apache-arrow/*": [ - "targets/esnext/esm/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.esnext.umd.json b/js/test/tsconfig/tsconfig.esnext.umd.json index c03793ddb55..42c114ec7b8 100644 --- a/js/test/tsconfig/tsconfig.esnext.umd.json +++ b/js/test/tsconfig/tsconfig.esnext.umd.json @@ -3,17 +3,9 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", + "module": "umd", "declaration": false, "noEmitHelpers": true, "importHelpers": true, - "paths": { - "apache-arrow": [ - "targets/esnext/umd/Arrow" - ], - "apache-arrow/*": [ - "targets/esnext/umd/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.src.json b/js/test/tsconfig/tsconfig.src.json index 82127502233..d991a626994 100644 --- a/js/test/tsconfig/tsconfig.src.json +++ b/js/test/tsconfig/tsconfig.src.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "paths": { - "apache-arrow": [ - "src/Arrow.node" - ], - "apache-arrow/*": [ - "src/*" - ] - } } } diff --git a/js/test/tsconfig/tsconfig.ts.json b/js/test/tsconfig/tsconfig.ts.json index 0952dd9cec8..a3c07ad3cab 100644 --- a/js/test/tsconfig/tsconfig.ts.json +++ b/js/test/tsconfig/tsconfig.ts.json @@ -4,13 +4,5 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "paths": { - "apache-arrow": [ - "targets/ts/Arrow.node" - ], - "apache-arrow/*": [ - "targets/ts/*" - ] - } } } diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index 5632d2c1445..3f9a373a850 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -36,7 +36,7 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' } const { parse: bignumJSONParse } = require('json-bignum'); - const { concatStream } = require('@openpgp/web-stream-tools').default; + const { concatStream } = require('@openpgp/web-stream-tools'); for (const table of generateRandomTables([10, 20, 30])) { diff --git a/js/test/unit/utils-tests.ts b/js/test/unit/utils-tests.ts index 560fd264c3c..985bec7aab4 100644 --- a/js/test/unit/utils-tests.ts +++ b/js/test/unit/utils-tests.ts @@ -15,8 +15,7 @@ // specific language governing permissions and limitations // under the License. -import { isTypedArray } from 'apache-arrow/util/args'; - +import { isTypedArray } from 'apache-arrow'; describe('isTypedArray', () => { test('works for typed arrays', () => { diff --git a/js/tsconfig.json b/js/tsconfig.json index 1e512e8095f..d8fa6445677 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -8,6 +8,7 @@ "target": "ESNEXT", "module": "CommonJS", "noEmit": true, + "esModuleInterop": true, "baseUrl": "./", "paths": { "apache-arrow": [ diff --git a/js/yarn.lock b/js/yarn.lock index cf77162d673..7e32bb3cf2a 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -8800,10 +8800,10 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= -ts-jest@27.0.0: - version "27.0.0" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.0.tgz#b94dbad8f39276b583edc7712e6b3c29e16c8863" - integrity sha512-YhuEjDZz9ZjxKbUlgT3XtJb9lyditEjctlo1nLcn983my3Xz4BE3c2ogHhonmGlAdUUiGlz/Dq2KOMXmf1WHfA== +ts-jest@27.0.3: + version "27.0.3" + resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.3.tgz#808492f022296cde19390bb6ad627c8126bf93f8" + integrity sha512-U5rdMjnYam9Ucw+h0QvtNDbc5+88nxt7tbIvqaZUhFrfG4+SkWhMXjejCLVGcpILTPuV+H3W/GZDZrnZFpPeXw== dependencies: bs-logger "0.x" buffer-from "1.x" From 9678a0d828e63991d01e4d1c3ea2fc86ce334e5e Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 10:36:00 -0700 Subject: [PATCH 12/21] Get ESM tests to work --- js/gulp/test-task.js | 3 +++ js/jest.config.js | 4 +--- js/jestconfigs/jest.es2015.esm.config.js | 8 ++++++-- js/jestconfigs/jest.es5.esm.config.js | 8 ++++++-- js/jestconfigs/jest.esnext.esm.config.js | 8 ++++++-- js/jestconfigs/jest.ts.config.js | 7 +++++-- js/package.json | 6 +++--- js/test/generate-test-data.ts | 2 +- js/test/tsconfig/tsconfig.apache-arrow.json | 2 +- js/test/tsconfig/tsconfig.es2015.cjs.json | 2 +- js/test/tsconfig/tsconfig.es2015.esm.json | 2 +- js/test/tsconfig/tsconfig.es2015.umd.json | 2 +- js/test/tsconfig/tsconfig.es5.cjs.json | 2 +- js/test/tsconfig/tsconfig.es5.esm.json | 4 ++-- js/test/tsconfig/tsconfig.es5.umd.json | 2 +- js/test/tsconfig/tsconfig.esnext.cjs.json | 2 +- js/test/tsconfig/tsconfig.esnext.esm.json | 2 +- js/test/tsconfig/tsconfig.esnext.umd.json | 2 +- js/test/tsconfig/tsconfig.src.json | 2 +- js/test/tsconfig/tsconfig.ts.json | 2 +- js/test/unit/builders/utils.ts | 2 +- js/test/unit/dataframe-tests.ts | 1 + js/test/unit/ipc/helpers.ts | 3 +-- .../unit/ipc/reader/from-inference-tests.ts | 4 +--- js/test/unit/ipc/reader/json-reader-tests.ts | 4 +--- js/test/unit/ipc/reader/streams-dom-tests.ts | 3 +-- js/test/unit/ipc/reader/streams-node-tests.ts | 13 +++++++----- js/test/unit/ipc/writer/json-writer-tests.ts | 4 +--- js/test/unit/ipc/writer/streams-dom-tests.ts | 4 +--- js/test/unit/ipc/writer/streams-node-tests.ts | 4 +--- js/yarn.lock | 20 +++++++++---------- 31 files changed, 70 insertions(+), 64 deletions(-) diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index ec9affa5876..6b5a6d9d75a 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -45,6 +45,9 @@ const testOptions = { const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format) { const opts = { ...testOptions }; const args = [...execArgv]; + if (format === 'esm' || target === 'ts') { + args.unshift(`--experimental-vm-modules`); + } if (argv.coverage) { args.push(`-c`, `jest.coverage.config.js`, `--coverage`, `-i`, `--no-cache`); } else { diff --git a/js/jest.config.js b/js/jest.config.js index 778c4c37432..75a1528fb38 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -45,9 +45,7 @@ module.exports = { "^.+\\.ts$": "ts-jest" }, "transformIgnorePatterns": [ - "/targets/.*?/cjs/", - "/targets/.*?/(!esm)/", - "/targets/(es5|es2015|esnext)/umd/", + "/targets/(es5|es2015|esnext)/", "/node_modules/(?!@openpgp/web-stream-tools)/" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index 8fff0181e97..27d131134c6 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -18,13 +18,17 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es2015.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.es2015.esm.json", + "useESM": true, } }, "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es2015/esm$1" + "^apache-arrow(.*)": "/targets/es2015/esm$1", + "tslib": "tslib/tslib.es6.js", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index 40b50743b4c..3ac8614d175 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -18,13 +18,17 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es5.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.es5.esm.json", + "useESM": true, } }, "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es5/esm$1" + "^apache-arrow(.*)": "/targets/es5/esm$1", + "tslib": "tslib/tslib.es6.js", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index 31f0d9b17fd..d27516212ea 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -18,13 +18,17 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.esnext.esm.json" + "tsconfig": "/test/tsconfig/tsconfig.esnext.esm.json", + "useESM": true, } }, "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/esnext/esm$1" + "^apache-arrow(.*)": "/targets/esnext/esm$1", + "tslib": "tslib/tslib.es6.js", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index 0bc67da7985..284da3df8fa 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -18,13 +18,16 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.ts.json" + "tsconfig": "/test/tsconfig/tsconfig.ts.json", + "useESM": true } }, "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/ts$1" + "^apache-arrow(.*)": "/targets/ts$1", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/package.json b/js/package.json index c6bca649670..d3dc9a1c5ff 100644 --- a/js/package.json +++ b/js/package.json @@ -59,12 +59,13 @@ "flatbuffers": "1.12.0", "json-bignum": "^0.0.3", "pad-left": "^2.1.0", - "tslib": "^2.2.0" + "tslib": "^2.3.0" }, "devDependencies": { + "@openpgp/web-stream-tools": "0.0.5", "@types/glob": "7.1.3", "@types/jest": "26.0.23", - "@types/multistream": "2.1.1", + "@types/randomatic": "3.1.2", "@typescript-eslint/eslint-plugin": "4.25.0", "@typescript-eslint/parser": "4.25.0", "async-done": "1.3.2", @@ -96,7 +97,6 @@ "ts-node": "10.0.0", "typedoc": "0.20.36", "typescript": "4.0.2", - "@openpgp/web-stream-tools": "0.0.5", "web-streams-polyfill": "3.0.3", "xml2js": "0.4.23" }, diff --git a/js/test/generate-test-data.ts b/js/test/generate-test-data.ts index 73c1fd2406e..030176e629b 100644 --- a/js/test/generate-test-data.ts +++ b/js/test/generate-test-data.ts @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -const randomatic = require('randomatic'); +import randomatic from 'randomatic'; import { VectorType as V } from 'apache-arrow/interfaces'; import { diff --git a/js/test/tsconfig/tsconfig.apache-arrow.json b/js/test/tsconfig/tsconfig.apache-arrow.json index fdf3179f479..161374e02e1 100644 --- a/js/test/tsconfig/tsconfig.apache-arrow.json +++ b/js/test/tsconfig/tsconfig.apache-arrow.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "commonjs" } } diff --git a/js/test/tsconfig/tsconfig.es2015.cjs.json b/js/test/tsconfig/tsconfig.es2015.cjs.json index f83a2dde910..ed600bc24d2 100644 --- a/js/test/tsconfig/tsconfig.es2015.cjs.json +++ b/js/test/tsconfig/tsconfig.es2015.cjs.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "commonjs" } } diff --git a/js/test/tsconfig/tsconfig.es2015.esm.json b/js/test/tsconfig/tsconfig.es2015.esm.json index 888d61d7813..a030beba7c1 100644 --- a/js/test/tsconfig/tsconfig.es2015.esm.json +++ b/js/test/tsconfig/tsconfig.es2015.esm.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", + "module": "es2020" } } diff --git a/js/test/tsconfig/tsconfig.es2015.umd.json b/js/test/tsconfig/tsconfig.es2015.umd.json index 3fd3c28dc8d..3e4de6f3cb5 100644 --- a/js/test/tsconfig/tsconfig.es2015.umd.json +++ b/js/test/tsconfig/tsconfig.es2015.umd.json @@ -6,6 +6,6 @@ "module": "umd", "declaration": false, "noEmitHelpers": true, - "importHelpers": true, + "importHelpers": true } } diff --git a/js/test/tsconfig/tsconfig.es5.cjs.json b/js/test/tsconfig/tsconfig.es5.cjs.json index ab895875999..edcd6977366 100644 --- a/js/test/tsconfig/tsconfig.es5.cjs.json +++ b/js/test/tsconfig/tsconfig.es5.cjs.json @@ -4,6 +4,6 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "downlevelIteration": true, + "downlevelIteration": true } } diff --git a/js/test/tsconfig/tsconfig.es5.esm.json b/js/test/tsconfig/tsconfig.es5.esm.json index f7d1c0ccaab..01af8fabdfe 100644 --- a/js/test/tsconfig/tsconfig.es5.esm.json +++ b/js/test/tsconfig/tsconfig.es5.esm.json @@ -3,7 +3,7 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", - "downlevelIteration": true, + "module": "es2020", + "downlevelIteration": true } } diff --git a/js/test/tsconfig/tsconfig.es5.umd.json b/js/test/tsconfig/tsconfig.es5.umd.json index 5769fb352c6..445ec8809b7 100644 --- a/js/test/tsconfig/tsconfig.es5.umd.json +++ b/js/test/tsconfig/tsconfig.es5.umd.json @@ -7,6 +7,6 @@ "declaration": false, "noEmitHelpers": true, "importHelpers": true, - "downlevelIteration": true, + "downlevelIteration": true } } diff --git a/js/test/tsconfig/tsconfig.esnext.cjs.json b/js/test/tsconfig/tsconfig.esnext.cjs.json index 41c221ec64d..6f21fd56c50 100644 --- a/js/test/tsconfig/tsconfig.esnext.cjs.json +++ b/js/test/tsconfig/tsconfig.esnext.cjs.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "commonjs" } } diff --git a/js/test/tsconfig/tsconfig.esnext.esm.json b/js/test/tsconfig/tsconfig.esnext.esm.json index 01d0f2b1c1c..3a9c277453e 100644 --- a/js/test/tsconfig/tsconfig.esnext.esm.json +++ b/js/test/tsconfig/tsconfig.esnext.esm.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "es2015", + "module": "es2020" } } diff --git a/js/test/tsconfig/tsconfig.esnext.umd.json b/js/test/tsconfig/tsconfig.esnext.umd.json index 42c114ec7b8..baccc6994c1 100644 --- a/js/test/tsconfig/tsconfig.esnext.umd.json +++ b/js/test/tsconfig/tsconfig.esnext.umd.json @@ -6,6 +6,6 @@ "module": "umd", "declaration": false, "noEmitHelpers": true, - "importHelpers": true, + "importHelpers": true } } diff --git a/js/test/tsconfig/tsconfig.src.json b/js/test/tsconfig/tsconfig.src.json index d991a626994..a73433c9de3 100644 --- a/js/test/tsconfig/tsconfig.src.json +++ b/js/test/tsconfig/tsconfig.src.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "commonjs" } } diff --git a/js/test/tsconfig/tsconfig.ts.json b/js/test/tsconfig/tsconfig.ts.json index a3c07ad3cab..1e053698e99 100644 --- a/js/test/tsconfig/tsconfig.ts.json +++ b/js/test/tsconfig/tsconfig.ts.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "es2020" } } diff --git a/js/test/unit/builders/utils.ts b/js/test/unit/builders/utils.ts index 0968910a96e..a9162f64554 100644 --- a/js/test/unit/builders/utils.ts +++ b/js/test/unit/builders/utils.ts @@ -20,9 +20,9 @@ import { AsyncIterable } from 'ix'; import { util } from 'apache-arrow'; import { Builder } from 'apache-arrow'; import { DataType, Vector, Chunked } from 'apache-arrow'; +import randstr from 'randomatic'; const rand = Math.random.bind(Math); -const randstr = require('randomatic'); const randnulls = (values: T[], n: TNull = null) => values.map((x) => Math.random() > 0.25 ? x : n) as (T | TNull)[]; export const randomBytes = (length: number) => fillRandom(Uint8Array, length); diff --git a/js/test/unit/dataframe-tests.ts b/js/test/unit/dataframe-tests.ts index cb9c2323b51..8330b6ead53 100644 --- a/js/test/unit/dataframe-tests.ts +++ b/js/test/unit/dataframe-tests.ts @@ -20,6 +20,7 @@ import { predicate, DataFrame, RecordBatch } from 'apache-arrow'; import { test_data } from './table-tests'; +import { jest } from '@jest/globals'; const { col, lit, custom, and, or, And, Or } = predicate; diff --git a/js/test/unit/ipc/helpers.ts b/js/test/unit/ipc/helpers.ts index 86cdca045d0..9fccefec968 100644 --- a/js/test/unit/ipc/helpers.ts +++ b/js/test/unit/ipc/helpers.ts @@ -28,8 +28,7 @@ import { import * as fs from 'fs'; import { fs as memfs } from 'memfs'; import { Readable, PassThrough } from 'stream'; - -const randomatic = require('randomatic'); +import randomatic from 'randomatic'; export abstract class ArrowIOTestHelper { diff --git a/js/test/unit/ipc/reader/from-inference-tests.ts b/js/test/unit/ipc/reader/from-inference-tests.ts index 93119c61243..c444b78fcc8 100644 --- a/js/test/unit/ipc/reader/from-inference-tests.ts +++ b/js/test/unit/ipc/reader/from-inference-tests.ts @@ -29,8 +29,6 @@ import { AsyncRecordBatchStreamReader } from 'apache-arrow'; -const { parse: bignumJSONParse } = require('json-bignum'); - for (const table of generateRandomTables([10, 20, 30])) { const name = `[\n ${table.schema.fields.join(',\n ')}\n]`; // eslint-disable-next-line jest/valid-describe @@ -44,7 +42,7 @@ for (const table of generateRandomTables([10, 20, 30])) { function testFromJSON(io: ArrowIOTestHelper, name: string) { describe(`should return a RecordBatchJSONReader (${name})`, () => { test(`Uint8Array`, io.buffer((buffer) => { - const json = bignumJSONParse(`${Buffer.from(buffer)}`); + const json = JSON.parse(`${Buffer.from(buffer)}`); const reader = RecordBatchReader.from(json); expect(reader.isSync()).toEqual(true); expect(reader.isAsync()).toEqual(false); diff --git a/js/test/unit/ipc/reader/json-reader-tests.ts b/js/test/unit/ipc/reader/json-reader-tests.ts index 0e7bab112ac..9bd1e346625 100644 --- a/js/test/unit/ipc/reader/json-reader-tests.ts +++ b/js/test/unit/ipc/reader/json-reader-tests.ts @@ -24,8 +24,6 @@ import { ArrowIOTestHelper } from '../helpers'; import { RecordBatchReader } from 'apache-arrow'; import { validateRecordBatchReader } from '../validate'; -const { parse: bignumJSONParse } = require('json-bignum'); - for (const table of generateRandomTables([10, 20, 30])) { const io = ArrowIOTestHelper.json(table); @@ -34,7 +32,7 @@ for (const table of generateRandomTables([10, 20, 30])) { describe(`RecordBatchJSONReader (${name})`, () => { describe(`should read all RecordBatches`, () => { test(`Uint8Array`, io.buffer((buffer) => { - const json = bignumJSONParse(Buffer.from(buffer).toString()); + const json = JSON.parse(Buffer.from(buffer).toString()); validateRecordBatchReader('json', 3, RecordBatchReader.from(json)); })); }); diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index 3f9a373a850..ca744eaa5f1 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -35,7 +35,6 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' return test('not testing DOM streams because process.env.TEST_DOM_STREAMS !== "true"', () => {}); } - const { parse: bignumJSONParse } = require('json-bignum'); const { concatStream } = require('@openpgp/web-stream-tools'); for (const table of generateRandomTables([10, 20, 30])) { @@ -63,7 +62,7 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' describe(`toDOMStream (${name})`, () => { describe(`RecordBatchJSONReader`, () => { - test('Uint8Array', json.buffer((source) => validate(bignumJSONParse(`${Buffer.from(source)}`)))); + test('Uint8Array', json.buffer((source) => validate(JSON.parse(`${Buffer.from(source)}`)))); }); describe(`RecordBatchFileReader`, () => { diff --git a/js/test/unit/ipc/reader/streams-node-tests.ts b/js/test/unit/ipc/reader/streams-node-tests.ts index 909a69a2c4c..822f9935020 100644 --- a/js/test/unit/ipc/reader/streams-node-tests.ts +++ b/js/test/unit/ipc/reader/streams-node-tests.ts @@ -34,10 +34,6 @@ import { validateRecordBatchAsyncIterator } from '../validate'; return test('not testing node streams because process.env.TEST_NODE_STREAMS !== "true"', () => {}); } - const { PassThrough } = require('stream'); - const MultiStream = require('multistream'); - const { parse: bignumJSONParse } = require('json-bignum'); - for (const table of generateRandomTables([10, 20, 30])) { const file = ArrowIOTestHelper.file(table); @@ -63,7 +59,7 @@ import { validateRecordBatchAsyncIterator } from '../validate'; describe(`toNodeStream (${name})`, () => { describe(`RecordBatchJSONReader`, () => { - test('Uint8Array', json.buffer((source) => validate(bignumJSONParse(`${Buffer.from(source)}`)))); + test('Uint8Array', json.buffer((source) => validate(JSON.parse(`${Buffer.from(source)}`)))); }); describe(`RecordBatchFileReader`, () => { @@ -108,6 +104,9 @@ import { validateRecordBatchAsyncIterator } from '../validate'; } it('readAll() should pipe to separate NodeJS WritableStreams', async () => { + // @ts-ignore + const { default: MultiStream } = await import('multistream'); + const { PassThrough } = await import('stream'); expect.hasAssertions(); @@ -142,6 +141,8 @@ import { validateRecordBatchAsyncIterator } from '../validate'; }); it('should not close the underlying NodeJS ReadableStream when reading multiple tables to completion', async () => { + // @ts-ignore + const { default: MultiStream } = await import('multistream'); expect.hasAssertions(); @@ -170,6 +171,8 @@ import { validateRecordBatchAsyncIterator } from '../validate'; }); it('should close the underlying NodeJS ReadableStream when reading multiple tables and we break early', async () => { + // @ts-ignore + const { default: MultiStream } = await import('multistream'); expect.hasAssertions(); diff --git a/js/test/unit/ipc/writer/json-writer-tests.ts b/js/test/unit/ipc/writer/json-writer-tests.ts index 2345483c1bb..05be0e27272 100644 --- a/js/test/unit/ipc/writer/json-writer-tests.ts +++ b/js/test/unit/ipc/writer/json-writer-tests.ts @@ -23,8 +23,6 @@ import { import { validateRecordBatchIterator } from '../validate'; import { Table, RecordBatchJSONWriter } from 'apache-arrow'; -const { parse: bignumJSONParse } = require('json-bignum'); - describe('RecordBatchJSONWriter', () => { for (const table of generateRandomTables([10, 20, 30])) { testJSONWriter(table, `[${table.schema.fields.join(', ')}]`); @@ -42,7 +40,7 @@ function testJSONWriter(table: Table, name: string) { async function validateTable(source: Table) { const writer = RecordBatchJSONWriter.writeAll(source); - const result = Table.from(bignumJSONParse(await writer.toString())); + const result = Table.from(JSON.parse(await writer.toString())); validateRecordBatchIterator(3, source.chunks); expect(result).toEqualTable(source); } diff --git a/js/test/unit/ipc/writer/streams-dom-tests.ts b/js/test/unit/ipc/writer/streams-dom-tests.ts index 4e2844cb451..18f161f7d73 100644 --- a/js/test/unit/ipc/writer/streams-dom-tests.ts +++ b/js/test/unit/ipc/writer/streams-dom-tests.ts @@ -49,8 +49,6 @@ import { return test('not testing DOM streams because process.env.TEST_DOM_STREAMS !== "true"', () => {}); } - const { parse: bignumJSONParse } = require('json-bignum'); - for (const table of generateRandomTables([10, 20, 30])) { const file = ArrowIOTestHelper.file(table); @@ -105,7 +103,7 @@ import { describe(`RecordBatchJSONWriter`, () => { - const toJSON = (x: any): { schema: any } => bignumJSONParse(`${Buffer.from(x)}`); + const toJSON = (x: any): { schema: any } => JSON.parse(`${Buffer.from(x)}`); test('Uint8Array', json.buffer((source) => validate(toJSON(source)))); test('Promise', json.buffer((source) => validate(Promise.resolve(toJSON(source))))); diff --git a/js/test/unit/ipc/writer/streams-node-tests.ts b/js/test/unit/ipc/writer/streams-node-tests.ts index 15723fb17a5..52126f612c3 100644 --- a/js/test/unit/ipc/writer/streams-node-tests.ts +++ b/js/test/unit/ipc/writer/streams-node-tests.ts @@ -48,8 +48,6 @@ import { return test('not testing node streams because process.env.TEST_NODE_STREAMS !== "true"', () => {}); } - const { parse: bignumJSONParse } = require('json-bignum'); - for (const table of generateRandomTables([10, 20, 30])) { const file = ArrowIOTestHelper.file(table); @@ -104,7 +102,7 @@ import { describe(`RecordBatchJSONWriter`, () => { - const toJSON = (x: any): { schema: any } => bignumJSONParse(`${Buffer.from(x)}`); + const toJSON = (x: any): { schema: any } => JSON.parse(`${Buffer.from(x)}`); test('Uint8Array', json.buffer((source) => validate(toJSON(source)))); test('Promise', json.buffer((source) => validate(Promise.resolve(toJSON(source))))); diff --git a/js/yarn.lock b/js/yarn.lock index 7e32bb3cf2a..3d88ffd759a 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -1581,13 +1581,6 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== -"@types/multistream@2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@types/multistream/-/multistream-2.1.1.tgz#4badd2440ee3570594ea552420fe2e29ebe512bd" - integrity sha512-PqavtNFnMyXRZS5vuW16wMOKeJUCD5PIGHdNBHzF5Urjncsij90hRQ82Wcy9+uSdnmrR2Gfao6xoJVq1wAWzbA== - dependencies: - "@types/node" "*" - "@types/node@*", "@types/node@^15.6.1": version "15.9.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-15.9.0.tgz#0b7f6c33ca5618fe329a9d832b478b4964d325a8" @@ -1613,6 +1606,11 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0" integrity sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA== +"@types/randomatic@3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@types/randomatic/-/randomatic-3.1.2.tgz#3485f0e113bf47fe25fee62fc20ca27713642975" + integrity sha512-lLsR0U1lUTjJ8vy1r3VGWlgprGtB/QPVwxs+QVSe28b0MS/7sR5tUfvhDd9XLV/AWc50OmDADAhzdqujavdykg== + "@types/stack-utils@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff" @@ -8837,10 +8835,10 @@ tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" - integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== +tslib@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" + integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== tsutils@^3.17.1, tsutils@^3.21.0: version "3.21.0" From e6d31d61fcb3f149978e40b02e55b8c84f64e156 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 11:02:21 -0700 Subject: [PATCH 13/21] Get source target tests to work --- js/gulp/test-task.js | 2 +- js/jest.config.js | 2 +- js/jestconfigs/jest.src.config.js | 8 ++++++-- js/test/tsconfig/tsconfig.src.json | 2 +- js/test/unit/ipc/reader/streams-dom-tests.ts | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 6b5a6d9d75a..d7cfdb41a77 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -45,7 +45,7 @@ const testOptions = { const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format) { const opts = { ...testOptions }; const args = [...execArgv]; - if (format === 'esm' || target === 'ts') { + if (format === 'esm' || target === 'ts' || target === 'src') { args.unshift(`--experimental-vm-modules`); } if (argv.coverage) { diff --git a/js/jest.config.js b/js/jest.config.js index 75a1528fb38..ba2e409f356 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -45,7 +45,7 @@ module.exports = { "^.+\\.ts$": "ts-jest" }, "transformIgnorePatterns": [ - "/targets/(es5|es2015|esnext)/", + "/targets/(es5|es2015|esnext|apache-arrow)/", "/node_modules/(?!@openpgp/web-stream-tools)/" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js index 0f0091bee58..14ca19d7229 100644 --- a/js/jestconfigs/jest.src.config.js +++ b/js/jestconfigs/jest.src.config.js @@ -18,13 +18,17 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.src.json" + "tsconfig": "/test/tsconfig/tsconfig.src.json", + "useESM": true } }, "moduleNameMapper": { - "^apache-arrow(.*)": "/src$1" + "^apache-arrow$": "/src/Arrow.node", + "^apache-arrow(.*)": "/src$1", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/test/tsconfig/tsconfig.src.json b/js/test/tsconfig/tsconfig.src.json index a73433c9de3..5413898f79d 100644 --- a/js/test/tsconfig/tsconfig.src.json +++ b/js/test/tsconfig/tsconfig.src.json @@ -3,6 +3,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "target": "esnext", - "module": "commonjs" + "module": "es2020" } } diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index ca744eaa5f1..37ace96519d 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -25,6 +25,8 @@ import { RecordBatchReader, RecordBatchStreamWriter } from 'apache-arrow'; +// @ts-ignore +import { concatStream } from '@openpgp/web-stream-tools'; import { validateRecordBatchAsyncIterator } from '../validate'; import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers'; @@ -35,8 +37,6 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' return test('not testing DOM streams because process.env.TEST_DOM_STREAMS !== "true"', () => {}); } - const { concatStream } = require('@openpgp/web-stream-tools'); - for (const table of generateRandomTables([10, 20, 30])) { const file = ArrowIOTestHelper.file(table); From 198206135a8d915d40aac8650e637fe3f868160e Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 11:39:41 -0700 Subject: [PATCH 14/21] Fix src tests --- js/test/unit/ipc/reader/streams-dom-tests.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/test/unit/ipc/reader/streams-dom-tests.ts b/js/test/unit/ipc/reader/streams-dom-tests.ts index 37ace96519d..a380e161932 100644 --- a/js/test/unit/ipc/reader/streams-dom-tests.ts +++ b/js/test/unit/ipc/reader/streams-dom-tests.ts @@ -25,8 +25,6 @@ import { RecordBatchReader, RecordBatchStreamWriter } from 'apache-arrow'; -// @ts-ignore -import { concatStream } from '@openpgp/web-stream-tools'; import { validateRecordBatchAsyncIterator } from '../validate'; import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers'; @@ -108,6 +106,8 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' } it('readAll() should pipe to separate WhatWG WritableStreams', async () => { + // @ts-ignore + const { concatStream } = await import('@openpgp/web-stream-tools'); expect.hasAssertions(); @@ -145,6 +145,8 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' }); it('should not close the underlying WhatWG ReadableStream when reading multiple tables to completion', async () => { + // @ts-ignore + const { concatStream } = await import('@openpgp/web-stream-tools'); expect.hasAssertions(); @@ -176,6 +178,8 @@ import { ArrowIOTestHelper, readableDOMStreamToAsyncIterator } from '../helpers' }); it('should close the underlying WhatWG ReadableStream when reading multiple tables and we break early', async () => { + // @ts-ignore + const { concatStream } = await import('@openpgp/web-stream-tools'); expect.hasAssertions(); From fb29aa88d3c0413120a091fbe5500434ba735cb7 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 22:11:14 -0700 Subject: [PATCH 15/21] Make launch tasks work --- js/.vscode/launch.json | 25 +++++++++++ js/gulp/test-task.js | 2 +- js/jest.config.js | 11 +++-- js/jestconfigs/jest.apache-arrow.config.js | 1 + js/{ => jestconfigs}/jest.coverage.config.js | 10 ++--- js/jestconfigs/jest.es2015.cjs.config.js | 1 + js/jestconfigs/jest.es2015.esm.config.js | 1 - js/jestconfigs/jest.es2015.umd.config.js | 1 + js/jestconfigs/jest.es5.cjs.config.js | 1 + js/jestconfigs/jest.es5.esm.config.js | 1 - js/jestconfigs/jest.es5.umd.config.js | 1 + js/jestconfigs/jest.esnext.cjs.config.js | 1 + js/jestconfigs/jest.esnext.esm.config.js | 1 - js/jestconfigs/jest.esnext.umd.config.js | 1 + js/jestconfigs/jest.src.config.js | 6 --- js/jestconfigs/jest.ts.config.js | 1 - js/package.json | 9 ++-- js/test/tsconfig.coverage.json | 2 +- js/test/tsconfig.json | 45 +++++++++----------- js/test/tsconfig/tsconfig.base.json | 16 ++----- js/tsconfig.json | 18 +++----- js/tsconfig/tsconfig.base.json | 6 +-- 22 files changed, 82 insertions(+), 79 deletions(-) rename js/{ => jestconfigs}/jest.coverage.config.js (85%) diff --git a/js/.vscode/launch.json b/js/.vscode/launch.json index 40fc0710ee5..7188641367c 100644 --- a/js/.vscode/launch.json +++ b/js/.vscode/launch.json @@ -36,6 +36,9 @@ // "TEST_TARGET": "es5", // "TEST_MODULE": "umd" }, + "runtimeArgs": [ + "--experimental-vm-modules" + ], "args": [ "-i", "test/unit/", @@ -205,6 +208,28 @@ "${workspaceFolder}/bin/print-buffer-alignment.js", "./test/data/cpp/stream/struct_example.arrow" ] + },{ + "type": "node", + "name": "vscode-jest-tests", + "request": "launch", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "disableOptimisticBPs": true, + "cwd": "${workspaceFolder}", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "runtimeArgs": [ + "--experimental-vm-modules" + ], + "args": [ + "--runInBand", + "--watchAll=false" + ], + "env": { + "NODE_NO_WARNINGS": "1", + "TEST_DOM_STREAMS": "true", + "TEST_NODE_STREAMS": "true", + "TEST_TS_SOURCE": "true" + }, } ] } diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index d7cfdb41a77..9eac9dbae68 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -49,7 +49,7 @@ const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function args.unshift(`--experimental-vm-modules`); } if (argv.coverage) { - args.push(`-c`, `jest.coverage.config.js`, `--coverage`, `-i`, `--no-cache`); + args.push(`-c`, `jestconfigs/jest.coverage.config.js`, `-i`, `--no-cache`); } else { const cfgname = [target, format].filter(Boolean).join('.'); args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `-i`, `--no-cache`, `test/unit/`); diff --git a/js/jest.config.js b/js/jest.config.js index ba2e409f356..2b335174667 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -21,19 +21,21 @@ module.exports = { "globals": { "ts-jest": { "diagnostics": false, - "tsconfig": "test/tsconfig.json" + "tsconfig": "test/tsconfig.json", + "useESM": true } }, "rootDir": ".", "roots": [ "/test/" ], + "preset": "ts-jest/presets/default-esm", "moduleFileExtensions": [ "js", "ts" ], "coverageReporters": [ - "lcov" + "lcov", "json" ], "coveragePathIgnorePatterns": [ "fb\\/(File|Message|Schema|Tensor)\\.(js|ts)$", @@ -49,9 +51,10 @@ module.exports = { "/node_modules/(?!@openpgp/web-stream-tools)/" ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", - "preset": "ts-jest", "testMatch": null, "moduleNameMapper": { - "^apache-arrow(.*)": "/src/$1.js" + "^apache-arrow$": "/src/Arrow.node", + "^apache-arrow(.*)": "/src$1", + "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js index 0e5e157fb26..513c7c66f19 100644 --- a/js/jestconfigs/jest.apache-arrow.config.js +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jest.coverage.config.js b/js/jestconfigs/jest.coverage.config.js similarity index 85% rename from js/jest.coverage.config.js rename to js/jestconfigs/jest.coverage.config.js index 37917720367..673a2c9e8a7 100644 --- a/js/jest.coverage.config.js +++ b/js/jestconfigs/jest.coverage.config.js @@ -16,15 +16,15 @@ // under the License. module.exports = { - ...require('./jest.config'), + ...require('../jest.config'), + "rootDir": "../", + collectCoverage: true, reporters: undefined, - coverageReporters: [ - lcov, 'json' - ], globals: { 'ts-jest': { diagnostics: false, - tsconfig: 'test/tsconfig.coverage.json' + tsconfig: 'test/tsconfig.coverage.json', + useESM: true } } }; diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js index 32c6aa4416b..8fc6421ce22 100644 --- a/js/jestconfigs/jest.es2015.cjs.config.js +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index 27d131134c6..8ccb7227446 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -18,7 +18,6 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", - "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js index 3dbacf289ec..76eeb1ae005 100644 --- a/js/jestconfigs/jest.es2015.umd.config.js +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js index 1f8d044cead..d903efa13e2 100644 --- a/js/jestconfigs/jest.es5.cjs.config.js +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index 3ac8614d175..24dcf8534c0 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -18,7 +18,6 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", - "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js index e42ba21a924..5993414e599 100644 --- a/js/jestconfigs/jest.es5.umd.config.js +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js index b7505558b0a..c941c12e2a6 100644 --- a/js/jestconfigs/jest.esnext.cjs.config.js +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index d27516212ea..0b72edd09ca 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -18,7 +18,6 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", - "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js index 6e38e2cc7f3..5171dd8fb51 100644 --- a/js/jestconfigs/jest.esnext.umd.config.js +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -18,6 +18,7 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", + "preset": "ts-jest", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js index 14ca19d7229..d20eff08054 100644 --- a/js/jestconfigs/jest.src.config.js +++ b/js/jestconfigs/jest.src.config.js @@ -18,17 +18,11 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", - "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, "tsconfig": "/test/tsconfig/tsconfig.src.json", "useESM": true } - }, - "moduleNameMapper": { - "^apache-arrow$": "/src/Arrow.node", - "^apache-arrow(.*)": "/src$1", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" } }; diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index 284da3df8fa..278c1b69730 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -18,7 +18,6 @@ module.exports = { ...require('../jest.config'), "rootDir": "../", - "preset": "ts-jest/presets/default-esm", "globals": { "ts-jest": { "diagnostics": false, diff --git a/js/package.json b/js/package.json index d3dc9a1c5ff..a7545a7d349 100644 --- a/js/package.json +++ b/js/package.json @@ -21,8 +21,7 @@ "doc": "del-cli ./doc && typedoc --options typedoc.js", "lint": "eslint src test --fix", "lint:ci": "eslint src test", - "prepublishOnly": "echo \"Error: do 'yarn release' instead of 'npm publish'\" && exit 1", - "version": "yarn && yarn clean:all" + "prepublishOnly": "echo \"Error: do 'yarn release' instead of 'npm publish'\" && exit 1" }, "repository": { "type": "git", @@ -42,14 +41,14 @@ "bin", "src", "gulp", + "jestconfigs", "test", "*.json", - "tsconfig", + "tsconfigs", "README.md", "gulpfile.js", "npm-release.sh", - "jest.config.js", - "jest.coverage.config.js" + "jest.config.js" ], "dependencies": { "@types/flatbuffers": "^1.10.0", diff --git a/js/test/tsconfig.coverage.json b/js/test/tsconfig.coverage.json index 6830bfb9d66..e903aa1e5b7 100644 --- a/js/test/tsconfig.coverage.json +++ b/js/test/tsconfig.coverage.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "target": "es2015" + "target": "esnext" } } diff --git a/js/test/tsconfig.json b/js/test/tsconfig.json index 3c1da87a690..8cf2e7e7b66 100644 --- a/js/test/tsconfig.json +++ b/js/test/tsconfig.json @@ -1,27 +1,24 @@ { - "extends": "../tsconfig.json", - "include": [ - "../src/**/*.ts", - "../test/**/*.ts" - ], - "compilerOptions": { - "target": "esnext", - "module": "commonjs", - "allowJs": true, - "declaration": false, - "declarationMap": false, - "importHelpers": false, - "noEmit": true, - "noEmitHelpers": false, - "noEmitOnError": false, - "sourceMap": false, - "inlineSources": false, - "inlineSourceMap": false, - "downlevelIteration": false, - "baseUrl": "../", - "paths": { - "apache-arrow": ["src/Arrow.node"], - "apache-arrow/*": ["src/*"] - } + "extends": "../tsconfig.json", + "include": ["../src/**/*.ts", "../test/**/*.ts"], + "compilerOptions": { + "target": "esnext", + "module": "es2020", + "allowJs": true, + "declaration": false, + "declarationMap": false, + "importHelpers": false, + "noEmit": true, + "noEmitHelpers": false, + "noEmitOnError": false, + "sourceMap": true, + "inlineSources": false, + "inlineSourceMap": false, + "downlevelIteration": false, + "baseUrl": "../", + "paths": { + "apache-arrow": ["src/Arrow.node"], + "apache-arrow/*": ["src/*"] } + } } diff --git a/js/test/tsconfig/tsconfig.base.json b/js/test/tsconfig/tsconfig.base.json index c42a7fda366..fcae71fb45d 100644 --- a/js/test/tsconfig/tsconfig.base.json +++ b/js/test/tsconfig/tsconfig.base.json @@ -17,18 +17,10 @@ "esModuleInterop": true, "baseUrl": "../../", "paths": { - "apache-arrow": [ - "src/Arrow.node" - ], - "apache-arrow/*": [ - "src/*" - ] + "apache-arrow": ["src/Arrow.node"], + "apache-arrow/*": ["src/*"] } }, - "exclude": [ - "../../node_modules" - ], - "include": [ - "../../src/**/*.ts" - ], + "exclude": ["../../node_modules"], + "include": ["../../src/**/*.ts"] } diff --git a/js/tsconfig.json b/js/tsconfig.json index d8fa6445677..72351f25971 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -5,23 +5,15 @@ "indentSize": 2 }, "compilerOptions": { - "target": "ESNEXT", - "module": "CommonJS", + "target": "esnext", + "module": "es2020", "noEmit": true, "esModuleInterop": true, "baseUrl": "./", "paths": { - "apache-arrow": [ - "src/Arrow.node" - ], - "apache-arrow/*": [ - "src/*" - ] + "apache-arrow": ["src/Arrow.node"], + "apache-arrow/*": ["src/*"] } }, - "include": [ - "src/**/*.ts", - "test/**/*.ts", - "perf/**/*.ts" - ] + "include": ["src/**/*.ts", "test/**/*.ts", "perf/**/*.ts"] } diff --git a/js/tsconfig/tsconfig.base.json b/js/tsconfig/tsconfig.base.json index dcabee543b0..8ee0d98f65b 100644 --- a/js/tsconfig/tsconfig.base.json +++ b/js/tsconfig/tsconfig.base.json @@ -5,9 +5,7 @@ "compilerOptions": { "baseUrl": "./", "paths": { - "apache-arrow/*": [ - "src/*" - ] + "apache-arrow/*": ["src/*"] }, /* Basic stuff */ @@ -47,6 +45,6 @@ "allowUnreachableCode": false, "noStrictGenericChecks": false, "noFallthroughCasesInSwitch": true, - "forceConsistentCasingInFileNames": true, + "forceConsistentCasingInFileNames": true } } From 6aa3df6e5aa247e6677f8ca38580787af1251fce Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 22:35:33 -0700 Subject: [PATCH 16/21] Format jest config files --- js/jest.config.js | 73 +++++++++---------- js/jestconfigs/jest.apache-arrow.config.js | 22 +++--- js/jestconfigs/jest.coverage.config.js | 22 +++--- js/jestconfigs/jest.es2015.cjs.config.js | 22 +++--- js/jestconfigs/jest.es2015.esm.config.js | 26 +++---- js/jestconfigs/jest.es2015.umd.config.js | 22 +++--- js/jestconfigs/jest.es5.cjs.config.js | 22 +++--- js/jestconfigs/jest.es5.esm.config.js | 26 +++---- js/jestconfigs/jest.es5.umd.config.js | 22 +++--- js/jestconfigs/jest.esnext.cjs.config.js | 22 +++--- js/jestconfigs/jest.esnext.esm.config.js | 26 +++---- js/jestconfigs/jest.esnext.umd.config.js | 22 +++--- js/jestconfigs/jest.src.config.js | 18 ++--- js/jestconfigs/jest.ts.config.js | 24 +++--- js/test/{ => tsconfig}/tsconfig.coverage.json | 0 js/tsconfig/tsconfig.bin.cjs.json | 18 ++--- js/tsconfig/tsconfig.docs.json | 10 +-- 17 files changed, 195 insertions(+), 202 deletions(-) rename js/test/{ => tsconfig}/tsconfig.coverage.json (100%) diff --git a/js/jest.config.js b/js/jest.config.js index 2b335174667..e4795e654a9 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -16,45 +16,38 @@ // under the License. module.exports = { - "verbose": false, - "testEnvironment": "node", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "test/tsconfig.json", - "useESM": true - } + verbose: false, + testEnvironment: "node", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "test/tsconfig.json", + useESM: true, }, - "rootDir": ".", - "roots": [ - "/test/" - ], - "preset": "ts-jest/presets/default-esm", - "moduleFileExtensions": [ - "js", - "ts" - ], - "coverageReporters": [ - "lcov", "json" - ], - "coveragePathIgnorePatterns": [ - "fb\\/(File|Message|Schema|Tensor)\\.(js|ts)$", - "test\\/.*\\.(ts|js)$", - "/node_modules/" - ], - "transform": { - "^.+\\.js$": "ts-jest", - "^.+\\.ts$": "ts-jest" - }, - "transformIgnorePatterns": [ - "/targets/(es5|es2015|esnext|apache-arrow)/", - "/node_modules/(?!@openpgp/web-stream-tools)/" - ], - "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", - "testMatch": null, - "moduleNameMapper": { - "^apache-arrow$": "/src/Arrow.node", - "^apache-arrow(.*)": "/src$1", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" - } + }, + rootDir: ".", + roots: ["/test/"], + preset: "ts-jest/presets/default-esm", + moduleFileExtensions: ["js", "ts"], + coverageReporters: ["lcov", "json"], + coveragePathIgnorePatterns: [ + "fb\\/(File|Message|Schema|Tensor)\\.(js|ts)$", + "test\\/.*\\.(ts|js)$", + "/node_modules/", + ], + transform: { + "^.+\\.js$": "ts-jest", + "^.+\\.ts$": "ts-jest", + }, + transformIgnorePatterns: [ + "/targets/(es5|es2015|esnext|apache-arrow)/", + "/node_modules/(?!@openpgp/web-stream-tools)/", + ], + testRegex: "(.*(-|\\.)(test|spec)s?)\\.(ts|js)$", + testMatch: null, + moduleNameMapper: { + "^apache-arrow$": "/src/Arrow.node", + "^apache-arrow(.*)": "/src$1", + flatbuffers: "flatbuffers/js/flatbuffers.mjs", + }, }; diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js index 513c7c66f19..9bd011c7aec 100644 --- a/js/jestconfigs/jest.apache-arrow.config.js +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.apache-arrow.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.apache-arrow.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/apache-arrow$1" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/apache-arrow$1", + }, }; diff --git a/js/jestconfigs/jest.coverage.config.js b/js/jestconfigs/jest.coverage.config.js index 673a2c9e8a7..3b0b6a1c6c4 100644 --- a/js/jestconfigs/jest.coverage.config.js +++ b/js/jestconfigs/jest.coverage.config.js @@ -16,15 +16,15 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - collectCoverage: true, - reporters: undefined, - globals: { - 'ts-jest': { - diagnostics: false, - tsconfig: 'test/tsconfig.coverage.json', - useESM: true - } - } + ...require("../jest.config"), + rootDir: "../", + collectCoverage: true, + reporters: undefined, + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.coverage.json", + useESM: true, + }, + }, }; diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js index 8fc6421ce22..a07bf8418a8 100644 --- a/js/jestconfigs/jest.es2015.cjs.config.js +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es2015.cjs.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es2015.cjs.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es2015/cjs$1" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es2015/cjs$1", + }, }; diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index 8ccb7227446..faf59792cdd 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -16,18 +16,18 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es2015.esm.json", - "useESM": true, - } + ...require("../jest.config"), + rootDir: "../", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es2015.esm.json", + useESM: true, }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es2015/esm$1", - "tslib": "tslib/tslib.es6.js", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es2015/esm$1", + tslib: "tslib/tslib.es6.js", + flatbuffers: "flatbuffers/js/flatbuffers.mjs", + }, }; diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js index 76eeb1ae005..1e861e0eedf 100644 --- a/js/jestconfigs/jest.es2015.umd.config.js +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es2015.umd.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es2015.umd.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es2015/umd/Arrow.js" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es2015/umd/Arrow.js", + }, }; diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js index d903efa13e2..c65c71b2ca3 100644 --- a/js/jestconfigs/jest.es5.cjs.config.js +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es5.cjs.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es5.cjs.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es5/cjs$1" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es5/cjs$1", + }, }; diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index 24dcf8534c0..ca46e9162f7 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -16,18 +16,18 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es5.esm.json", - "useESM": true, - } + ...require("../jest.config"), + rootDir: "../", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es5.esm.json", + useESM: true, }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es5/esm$1", - "tslib": "tslib/tslib.es6.js", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es5/esm$1", + tslib: "tslib/tslib.es6.js", + flatbuffers: "flatbuffers/js/flatbuffers.mjs", + }, }; diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js index 5993414e599..893a46149d2 100644 --- a/js/jestconfigs/jest.es5.umd.config.js +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.es5.umd.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.es5.umd.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/es5/umd/Arrow.js" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/es5/umd/Arrow.js", + }, }; diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js index c941c12e2a6..26cb9c60634 100644 --- a/js/jestconfigs/jest.esnext.cjs.config.js +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.esnext.cjs.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.esnext.cjs.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/esnext/cjs$1" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/esnext/cjs$1", + }, }; diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index 0b72edd09ca..26393694908 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -16,18 +16,18 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.esnext.esm.json", - "useESM": true, - } + ...require("../jest.config"), + rootDir: "../", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.esnext.esm.json", + useESM: true, }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/esnext/esm$1", - "tslib": "tslib/tslib.es6.js", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/esnext/esm$1", + tslib: "tslib/tslib.es6.js", + flatbuffers: "flatbuffers/js/flatbuffers.mjs", + }, }; diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js index 5171dd8fb51..eeee01fc993 100644 --- a/js/jestconfigs/jest.esnext.umd.config.js +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -16,16 +16,16 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "preset": "ts-jest", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.esnext.umd.json" - } + ...require("../jest.config"), + rootDir: "../", + preset: "ts-jest", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.esnext.umd.json", }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/esnext/umd/Arrow.js" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/esnext/umd/Arrow.js", + }, }; diff --git a/js/jestconfigs/jest.src.config.js b/js/jestconfigs/jest.src.config.js index d20eff08054..08ccad061ba 100644 --- a/js/jestconfigs/jest.src.config.js +++ b/js/jestconfigs/jest.src.config.js @@ -16,13 +16,13 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.src.json", - "useESM": true - } - } + ...require("../jest.config"), + rootDir: "../", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.src.json", + useESM: true, + }, + }, }; diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index 278c1b69730..7e9ac9b603d 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -16,17 +16,17 @@ // under the License. module.exports = { - ...require('../jest.config'), - "rootDir": "../", - "globals": { - "ts-jest": { - "diagnostics": false, - "tsconfig": "/test/tsconfig/tsconfig.ts.json", - "useESM": true - } + ...require("../jest.config"), + rootDir: "../", + globals: { + "ts-jest": { + diagnostics: false, + tsconfig: "/test/tsconfig/tsconfig.ts.json", + useESM: true, }, - "moduleNameMapper": { - "^apache-arrow(.*)": "/targets/ts$1", - "flatbuffers": "flatbuffers/js/flatbuffers.mjs" - } + }, + moduleNameMapper: { + "^apache-arrow(.*)": "/targets/ts$1", + flatbuffers: "flatbuffers/js/flatbuffers.mjs", + }, }; diff --git a/js/test/tsconfig.coverage.json b/js/test/tsconfig/tsconfig.coverage.json similarity index 100% rename from js/test/tsconfig.coverage.json rename to js/test/tsconfig/tsconfig.coverage.json diff --git a/js/tsconfig/tsconfig.bin.cjs.json b/js/tsconfig/tsconfig.bin.cjs.json index bb40e342f9b..e9671810a7b 100644 --- a/js/tsconfig/tsconfig.bin.cjs.json +++ b/js/tsconfig/tsconfig.bin.cjs.json @@ -1,12 +1,12 @@ // Compiler configuration to build the ES5 CommonJS bin files { - "extends": "./tsconfig.base.json", - "exclude": ["../node_modules"], - "include": ["../src/bin/*.ts"], - "compilerOptions": { - "target": "esnext", - "module": "commonjs", - "declaration": false, - "declarationMap": false - } + "extends": "./tsconfig.base.json", + "exclude": ["../node_modules"], + "include": ["../src/bin/*.ts"], + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "declaration": false, + "declarationMap": false } +} diff --git a/js/tsconfig/tsconfig.docs.json b/js/tsconfig/tsconfig.docs.json index c73c307d598..b7b990ed8ec 100644 --- a/js/tsconfig/tsconfig.docs.json +++ b/js/tsconfig/tsconfig.docs.json @@ -1,8 +1,8 @@ // Compiler configuration to build the docs { - "extends": "./tsconfig.base.json", - "include": ["../src/**/*.ts"], - "compilerOptions": { - "target": "ESNEXT" - } + "extends": "./tsconfig.base.json", + "include": ["../src/**/*.ts"], + "compilerOptions": { + "target": "ESNEXT" } +} From ef38d41115d8cb32234bf94aa4430d5e593ae770 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sat, 10 Jul 2021 23:02:45 -0700 Subject: [PATCH 17/21] Remove auto format json in vscode --- js/.vscode/settings.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/js/.vscode/settings.json b/js/.vscode/settings.json index 0173f14c9b2..379ddf14d0f 100644 --- a/js/.vscode/settings.json +++ b/js/.vscode/settings.json @@ -3,15 +3,5 @@ "editor.trimAutoWhitespace": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true - }, - "[json]": { - "editor.tabSize": 2, - "editor.wordWrap": "on", - "editor.formatOnSave": true, - }, - "[jsonc]": { - "editor.tabSize": 2, - "editor.wordWrap": "on", - "editor.formatOnSave": true, } } From 740f0096a6c6302ed336d0a0f6987a3be495d81e Mon Sep 17 00:00:00 2001 From: ptaylor Date: Sun, 11 Jul 2021 14:19:06 -0500 Subject: [PATCH 18/21] run jest tests in parallel when testing 1 target, sequentially when testing multiple targets --- js/gulp/test-task.js | 15 ++++++++++++--- js/gulp/util.js | 4 +++- js/gulpfile.js | 7 ++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 9eac9dbae68..415f0afb28a 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -28,9 +28,17 @@ const readFile = promisify(require('fs').readFile); const asyncDone = promisify(require('async-done')); const exec = promisify(require('child_process').exec); const parseXML = promisify(require('xml2js').parseString); +const { targetAndModuleCombinations } = require('./util'); const jestArgv = [`--reporters=jest-silent-reporter`]; -argv.verbose && jestArgv.push(`--verbose`); + +if (argv.verbose) { + jestArgv.push(`--verbose`); +} + +if (targetAndModuleCombinations.length > 1) { + jestArgv.push(`--detectOpenHandles`); +} const jest = path.join(path.parse(require.resolve(`jest`)).dir, `../bin/jest.js`); const testOptions = { @@ -49,11 +57,12 @@ const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function args.unshift(`--experimental-vm-modules`); } if (argv.coverage) { - args.push(`-c`, `jestconfigs/jest.coverage.config.js`, `-i`, `--no-cache`); + args.push(`-c`, `jestconfigs/jest.coverage.config.js`); } else { const cfgname = [target, format].filter(Boolean).join('.'); - args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `-i`, `--no-cache`, `test/unit/`); + args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `test/unit/`); } + console.log({ target, format, args: args.join(' ') }); opts.env = { ...opts.env, TEST_TARGET: target, diff --git a/js/gulp/util.js b/js/gulp/util.js index 673cd849799..b86bb656e06 100644 --- a/js/gulp/util.js +++ b/js/gulp/util.js @@ -181,5 +181,7 @@ module.exports = { knownTargets, knownModules, tasksToSkipPerTargetOrFormat, gCCLanguageNames, taskName, packageName, tsconfigName, targetDir, combinations, observableFromStreams, - publicModulePaths, esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess + publicModulePaths, esmRequire, shouldRunInChildProcess, spawnGulpCommandInChildProcess, + + targetAndModuleCombinations: [...combinations(targets, modules)] }; diff --git a/js/gulpfile.js b/js/gulpfile.js index ad520462818..bd860e16340 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -18,15 +18,16 @@ const del = require('del'); const gulp = require('gulp'); const { Observable } = require('rxjs'); +const { targets } = require('./gulp/argv'); const cleanTask = require('./gulp/clean-task'); const compileTask = require('./gulp/compile-task'); const packageTask = require('./gulp/package-task'); -const { targets, modules } = require('./gulp/argv'); const { testTask, createTestData, cleanTestData } = require('./gulp/test-task'); const { taskName, combinations, targetDir, knownTargets, - npmPkgName, tasksToSkipPerTargetOrFormat + npmPkgName, tasksToSkipPerTargetOrFormat, + targetAndModuleCombinations } = require('./gulp/util'); for (const [target, format] of combinations([`all`], [`all`])) { @@ -92,7 +93,7 @@ function getTasks(name) { const tasks = []; if (targets.includes(`ts`)) tasks.push(`${name}:ts`); if (targets.includes(npmPkgName)) tasks.push(`${name}:${npmPkgName}`); - for (const [target, format] of combinations(targets, modules)) { + for (const [target, format] of targetAndModuleCombinations) { if (tasksToSkipPerTargetOrFormat[target] && tasksToSkipPerTargetOrFormat[target][name]) continue; if (tasksToSkipPerTargetOrFormat[format] && tasksToSkipPerTargetOrFormat[format][name]) continue; tasks.push(`${name}:${taskName(target, format)}`); From 81c7674b46789dba39d734a69593bdbb695f873b Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sun, 11 Jul 2021 12:28:57 -0700 Subject: [PATCH 19/21] Expect node 12 --- js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index a7545a7d349..040bb4ff5b6 100644 --- a/js/package.json +++ b/js/package.json @@ -100,7 +100,7 @@ "xml2js": "0.4.23" }, "engines": { - "node": ">=11.12" + "node": ">=12.0" }, "version": "5.0.0-SNAPSHOT" } From 50362b42a20cb7b5dd18ece7b83b3df1c625bdb3 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sun, 11 Jul 2021 13:34:10 -0700 Subject: [PATCH 20/21] Remove stray console.log --- js/gulp/test-task.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 415f0afb28a..7a2cc0441ce 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -62,7 +62,6 @@ const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function const cfgname = [target, format].filter(Boolean).join('.'); args.push(`-c`, `jestconfigs/jest.${cfgname}.config.js`, `test/unit/`); } - console.log({ target, format, args: args.join(' ') }); opts.env = { ...opts.env, TEST_TARGET: target, From bf119b1d1a463bc64360cc0236c36446cca18d7a Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sun, 11 Jul 2021 13:36:19 -0700 Subject: [PATCH 21/21] ARROW-13303: [JS] Revise bundles --- js/gulp/arrow-task.js | 16 ++++++------- js/gulp/package-task.js | 23 +++++++++++++------ js/gulp/typescript-task.js | 26 +++++++++++++++------- js/gulpfile.js | 8 +++---- js/jest.config.js | 5 ++--- js/jestconfigs/jest.apache-arrow.config.js | 1 + js/jestconfigs/jest.es2015.cjs.config.js | 1 + js/jestconfigs/jest.es2015.esm.config.js | 3 +-- js/jestconfigs/jest.es2015.umd.config.js | 1 + js/jestconfigs/jest.es5.cjs.config.js | 1 + js/jestconfigs/jest.es5.esm.config.js | 3 +-- js/jestconfigs/jest.es5.umd.config.js | 1 + js/jestconfigs/jest.esnext.cjs.config.js | 1 + js/jestconfigs/jest.esnext.esm.config.js | 3 +-- js/jestconfigs/jest.esnext.umd.config.js | 1 + js/jestconfigs/jest.ts.config.js | 3 +-- 16 files changed, 59 insertions(+), 38 deletions(-) diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js index 277ee745f9e..029ba68d343 100644 --- a/js/gulp/arrow-task.js +++ b/js/gulp/arrow-task.js @@ -29,9 +29,9 @@ const pipeline = require('util').promisify(require('stream').pipeline); const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target) { const out = targetDir(target); - const dtsGlob = `${targetDir(`esnext`, `cjs`)}/**/*.ts`; - const cjsGlob = `${targetDir(`esnext`, `cjs`)}/**/*.js`; - const esmGlob = `${targetDir(`esnext`, `esm`)}/**/*.js`; + const tsGlob = `${targetDir(`esnext`, `cjs`)}/**/*.ts`; + const cjsGlob = `${targetDir(`es2015`, `cjs`)}/**/*.cjs`; + const esmGlob = `${targetDir(`es2015`, `esm`)}/**/*.mjs`; const es2015UmdGlob = `${targetDir(`es2015`, `umd`)}/*.js`; const esnextUmdGlob = `${targetDir(`esnext`, `umd`)}/*.js`; const cjsSourceMapsGlob = `${targetDir(`esnext`, `cjs`)}/**/*.map`; @@ -39,13 +39,13 @@ const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target) { const es2015UmdSourceMapsGlob = `${targetDir(`es2015`, `umd`)}/*.map`; const esnextUmdSourceMapsGlob = `${targetDir(`esnext`, `umd`)}/*.map`; return Observable.forkJoin( - observableFromStreams(gulp.src(dtsGlob), gulp.dest(out)), // copy d.ts files - observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy esnext cjs files - observableFromStreams(gulp.src(cjsSourceMapsGlob), gulp.dest(out)), // copy esnext cjs sourcemaps - observableFromStreams(gulp.src(esmSourceMapsGlob), gulp.dest(out)), // copy esnext esm sourcemaps + observableFromStreams(gulp.src(tsGlob), gulp.dest(out)), // copy ts and d.ts files + observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy es2015 cjs files + observableFromStreams(gulp.src(esmGlob), gulp.dest(out)), // copy es2015 esm 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 esnext umd sourcemap files, but don't rename - observableFromStreams(gulp.src(esmGlob), gulpRename((p) => { p.extname = '.mjs'; }), gulp.dest(out)), // copy esnext 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` ).publish(new ReplaySubject()).refCount(); diff --git a/js/gulp/package-task.js b/js/gulp/package-task.js index c320c908d3d..da92b1f999c 100644 --- a/js/gulp/package-task.js +++ b/js/gulp/package-task.js @@ -46,12 +46,21 @@ const createMainPackageJson = (target, format) => (orig) => ({ ...createTypeScriptPackageJson(target, format)(orig), bin: orig.bin, name: npmPkgName, - main: `${mainExport}.node`, - browser: `${mainExport}.dom`, - module: `${mainExport}.dom.mjs`, + main: `${mainExport}.node.cjs`, + module: `${mainExport}.node.mjs`, + browser: { + [`./${mainExport}.node.cjs`]: `./${mainExport}.dom.cjs`, + [`./${mainExport}.node.mjs`]: `./${mainExport}.dom.mjs` + }, types: `${mainExport}.node.d.ts`, unpkg: `${mainExport}.es2015.min.js`, jsdelivr: `${mainExport}.es2015.min.js`, + exports: { + import: `./${mainExport}.mjs`, + require: `./${mainExport}.cjs`, + node: `./${mainExport}.node.cjs`, + default: `./${mainExport}.es2015.min.js` + }, sideEffects: false, esm: { mode: `all`, sourceMap: true }, }); @@ -82,13 +91,13 @@ const createScopedPackageJSON = (target, format) => (({ name, ...orig }) => unpkg: format === 'umd' ? `${mainExport}.js` : undefined, jsdelivr: format === 'umd' ? `${mainExport}.js` : undefined, // set "browser" if building scoped UMD target, otherwise "Arrow.dom" - browser: format === 'umd' ? `${mainExport}.js` : `${mainExport}.dom.js`, + browser: format === 'umd' ? `${mainExport}.js` : format === 'cjs' ? `${mainExport}.dom.cjs` : `${mainExport}.dom.mjs`, // set "main" to "Arrow" if building scoped UMD target, otherwise "Arrow.node" - main: format === 'umd' ? `${mainExport}.js` : `${mainExport}.node`, + main: format === 'umd' ? `${mainExport}.js` : format === 'cjs' ? `${mainExport}.node.cjs` : `${mainExport}.node.mjs`, + // set "module" if building scoped ESM target + module: format === 'esm' ? `${mainExport}.node.mjs` : undefined, // 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 diff --git a/js/gulp/typescript-task.js b/js/gulp/typescript-task.js index 928e473141b..1cbf6b7f7fe 100644 --- a/js/gulp/typescript-task.js +++ b/js/gulp/typescript-task.js @@ -27,6 +27,7 @@ const gulp = require('gulp'); const path = require('path'); const ts = require(`gulp-typescript`); const sourcemaps = require('gulp-sourcemaps'); +const gulpRename = require(`gulp-rename`); const { memoizeTask } = require('./memoize-task'); const { Observable, ReplaySubject } = require('rxjs'); @@ -37,7 +38,7 @@ const typescriptTask = ((cache) => memoizeTask(cache, function typescript(target const out = targetDir(target, format); const tsconfigPath = path.join(`tsconfig`, `tsconfig.${tsconfigName(target, format)}.json`); - return compileTypescript(out, tsconfigPath) + return compileTypescript(out, tsconfigPath, format) .merge(compileBinFiles(target, format)).takeLast(1) .publish(new ReplaySubject()).refCount(); }))({}); @@ -45,25 +46,34 @@ const typescriptTask = ((cache) => memoizeTask(cache, function typescript(target function compileBinFiles(target, format) { const out = targetDir(target, format); const tsconfigPath = path.join(`tsconfig`, `tsconfig.${tsconfigName('bin', 'cjs')}.json`); - return compileTypescript(path.join(out, 'bin'), tsconfigPath, { target }); + return compileTypescript(path.join(out, 'bin'), tsconfigPath, format, { target }); } -function compileTypescript(out, tsconfigPath, tsconfigOverrides) { +function compileTypescript(out, tsconfigPath, format, tsconfigOverrides) { const tsProject = ts.createProject(tsconfigPath, { typescript: require(`typescript`), ...tsconfigOverrides }); const { stream: { js, dts } } = observableFromStreams( tsProject.src(), sourcemaps.init(), tsProject(ts.reporter.defaultReporter()) ); + const fileExtension = format === 'esm' ? '.mjs' : format === 'cjs' ? '.cjs' : '.js'; const writeSources = observableFromStreams(tsProject.src(), gulp.dest(out)); const writeDTypes = observableFromStreams(dts, sourcemaps.write('./', { includeContent: false }), gulp.dest(out)); - const mapFile = tsProject.options.module === 5 ? esmMapFile : cjsMapFile; - const writeJS = observableFromStreams(js, sourcemaps.write('./', { mapFile, includeContent: false }), gulp.dest(out)); + const writeJS = observableFromStreams( + js, + sourcemaps.write('./', { + includeContent: false, + // map file extensions in source maps + mapFile: (mapFilePath) => mapFilePath.replace('.js.map', `${fileExtension}.map`) + }), + gulpRename((p) => { + // change file extension of js files + p.extname = p.extname.replace('.js', fileExtension); + }), + gulp.dest(out) + ); return Observable.forkJoin(writeSources, writeDTypes, writeJS); } -function cjsMapFile(mapFilePath) { return mapFilePath; } -function esmMapFile(mapFilePath) { return mapFilePath.replace('.js.map', '.mjs.map'); } - module.exports = typescriptTask; module.exports.typescriptTask = typescriptTask; module.exports.compileBinFiles = compileBinFiles; diff --git a/js/gulpfile.js b/js/gulpfile.js index bd860e16340..170627ee645 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -56,15 +56,15 @@ knownTargets.forEach((target) => { )); }); -// The main "apache-arrow" module builds the es2015/umd, esnext/cjs, -// esnext/esm, and esnext/umd targets, then copies and renames the +// The main "apache-arrow" module builds the es2015/umd, es2015/cjs, +// es2015/esm, and esnext/umd targets, then copies and renames the // compiled output into the apache-arrow folder gulp.task(`build:${npmPkgName}`, gulp.series( gulp.parallel( `build:${taskName(`es2015`, `umd`)}`, - `build:${taskName(`esnext`, `cjs`)}`, - `build:${taskName(`esnext`, `esm`)}`, + `build:${taskName(`es2015`, `cjs`)}`, + `build:${taskName(`es2015`, `esm`)}`, `build:${taskName(`esnext`, `umd`)}` ), `clean:${npmPkgName}`, diff --git a/js/jest.config.js b/js/jest.config.js index e4795e654a9..3b2da73cb89 100644 --- a/js/jest.config.js +++ b/js/jest.config.js @@ -28,7 +28,7 @@ module.exports = { rootDir: ".", roots: ["/test/"], preset: "ts-jest/presets/default-esm", - moduleFileExtensions: ["js", "ts"], + moduleFileExtensions: ["mjs", "js", "ts"], coverageReporters: ["lcov", "json"], coveragePathIgnorePatterns: [ "fb\\/(File|Message|Schema|Tensor)\\.(js|ts)$", @@ -47,7 +47,6 @@ module.exports = { testMatch: null, moduleNameMapper: { "^apache-arrow$": "/src/Arrow.node", - "^apache-arrow(.*)": "/src$1", - flatbuffers: "flatbuffers/js/flatbuffers.mjs", + "^apache-arrow(.*)": "/src$1" }, }; diff --git a/js/jestconfigs/jest.apache-arrow.config.js b/js/jestconfigs/jest.apache-arrow.config.js index 9bd011c7aec..a81b937c823 100644 --- a/js/jestconfigs/jest.apache-arrow.config.js +++ b/js/jestconfigs/jest.apache-arrow.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["cjs", "js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.es2015.cjs.config.js b/js/jestconfigs/jest.es2015.cjs.config.js index a07bf8418a8..05b758a4929 100644 --- a/js/jestconfigs/jest.es2015.cjs.config.js +++ b/js/jestconfigs/jest.es2015.cjs.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["cjs", "js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.es2015.esm.config.js b/js/jestconfigs/jest.es2015.esm.config.js index faf59792cdd..cf564fb234a 100644 --- a/js/jestconfigs/jest.es2015.esm.config.js +++ b/js/jestconfigs/jest.es2015.esm.config.js @@ -27,7 +27,6 @@ module.exports = { }, moduleNameMapper: { "^apache-arrow(.*)": "/targets/es2015/esm$1", - tslib: "tslib/tslib.es6.js", - flatbuffers: "flatbuffers/js/flatbuffers.mjs", + tslib: "tslib/tslib.es6.js" }, }; diff --git a/js/jestconfigs/jest.es2015.umd.config.js b/js/jestconfigs/jest.es2015.umd.config.js index 1e861e0eedf..21f27872d91 100644 --- a/js/jestconfigs/jest.es2015.umd.config.js +++ b/js/jestconfigs/jest.es2015.umd.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.es5.cjs.config.js b/js/jestconfigs/jest.es5.cjs.config.js index c65c71b2ca3..17d3e32e726 100644 --- a/js/jestconfigs/jest.es5.cjs.config.js +++ b/js/jestconfigs/jest.es5.cjs.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["cjs", "js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.es5.esm.config.js b/js/jestconfigs/jest.es5.esm.config.js index ca46e9162f7..0a0a21b761c 100644 --- a/js/jestconfigs/jest.es5.esm.config.js +++ b/js/jestconfigs/jest.es5.esm.config.js @@ -27,7 +27,6 @@ module.exports = { }, moduleNameMapper: { "^apache-arrow(.*)": "/targets/es5/esm$1", - tslib: "tslib/tslib.es6.js", - flatbuffers: "flatbuffers/js/flatbuffers.mjs", + tslib: "tslib/tslib.es6.js" }, }; diff --git a/js/jestconfigs/jest.es5.umd.config.js b/js/jestconfigs/jest.es5.umd.config.js index 893a46149d2..f52af07bc8a 100644 --- a/js/jestconfigs/jest.es5.umd.config.js +++ b/js/jestconfigs/jest.es5.umd.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.esnext.cjs.config.js b/js/jestconfigs/jest.esnext.cjs.config.js index 26cb9c60634..697dfca7154 100644 --- a/js/jestconfigs/jest.esnext.cjs.config.js +++ b/js/jestconfigs/jest.esnext.cjs.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["cjs", "js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.esnext.esm.config.js b/js/jestconfigs/jest.esnext.esm.config.js index 26393694908..aca4c520805 100644 --- a/js/jestconfigs/jest.esnext.esm.config.js +++ b/js/jestconfigs/jest.esnext.esm.config.js @@ -27,7 +27,6 @@ module.exports = { }, moduleNameMapper: { "^apache-arrow(.*)": "/targets/esnext/esm$1", - tslib: "tslib/tslib.es6.js", - flatbuffers: "flatbuffers/js/flatbuffers.mjs", + tslib: "tslib/tslib.es6.js" }, }; diff --git a/js/jestconfigs/jest.esnext.umd.config.js b/js/jestconfigs/jest.esnext.umd.config.js index eeee01fc993..5013d45e03a 100644 --- a/js/jestconfigs/jest.esnext.umd.config.js +++ b/js/jestconfigs/jest.esnext.umd.config.js @@ -19,6 +19,7 @@ module.exports = { ...require("../jest.config"), rootDir: "../", preset: "ts-jest", + moduleFileExtensions: ["js", "ts"], globals: { "ts-jest": { diagnostics: false, diff --git a/js/jestconfigs/jest.ts.config.js b/js/jestconfigs/jest.ts.config.js index 7e9ac9b603d..e56161b8b4c 100644 --- a/js/jestconfigs/jest.ts.config.js +++ b/js/jestconfigs/jest.ts.config.js @@ -26,7 +26,6 @@ module.exports = { }, }, moduleNameMapper: { - "^apache-arrow(.*)": "/targets/ts$1", - flatbuffers: "flatbuffers/js/flatbuffers.mjs", + "^apache-arrow(.*)": "/targets/ts$1" }, };