Socket
Book a DemoInstallSign in
Socket

@ms-cloudpack/bundler-capabilities

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/bundler-capabilities - npm Package Compare versions

Comparing version

to
0.1.12

9

lib/processCapabilities.d.ts

@@ -9,7 +9,8 @@ import type { BundlerCapabilitiesOptions, InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';

*/
export declare function processCapabilities<TConfig>(params: {
export declare function processCapabilities<TConfig>(input: {
bundlerName: string;
baseConfig: TConfig;
processors: InternalBundlerCapabilityImplementations<TConfig>;
bundlerCapabilities: BundlerCapabilitiesOptions;
}): TConfig;
internalCapabilities: InternalBundlerCapabilityImplementations<TConfig>;
bundlerCapabilitiesOptions: BundlerCapabilitiesOptions;
}): Promise<TConfig>;
//# sourceMappingURL=processCapabilities.d.ts.map
/**
* Try to import an external capability module
* @param input - importSpecifier is a fully resolved path to the module
* @returns - The capability function if the module is found, otherwise undefined
*/
async function tryImportExternalCapability(input) {
try {
const { bundler, importSpecifier } = input;
// importSpecifier has already been resolved to a full path in readAppConfig
const capabilityModule = await import(importSpecifier);
const capabilityFunction = capabilityModule.default.implementations[bundler];
return capabilityFunction;
}
catch {
return undefined;
}
}
/**
* Process the capabilities of the bundler and apply the capabilities to the base configuration

@@ -8,6 +25,7 @@ * @param baseConfig - The base configuration to apply the capabilities to

*/
export function processCapabilities(params) {
for (const key in params.bundlerCapabilities) {
const typekey = key;
const options = params.bundlerCapabilities[typekey];
export async function processCapabilities(input) {
const { baseConfig, bundlerCapabilitiesOptions, internalCapabilities, bundlerName: bundler } = input;
let config = baseConfig;
for (const key in bundlerCapabilitiesOptions) {
const options = bundlerCapabilitiesOptions[key];
// If the capability is disabled, skip it and continue to the next capability

@@ -17,13 +35,17 @@ if (options === false) {

}
const processor = params.processors[typekey];
if (!options) {
throw new Error(`No options found for capability ${key}. This must be a Cloudpack bug, please report it.`);
}
// key is the capability name for the internal capabilities
// key is the import specifier for the external capabilities
const processor = (key in internalCapabilities
? internalCapabilities[key]
: await tryImportExternalCapability({ importSpecifier: key, bundler }));
if (!processor) {
throw new Error(`No processor found for capability ${typekey}`);
throw new Error(`No processor found for capability ${key}`);
}
if (!options) {
throw new Error(`No options found for capability ${typekey}. This must be a Cloudpak bug, please report it.`);
}
params.baseConfig = processor(params.baseConfig, options);
config = processor(config, options);
}
return params.baseConfig;
return config;
}
//# sourceMappingURL=processCapabilities.js.map
{
"name": "@ms-cloudpack/bundler-capabilities",
"version": "0.1.11",
"version": "0.1.12",
"description": "Definition and utilities for bundler capabilities for cloudpack.",

@@ -17,3 +17,3 @@ "license": "MIT",

"dependencies": {
"@ms-cloudpack/common-types": "^0.17.0"
"@ms-cloudpack/common-types": "^0.18.0"
},

@@ -20,0 +20,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.