Skip to content

Commit

Permalink
fix rest of the mangling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Jan 18, 2018
1 parent fa7c17a commit e3f629d
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 262 deletions.
5 changes: 2 additions & 3 deletions js/gulp/closure-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
const src = targetDir(target, `cls`);
const out = targetDir(target, format);
const entry = path.join(src, mainExport);
const externs = path.join(src, `${mainExport}.externs`);
const externs = path.join(`src/Arrow.externs.js`);
return observableFromStreams(
gulp.src([
/* external libs first --> */ `node_modules/tslib/package.json`,
Expand All @@ -46,7 +46,6 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
`node_modules/text-encoding-utf-8/package.json`,
`node_modules/text-encoding-utf-8/src/encoding.js`,
/* then sources globs --> */ `${src}/**/*.js`,
/* and exclusions last --> */ `!${src}/Arrow.externs.js`,
], { base: `./` }),
sourcemaps.init(),
closureCompiler(createClosureArgs(entry, externs)),
Expand All @@ -60,11 +59,11 @@ const closureTask = ((cache) => memoizeTask(cache, function closure(target, form
}))({});

const createClosureArgs = (entry, externs) => ({
externs,
third_party: true,
warning_level: `QUIET`,
dependency_mode: `STRICT`,
rewrite_polyfills: false,
externs: `${externs}.js`,
entry_point: `${entry}.js`,
module_resolution: `NODE`,
// formatting: `PRETTY_PRINT`, debug: true,
Expand Down
19 changes: 13 additions & 6 deletions js/gulp/uglify-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ module.exports = uglifyTask;
module.exports.uglifyTask = uglifyTask;

const reservePublicNames = ((ESKeywords) => function reservePublicNames(target, format) {
const publicModulePath = `../${targetDir(target, format)}/${mainExport}.js`;
return [
...ESKeywords,
...reserveExportedNames(esmRequire(publicModulePath))
const src = targetDir(target, format);
const publicModulePaths = [
`../${src}/data.js`,
`../${src}/type.js`,
`../${src}/table.js`,
`../${src}/vector.js`,
`../${src}/util/int.js`,
`../${src}/${mainExport}.js`,
];
return publicModulePaths.reduce((keywords, publicModulePath) => [
...keywords, ...reserveExportedNames(esmRequire(publicModulePath, { warnings: false }))
], [...ESKeywords]);
})(ESKeywords);

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

0 comments on commit e3f629d

Please sign in to comment.