Skip to content

Commit e3f629d

Browse files
committed
fix rest of the mangling issues
1 parent fa7c17a commit e3f629d

File tree

9 files changed

+354
-262
lines changed

9 files changed

+354
-262
lines changed

js/gulp/closure-task.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
3636
const src = targetDir(target, `cls`);
3737
const out = targetDir(target, format);
3838
const entry = path.join(src, mainExport);
39-
const externs = path.join(src, `${mainExport}.externs`);
39+
const externs = path.join(`src/Arrow.externs.js`);
4040
return observableFromStreams(
4141
gulp.src([
4242
/* external libs first --> */ `node_modules/tslib/package.json`,
@@ -46,7 +46,6 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
4646
`node_modules/text-encoding-utf-8/package.json`,
4747
`node_modules/text-encoding-utf-8/src/encoding.js`,
4848
/* then sources globs --> */ `${src}/**/*.js`,
49-
/* and exclusions last --> */ `!${src}/Arrow.externs.js`,
5049
], { base: `./` }),
5150
sourcemaps.init(),
5251
closureCompiler(createClosureArgs(entry, externs)),
@@ -60,11 +59,11 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
6059
}))({});
6160

6261
const createClosureArgs = (entry, externs) => ({
62+
externs,
6363
third_party: true,
6464
warning_level: `QUIET`,
6565
dependency_mode: `STRICT`,
6666
rewrite_polyfills: false,
67-
externs: `${externs}.js`,
6867
entry_point: `${entry}.js`,
6968
module_resolution: `NODE`,
7069
// formatting: `PRETTY_PRINT`, debug: true,

js/gulp/uglify-task.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,18 @@ module.exports = uglifyTask;
8484
module.exports.uglifyTask = uglifyTask;
8585

8686
const reservePublicNames = ((ESKeywords) => function reservePublicNames(target, format) {
87-
const publicModulePath = `../${targetDir(target, format)}/${mainExport}.js`;
88-
return [
89-
...ESKeywords,
90-
...reserveExportedNames(esmRequire(publicModulePath))
87+
const src = targetDir(target, format);
88+
const publicModulePaths = [
89+
`../${src}/data.js`,
90+
`../${src}/type.js`,
91+
`../${src}/table.js`,
92+
`../${src}/vector.js`,
93+
`../${src}/util/int.js`,
94+
`../${src}/${mainExport}.js`,
9195
];
96+
return publicModulePaths.reduce((keywords, publicModulePath) => [
97+
...keywords, ...reserveExportedNames(esmRequire(publicModulePath, { warnings: false }))
98+
], [...ESKeywords]);
9299
})(ESKeywords);
93100

94101
// Reflect on the Arrow modules to come up with a list of keys to save from Uglify's
@@ -104,8 +111,8 @@ const reserveExportedNames = (entryModule) => (
104111
.map((name) => [name, entryModule[name]])
105112
.reduce((reserved, [name, value]) => {
106113
const fn = function() {};
107-
const ownKeys = value && Object.getOwnPropertyNames(value) || [];
108-
const protoKeys = typeof value === `function` && Object.getOwnPropertyNames(value.prototype) || [];
114+
const ownKeys = value && typeof value === 'object' && Object.getOwnPropertyNames(value) || [];
115+
const protoKeys = typeof value === `function` && Object.getOwnPropertyNames(value.prototype || {}) || [];
109116
const publicNames = [...ownKeys, ...protoKeys].filter((x) => x !== `default` && x !== `undefined` && !(x in fn));
110117
return [...reserved, name, ...publicNames];
111118
}, []

0 commit comments

Comments
 (0)