From 01f50612f9b30053ea064c6490d15a835aa2d61c Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:49:41 +0000 Subject: [PATCH] feat: remove comments from FESM files This reduces the NPM package size of `@angular/core` by around 2mbs --- package.json | 6 +- pnpm-lock.yaml | 206 +++++++++++++--------- src/ng_package/angular_package_format.bzl | 1 + src/ng_package/rollup/rollup.config.js | 36 +++- 4 files changed, 160 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index 0eaf1e3..03d89c3 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "@angular/compiler-cli": "20.2.0-next.2", "@angular/core": "20.2.0-next.2", "@angular/platform-browser": "20.2.0-next.2", + "@babel/core": "^7.28.5", "@bazel/bazelisk": "1.26.0", "@bazel/buildifier": "^7.3.1", "@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-node-resolve": "^15.3.0", - "@rollup/plugin-terser": "^0.4.4", "@types/node": "^22.10.1", "json-stable-stringify": "^1.2.1", "lru-cache": "^11.1.0", @@ -32,13 +32,11 @@ "prettier": "^3.4.1", "rollup": "^4.27.4", "rollup-plugin-dts": "6.1.1", + "rollup-plugin-sourcemaps2": "^0.5.0", "rxjs": "^7.8.2", "tinyglobby": "0.2.12", "tslib": "^2.8.1", "typescript-local": "npm:typescript@5.9.2", "zone.js": "^0.15.0" - }, - "dependencies": { - "rollup-plugin-sourcemaps2": "^0.5.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3dbf80..e1a28bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,14 +9,10 @@ pnpmfileChecksum: sha256-XtUaqxMdcZeX6V2GgPPg1gDpiDUY/qXsjmAn+Gha8jY= importers: .: - dependencies: - rollup-plugin-sourcemaps2: - specifier: ^0.5.0 - version: 0.5.0(@types/node@22.10.1)(rollup@4.27.4) devDependencies: '@angular/build': specifier: 20.2.0-next.2 - version: 20.2.0-next.2(@angular/compiler-cli@20.2.0-next.2(@angular/compiler@20.2.0-next.2))(@angular/compiler@20.2.0-next.2)(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(@angular/platform-browser@20.2.0-next.2(@angular/common@20.2.0-next.2(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(rxjs@7.8.2))(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0)))(@types/node@22.10.1)(chokidar@4.0.1)(postcss@8.5.6)(terser@5.36.0)(tslib@2.8.1)(typescript@5.9.2) + version: 20.2.0-next.2(@angular/compiler-cli@20.2.0-next.2(@angular/compiler@20.2.0-next.2))(@angular/compiler@20.2.0-next.2)(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(@angular/platform-browser@20.2.0-next.2(@angular/common@20.2.0-next.2(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(rxjs@7.8.2))(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0)))(@types/node@22.10.1)(chokidar@4.0.1)(postcss@8.5.6)(tslib@2.8.1)(typescript@5.9.2) '@angular/cli': specifier: 20.2.0-next.2 version: 20.2.0-next.2(@types/node@22.10.1)(chokidar@4.0.1) @@ -35,6 +31,9 @@ importers: '@angular/platform-browser': specifier: 20.2.0-next.2 version: 20.2.0-next.2(@angular/common@20.2.0-next.2(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(rxjs@7.8.2))(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0)) + '@babel/core': + specifier: ^7.28.5 + version: 7.28.5 '@bazel/bazelisk': specifier: 1.26.0 version: 1.26.0 @@ -47,9 +46,6 @@ importers: '@rollup/plugin-node-resolve': specifier: ^15.3.0 version: 15.3.0(rollup@4.27.4) - '@rollup/plugin-terser': - specifier: ^0.4.4 - version: 0.4.4(rollup@4.27.4) '@types/node': specifier: ^22.10.1 version: 22.10.1 @@ -74,6 +70,9 @@ importers: rollup-plugin-dts: specifier: 6.1.1 version: 6.1.1(rollup@4.27.4)(typescript@5.9.2) + rollup-plugin-sourcemaps2: + specifier: ^0.5.0 + version: 0.5.0(@types/node@22.10.1)(rollup@4.27.4) rxjs: specifier: ^7.8.2 version: 7.8.2 @@ -274,10 +273,18 @@ packages: resolution: {integrity: sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==} engines: {node: '>=6.9.0'} + '@babel/core@7.28.5': + resolution: {integrity: sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==} + engines: {node: '>=6.9.0'} + '@babel/generator@7.28.0': resolution: {integrity: sha512-lJjzvrbEeWrhB4P3QBsH7tey117PjLZnDbLiQEKjQ/fNJTjuq4HSqgFA+UNSwZT8D7dxxbnuSBMsa1lrWzKlQg==} engines: {node: '>=6.9.0'} + '@babel/generator@7.28.5': + resolution: {integrity: sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.27.3': resolution: {integrity: sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==} engines: {node: '>=6.9.0'} @@ -300,6 +307,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-module-transforms@7.28.3': + resolution: {integrity: sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-split-export-declaration@7.24.7': resolution: {integrity: sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==} engines: {node: '>=6.9.0'} @@ -316,6 +329,10 @@ packages: resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.28.5': + resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} + engines: {node: '>=6.9.0'} + '@babel/helper-validator-option@7.27.1': resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==} engines: {node: '>=6.9.0'} @@ -324,6 +341,10 @@ packages: resolution: {integrity: sha512-/V9771t+EgXz62aCcyofnQhGM8DQACbRhvzKFsXKC9QM+5MadF8ZmIm0crDMaz3+o0h0zXfJnd4EhbYbxsrcFw==} engines: {node: '>=6.9.0'} + '@babel/helpers@7.28.4': + resolution: {integrity: sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w==} + engines: {node: '>=6.9.0'} + '@babel/parser@7.27.1': resolution: {integrity: sha512-I0dZ3ZpCrJ1c04OqlNsQcKiZlsrXf/kkE4FXzID9rIOYICsAbA8mMDzhW/luRNAHdCNt7os/u8wenklZDlUVUQ==} engines: {node: '>=6.0.0'} @@ -334,6 +355,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + '@babel/parser@7.28.5': + resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/template@7.27.2': resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==} engines: {node: '>=6.9.0'} @@ -342,6 +368,10 @@ packages: resolution: {integrity: sha512-mGe7UK5wWyh0bKRfupsUchrQGqvDbZDbKJw+kcRGSmdHVYrv+ltd0pnpDTVpiTqnaBru9iEvA8pz8W46v0Amwg==} engines: {node: '>=6.9.0'} + '@babel/traverse@7.28.5': + resolution: {integrity: sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ==} + engines: {node: '>=6.9.0'} + '@babel/types@7.27.1': resolution: {integrity: sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==} engines: {node: '>=6.9.0'} @@ -350,6 +380,10 @@ packages: resolution: {integrity: sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==} engines: {node: '>=6.9.0'} + '@babel/types@7.28.5': + resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==} + engines: {node: '>=6.9.0'} + '@bazel/bazelisk@1.26.0': resolution: {integrity: sha512-bTNcHdGyEQ9r7SczEYUa0gkEQhJo1ld2BjXI8fWBvsUeoHi03QpUs2HZgDbjjrpQFQqG2ZbO7ihZvH8MjhUTHw==} hasBin: true @@ -671,6 +705,9 @@ packages: resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} engines: {node: '>=6.0.0'} + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -679,9 +716,6 @@ packages: resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} engines: {node: '>=6.0.0'} - '@jridgewell/source-map@0.3.6': - resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==} - '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} @@ -1109,15 +1143,6 @@ packages: rollup: optional: true - '@rollup/plugin-terser@0.4.4': - resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - '@rollup/pluginutils@5.1.3': resolution: {integrity: sha512-Pnsb6f32CD2W3uCaLZIzDmeFyQ2b8UWMFI7xtwUezpcGBDVDW6y9XgAWIlARiGAo6eNF5FK5aQTr0LFyNyqq5A==} engines: {node: '>=14.0.0'} @@ -1394,11 +1419,6 @@ packages: resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==} engines: {node: '>= 0.6'} - acorn@8.14.0: - resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} - engines: {node: '>=0.4.0'} - hasBin: true - agent-base@7.1.3: resolution: {integrity: sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==} engines: {node: '>= 14'} @@ -1545,9 +1565,6 @@ packages: colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} - commander@2.20.3: - resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} @@ -2388,9 +2405,6 @@ packages: resolution: {integrity: sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==} engines: {node: '>=0.6'} - randombytes@2.1.0: - resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} - range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} engines: {node: '>= 0.6'} @@ -2492,9 +2506,6 @@ packages: resolution: {integrity: sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==} engines: {node: '>= 18'} - serialize-javascript@6.0.2: - resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} - serve-static@2.2.0: resolution: {integrity: sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==} engines: {node: '>= 18'} @@ -2550,9 +2561,6 @@ packages: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} - smob@1.5.0: - resolution: {integrity: sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==} - socks-proxy-agent@8.0.5: resolution: {integrity: sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==} engines: {node: '>= 14'} @@ -2639,11 +2647,6 @@ packages: resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} engines: {node: '>=18'} - terser@5.36.0: - resolution: {integrity: sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w==} - engines: {node: '>=10'} - hasBin: true - thingies@1.21.0: resolution: {integrity: sha512-hsqsJsFMsV+aD4s3CWKk85ep/3I9XzYV/IXaSouJMYIoDlgyi11cBhsqYe9/geRfB0YIikBQg6raRaM+nIMP9g==} engines: {node: '>=10.18'} @@ -2956,7 +2959,7 @@ snapshots: transitivePeerDependencies: - chokidar - '@angular/build@20.2.0-next.2(@angular/compiler-cli@20.2.0-next.2(@angular/compiler@20.2.0-next.2))(@angular/compiler@20.2.0-next.2)(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(@angular/platform-browser@20.2.0-next.2(@angular/common@20.2.0-next.2(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(rxjs@7.8.2))(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0)))(@types/node@22.10.1)(chokidar@4.0.1)(postcss@8.5.6)(terser@5.36.0)(tslib@2.8.1)(typescript@5.9.2)': + '@angular/build@20.2.0-next.2(@angular/compiler-cli@20.2.0-next.2(@angular/compiler@20.2.0-next.2))(@angular/compiler@20.2.0-next.2)(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(@angular/platform-browser@20.2.0-next.2(@angular/common@20.2.0-next.2(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0))(rxjs@7.8.2))(@angular/core@20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0)))(@types/node@22.10.1)(chokidar@4.0.1)(postcss@8.5.6)(tslib@2.8.1)(typescript@5.9.2)': dependencies: '@ampproject/remapping': 2.3.0 '@angular-devkit/architect': 0.2002.0-next.2(chokidar@4.0.1) @@ -2966,7 +2969,7 @@ snapshots: '@babel/helper-annotate-as-pure': 7.27.3 '@babel/helper-split-export-declaration': 7.24.7 '@inquirer/confirm': 5.1.14(@types/node@22.10.1) - '@vitejs/plugin-basic-ssl': 2.1.0(vite@7.0.6(@types/node@22.10.1)(sass@1.89.2)(terser@5.36.0)) + '@vitejs/plugin-basic-ssl': 2.1.0(vite@7.0.6(@types/node@22.10.1)(sass@1.89.2)) beasties: 0.3.5 browserslist: 4.24.5 esbuild: 0.25.8 @@ -2986,7 +2989,7 @@ snapshots: tinyglobby: 0.2.14 tslib: 2.8.1 typescript: 5.9.2 - vite: 7.0.6(@types/node@22.10.1)(sass@1.89.2)(terser@5.36.0) + vite: 7.0.6(@types/node@22.10.1)(sass@1.89.2) watchpack: 2.4.4 optionalDependencies: '@angular/core': 20.2.0-next.2(@angular/compiler@20.2.0-next.2)(rxjs@7.8.2)(zone.js@0.15.0) @@ -3104,6 +3107,26 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/core@7.28.5': + dependencies: + '@babel/code-frame': 7.27.1 + '@babel/generator': 7.28.5 + '@babel/helper-compilation-targets': 7.27.2 + '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.5) + '@babel/helpers': 7.28.4 + '@babel/parser': 7.28.5 + '@babel/template': 7.27.2 + '@babel/traverse': 7.28.5 + '@babel/types': 7.28.5 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.1 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + '@babel/generator@7.28.0': dependencies: '@babel/parser': 7.28.0 @@ -3112,6 +3135,14 @@ snapshots: '@jridgewell/trace-mapping': 0.3.29 jsesc: 3.0.2 + '@babel/generator@7.28.5': + dependencies: + '@babel/parser': 7.28.5 + '@babel/types': 7.28.5 + '@jridgewell/gen-mapping': 0.3.12 + '@jridgewell/trace-mapping': 0.3.29 + jsesc: 3.0.2 + '@babel/helper-annotate-as-pure@7.27.3': dependencies: '@babel/types': 7.28.2 @@ -3142,6 +3173,15 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-module-transforms@7.28.3(@babel/core@7.28.5)': + dependencies: + '@babel/core': 7.28.5 + '@babel/helper-module-imports': 7.27.1 + '@babel/helper-validator-identifier': 7.27.1 + '@babel/traverse': 7.28.5 + transitivePeerDependencies: + - supports-color + '@babel/helper-split-export-declaration@7.24.7': dependencies: '@babel/types': 7.27.1 @@ -3153,6 +3193,8 @@ snapshots: '@babel/helper-validator-identifier@7.27.1': {} + '@babel/helper-validator-identifier@7.28.5': {} + '@babel/helper-validator-option@7.27.1': {} '@babel/helpers@7.28.2': @@ -3160,6 +3202,11 @@ snapshots: '@babel/template': 7.27.2 '@babel/types': 7.28.2 + '@babel/helpers@7.28.4': + dependencies: + '@babel/template': 7.27.2 + '@babel/types': 7.28.5 + '@babel/parser@7.27.1': dependencies: '@babel/types': 7.27.1 @@ -3168,6 +3215,10 @@ snapshots: dependencies: '@babel/types': 7.28.2 + '@babel/parser@7.28.5': + dependencies: + '@babel/types': 7.28.5 + '@babel/template@7.27.2': dependencies: '@babel/code-frame': 7.27.1 @@ -3186,6 +3237,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/traverse@7.28.5': + dependencies: + '@babel/code-frame': 7.27.1 + '@babel/generator': 7.28.5 + '@babel/helper-globals': 7.28.0 + '@babel/parser': 7.28.5 + '@babel/template': 7.27.2 + '@babel/types': 7.28.5 + debug: 4.4.1 + transitivePeerDependencies: + - supports-color + '@babel/types@7.27.1': dependencies: '@babel/helper-string-parser': 7.27.1 @@ -3196,6 +3259,11 @@ snapshots: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 + '@babel/types@7.28.5': + dependencies: + '@babel/helper-string-parser': 7.27.1 + '@babel/helper-validator-identifier': 7.28.5 + '@bazel/bazelisk@1.26.0': {} '@bazel/buildifier@7.3.1': {} @@ -3442,15 +3510,15 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.12 + '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/set-array@1.2.1': {} - '@jridgewell/source-map@0.3.6': - dependencies: - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - '@jridgewell/sourcemap-codec@1.5.0': {} '@jridgewell/trace-mapping@0.3.25': @@ -3813,14 +3881,6 @@ snapshots: optionalDependencies: rollup: 4.27.4 - '@rollup/plugin-terser@0.4.4(rollup@4.27.4)': - dependencies: - serialize-javascript: 6.0.2 - smob: 1.5.0 - terser: 5.36.0 - optionalDependencies: - rollup: 4.27.4 - '@rollup/pluginutils@5.1.3(rollup@4.27.4)': dependencies: '@types/estree': 1.0.6 @@ -4013,9 +4073,9 @@ snapshots: '@types/resolve@1.20.2': {} - '@vitejs/plugin-basic-ssl@2.1.0(vite@7.0.6(@types/node@22.10.1)(sass@1.89.2)(terser@5.36.0))': + '@vitejs/plugin-basic-ssl@2.1.0(vite@7.0.6(@types/node@22.10.1)(sass@1.89.2))': dependencies: - vite: 7.0.6(@types/node@22.10.1)(sass@1.89.2)(terser@5.36.0) + vite: 7.0.6(@types/node@22.10.1)(sass@1.89.2) '@yarnpkg/lockfile@1.1.0': {} @@ -4026,8 +4086,6 @@ snapshots: mime-types: 3.0.1 negotiator: 1.0.0 - acorn@8.14.0: {} - agent-base@7.1.3: {} ajv-formats@3.0.1: @@ -4206,8 +4264,6 @@ snapshots: colorette@2.0.20: {} - commander@2.20.3: {} - commondir@1.0.1: {} content-disposition@1.0.0: @@ -4647,7 +4703,7 @@ snapshots: istanbul-lib-instrument@6.0.3: dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.5 '@babel/parser': 7.27.1 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 @@ -5084,10 +5140,6 @@ snapshots: dependencies: side-channel: 1.1.0 - randombytes@2.1.0: - dependencies: - safe-buffer: 5.2.1 - range-parser@1.2.1: {} raw-body@3.0.0: @@ -5257,10 +5309,6 @@ snapshots: transitivePeerDependencies: - supports-color - serialize-javascript@6.0.2: - dependencies: - randombytes: 2.1.0 - serve-static@2.2.0: dependencies: encodeurl: 2.0.0 @@ -5340,8 +5388,6 @@ snapshots: smart-buffer@4.2.0: {} - smob@1.5.0: {} - socks-proxy-agent@8.0.5: dependencies: agent-base: 7.1.3 @@ -5438,13 +5484,6 @@ snapshots: mkdirp: 3.0.1 yallist: 5.0.0 - terser@5.36.0: - dependencies: - '@jridgewell/source-map': 0.3.6 - acorn: 8.14.0 - commander: 2.20.3 - source-map-support: 0.5.21 - thingies@1.21.0(tslib@2.8.1): dependencies: tslib: 2.8.1 @@ -5525,7 +5564,7 @@ snapshots: vary@1.1.2: {} - vite@7.0.6(@types/node@22.10.1)(sass@1.89.2)(terser@5.36.0): + vite@7.0.6(@types/node@22.10.1)(sass@1.89.2): dependencies: esbuild: 0.25.8 fdir: 6.4.6(picomatch@4.0.3) @@ -5537,7 +5576,6 @@ snapshots: '@types/node': 22.10.1 fsevents: 2.3.3 sass: 1.89.2 - terser: 5.36.0 watchpack@2.4.4: dependencies: diff --git a/src/ng_package/angular_package_format.bzl b/src/ng_package/angular_package_format.bzl index a5a321f..ee5bfcc 100644 --- a/src/ng_package/angular_package_format.bzl +++ b/src/ng_package/angular_package_format.bzl @@ -431,6 +431,7 @@ angular_package_format = rule( # TODO: Remove rollup_runtime_deps once we can pass in the rollup deps from the external. "rollup_runtime_deps": attr.label_list( default = [ + Label("//:node_modules/@babel/core"), Label("//:node_modules/@rollup/plugin-commonjs"), Label("//:node_modules/@rollup/plugin-node-resolve"), Label("//:node_modules/magic-string"), diff --git a/src/ng_package/rollup/rollup.config.js b/src/ng_package/rollup/rollup.config.js index b6810e5..293aac6 100644 --- a/src/ng_package/rollup/rollup.config.js +++ b/src/ng_package/rollup/rollup.config.js @@ -11,12 +11,45 @@ const {nodeResolve} = require('@rollup/plugin-node-resolve'); const commonjs = require('@rollup/plugin-commonjs'); +const {transformSync} = require('@babel/core'); const MagicString = require('magic-string'); const sourcemaps = require('rollup-plugin-sourcemaps2'); const {dts} = require('rollup-plugin-dts'); const path = require('path'); const fs = require('fs'); +function removeCommentsPlugin() { + return { + name: 'comment-filter', + transform(code, id) { + // Only process JavaScript files (and optionally exclude node_modules) + if (!/\.m?js$/.test(id) || id.includes('node_modules')) { + return null; + } + + const result = transformSync(code, { + filename: id, + comments: true, + sourceMaps: true, + generatorOpts: { + shouldPrintComment: comment => { + if (!comment) { + return false; + } + + return comment.includes('__PURE__') || /@license|@preserve|^!/i.test(comment); + }, + }, + }); + + return { + code: result.code, + map: result.map, + }; + }, + }; +} + function log_verbose(...m) { // This is a template file so we use __filename to output the actual filename if (!!process.env['VERBOSE_LOGS']) console.error(`[${path.basename(__filename)}]`, ...m); @@ -143,7 +176,7 @@ if (bannerFile) { const stripBannerPlugin = { name: 'strip-license-banner', transform(code, _filePath) { - const banner = /(\/\**\s+\*\s@license.*?\*\/)/s.exec(code); + const banner = /(\/\*[\!\*]\s+\*\s@license.*?\*\/)/s.exec(code); if (!banner) { return; } @@ -191,6 +224,7 @@ if (dtsMode) { customResolveOptions: {moduleDirectory: nodeModulesRoot}, }), commonjs({ignoreGlobal: true}), + removeCommentsPlugin(), sourcemaps(), ); }