Skip to content

Commit

Permalink
feat: compress compat patches and the pnp hook (yarnpkg#1400)
Browse files Browse the repository at this point in the history
* feat(compat): compress patches using brotli

* feat(pnp): compress the hook source using brotli

* chore: versions

* Tries to add patch validations to the workflow

* Verifies the patches when they change

* Fixes path

* Adds author config

* Validates the hook too

* Fixes the hook

* fix: normalize line endings

Co-authored-by: Maël Nison <nison.mael@gmail.com>
  • Loading branch information
merceyz and arcanis committed May 25, 2020
1 parent 4965fa0 commit 2035b20
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 75 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/integration-workflow.yml
Expand Up @@ -38,6 +38,32 @@ jobs:
env:
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}

- name: 'Check that the patch files are consistent with fresh builds'
run: |
if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- packages/plugin-compat/sources/patches | wc -l) -gt 0 ]]; then
for generator in packages/plugin-compat/extra/*/gen-*-patch.sh; do
bash $generator;
done
[[ $(git diff --name-only packages/plugin-compat/sources/patches | wc -l) -eq 0 ]]
fi
shell: bash
if: |
github.event.pull_request != ''
env:
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}

- name: 'Check that the PnP hook is consistent with a fresh build'
run: |
if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- packages/yarnpkg-pnp/sources/hook.js | wc -l) -gt 0 ]]; then
node ./scripts/run-yarn.js build:pnp:hook
[[ $(git diff --name-only packages/yarnpkg-pnp/sources/hook.js | wc -l) -eq 0 ]]
fi
shell: bash
if: |
github.event.pull_request != ''
env:
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}

- name: 'Check that the PR describes which packages should be bumped (fix w/ "yarn version check -i")'
run: |
node ./scripts/run-yarn.js version check
Expand Down
24 changes: 24 additions & 0 deletions .yarn/versions/c7c5c8f8.yml
@@ -0,0 +1,24 @@
releases:
"@yarnpkg/cli": prerelease
"@yarnpkg/plugin-compat": prerelease
"@yarnpkg/pnp": prerelease

declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/pnpify"
11 changes: 11 additions & 0 deletions packages/plugin-compat/extra/createPatch.js
@@ -0,0 +1,11 @@
const {readFileSync,writeFileSync} = require(`fs`);
const {brotliCompressSync} = require(`zlib`);

const patchContent = readFileSync(process.argv[2]);
const jsFile = process.argv[3];

writeFileSync(jsFile, `/* eslint-disable */
export const patch = require('zlib').brotliDecompressSync(Buffer.from('${
brotliCompressSync(patchContent).toString(`base64`)
}', 'base64')).toString();
`);
21 changes: 5 additions & 16 deletions packages/plugin-compat/extra/fsevents/gen-fsevents-patch.sh
Expand Up @@ -3,20 +3,9 @@ set -ex
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
TEMP_DIR="$(mktemp -d)"

echo $TEMP_DIR
cat "$THIS_DIR"/1.2.11.patch \
"$THIS_DIR"/2.1.2.patch \
"$THIS_DIR"/common.patch \
> "$TEMP_DIR"/patch.tmp

PATCHFILE="$THIS_DIR"/../../sources/patches/fsevents.patch.ts
rm -f "$PATCHFILE" && touch "$PATCHFILE"

echo '/* eslint-disable */' \
>> "$JSPATCH"
echo 'export const patch =' \
>> "$PATCHFILE"
(cat "$THIS_DIR"/1.2.11.patch \
"$THIS_DIR"/2.1.2.patch \
"$THIS_DIR"/common.patch) \
> "$TEMP_DIR"/patch.tmp || true
node "$THIS_DIR"/../jsonEscape.js < "$TEMP_DIR"/patch.tmp \
>> "$PATCHFILE"
echo ';' \
>> "$PATCHFILE"
node "$THIS_DIR/../createPatch.js" "$TEMP_DIR"/patch.tmp "$THIS_DIR"/../../sources/patches/fsevents.patch.ts
4 changes: 0 additions & 4 deletions packages/plugin-compat/extra/jsonEscape.js

This file was deleted.

17 changes: 4 additions & 13 deletions packages/plugin-compat/extra/resolve/gen-resolve-patch.sh
Expand Up @@ -16,19 +16,10 @@ tar xvfz resolve-1.14.1.tgz 2> /dev/null

cp "$THIS_DIR"/normalize-options.js "$TEMP_DIR"/patched/package/lib/normalize-options.js

PATCHFILE="$THIS_DIR"/../../sources/patches/resolve.patch.ts
rm -f "$PATCHFILE" && touch "$PATCHFILE"

echo '/* eslint-disable */' \
>> "$JSPATCH"
echo 'export const patch =' \
>> "$PATCHFILE"
(git diff --no-index "$TEMP_DIR"/orig/package "$TEMP_DIR"/patched/package) \
git diff --no-index "$TEMP_DIR"/orig/package "$TEMP_DIR"/patched/package \
| perl -p -e"s#^--- #semver exclusivity >=1.9\n--- #" \
| perl -p -e"s#$TEMP_DIR/orig/package##" \
| perl -p -e"s#$TEMP_DIR/patched/package##" \
> "$TEMP_DIR"/patch.tmp || true
node "$THIS_DIR"/../jsonEscape.js < "$TEMP_DIR"/patch.tmp \
>> "$PATCHFILE"
echo ';' \
>> "$PATCHFILE"
> "$TEMP_DIR"/patch.tmp

node "$THIS_DIR/../createPatch.js" "$TEMP_DIR"/patch.tmp "$THIS_DIR"/../../sources/patches/resolve.patch.ts
76 changes: 48 additions & 28 deletions packages/plugin-compat/extra/typescript/gen-typescript-patch.sh
Expand Up @@ -18,15 +18,19 @@ HASHES=(

mkdir -p "$TEMP_DIR"
if ! [[ -d "$TEMP_DIR"/clone ]]; then (
git clone git@github.com:arcanis/typescript "$TEMP_DIR"/clone
git clone https://github.com/arcanis/typescript "$TEMP_DIR"/clone
cd "$TEMP_DIR"/clone
git remote add upstream git@github.com:microsoft/typescript
git remote add upstream https://github.com/microsoft/typescript
); fi

rm -rf "$TEMP_DIR"/builds
cd "$TEMP_DIR"/clone

git cherry-pick --abort || true

git config user.email "you@example.com"
git config user.name "Your Name"

git fetch origin
git fetch upstream

Expand All @@ -37,6 +41,40 @@ reset-git() {
npm install --before "$(git show -s --format=%ci)"
}

build-dir-for() {
local HASH="$1"
local CHERRY_PICK="$2"

local BUILD_DIR="$TEMP_DIR"/builds/"$HASH"

if [[ ! -z "$CHERRY_PICK" ]]; then
BUILD_DIR="$BUILD_DIR-$CHERRY_PICK"
fi

echo "$BUILD_DIR"
}

make-build-for() {
local HASH="$1"
local CHERRY_PICK="$2"

local BUILD_DIR="$(build-dir-for "$HASH" "$CHERRY_PICK")"

if [[ ! -e "$BUILD_DIR" ]]; then
mkdir -p "$BUILD_DIR"
reset-git "$HASH"

if [[ ! -z "$CHERRY_PICK" ]]; then
git cherry-pick "$FIRST_PR_COMMIT"^.."$CHERRY_PICK"
fi

yarn gulp local LKG
cp -r lib/ "$BUILD_DIR"/
fi

echo "$BUILD_DIR"
}

rm -f "$PATCHFILE" && touch "$PATCHFILE"
rm -f "$JSPATCH" && touch "$JSPATCH"

Expand All @@ -46,41 +84,23 @@ while [[ ${#HASHES[@]} -gt 0 ]]; do
RANGE="${HASHES[2]}"
HASHES=("${HASHES[@]:3}")

rm -rf "$TEMP_DIR"/orig
rm -rf "$TEMP_DIR"/patched

mkdir -p "$TEMP_DIR"/orig
mkdir -p "$TEMP_DIR"/patched

reset-git "$BASE"

yarn gulp local LKG
cp -r lib/ "$TEMP_DIR"/orig/

reset-git "$BASE"
git cherry-pick "$FIRST_PR_COMMIT"^.."$HASH"
make-build-for "$BASE"
ORIG_DIR=$(build-dir-for "$BASE")

yarn gulp local LKG
cp -r lib/ "$TEMP_DIR"/patched/
make-build-for "$BASE" "$HASH"
PATCHED_DIR=$(build-dir-for "$BASE" "$HASH")

DIFF="$THIS_DIR"/patch."${HASH}"-on-"${BASE}".diff

git diff --no-index "$TEMP_DIR"/orig "$TEMP_DIR"/patched \
git diff --no-index "$ORIG_DIR" "$PATCHED_DIR" \
| perl -p -e"s#^--- #semver exclusivity $RANGE\n--- #" \
| perl -p -e"s#$TEMP_DIR/orig##" \
| perl -p -e"s#$TEMP_DIR/patched##" \
| perl -p -e"s#$ORIG_DIR/#/#" \
| perl -p -e"s#$PATCHED_DIR/#/#" \
| perl -p -e"s#__spreadArrays#[].concat#" \
> "$DIFF"

cat "$DIFF" \
>> "$PATCHFILE"
done

echo '/* eslint-disable */' \
>> "$JSPATCH"
echo 'export const patch =' \
>> "$JSPATCH"
node "$THIS_DIR"/../jsonEscape.js < "$PATCHFILE" \
>> "$JSPATCH"
echo ';' \
>> "$JSPATCH"
node "$THIS_DIR/../createPatch.js" "$PATCHFILE" "$JSPATCH"
5 changes: 2 additions & 3 deletions packages/plugin-compat/sources/patches/fsevents.patch.ts
@@ -1,3 +1,2 @@
export const patch =
`diff --git a/fsevents.js b/fsevents.js\nsemver exclusivity ^1\n--- a/fsevents.js\n+++ b/fsevents.js\n@@ -36,11 +36,15 @@ module.exports.Constants = Native.Constants;\n var defer = global.setImmediate || process.nextTick;\n\n function watch(path) {\n- var fse = new FSEvents(String(path || ''), handler);\n+ var VFS = require('./vfs');\n+ var vfs = new VFS(String(path || ''));\n+\n+ var fse = new FSEvents(vfs.resolvedPath, handler);\n EventEmitter.call(fse);\n return fse;\n\n function handler(path, flags, id) {\n+ path = vfs.transpose(path);\n defer(function() {\n fse.emit('fsevent', path, flags, id);\n var info = getInfo(path, flags);\ndiff --git a/fsevents.js b/fsevents.js\nsemver exclusivity ^2.1\n--- a/fsevents.js\n+++ b/fsevents.js\n@@ -21,5 +21,7 @@ function watch(path, handler) {\n throw new TypeError(\`fsevents argument 2 must be a function and not a \${typeof handler}\`);\n }\n\n- let instance = Native.start(path, handler);\n+ let VFS = require('./vfs');\n+ let vfs = new VFS(path);\n+ let instance = Native.start(vfs.resolvedPath, vfs.wrap(handler));\n if (!instance) throw new Error(\`could not watch: \${path}\`);\ndiff --git a/vfs.js b/vfs.js\nnew file mode 100644\n--- /dev/null\n+++ b/vfs.js\n@@ -0,0 +1,41 @@\n+const path = require(\`path\`);\n+\n+const NUMBER_REGEXP = /^[0-9]+$/;\n+const VIRTUAL_REGEXP = /^(\\/(?:[^\\/]+\\/)*?\\$\\$virtual)((?:\\/([^\\/]+)(?:\\/([^\\/]+))?)?((?:\\/.*)?))$/;\n+\n+function resolveVirtual(p) {\n+ const match = p.match(VIRTUAL_REGEXP);\n+ if (!match)\n+ return p;\n+\n+ const target = path.dirname(match[1]);\n+ if (!match[3] || !match[4])\n+ return target;\n+\n+ const isnum = NUMBER_REGEXP.test(match[4]);\n+ if (!isnum)\n+ return p;\n+\n+ const depth = Number(match[4]);\n+ const backstep = \`../\`.repeat(depth);\n+ const subpath = (match[5] || \`.\`);\n+\n+ return resolveVirtual(path.join(target, backstep, subpath));\n+}\n+\n+module.exports = class FsePnp {\n+ constructor(p) {\n+ this.normalizedPath = path.resolve(p);\n+ this.resolvedPath = resolveVirtual(this.normalizedPath);\n+ }\n+\n+ transpose(p) {\n+ return this.normalizedPath + p.substr(this.resolvedPath.length);\n+ }\n+\n+ wrap(fn) {\n+ return (path, ...args) => {\n+ return fn(this.transpose(path), ...args);\n+ };\n+ }\n+};\n`
;
/* eslint-disable */
export const patch = require('zlib').brotliDecompressSync(Buffer.from('G8EIABwHuTnyDkxeQiomXep01zJ90cJ3iFSgGcnN+dVTE5YC1CBsZn0bRMFnq2+/bPJOWLRlcCblbWaytN6yn94lDuHQVXEMzob/mhDOafB/uXcOjPnzEX5TF8I/4H+A7n4PCzSY0xTuWjDfxxV8F1neM4x7jymltl+dnYEp13SxCOpkQxUClagaNItavHVUdwD73pT3+c52oJFtOTmagkX/GAaKFyr1bLfAnKMY+OZmY+0YsC6Sci7AJQI2zADQHhdIcc03Dz+GOC05kpj3M0kiNKsdFu1U3ornmwco/hOeYDp3IUlCIQqaE6eg8ho+SQaBwAeE4PktvsKmDJJy8fXAx0jTz4Oj2wWKVgNnuMz/CR5AZNuo2eZk0HwujkkFQBytGPu+p1RoCpRBYVcTf7REjfuVBUIa+MgTpb+ZaKgASLlmw2dFNlIsdYEsSntc1vhEJfQLSkVdBXXK67OUoZjcjVu8DPd8oSwu1vK52tVmsLNeekvJW3ss4Z1+thxuul1A0bzLBLT7MQMQxaGNFQUpvaAsmmOVo1hZFKHViytsKRvkULx6+VpOghLO9W/tHqSTQkqQkLWIKtzBlsPNUviOym6eOz3jjDM43Jfi2pXbla5apaLf+jR3njZPcG1zp9bxgi6Acg2V4n8rU8+1ANM2CXkW5tkqS6QfhnL1z8/s5G8r/f4omOaXOkzbHh9HdPhfxz9Tftr698n6L7UYF/L089Ch+9QgeDSlUXdaBAyLU3G6bkC5ygWmNqZMBYJHB6iFj4uo0iI9yR5r3KUooI0Zg1IkiYsgqxR8jMug6VgwtyIaxNxP30CqZH3zo/g16/wof1VdCLhd+YIOeBHFhA/D2eAvyld7FIAT8EiOA1Msg41mq8UNYCwZt2Pc519uZYhp9gP6kOwhcU+Ydc0CsPIqfy0ZGgbIKNYGZ+RP4ESfRzdDW6vhSsXuu2VB29YEdri/7CbQ7XCsVevHtY2mms7dVEMb6Wa/Ln6ZokATZTjZ/kMMNoWEp0AqBKG0DaCyBxlBsylqymr/6xM+mxOAAVREIXXGnW4IXuQ5oSGimw0C7BKZb3ZDLEWtkWXM5FB7jjp37QA=', 'base64')).toString();
5 changes: 2 additions & 3 deletions packages/plugin-compat/sources/patches/resolve.patch.ts
@@ -1,3 +1,2 @@
export const patch =
`diff --git a/lib/normalize-options.js b/lib/normalize-options.js\nindex 4b56904..53a3219 100644\nsemver exclusivity >=1.9\n--- a/lib/normalize-options.js\n+++ b/lib/normalize-options.js\n@@ -1,10 +1,108 @@\n-module.exports = function (x, opts) {\n- /**\n- * This file is purposefully a passthrough. It's expected that third-party\n- * environments will override it at runtime in order to inject special logic\n- * into \`resolve\` (by manipulating the options). One such example is the PnP\n- * code path in Yarn.\n- */\n-\n- return opts || {};\n+// Info: this file has been generated by Yarn with the approval of the\n+// \`resolve\` maintainers. Bugs caused by a code located here should be\n+// opened against the Yarn repository.\n+\n+const path = require(\`path\`);\n+\n+module.exports = function (_, opts) {\n+ opts = opts || {};\n+\n+ if (opts.forceNodeResolution || !process.versions.pnp)\n+ return opts;\n+\n+ // It would be nice if we could throw, but that would break the transparent\n+ // compatibility with packages that use \`resolve\` today (such as Gulp). Since\n+ // it's the whole point of this patch, we don't.\n+ //\n+ // if (opts.packageIterator || opts.paths)\n+ // throw new Error(\`The "packageIterator" and "paths" options cannot be used in PnP environments. Set "forceNodeResolution: true" if absolutely needed, or branch on process.versions.pnp otherwise.\`);\n+\n+ const {findPnpApi} = require(\`module\`);\n+\n+ const runPnpResolution = (request, basedir) => {\n+ // Extract the name of the package being requested (1=package name, 2=internal path)\n+ const parts = request.match(/^((?:@[^\\/]+\\/)?[^\\/]+)(\\/.*)?/);\n+ if (!parts)\n+ throw new Error(\`Assertion failed: Expected the "resolve" package to call the "paths" callback with package names only (got "\${request}")\`);\n+\n+ // Make sure that basedir ends with a slash\n+ if (basedir.charAt(basedir.length - 1) !== \`/\`)\n+ basedir = path.join(basedir, \`/\`);\n+\n+ const api = findPnpApi(basedir);\n+ if (api === null)\n+ return undefined;\n+\n+ // This is guaranteed to return the path to the "package.json" file from the given package\n+ let manifestPath;\n+ try {\n+ manifestPath = api.resolveToUnqualified(\`\${parts[1]}/package.json\`, basedir, {considerBuiltins: false});\n+ } catch (err) {\n+ return null;\n+ }\n+\n+ if (manifestPath === null)\n+ throw new Error(\`Assertion failed: The resolution thinks that "\${parts[1]}" is a Node builtin\`);\n+\n+ // Strip the package.json to get the package folder\n+ const packagePath = path.dirname(manifestPath);\n+\n+ // Attach the internal path to the resolved package directory\n+ const unqualifiedPath = typeof parts[2] !== \`undefined\`\n+ ? path.join(packagePath, parts[2])\n+ : packagePath;\n+\n+ return {packagePath, unqualifiedPath};\n+ };\n+\n+ const packageIterator = (request, basedir, getCandidates, opts) => {\n+ const resolution = runPnpResolution(request, basedir);\n+ if (typeof resolution === \`undefined\`)\n+ return getCandidates();\n+\n+ if (resolution === null)\n+ return [];\n+\n+ return [resolution.unqualifiedPath];\n+ };\n+\n+ const paths = (request, basedir, getNodeModulePaths, opts) => {\n+ const resolution = runPnpResolution(request, basedir);\n+ if (typeof resolution === \`undefined\`)\n+ return getNodeModulePaths();\n+\n+ if (resolution === null)\n+ return [];\n+\n+ // Stip the local named folder\n+ let nodeModules = path.dirname(resolution.packagePath);\n+\n+ // Strip the scope named folder if needed\n+ if (request.match(/^@[^\\/]+\\//))\n+ nodeModules = path.dirname(nodeModules);\n+\n+ return [nodeModules];\n+ };\n+\n+ // We need to keep track whether we're in \`packageIterator\` or not so that\n+ // the code is compatible with both \`resolve\` 1.9+ and \`resolve\` 1.15+\n+ let isInsideIterator = false;\n+\n+ opts.packageIterator = function (request, basedir, getCandidates, opts) {\n+ isInsideIterator = true;\n+ try {\n+ return packageIterator(request, basedir, getCandidates, opts);\n+ } finally {\n+ isInsideIterator = false;\n+ }\n+ };\n+\n+ opts.paths = function (request, basedir, getNodeModulePaths, opts) {\n+ if (isInsideIterator)\n+ return getNodeModulePaths();\n+\n+ return paths(request, basedir, getNodeModulePaths, opts);\n+ };\n+\n+ return opts;\n };\n`
;
/* eslint-disable */
export const patch = require('zlib').brotliDecompressSync(Buffer.from('G+4QAIzURnVBnOZ/S7W7LqcXJbsLsg1ujW3lVCvYwhYpoIGvNI1ypQXI/9z7C4lxoATjm1Wcm5MwCa101e7Ne78qBrVNrStdyFYkUu2sNrsMp9uuWixKwC9/Lt3hgMHg6AhGXrqddLrh7u0gmNcT5wm7wylL0a8x3c3mq+FUiNnETMajFUd8bz6dZsleXduIIQn/rqM7PFYjscoGg0Gkw5l3pSP+xE8xGPVHQ/hseInvjWdBOiB4zQ5vexjYbR+hpsTRZgGALIq3ORRgK+zenrSWdSZBQP4M5ofv6FHCgrFCsjQgaAjT8D6MOWAeGQrwvEuIjce8Nh0vO39u9wQBF2H0L7B5B7TiWNBgq/TMuboRmYHjb3tylwu895NMZRRs2wf/AeofM0oc/jTRi8N98gt3R7GBFeQkdTcjJaRlaQ3CW74rgNFKEmxEPbXWsvgewtIgebG8ZWMSeN4c+yf0m9RS/cHUDXpNLk6GrN6QBDwo2jokRyHeiUxmH3wiqAfUP+1y1N+b1XzjqCwDdfo/DkhponCDY1BIuE9CMNGFUnXAg+OBE/nzO6H4OFH7mmfwzRB7n3WlH/IExJJuJloDYw7dDFQbNK6lNUGLN4O0M1/5RacfbZKljBgNZsmCC2+ay5qLpaL4suboUdoeaULfIuEPGel+9caiDP4RCX/0HdDFRLS/IxtHQ0QVj21QlbiPfgC8Bm9vVjT/OKa/VBZ5AGdzGF8ivx3MRSIUx/y4O4iC+em0XvXZEnLKpXW58447lLLdyrDzIeKX3l1I3/AbHCKfjQOsGFvV/KEPvn5Wu44l3WvOw0xs/K3mpwUFtrSrZNAdXORQj9EuSIlOgrnck1iTAin/PlwLbKQOy4j3ybEybIFTcqqXIycjDIJGzp/lP8aerJ/+/vdH/u39kfzJV8Oc3Q2L4i5KuMYBSUknwTDgIgrvPUvJRnDdnwnIT9IRifjcQeEAdveDxjHPBH4DTQZE9H65xo6BkJ+1sCx0OUc+EYn6dSwSTmxH7L3pfQbp0qQKNjq7LPaVic/oW958mhtgNMbzSEFLDb8POSlcY6Mf3m/qO2aqPAFmTO1uFQt5DwbF4m5WKVhyjCxomWDcaGiD5afmhHMDJjD1WD2JXhQz0kbseq5FJj6kKxfH8y8toWMiujAzsWIeuksjbkehAB0QdN74Er76tb7OOlsyfdayzwu/R387mZYl3QfmBlurVvpLtzpaj4MdnliH9XHMxsjR3uLiHcsVMWvT6VFcNT6G3lJFMjEyqX3rc9hiTo1oZuDp30GR4c34uYnbXEAiFgkCw6eDvWpYiEcFDrLdbOmiYFgYbZyXnhGZfbXRXcsUpNZQGXWw5s1DXUNKpoBVEA748fFf8Qg8OqixW/9EOjQIQ33PgQ4NaxAJRSBtQ+s/m6LUEb2xU725HKbwMfaxroY30FLQ6phKXKvvvEY393lpJppMIJmXrIjbNEUWnLpTIZXTEPf+/ou6ut8+m4nnnv8+G1UJXeBrNxspwvj/cZZPWPURZyWU11IHI4VBK4xHl5bg422anjXONdeWUQJSSLXxIOHOSFFwZDPrkFFPSg5P6VTpw805i+gXyxNI68D3HfihPCzV4axi/0s39lG0cB5a2q5phAgfaPIFFyL2q3wfXJ0vSr/afF0biVXPIDTfHhvN0gYSjLs0O6+Wb8klmPxC61SXCaqiC3hfGCNMy8K8kJjNxV+NOEMOxzqCEHRJmOlL006b4BrsKsp0Xct+2dirJ4N0JwmqWiIsL9rSFY4A', 'base64')).toString();
5 changes: 2 additions & 3 deletions packages/plugin-compat/sources/patches/typescript.patch.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/hook.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions packages/yarnpkg-pnp/webpack.config.hook.js
@@ -1,10 +1,11 @@
const {makeConfig} = require(`@yarnpkg/builder/sources/tools/makeConfig`);
const {RawSource} = require(`webpack-sources`);
const {brotliCompressSync} = require(`zlib`);

module.exports = makeConfig({
context: __dirname,

mode: 'production',
mode: `production`,
optimization: {
minimize: false,
},
Expand All @@ -27,9 +28,9 @@ module.exports = makeConfig({
compilation.hooks.optimizeChunkAssets.tap(`MyPlugin`, chunks => {
for (const chunk of chunks) {
for (const file of chunk.files) {
compilation.assets[file] = new RawSource(`module.exports = ${JSON.stringify(
compilation.assets[file].source(),
)};\n`);
compilation.assets[file] = new RawSource(
`module.exports = require('zlib').brotliDecompressSync(Buffer.from('${brotliCompressSync(compilation.assets[file].source().replace(/\r\n/g, `\n`)).toString(`base64`)}', 'base64')).toString();\n`
);
}
}
});
Expand Down

0 comments on commit 2035b20

Please sign in to comment.