This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 1a92846 ARROW-2223: [JS] compile src/bin as es5-cjs to all output
targets
1a92846 is described below
commit 1a92846d0559b0a3380ef9d15e0cf3d5a072b9b4
Author: Paul Taylor <[email protected]>
AuthorDate: Tue Feb 27 10:57:36 2018 -0500
ARROW-2223: [JS] compile src/bin as es5-cjs to all output targets
This ensures the `bin` files are uniformly es5/commonjs for all target
modules. Now this works:
```sh
npm i @apache-arrow/esnext-esm
npx arrow2csv -f some-file.arrow
```
Resolves https://issues.apache.org/jira/browse/ARROW-2223
Author: Paul Taylor <[email protected]>
Closes #1669 from trxcllnt/js-add-bin-to-umd-targets and squashes the
following commits:
9c6b7878 <Paul Taylor> compile src/bin as es5-cjs to all output targets
---
js/gulp/arrow-task.js | 8 ++++----
js/gulp/closure-task.js | 6 +++++-
js/gulp/typescript-task.js | 25 ++++++++++++++++++-------
js/gulp/uglify-task.js | 2 ++
js/gulpfile.js | 8 ++++----
js/src/bin/arrow2csv.ts | 2 --
js/tsconfig/tsconfig.base.json | 2 +-
js/tsconfig/tsconfig.bin.cjs.json | 12 ++++++++++++
8 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js
index d1e8046..eb83a6d 100644
--- a/js/gulp/arrow-task.js
+++ b/js/gulp/arrow-task.js
@@ -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(
diff --git a/js/gulp/closure-task.js b/js/gulp/closure-task.js
index 0b2ef1b..8833c2c 100644
--- a/js/gulp/closure-task.js
+++ b/js/gulp/closure-task.js
@@ -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');
@@ -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) => ({
diff --git a/js/gulp/typescript-task.js b/js/gulp/typescript-task.js
index c42357a..0fdd1c7 100644
--- a/js/gulp/typescript-task.js
+++ b/js/gulp/typescript-task.js
@@ -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`) {
diff --git a/js/gulp/uglify-task.js b/js/gulp/uglify-task.js
index 9ba3e41..f8dc123 100644
--- a/js/gulp/uglify-task.js
+++ b/js/gulp/uglify-task.js
@@ -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 });
@@ -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`] },
diff --git a/js/gulpfile.js b/js/gulpfile.js
index 7b82962..891d6c7 100644
--- a/js/gulpfile.js
+++ b/js/gulpfile.js
@@ -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`)}`
),
diff --git a/js/src/bin/arrow2csv.ts b/js/src/bin/arrow2csv.ts
index ee95613..6d197c7 100644
--- a/js/src/bin/arrow2csv.ts
+++ b/js/src/bin/arrow2csv.ts
@@ -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) {
diff --git a/js/tsconfig/tsconfig.base.json b/js/tsconfig/tsconfig.base.json
index 8b82101..d0b813e 100644
--- a/js/tsconfig/tsconfig.base.json
+++ b/js/tsconfig/tsconfig.base.json
@@ -1,5 +1,5 @@
{
- "exclude": ["../node_modules"],
+ "exclude": ["../node_modules", "../src/bin/*.ts"],
"include": ["../src/**/*.ts"],
"compileOnSave": false,
"compilerOptions": {
diff --git a/js/tsconfig/tsconfig.bin.cjs.json
b/js/tsconfig/tsconfig.bin.cjs.json
new file mode 100644
index 0000000..e17c1b5
--- /dev/null
+++ b/js/tsconfig/tsconfig.bin.cjs.json
@@ -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
+ }
+ }
+
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
[email protected].