Skip to content

Commit

Permalink
ARROW-1979: [JS] Fix JS builds hanging in es2015
Browse files Browse the repository at this point in the history
Also fixes [ARROW-1903](https://issues.apache.org/jira/browse/ARROW-1903)

Author: Paul Taylor <paul.e.taylor@me.com>

Closes apache#1471 from trxcllnt/fix-js-es2015-builds and squashes the following commits:

62db338 [Paul Taylor] update dependencies and add es6+ umd targets to jest transform ignore patterns to fix ci
6ff18e9 [Paul Taylor] ship es2015 commonJS in main package to avoid confusion
74e828a [Paul Taylor] fix typings issues (ARROW-1903)
  • Loading branch information
trxcllnt authored and wesm committed Jan 11, 2018
1 parent b49e8f3 commit 99e58da
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 38 deletions.
2 changes: 1 addition & 1 deletion js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions js/gulp/arrow-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions js/gulp/package-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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` }
});

Expand All @@ -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 }
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion js/gulp/test-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
38 changes: 19 additions & 19 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down Expand Up @@ -134,9 +131,12 @@
"/node_modules/"
],
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js",
".(js|jsx)": "<rootDir>/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)$"
}
}
4 changes: 0 additions & 4 deletions js/src/text-encoding-utf-8.d.ts

This file was deleted.

7 changes: 4 additions & 3 deletions js/src/vector/numeric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export class NumericVector<T, TArray extends TypedArray> extends Vector<T> {
concat(...vectors: Vector<T>[]): Vector<T> {
return new VirtualVector(this.data.constructor as TypedArrayConstructor, this, ...vectors);
}
slice(start?: number, end?: number) {
slice<R = TArray>(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;
}
}

Expand All @@ -49,7 +49,8 @@ export class FixedWidthNumericVector<T, TArray extends TypedArray> extends Numer

export class BoolVector extends NumericVector<boolean, Uint8Array> {
static pack(values: Iterable<any>) {
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);
Expand Down
2 changes: 1 addition & 1 deletion js/src/vector/virtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class VirtualVector<T> implements Vector<T> {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion js/test/Arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
2 changes: 1 addition & 1 deletion js/test/integration/validate-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 99e58da

Please sign in to comment.