Skip to content

Commit

Permalink
perf: remove comments from js-files (#3760)
Browse files Browse the repository at this point in the history
Strip comments from all .js files (except legacy-reexports and compat) while retaining them for .d.ts files. The legacy-reexport does not have any comments and will be removed with compat in next major version.

```
npx get-folder-size --folder=dist/package
// 5.88 Mb (with comments)
// 4.63 Mb (without comments)
```

Roughly 1.25 Mb is saved by removing comments.
  • Loading branch information
csvn authored and benlesh committed Jun 4, 2018
1 parent a95441b commit bb2c334
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
"scripts": {
"precommit": "lint-staged",
"commitmsg": "validate-commit-msg",
"build_all": "npm-run-all compat_build_all clean_dist copy_sources build_cjs build_esm5 build_esm2015 build_esm5_for_rollup build_umd build_legacy_reexport build_migrations generate_packages copy_for_tests",
"build_all": "npm-run-all compat_build_all clean_dist copy_sources build_cjs build_esm5 build_esm2015 build_esm5_for_rollup build_umd build_types build_legacy_reexport build_migrations generate_packages copy_for_tests",
"build_cjs": "npm-run-all clean_dist_cjs compile_dist_cjs",
"build_esm5": "npm-run-all clean_dist_esm5 compile_dist_esm5",
"build_esm5_for_rollup": "npm-run-all clean_dist_esm5_for_rollup compile_dist_esm5_for_rollup && mkdirp dist/esm5_for_rollup/node_modules && shx cp -r ./dist-compat/package ./dist/esm5_for_rollup/node_modules/rxjs-compat",
"build_esm2015": "npm-run-all clean_dist_esm2015 compile_dist_esm2015",
"build_esm2015_for_docs": "npm-run-all clean_dist_esm2015 compile_dist_esm2015_for_docs",
"build_legacy_reexport": "npm-run-all compile_legacy_reexport",
"build_migrations": "npm-run-all clean_dist_migrations compile_dist_migrations",
"build_types": "npm-run-all clean_dist_types compile_dist_types",
"build_closure_core": "node ./tools/make-closure-core.js",
"build_global": "npm-run-all clean_dist_global build_esm5_for_rollup && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core clean_dist_esm5_for_rollup",
"build_umd": "npm-run-all clean_dist_global && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core",
Expand All @@ -64,13 +65,15 @@
"clean_dist_esm2015": "shx rm -rf ./dist/esm2015",
"clean_dist_global": "shx rm -rf ./dist/global",
"clean_dist_migrations": "shx rm -rf ./dist/migrations",
"clean_dist_types": "shx rm -rf ./dist/typings",
"commit": "git-cz",
"compile_dist_cjs": "tsc -p ./tsconfig/tsconfig.cjs.json",
"compile_dist_esm5": "tsc -p ./tsconfig/tsconfig.esm5.json",
"compile_dist_esm2015": "tsc -p ./tsconfig/tsconfig.esm2015.json",
"compile_dist_esm2015_for_docs": "tsc ./dist/src/internal/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm5_for_rollup": "tsc -p ./tsconfig/tsconfig.esm5.rollup.json",
"compile_dist_migrations": "tsc -p ./tsconfig/tsconfig.migrations.json",
"compile_dist_types": "tsc -p ./tsconfig/tsconfig.types.json",
"compile_legacy_reexport": "tsc -p ./tsconfig/tsconfig.legacy-reexport.json",
"copy_sources": "mkdirp dist && shx cp -r ./src/ ./dist/src",
"copy_for_tests": "shx rm -rf ./spec-build && shx cp -r ./spec/ ./spec-build/ && mkdirp ./spec-build/node_modules && shx cp -r ./dist/package/ ./spec-build/node_modules/rxjs && shx cp -r ./dist-compat/package/ ./spec-build/node_modules/rxjs-compat",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"removeComments": false,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"strictFunctionTypes": true,
Expand Down
1 change: 1 addition & 0 deletions tsconfig/compat/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"removeComments": false,
"declaration": true,
"declarationDir": "../../dist-compat/typings",
"outDir": "../../dist-compat/cjs"
Expand Down
2 changes: 0 additions & 2 deletions tsconfig/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"declaration": true,
"declarationDir": "../dist/typings",
"outDir": "../dist/cjs"
}
}
1 change: 1 addition & 0 deletions tsconfig/tsconfig.legacy-reexport.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"removeComments": false,
"declaration": true,
"noEmit": false,
"outDir": "../dist/legacy-reexport",
Expand Down
11 changes: 11 additions & 0 deletions tsconfig/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "es2015",
"target": "esnext",
"removeComments": false,
"declaration": true,
"declarationDir": "../dist/typings",
"emitDeclarationOnly": true
}
}

0 comments on commit bb2c334

Please sign in to comment.