Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let optimizers = this.config.getOptimizerNames(filePath);
let deps = Promise.all(
[packager, ...optimizers].map(async pkg => {
let {pkg: resolvedPkg} = await this.options.packageManager.resolve(
`${pkg}/package.json`,
`${this.config.filePath}/index`,
);
let version = nullthrows(resolvedPkg).version;
return [pkg, version];
}),
);
// TODO: add third party configs to the cache key
let {minify, scopeHoist, sourceMaps} = this.options;
return md5FromObject({
parcelVersion: PARCEL_VERSION,
deps,
opts: {minify, scopeHoist, sourceMaps},
hash: bundleGraph.getHash(bundle),
});
}
export function getEnvironmentHash(env: Environment) {
// context is excluded from hash so that assets can be shared between e.g. workers and browser.
// Different engines should be sufficient to distinguish multi-target builds.
return md5FromObject({
engines: env.engines,
includeNodeModules: env.includeNodeModules,
outputFormat: env.outputFormat,
isLibrary: env.isLibrary,
});
}
async getCacheKey(assetGraph: AssetGraph) {
let bundler = this.config.bundler;
let {pkg} = await this.options.packageManager.resolve(
`${bundler}/package.json`,
`${this.config.filePath}/index`, // TODO: is this right?
);
let version = nullthrows(pkg).version;
return md5FromObject({
parcelVersion: PARCEL_VERSION,
bundler,
version,
hash: assetGraph.getHash(),
});
}
assets.map(asset =>
asset.commit(
md5FromObject({
impactfulOptions: this.impactfulOptions,
configs: getImpactfulConfigInfo(configs),
}),
),
),
generateRequestId(request: TRequest) {
return md5FromObject({type: this.type, request});
}
export function generateRequestId(type: string, request: mixed) {
return md5FromObject({type, request});
}
message:
'WARNING: You are using `extends` in your Babel config, which means you are losing out on some of the caching features of Parcel. Maybe try using a reusable preset instead.',
});
config.shouldInvalidateOnStartup();
}
if (dependsOnRelative || dependsOnLocal) {
logger.verbose({
message:
'WARNING: It looks like you are using local Babel plugins or presets. You will need to run with the `--no-cache` option in order to pick up changes to these until their containing package versions are bumped.',
});
}
if (canBeRehydrated) {
await definePluginDependencies(config);
config.setResultHash(md5FromObject(partialConfig.options));
} else {
logger.verbose({
message:
'WARNING: You are using `require` to configure Babel plugins or presets. This means Babel transformations cannot be cached and will run on each build. Please use strings to configure Babel instead.',
});
config.setResultHash(JSON.stringify(Date.now()));
config.shouldInvalidateOnStartup();
}
} else {
await buildDefaultBabelConfig(config);
}
}
const nodeFromConfigRequest = (configRequest: ConfigRequest) => ({
id: md5FromObject({
filePath: configRequest.filePath,
plugin: configRequest.plugin,
env: configRequest.env,
pipeline: configRequest.pipeline
}),
type: 'config_request',
value: configRequest
});
getCacheKey(assets: Array, configs: ConfigMap): string {
let assetsKeyInfo = assets.map(a => ({
filePath: a.value.filePath,
hash: a.value.hash,
}));
return md5FromObject({
parcelVersion: PARCEL_VERSION,
assets: assetsKeyInfo,
configs: getImpactfulConfigInfo(configs),
env: this.request.env,
impactfulOptions: this.impactfulOptions,
});
}