How to use the @parcel/utils.md5FromString 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 / transformers / html / src / inline.js View on Github external
new PostHTML().walk.call(program, (node: PostHTMLNode) => {
    let parcelKey = md5FromString(`${asset.id}:${key++}`);
    if (node.tag === 'script' || node.tag === 'style') {
      let value = node.content && node.content.join('').trim();
      if (value != null) {
        let type;

        if (node.tag === 'style') {
          if (node.attrs && node.attrs.type) {
            type = node.attrs.type.split('/')[1];
          } else {
            type = 'css';
          }
        } else if (node.attrs && node.attrs.type) {
          // Skip JSON
          if (SCRIPT_TYPES[node.attrs.type] === false) {
            return node;
          }
github parcel-bundler / parcel / packages / core / core / src / ConfigLoader.js View on Github external
let devDeps = [];
    switch (configRequest.meta.actionType) {
      case 'transformation':
        devDeps = parcelConfig.getTransformerNames(filePath, pipeline);
        break;
      case 'validation':
        devDeps = parcelConfig.getValidatorNames(filePath);
        break;
      case 'dependency':
        devDeps = parcelConfig.getResolverNames();
        break;
    }
    devDeps.forEach(devDep => publicConfig.addDevDependency(devDep));

    publicConfig.setResultHash(md5FromString(JSON.stringify(devDeps)));

    publicConfig.setWatchGlob('**/.parcelrc');

    // TODO: if extended config comes from a package, yarn.lock change should invalidate config request
    for (let extendedFile of extendedFiles) {
      publicConfig.addIncludedFile(extendedFile);
    }

    return config;
  }
github parcel-bundler / parcel / packages / core / core / src / PackagerRunner.js View on Github external
function getContentKey(cacheKey: string) {
  return md5FromString(`${cacheKey}:content`);
}
github parcel-bundler / parcel / packages / core / core / src / AssetGraphBuilder.js View on Github external
getCacheKeys() {
    let assetGraphKey = md5FromString(`${this.cacheKey}:assetGraph`);
    let requestGraphKey = md5FromString(`${this.cacheKey}:requestGraph`);
    let snapshotKey = md5FromString(`${this.cacheKey}:snapshot`);
    return {assetGraphKey, requestGraphKey, snapshotKey};
  }
github parcel-bundler / parcel / packages / core / core / src / AssetGraphBuilder.js View on Github external
getCacheKeys() {
    let assetGraphKey = md5FromString(`${this.cacheKey}:assetGraph`);
    let requestGraphKey = md5FromString(`${this.cacheKey}:requestGraph`);
    let snapshotKey = md5FromString(`${this.cacheKey}:snapshot`);
    return {assetGraphKey, requestGraphKey, snapshotKey};
  }
github parcel-bundler / parcel / packages / core / core / src / PackagerRunner.js View on Github external
function getMapKey(cacheKey: string) {
  return md5FromString(`${cacheKey}:map`);
}
github parcel-bundler / parcel / packages / core / core / src / InternalAsset.js View on Github external
createChildAsset(result: TransformerResult): InternalAsset {
    let content = result.content ?? result.code ?? '';

    let hash;
    let size;
    if (content === this.content) {
      hash = this.value.hash;
      size = this.value.stats.size;
    } else if (typeof content === 'string' || content instanceof Buffer) {
      hash = md5FromString(content);
      size = content.length;
    } else {
      hash = null;
      size = NaN;
    }

    let asset = new InternalAsset({
      value: createAsset({
        idBase: this.idBase,
        hash,
        filePath: this.value.filePath,
        type: result.type,
        isIsolated: result.isIsolated ?? this.value.isIsolated,
        isInline: result.isInline ?? this.value.isInline,
        isSource: result.isSource ?? this.value.isSource,
        env: mergeEnvironments(this.value.env, result.env),
github parcel-bundler / parcel / packages / core / core / src / InternalAsset.js View on Github external
getCacheKey(key: string): string {
    return md5FromString(
      PARCEL_VERSION + key + this.value.id + (this.value.hash || ''),
    );
  }