Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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;
}
function getContentKey(cacheKey: string) {
return md5FromString(`${cacheKey}:content`);
}
getCacheKeys() {
let assetGraphKey = md5FromString(`${this.cacheKey}:assetGraph`);
let requestGraphKey = md5FromString(`${this.cacheKey}:requestGraph`);
let snapshotKey = md5FromString(`${this.cacheKey}:snapshot`);
return {assetGraphKey, requestGraphKey, snapshotKey};
}
getCacheKeys() {
let assetGraphKey = md5FromString(`${this.cacheKey}:assetGraph`);
let requestGraphKey = md5FromString(`${this.cacheKey}:requestGraph`);
let snapshotKey = md5FromString(`${this.cacheKey}:snapshot`);
return {assetGraphKey, requestGraphKey, snapshotKey};
}
function getMapKey(cacheKey: string) {
return md5FromString(`${cacheKey}:map`);
}
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),
getCacheKey(key: string): string {
return md5FromString(
PARCEL_VERSION + key + this.value.id + (this.value.hash || ''),
);
}