[
https://issues.apache.org/jira/browse/ARROW-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16378831#comment-16378831
]
ASF GitHub Bot commented on ARROW-2223:
---------------------------------------
wesm closed pull request #1669: ARROW-2223: [JS] compile src/bin as es5-cjs to
all output targets
URL: https://github.com/apache/arrow/pull/1669
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/js/gulp/arrow-task.js b/js/gulp/arrow-task.js
index d1e8046e6..eb83a6da3 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 0b2ef1b84..8833c2c22 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 c42357adb..0fdd1c732 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 9ba3e41a1..f8dc123ca 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 7b8296203..891d6c79b 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 ee9561323..6d197c7b6 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 8b8210198..d0b813ef3 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 000000000..e17c1b589
--- /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
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [JS] installing umd release throws an error
> -------------------------------------------
>
> Key: ARROW-2223
> URL: https://issues.apache.org/jira/browse/ARROW-2223
> Project: Apache Arrow
> Issue Type: Bug
> Components: JavaScript
> Reporter: Brian Hulette
> Assignee: Paul Taylor
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> {code:sh}
> $ npm install @apache-arrow/es5-umd
> npm WARN [email protected] No repository field.
> npm ERR! path
> /home/ubuntu/working_dir/airspace-summary/node_modules/@apache-arrow/es5-umd/bin/arrow2csv.js
> npm ERR! code ENOENT
> npm ERR! errno -2
> npm ERR! syscall chmod
> npm ERR! enoent ENOENT: no such file or directory, chmod
> '/home/ubuntu/working_dir/airspace-summary/node_modules/@apache-arrow/es5-umd/bin/arrow2csv.js'
> npm ERR! enoent This is related to npm not being able to find a file.
> npm ERR! enoent
> npm ERR! A complete log of this run can be found in:
> npm ERR! /home/ubuntu/.npm/_logs/2018-02-26T21_22_42_518Z-debug.log
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)