Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mangle exported symbols #182935

Merged
merged 36 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fe29a68
Mangle exported functions
mjbvz Apr 21, 2023
27cf0e3
Fix missing call
mjbvz Apr 21, 2023
3b11c9a
Also try mangling top level exported consts too
mjbvz Apr 21, 2023
f9c14c9
Fixing errors
mjbvz Apr 21, 2023
f182262
Don't run on build files
mjbvz Apr 21, 2023
c1e0837
Skip a few more manglings and revert change to namespace
mjbvz Apr 21, 2023
c4dce2e
Skip a few more monaco files
mjbvz Apr 21, 2023
444df2a
Also mangle consts that shadow types
mjbvz Apr 25, 2023
935b652
Also mangle exported classes
mjbvz Apr 25, 2023
c3f1144
Skip mangling more localization functions for now
mjbvz Apr 25, 2023
d9710a1
Opt out pfs
mjbvz Apr 25, 2023
effa224
Update build script
mjbvz Apr 25, 2023
6219d5c
Run find locations task in parallel
mjbvz May 1, 2023
ea3d4c5
Cleanup before close
mjbvz May 1, 2023
b43b649
Limit workers to avoid hitting memory limit
mjbvz May 1, 2023
94c87b9
Limit pool size
mjbvz May 1, 2023
9e9681d
Merge branch 'main' into fancy-barracuda
mjbvz May 3, 2023
10e4c2b
Skip one more mangling
mjbvz May 3, 2023
e4e8dda
Exclude entrypoints from mangling
mjbvz May 3, 2023
0eb9ca9
Try to fix web build and clean up code
mjbvz May 3, 2023
bb6c410
Exempt a few more projects
mjbvz May 4, 2023
0587382
Exempt another file
mjbvz May 4, 2023
4d345c9
Also exempt html
mjbvz May 4, 2023
509187e
Merge branch 'main' into dev/mjbvz/mangle-exports-2
mjbvz May 19, 2023
a3be808
Skip mangling ext entrypoints
mjbvz May 19, 2023
fd98785
Use prefix that can't be confused with rpc calls
mjbvz May 19, 2023
a5e4f7e
Fix max call stack error
mjbvz May 19, 2023
f0d67a1
Switch prefixes
mjbvz May 19, 2023
1edd1e2
Don't mangle ambient declarations
mjbvz May 23, 2023
c219287
Use correct way of checking modifier flags
mjbvz May 23, 2023
a38e52c
Workaround getCombinedModifierFlags not doing what I'd expect
mjbvz May 23, 2023
f3ad7c5
Clean up code and add logic showing how enum mangling could work
mjbvz May 24, 2023
c6db2c5
Remove a few more skipMangles
mjbvz May 24, 2023
10cd3df
Fix entrypoint name
mjbvz May 24, 2023
3d73dd5
Merge branch 'main' into dev/mjbvz/mangle-exports-2
mjbvz Jun 12, 2023
7475241
Add option to disable export mangling
mjbvz Jun 12, 2023
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
16 changes: 8 additions & 8 deletions build/lib/compilation.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as os from 'os';
import ts = require('typescript');
import * as File from 'vinyl';
import * as task from './task';
import { Mangler } from './mangleTypeScript';
import { Mangler } from './mangle/index';
import { RawSourceMap } from 'source-map';
const watch = require('./watch');

Expand Down Expand Up @@ -126,19 +126,20 @@ export function compileTask(src: string, out: string, build: boolean, options: {
if (build && !options.disableMangle) {
let ts2tsMangler = new Mangler(compile.projectPath, (...data) => fancyLog(ansiColors.blue('[mangler]'), ...data));
const newContentsByFileName = ts2tsMangler.computeNewFileContents(new Set(['saveState']));
mangleStream = es.through(function write(data: File & { sourceMap?: RawSourceMap }) {
mangleStream = es.through(async function write(data: File & { sourceMap?: RawSourceMap }) {
type TypeScriptExt = typeof ts & { normalizePath(path: string): string };
const tsNormalPath = (<TypeScriptExt>ts).normalizePath(data.path);
const newContents = newContentsByFileName.get(tsNormalPath);
const newContents = (await newContentsByFileName).get(tsNormalPath);
if (newContents !== undefined) {
data.contents = Buffer.from(newContents.out);
data.sourceMap = newContents.sourceMap && JSON.parse(newContents.sourceMap);
}
this.push(data);
}, function end() {
this.push(null);
}, async function end() {
// free resources
newContentsByFileName.clear();
(await newContentsByFileName).clear();

this.push(null);
(<any>ts2tsMangler) = undefined;
});
}
Expand Down
Loading