-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
# Backport This will backport the following commits from `main` to `8.10`: - [Remove webpack compression plugin on v4 (#170203)](#170203) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tiago Costa","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-11-02T17:11:48Z","message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:prev-minor","v8.12.0"],"number":170203,"url":"https://github.com/elastic/kibana/pull/170203","mergeCommit":{"message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170203","number":170203,"mergeCommit":{"message":"Remove webpack compression plugin on v4 (#170203)\n\nCloses https://github.com/elastic/kibana/issues/170202\r\n\r\nThis PR fixes a problem with brotli generated assets when creating an\r\nexternal plugin by replacing the brotli assets generated by webpack with\r\nthe ones created separately with gulp brotli.","sha":"ecdd1f090b5d29ca29fd8fcbbcf179d5812cadb8"}},{"url":"https://github.com/elastic/kibana/pull/170461","number":170461,"branch":"8.11","state":"OPEN"}]}] BACKPORT-->
- Loading branch information
Showing
8 changed files
with
61 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import Path from 'path'; | ||
import { pipeline } from 'stream'; | ||
import { promisify } from 'util'; | ||
|
||
import vfs from 'vinyl-fs'; | ||
import del from 'del'; | ||
import gulpBrotli from 'gulp-brotli'; | ||
import zlib from 'zlib'; | ||
import { REPO_ROOT } from '@kbn/repo-info'; | ||
|
||
import { TaskContext } from '../task_context'; | ||
|
||
const asyncPipeline = promisify(pipeline); | ||
|
||
export async function brotliCompressBundles({ buildDir, log }: TaskContext) { | ||
const compressDir = Path.resolve(buildDir, 'target/public'); | ||
|
||
log.info( | ||
`compressing js and css bundles found at ${Path.relative(REPO_ROOT, compressDir)} to brotli` | ||
); | ||
|
||
try { | ||
await del(['**/*.br'], { cwd: compressDir }); | ||
await asyncPipeline( | ||
vfs.src(['**/*.{js,css}'], { cwd: compressDir }), | ||
gulpBrotli({ | ||
params: { | ||
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY, | ||
}, | ||
}), | ||
vfs.dest(compressDir) | ||
); | ||
} catch (e) { | ||
log.error(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8553,13 +8553,6 @@ | |
dependencies: | ||
"@types/color-convert" "*" | ||
|
||
"@types/compression-webpack-plugin@^2.0.2": | ||
version "2.0.2" | ||
resolved "https://registry.yarnpkg.com/@types/compression-webpack-plugin/-/compression-webpack-plugin-2.0.2.tgz#9d8956a542ea974e018ab5dc2316480edbaf17fb" | ||
integrity sha512-4GW0o21FHqRwP/HYC8o7ceiO9duBopo1v5MaTVZy8VqF6nnRRDoG/C6djGxAmC7uyXRBK8AdnB2IVQgkoRokXQ== | ||
dependencies: | ||
"@types/webpack" "*" | ||
|
||
"@types/connect-history-api-fallback@^1.3.5": | ||
version "1.3.5" | ||
resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" | ||
|
@@ -8818,13 +8811,6 @@ | |
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/gulp-zip@^4.0.1": | ||
version "4.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/gulp-zip/-/gulp-zip-4.0.1.tgz#96cd0b994219f9ae3bbbec7ec3baa043fba9d9ef" | ||
integrity sha512-dYwGsHmwv4pnMD+jtyuIdZchJ0CIivnl8PIApHC+rYN7FMj01tJSAiQb+YN4T/pOn10pmmucBLEB9wXEhQX2Ug== | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/gulp@^4.0.6": | ||
version "4.0.6" | ||
resolved "https://registry.yarnpkg.com/@types/gulp/-/gulp-4.0.6.tgz#68fe0e1f0ff3657cfca46fb564806b744a1bf899" | ||
|
@@ -12153,7 +12139,7 @@ cacache@^12.0.2: | |
unique-filename "^1.1.1" | ||
y18n "^4.0.0" | ||
|
||
cacache@^15.0.3, cacache@^15.0.4, cacache@^15.0.5, cacache@^15.2.0: | ||
cacache@^15.0.4, cacache@^15.0.5, cacache@^15.2.0: | ||
version "15.3.0" | ||
resolved "https://registry.yarnpkg.com/cacache/-/cacache-15.3.0.tgz#dc85380fb2f556fe3dda4c719bfa0ec875a7f1eb" | ||
integrity sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ== | ||
|
@@ -13047,17 +13033,6 @@ compressible@~2.0.16: | |
dependencies: | ||
mime-db ">= 1.40.0 < 2" | ||
|
||
compression-webpack-plugin@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-4.0.0.tgz#7599f592050002a49cd3ad3ee18ae7371e266bca" | ||
integrity sha512-DRoFQNTkQ8gadlk117Y2wxANU+MDY56b1FIZj/yJXucBOTViTHXjthM7G9ocnitksk4kLzt1N2RLF0gDjxI+hg== | ||
dependencies: | ||
cacache "^15.0.3" | ||
find-cache-dir "^3.3.1" | ||
schema-utils "^2.6.6" | ||
serialize-javascript "^3.0.0" | ||
webpack-sources "^1.4.3" | ||
|
||
compression@^1.7.4: | ||
version "1.7.4" | ||
resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f" | ||
|
@@ -17690,17 +17665,6 @@ gulp-terser@^2.1.0: | |
through2 "^4.0.2" | ||
vinyl-sourcemaps-apply "^0.2.1" | ||
|
||
gulp-zip@^5.0.2: | ||
version "5.0.2" | ||
resolved "https://registry.yarnpkg.com/gulp-zip/-/gulp-zip-5.0.2.tgz#2edf797ec842e770f4dfde8bef97d139015b1972" | ||
integrity sha512-rZd0Ppuc8Bf7J2/WzcdNaeb+lcEXf1R8mV/PJ9Kdu7PmnInWVeLSmiXIka/2QSe6uhAsGVFAMffWSaMzAPGTBg== | ||
dependencies: | ||
get-stream "^5.1.0" | ||
plugin-error "^1.0.1" | ||
through2 "^3.0.1" | ||
vinyl "^2.1.0" | ||
yazl "^2.5.1" | ||
|
||
gzip-size@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462" | ||
|
@@ -26593,7 +26557,7 @@ scheduler@^0.20.2: | |
loose-envify "^1.1.0" | ||
object-assign "^4.1.1" | ||
|
||
[email protected], schema-utils@^2.0.0, schema-utils@^2.0.1, schema-utils@^2.5.0, schema-utils@^2.6.5, schema-utils@^2.6.6, schema-utils@^2.7.0: | ||
[email protected], schema-utils@^2.0.0, schema-utils@^2.0.1, schema-utils@^2.5.0, schema-utils@^2.6.5, schema-utils@^2.7.0: | ||
version "2.7.0" | ||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7" | ||
integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A== | ||
|
@@ -26750,7 +26714,7 @@ [email protected], serialize-javascript@^6.0.0: | |
dependencies: | ||
randombytes "^2.1.0" | ||
|
||
serialize-javascript@^3.0.0, serialize-javascript@^3.1.0: | ||
serialize-javascript@^3.1.0: | ||
version "3.1.0" | ||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea" | ||
integrity sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg== | ||
|
@@ -30111,7 +30075,7 @@ vinyl-sourcemaps-apply@^0.2.1: | |
dependencies: | ||
source-map "^0.5.1" | ||
|
||
vinyl@^2.1.0, vinyl@^2.2.0: | ||
vinyl@^2.2.0: | ||
version "2.2.0" | ||
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86" | ||
integrity sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg== | ||
|