How to use the @parcel/utils.registerSerializableClass function in @parcel/utils

To help you get started, we’ve selected a few @parcel/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parcel-bundler / parcel / packages / core / cache / src / Cache.js View on Github external
// First, create the main cache directory if necessary.
  await fs.mkdirp(dir);

  // In parallel, create sub-directories for every possible hex value
  // This speeds up large caches on many file systems since there are fewer files in a single directory.
  let dirPromises = [];
  for (let i = 0; i < 256; i++) {
    dirPromises.push(
      fs.mkdirp(path.join(dir, ('00' + i.toString(16)).slice(-2))),
    );
  }

  await Promise.all(dirPromises);
}

registerSerializableClass(`${packageJson.version}:Cache`, Cache);
github parcel-bundler / parcel / packages / core / core / src / registerCoreWithSerializer.js View on Github external
function register(ctor: Class<*>): void {
  registerSerializableClass(packageVersion + ':' + ctor.name, ctor);
}
github parcel-bundler / parcel / packages / core / cache / src / HTTPCache.js View on Github external
return deserialize(response.body);
  }

  async set(key: string, value: mixed) {
    await this.request(this._getCachePath(key), {
      method: 'put',
      body: serialize(value),
      headers: {
        'content-type': 'application/octet-stream'
      }
    });
    return key;
  }
}

registerSerializableClass(`${packageJson.version}:HTTPCache`, HTTPCache);
github parcel-bundler / parcel / packages / core / fs / src / MemoryFS.js View on Github external
super.rimraf(filePath);
    return this.handleFn('rimraf', [filePath]);
  }

  ncp(source: FilePath, destination: FilePath) {
    super.ncp(source, destination);
    return this.handleFn('ncp', [source, destination]);
  }

  symlink(target: FilePath, path: FilePath) {
    super.symlink(target, path);
    return this.handleFn('symlink', [target, path]);
  }
}

registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
github parcel-bundler / parcel / packages / core / fs / src / MemoryFS.js View on Github external
ncp(source: FilePath, destination: FilePath) {
    super.ncp(source, destination);
    return this.handleFn('ncp', [source, destination]);
  }

  symlink(target: FilePath, path: FilePath) {
    super.symlink(target, path);
    return this.handleFn('symlink', [target, path]);
  }
}

registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
github parcel-bundler / parcel / packages / core / package-manager / src / Npm.js View on Github external
logger.log({
          origin: '@parcel/package-manager',
          message,
        });
      }
    } catch (e) {
      throw new Error('npm failed to install modules');
    }
  }
}

type NPMResults = {|
  added: Array<{name: string, ...}>,
|};

registerSerializableClass(`${pkg.version}:Npm`, Npm);
github parcel-bundler / parcel / packages / core / fs / src / OverlayFS.js View on Github external
snapshot,
      opts,
    );
    return [...writableEvents, ...readableEvents];
  }

  async writeSnapshot(
    dir: FilePath,
    snapshot: FilePath,
    opts: WatcherOptions,
  ): Promise {
    await this.writable.writeSnapshot(dir, snapshot, opts);
  }
}

registerSerializableClass(`${packageJSON.version}:OverlayFS`, OverlayFS);
github parcel-bundler / parcel / packages / core / fs / src / MemoryFS.js View on Github external
}

  ncp(source: FilePath, destination: FilePath) {
    super.ncp(source, destination);
    return this.handleFn('ncp', [source, destination]);
  }

  symlink(target: FilePath, path: FilePath) {
    super.symlink(target, path);
    return this.handleFn('symlink', [target, path]);
  }
}

registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
github parcel-bundler / parcel / packages / core / fs / src / NodeFS.js View on Github external
snapshot: FilePath,
    opts: WatcherOptions,
  ): Promise {
    await watcher.writeSnapshot(dir, snapshot, opts);
  }

  static deserialize() {
    return new NodeFS();
  }

  serialize() {
    return null;
  }
}

registerSerializableClass(`${packageJSON.version}:NodeFS`, NodeFS);
github parcel-bundler / parcel / packages / core / package-manager / src / Yarn.js View on Github external
}
      });

    try {
      return await promiseFromProcess(installProcess);
    } catch (e) {
      throw new Error('Yarn failed to install modules');
    }
  }
}

function prefix(message: string): string {
  return 'yarn: ' + message;
}

registerSerializableClass(`${pkg.version}:Yarn`, Yarn);