diff --git a/js/README.md b/js/README.md index e58d335cd0d..b427923e37e 100644 --- a/js/README.md +++ b/js/README.md @@ -178,7 +178,7 @@ The base `apache-arrow` package includes all the compilation targets for conveni The targets are also published under the `@apache-arrow` namespace: ```sh -npm install apache-arrow # <-- combined es5/CommonJS + UMD, es2015/ESModules + UMD, and TypeScript package +npm install apache-arrow # <-- combined es5/UMD, es2015/CommonJS/ESModules/UMD, and TypeScript package npm install @apache-arrow/ts # standalone TypeScript package npm install @apache-arrow/es5-cjs # standalone es5/CommonJS package npm install @apache-arrow/es5-esm # standalone es5/ESModules package diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js index cc33ee14497..d1e8046e67a 100644 --- a/js/gulp/arrow-task.js +++ b/js/gulp/arrow-task.js @@ -28,8 +28,8 @@ const { Observable, ReplaySubject } = require('rxjs'); const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target, format) { const out = targetDir(target); - const srcGlob = `src/**/*.ts`; - const es5Glob = `${targetDir(`es5`, `cjs`)}/**/*.js`; + const dtsGlob = `${targetDir(`es2015`, `cjs`)}/**/*.ts`; + const cjsGlob = `${targetDir(`es2015`, `cjs`)}/**/*.js`; const esmGlob = `${targetDir(`es2015`, `esm`)}/**/*.js`; const es5UmdGlob = `${targetDir(`es5`, `umd`)}/**/*.js`; const es5UmdMaps = `${targetDir(`es5`, `umd`)}/**/*.map`; @@ -38,8 +38,8 @@ const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target, forma const ch_ext = (ext) => gulpRename((p) => { p.extname = ext; }); const append = (ap) => gulpRename((p) => { p.basename += ap; }); return Observable.forkJoin( - observableFromStreams(gulp.src(srcGlob), gulp.dest(out)), // copy src ts files - observableFromStreams(gulp.src(es5Glob), gulp.dest(out)), // copy es5 cjs files + observableFromStreams(gulp.src(dtsGlob), gulp.dest(out)), // copy d.ts files + observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy es2015 cjs files observableFromStreams(gulp.src(esmGlob), ch_ext(`.mjs`), gulp.dest(out)), // copy es2015 esm files and rename to `.mjs` observableFromStreams(gulp.src(es5UmdGlob), append(`.es5.min`), gulp.dest(out)), // copy es5 umd files and add `.min` observableFromStreams(gulp.src(es5UmdMaps), gulp.dest(out)), // copy es5 umd sourcemap files, but don't rename diff --git a/js/gulp/package-task.js b/js/gulp/package-task.js index fc959643503..2976d0ad45d 100644 --- a/js/gulp/package-task.js +++ b/js/gulp/package-task.js @@ -46,8 +46,8 @@ const createMainPackageJson = (target, format) => (orig) => ({ name: npmPkgName, main: mainExport, module: `${mainExport}.mjs`, - browser: `${mainExport}.es5.min.js`, - [`browser:es2015`]: `${mainExport}.es2015.min.js`, + dist: `${mainExport}.es5.min.js`, + [`dist:es2015`]: `${mainExport}.es2015.min.js`, [`@std/esm`]: { esm: `mjs` } }); @@ -67,7 +67,7 @@ const createScopedPackageJSON = (target, format) => (({ name, ...orig }) => (xs, key) => ({ ...xs, [key]: xs[key] || orig[key] }), { name: `${npmOrgName}/${packageName(target, format)}`, version: undefined, main: `${mainExport}.js`, types: `${mainExport}.d.ts`, - browser: undefined, [`browser:es2015`]: undefined, module: undefined, [`@std/esm`]: undefined } + dist: undefined, [`dist:es2015`]: undefined, module: undefined, [`@std/esm`]: undefined } ) ) ); diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index f21aaf2364d..ab280b09263 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -34,7 +34,7 @@ argv.update && jestArgv.push(`-u`); argv.verbose && jestArgv.push(`--verbose`); argv.coverage && jestArgv.push(`--coverage`); -const debugArgv = [`--runInBand`, `--env`, `jest-environment-node-debug`]; +const debugArgv = [`--runInBand`, `--env`, `node-debug`]; const jest = require.resolve(path.join(`..`, `node_modules`, `.bin`, `jest`)); const testOptions = { env: { ...process.env }, diff --git a/js/package.json b/js/package.json index 3903d1eedc4..d68e7a6279e 100644 --- a/js/package.json +++ b/js/package.json @@ -49,10 +49,8 @@ "gulpfile.js", "npm-release.sh" ], - "peerDependencies": { - "command-line-usage": "4.0.1" - }, "dependencies": { + "@types/text-encoding-utf-8": "1.0.1", "command-line-args": "4.0.7", "command-line-usage": "4.0.2", "flatbuffers": "trxcllnt/flatbuffers-esm", @@ -61,45 +59,44 @@ "tslib": "1.8.1" }, "devDependencies": { - "@std/esm": "0.18.0", + "@std/esm": "0.19.1", "@types/flatbuffers": "1.6.5", "@types/glob": "5.0.34", - "@types/jest": "21.1.8", - "@types/node": "8.5.0", - "@types/text-encoding": "0.0.32", + "@types/jest": "22.0.1", + "@types/node": "9.3.0", "ast-types": "0.10.1", "benchmark": "2.1.4", "coveralls": "3.0.0", "del": "3.0.0", - "esdoc": "1.0.3", + "esdoc": "1.0.4", "esdoc-standard-plugin": "1.0.0", "glob": "7.1.2", - "google-closure-compiler": "20171203.0.0", + "google-closure-compiler": "20180101.0.0", "gulp": "github:gulpjs/gulp#6d71a658c61edb3090221579d8f97dbe086ba2ed", "gulp-json-transform": "0.4.5", "gulp-rename": "1.2.2", - "gulp-sourcemaps": "2.6.1", + "gulp-sourcemaps": "2.6.3", "gulp-transform-js-ast": "1.0.2", "gulp-typescript": "3.2.3", "ix": "2.3.4", - "jest": "21.2.1", + "jest": "22.0.5", "jest-environment-node-debug": "2.0.0", "json": "9.0.6", - "lerna": "2.5.1", + "lerna": "2.6.0", "lint-staged": "6.0.0", - "merge2": "1.2.0", + "merge2": "1.2.1", "mkdirp": "0.5.1", "npm-run-all": "4.1.2", "pump": "1.0.2", "rimraf": "2.6.2", - "rxjs": "5.5.5", + "rxjs": "5.5.6", "shx": "0.2.2", "source-map-loader": "0.2.3", "trash": "4.2.1", - "ts-jest": "21.2.4", - "tslint": "5.8.0", + "ts-jest": "22.0.1", + "tslint": "5.9.1", "typescript": "2.6.2", - "uglifyjs-webpack-plugin": "1.1.2", + "uglifyjs-webpack-plugin": "1.1.6", "webpack": "3.10.0", "xml2js": "0.4.19" }, @@ -134,9 +131,12 @@ "/node_modules/" ], "transform": { - ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js", - ".(js|jsx)": "/node_modules/babel-jest/build/index.js" + ".(ts|tsx)": "./node_modules/ts-jest/preprocessor.js", + ".(js|jsx)": "./node_modules/babel-jest/build/index.js" }, + "transformIgnorePatterns": [ + "/node_modules/", "/(es2015|esnext)\/umd/" + ], "testRegex": "(.*(-|\\.)(test|spec)s?)\\.(ts|tsx|js)$" } } diff --git a/js/src/text-encoding-utf-8.d.ts b/js/src/text-encoding-utf-8.d.ts deleted file mode 100644 index 68ba4dfd9a3..00000000000 --- a/js/src/text-encoding-utf-8.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'text-encoding-utf-8' { - import * as TextEncoding from 'text-encoding'; - export = TextEncoding; -} diff --git a/js/src/vector/numeric.ts b/js/src/vector/numeric.ts index fe4767809f4..830d6082bcc 100644 --- a/js/src/vector/numeric.ts +++ b/js/src/vector/numeric.ts @@ -34,10 +34,10 @@ export class NumericVector extends Vector { concat(...vectors: Vector[]): Vector { return new VirtualVector(this.data.constructor as TypedArrayConstructor, this, ...vectors); } - slice(start?: number, end?: number) { + slice(start?: number, end?: number): R { const { data, stride } = this, from = start! | 0; const to = end === undefined ? data.length : Math.max(end | 0, from); - return data.subarray(Math.min(from, to) * stride | 0, to * stride | 0); + return data.subarray(Math.min(from, to) * stride | 0, to * stride | 0) as any as R; } } @@ -49,7 +49,8 @@ export class FixedWidthNumericVector extends Numer export class BoolVector extends NumericVector { static pack(values: Iterable) { - let xs = [], n, i = 0; + let n = 0, i = 0; + let xs: number[] = []; let bit = 0, byte = 0; for (const value of values) { value && (byte |= 1 << bit); diff --git a/js/src/vector/virtual.ts b/js/src/vector/virtual.ts index 6ec3a8eef9f..42db78706db 100644 --- a/js/src/vector/virtual.ts +++ b/js/src/vector/virtual.ts @@ -93,7 +93,7 @@ export class VirtualVector implements Vector { // this is a significant improvement as we avoid the memcpy 🎉 if ((source.length / vector.stride | 0) < total) { let vectorsLength = vectors.length; - let count = 0, length = 0, sources = []; + let count = 0, length = 0, sources = [] as any[]; do { sources.push(source); length += source.length; diff --git a/js/test/Arrow.ts b/js/test/Arrow.ts index 87641e52bf3..f2c4e930f92 100644 --- a/js/test/Arrow.ts +++ b/js/test/Arrow.ts @@ -16,7 +16,7 @@ // under the License. /* tslint:disable */ -// Dynamically load an Ix target build based on command line arguments +// Dynamically load an Arrow target build based on command line arguments const path = require('path'); const target = process.env.TEST_TARGET!; diff --git a/js/test/integration/validate-tests.ts b/js/test/integration/validate-tests.ts index c8778ba2b33..c612d62ad0c 100644 --- a/js/test/integration/validate-tests.ts +++ b/js/test/integration/validate-tests.ts @@ -37,7 +37,7 @@ const arrowBuffers: Uint8Array[] = [fs.readFileSync(arrowPath)]; import Arrow from '../Arrow'; import { zip } from 'ix/iterable/zip'; -import { toArray } from 'ix/iterable/toArray'; +import { toArray } from 'ix/iterable/toarray'; const { Table, read } = Arrow;