Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions js/gulp/arrow-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target, forma
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`;
const es2015UmdGlob = `${targetDir(`es2015`, `umd`)}/**/*.js`;
const es2015UmdMaps = `${targetDir(`es2015`, `umd`)}/**/*.map`;
const es5UmdGlob = `${targetDir(`es5`, `umd`)}/*.js`;
const es5UmdMaps = `${targetDir(`es5`, `umd`)}/*.map`;
const es2015UmdGlob = `${targetDir(`es2015`, `umd`)}/*.js`;
const es2015UmdMaps = `${targetDir(`es2015`, `umd`)}/*.map`;
const ch_ext = (ext) => gulpRename((p) => { p.extname = ext; });
const append = (ap) => gulpRename((p) => { p.basename += ap; });
return Observable.forkJoin(
Expand Down
6 changes: 5 additions & 1 deletion js/gulp/closure-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const gulp = require('gulp');
const path = require('path');
const sourcemaps = require('gulp-sourcemaps');
const { memoizeTask } = require('./memoize-task');
const { compileBinFiles } = require('./typescript-task');
const ASTBuilders = require('ast-types').builders;
const transformAST = require('gulp-transform-js-ast');
const { Observable, ReplaySubject } = require('rxjs');
Expand Down Expand Up @@ -55,7 +56,10 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
// rename the sourcemaps from *.js.map files to *.min.js.map
sourcemaps.write(`.`, { mapFile: (mapPath) => mapPath.replace(`.js.map`, `.${target}.min.js.map`) }),
gulp.dest(out)
).publish(new ReplaySubject()).refCount();
)
.merge(compileBinFiles(target, format))
.takeLast(1)
.publish(new ReplaySubject()).refCount();
}))({});

const createClosureArgs = (entry, externs) => ({
Expand Down
25 changes: 18 additions & 7 deletions js/gulp/typescript-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,33 @@ const { Observable, ReplaySubject } = require('rxjs');

const typescriptTask = ((cache) => memoizeTask(cache, function typescript(target, format) {
const out = targetDir(target, format);
const tsconfigFile = `tsconfig.${tsconfigName(target, format)}.json`;
const tsProject = ts.createProject(path.join(`tsconfig`, tsconfigFile), { typescript: require(`typescript`) });
const tsconfigPath = path.join(`tsconfig`, `tsconfig.${tsconfigName(target, format)}.json`);
return compileTypescript(out, tsconfigPath)
.merge(compileBinFiles(target, format)).takeLast(1)
.concat(maybeCopyRawJSArrowFormatFiles(target, format))
.publish(new ReplaySubject()).refCount();
}))({});

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);
}

function compileTypescript(out, tsconfigPath) {
const tsProject = ts.createProject(tsconfigPath, { typescript: require(`typescript`) });
const { stream: { js, dts } } = observableFromStreams(
tsProject.src(), sourcemaps.init(),
tsProject(ts.reporter.defaultReporter())
);
const writeDTypes = observableFromStreams(dts, gulp.dest(out));
const writeJS = observableFromStreams(js, sourcemaps.write(), gulp.dest(out));
return Observable
.forkJoin(writeDTypes, writeJS)
.concat(maybeCopyRawJSArrowFormatFiles(target, format))
.publish(new ReplaySubject()).refCount();
}))({});
return Observable.forkJoin(writeDTypes, writeJS);
}

module.exports = typescriptTask;
module.exports.typescriptTask = typescriptTask;
module.exports.compileBinFiles = compileBinFiles;

function maybeCopyRawJSArrowFormatFiles(target, format) {
if (target !== `es5` || format !== `cls`) {
Expand Down
2 changes: 2 additions & 0 deletions js/gulp/uglify-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
const path = require('path');
const webpack = require(`webpack`);
const { memoizeTask } = require('./memoize-task');
const { compileBinFiles } = require('./typescript-task');
const { Observable, ReplaySubject } = require('rxjs');
const UglifyJSPlugin = require(`uglifyjs-webpack-plugin`);
const esmRequire = require(`@std/esm`)(module, { cjs: true, esm: `js`, warnings: false });
Expand Down Expand Up @@ -73,6 +74,7 @@ const uglifyTask = ((cache, commonConfig) => memoizeTask(cache, function uglifyJ
const compilers = webpack(webpackConfigs);
return Observable
.bindNodeCallback(compilers.run.bind(compilers))()
.merge(compileBinFiles(target, format)).takeLast(1)
.multicast(new ReplaySubject()).refCount();
}))({}, {
resolve: { mainFields: [`module`, `main`] },
Expand Down
8 changes: 4 additions & 4 deletions js/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ knownTargets.forEach((target) =>
)
);

// The main "apache-arrow" module builds the es5/cjs, es5/umd,
// es2015/esm, es2015/umd, and ts targets, then copies and
// renames the compiled output into the apache-arrow folder
// The main "apache-arrow" module builds the es5/umd, es2015/cjs,
// es2015/esm, and es2015/umd targets, then copies and renames the
// compiled output into the apache-arrow folder
gulp.task(`build:${npmPkgName}`,
gulp.series(
cleanTask(npmPkgName),
gulp.parallel(
`build:${taskName(`es5`, `cjs`)}`,
`build:${taskName(`es5`, `umd`)}`,
`build:${taskName(`es2015`, `cjs`)}`,
`build:${taskName(`es2015`, `esm`)}`,
`build:${taskName(`es2015`, `umd`)}`
),
Expand Down
2 changes: 0 additions & 2 deletions js/src/bin/arrow2csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ if (!files.length) {
}

files.forEach((source) => {
debugger;
let table: Arrow.Table, input = fs.readFileSync(source);
try {
table = Arrow.Table.from(input);
} catch (e) {
debugger;
table = Arrow.Table.from(parse(input + ''));
}
if (argv.schema && argv.schema.length) {
Expand Down
2 changes: 1 addition & 1 deletion js/tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"exclude": ["../node_modules"],
"exclude": ["../node_modules", "../src/bin/*.ts"],
"include": ["../src/**/*.ts"],
"compileOnSave": false,
"compilerOptions": {
Expand Down
12 changes: 12 additions & 0 deletions js/tsconfig/tsconfig.bin.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//Compiler configuaration to build the ES5 CommonJS bin files
{
"extends": "./tsconfig.base.json",
"exclude": ["../node_modules"],
"include": ["../src/bin/*.ts"],
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"declaration": false
}
}