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

Fix broken yarn pnp #32867

Merged
merged 7 commits into from Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
290 changes: 21 additions & 269 deletions packages/next/compiled/webpack/bundle5.js
Expand Up @@ -129584,56 +129584,44 @@ class OperationMergerBackend {
* @param {any} providerContext call context for the provider methods
*/
constructor(provider, syncProvider, providerContext) {
const activeAsyncOperations = new Map();
this._provider = provider;
this._syncProvider = syncProvider;
this._providerContext = providerContext;
this._activeAsyncOperations = new Map();

this.provide = provider
this.provide = this._provider
? (path, options, callback) => {
if (typeof options === "function") {
callback = options;
options = undefined;
}
if (options) {
return provider.call(providerContext, path, options, callback);
return this._provider.call(
this._providerContext,
path,
options,
callback
);
}
if (typeof path !== "string") {
callback(new TypeError("path must be a string"));
return;
}
let callbacks = activeAsyncOperations.get(path);
let callbacks = this._activeAsyncOperations.get(path);
if (callbacks) {
callbacks.push(callback);
return;
}
activeAsyncOperations.set(path, (callbacks = [callback]));
provider.call(providerContext, path, (err, result) => {
activeAsyncOperations.delete(path);
this._activeAsyncOperations.set(path, (callbacks = [callback]));
provider(path, (err, result) => {
this._activeAsyncOperations.delete(path);
runCallbacks(callbacks, err, result);
});
}
: null;
this.provideSync = syncProvider
this.provideSync = this._syncProvider
? (path, options) => {
return syncProvider.call(providerContext, path, options);
}
: null;

this.provideCustom = provider
? (provider, providerContext, path, callback) => {
let callbacks = activeAsyncOperations.get(path);
if (callbacks) {
callbacks.push(callback);
return;
}
activeAsyncOperations.set(path, (callbacks = [callback]));
provider.call(providerContext, path, (err, result) => {
activeAsyncOperations.delete(path);
runCallbacks(callbacks, err, result);
});
}
: null;
this.provideCustomSync = syncProvider
? (syncProvider, providerContext, path) => {
return syncProvider.call(providerContext, path);
return this._syncProvider.call(this._providerContext, path, options);
}
: null;
}
Expand Down Expand Up @@ -129698,11 +129686,6 @@ class CacheBackend {

this.provide = provider ? this.provide.bind(this) : null;
this.provideSync = syncProvider ? this.provideSync.bind(this) : null;

this.provideCustom = provider ? this.provideCustom.bind(this) : null;
this.provideCustomSync = syncProvider
? this.provideCustomSync.bind(this)
: null;
}

provide(path, options, callback) {
Expand Down Expand Up @@ -129797,74 +129780,6 @@ class CacheBackend {
return result;
}

provideCustom(provider, providerContext, path, callback) {
// When in sync mode we can move to async mode
if (this._mode === STORAGE_MODE_SYNC) {
this._enterAsyncMode();
}

// Check in cache
let cacheEntry = this._data.get(path);
if (cacheEntry !== undefined) {
if (cacheEntry.err) return nextTick(callback, cacheEntry.err);
return nextTick(callback, null, cacheEntry.result);
}

// Check if there is already the same operation running
let callbacks = this._activeAsyncOperations.get(path);
if (callbacks !== undefined) {
callbacks.push(callback);
return;
}
this._activeAsyncOperations.set(path, (callbacks = [callback]));

// Run the operation
provider.call(providerContext, path, (err, result) => {
this._activeAsyncOperations.delete(path);
this._storeResult(path, err, result);

// Enter async mode if not yet done
this._enterAsyncMode();

runCallbacks(callbacks, err, result);
});
}

provideCustomSync(provider, providerContext, path) {
// In sync mode we may have to decay some cache items
if (this._mode === STORAGE_MODE_SYNC) {
this._runDecays();
}

// Check in cache
let cacheEntry = this._data.get(path);
if (cacheEntry !== undefined) {
if (cacheEntry.err) throw cacheEntry.err;
return cacheEntry.result;
}

// Get all active async operations
// This sync operation will also complete them
const callbacks = this._activeAsyncOperations.get(path);
this._activeAsyncOperations.delete(path);

// Run the operation
// When in idle mode, we will enter sync mode
let result;
try {
result = provider.call(providerContext, path);
} catch (err) {
this._storeResult(path, err, undefined);
this._enterSyncModeWhenIdle();
if (callbacks) runCallbacks(callbacks, err, undefined);
throw err;
}
this._storeResult(path, undefined, result);
this._enterSyncModeWhenIdle();
if (callbacks) runCallbacks(callbacks, undefined, result);
return result;
}

purge(what) {
if (!what) {
if (this._mode !== STORAGE_MODE_IDLE) {
Expand Down Expand Up @@ -130017,10 +129932,8 @@ module.exports = class CachedInputFileSystem {
this.fileSystem
);
const stat = this._statBackend.provide;
const customStat = this._statBackend.provideCustom;
this.stat = /** @type {FileSystem["stat"]} */ (stat);
const statSync = this._statBackend.provideSync;
const customStatSync = this._statBackend.provideCustomSync;
this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync);

this._readdirBackend = createBackend(
Expand All @@ -130036,161 +129949,8 @@ module.exports = class CachedInputFileSystem {

this._readFileBackend = createBackend(
duration,
this.fileSystem.readFile &&
this.fileSystem.fstat &&
this.fileSystem.read &&
this.fileSystem.open &&
this.fileSystem.close &&
customStat
? /**
* @this {{ fstat: NonNullable<FileSystem["fstat"]>, readFile: NonNullable<FileSystem["readFile"]>, open: NonNullable<FileSystem["open"]>, read: NonNullable<FileSystem["read"]>, close: NonNullable<FileSystem["close"]> }}
*/
function (path, options, callback) {
if (typeof options === "function") {
callback = options;
options = undefined;
}
if (typeof options === "object")
return this.readFile(path, options, callback);
this.open(path, "r", (err, fd) => {
if (err) return callback(err);
if (typeof fd !== "number")
return callback(new Error("fd must be a number"));
customStat(
(path, callback) => this.fstat(fd, callback),
null,
path,
(err, stats) => {
if (err) return callback(err);
if (stats.size > 0 && stats.size < 128 * 1024) {
let remaining = stats.size + 1;
const buffer = Buffer.allocUnsafe(remaining);
const afterRead = (err, bytesRead) => {
if (err) {
return this.close(fd, () => {
callback(err);
});
}
remaining -= bytesRead;
if (bytesRead === 0 || remaining === 1) {
this.close(fd, err => {
if (err) return callback(err);
return callback(
null,
buffer.slice(0, buffer.length - remaining)
);
});
} else if (remaining === 0) {
// The file size has changed from the cached info
// We keep reading until the end is found
let buf = Buffer.allocUnsafe(16 * 1024);
let bufPos = 0;
const buffers = [buffer];
const afterUnknownRead = (err, bytesRead) => {
if (err) {
return this.close(fd, () => {
callback(err);
});
}
bufPos += bytesRead;
if (bytesRead === 0) {
if (bufPos > 0) buffers.push(buf.slice(0, bufPos));
this.close(fd, err => {
if (err) return callback(err);
return callback(null, Buffer.concat(buffers));
});
} else {
if (bufPos === buf.length) {
buffers.push(buf);
buf = Buffer.allocUnsafe(16 * 1024);
bufPos = 0;
}
this.read(
fd,
buf,
bufPos,
buf.length - bufPos,
-1,
afterUnknownRead
);
}
};
this.read(
fd,
buf,
bufPos,
buf.length - bufPos,
-1,
afterUnknownRead
);
} else {
this.read(
fd,
buffer,
stats.size - remaining,
remaining + 1,
-1,
afterRead
);
}
};
this.read(fd, buffer, 0, remaining, -1, afterRead);
} else {
this.readFile(fd, options, (err, buffer) => {
this.close(fd, closeErr => {
if (err) return callback(err);
if (closeErr) return callback(closeErr);
callback(null, buffer);
});
});
}
}
);
});
}
: this.fileSystem.readFile,
this.fileSystem.readFileSync &&
this.fileSystem.fstatSync &&
this.fileSystem.readSync &&
this.fileSystem.openSync &&
this.fileSystem.closeSync &&
customStatSync
? /**
* @this {{ fstatSync: NonNullable<SyncFileSystem["fstatSync"]>, readFileSync: NonNullable<SyncFileSystem["readFileSync"]>, openSync: NonNullable<SyncFileSystem["openSync"]>, readSync: NonNullable<SyncFileSystem["readSync"]>, closeSync: NonNullable<SyncFileSystem["closeSync"]> }}
*/
function (path, options) {
if (typeof options === "object")
return this.readFileSync(path, options);
const fd = this.openSync(path, "r");
if (typeof fd !== "number") throw new Error("fd must be a number");
const stats = customStatSync(() => this.fstatSync(fd), null, path);
if (stats.size > 0 && stats.size < 128 * 1024) {
let remaining = stats.size;
const buffer = Buffer.allocUnsafe(remaining);
try {
let bytesRead = this.readSync(fd, buffer, 0, remaining, -1);
remaining -= bytesRead;
while (bytesRead !== 0 && remaining !== 0) {
bytesRead = this.readSync(
fd,
buffer,
stats.size - remaining,
remaining,
-1
);
remaining -= bytesRead;
}
return buffer;
} finally {
this.closeSync(fd);
}
} else {
const buffer = this.readFileSync(fd);
this.closeSync(fd);
return buffer;
}
}
: this.fileSystem.readFileSync,
this.fileSystem.readFile,
this.fileSystem.readFileSync,
this.fileSystem
);
const readFile = this._readFileBackend.provide;
Expand Down Expand Up @@ -131829,11 +131589,7 @@ const {

/**
* @typedef {Object} FileSystem
* @property {(function(string | number, FileSystemCallback<Buffer | string>): void) & function(string | number, object, FileSystemCallback<Buffer | string>): void} readFile
* @property {(function(string, string | number, FileSystemCallback<number>): void) & function(string, string | number, string | number, FileSystemCallback<number>): void=} open
* @property {(function(number, FileSystemCallback<FileSystemStats>): void) & function(number, object, FileSystemCallback<Buffer | string>): void=} fstat
* @property {function(number, Buffer | Uint8Array, number, number, number, function(PossibleFileSystemError & Error | null | undefined, number=): void): void=} read
* @property {function(number, function(PossibleFileSystemError & Error | null | undefined): void): void=} close
* @property {(function(string, FileSystemCallback<Buffer | string>): void) & function(string, object, FileSystemCallback<Buffer | string>): void} readFile
* @property {(function(string, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void) & function(string, object, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void} readdir
* @property {((function(string, FileSystemCallback<object>): void) & function(string, object, FileSystemCallback<object>): void)=} readJson
* @property {(function(string, FileSystemCallback<Buffer | string>): void) & function(string, object, FileSystemCallback<Buffer | string>): void} readlink
Expand All @@ -131843,11 +131599,7 @@ const {

/**
* @typedef {Object} SyncFileSystem
* @property {function(string | number, object=): Buffer | string} readFileSync
* @property {function(string, string | number, string | number=): number=} openSync
* @property {function(number, object=): FileSystemStats=} fstatSync
* @property {function(number, Buffer | Uint8Array, number, number, number): number=} readSync
* @property {function(number): void=} closeSync
* @property {function(string, object=): Buffer | string} readFileSync
* @property {function(string, object=): (Buffer | string)[] | FileSystemDirent[]} readdirSync
* @property {(function(string, object=): object)=} readJsonSync
* @property {function(string, object=): Buffer | string} readlinkSync
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Expand Up @@ -8809,7 +8809,8 @@ enhanced-resolve@^4.3.0:

enhanced-resolve@^5.8.3:
version "5.8.3"
resolved "https://codeload.github.com/webpack/enhanced-resolve/tar.gz/a7c161eeb141bfc7fda375df36c13df006a8cf76"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz#6d552d465cce0423f5b3d718511ea53826a7b2f0"
integrity sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"
Expand Down