safe-webpack-define-plugin
Version:
A webpack (typescript ready) plugin to define global variables on outputted bundles
24 lines • 919 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveExposureFunction = void 0;
const _1 = require(".");
const buildExposureFunction = (strategy = _1.ExposureStrategy.NONE) => {
switch (strategy) {
case _1.ExposureStrategy.NONE:
return (name) => name;
case _1.ExposureStrategy.WINDOW:
return buildArrayExposureFunction(['window']);
}
};
const buildArrayExposureFunction = (paths) => (name) => [...paths, name].join('.');
const resolveExposureFunction = (exposureStrategy) => {
if (exposureStrategy instanceof Function) {
return exposureStrategy;
}
if (Array.isArray(exposureStrategy)) {
return buildArrayExposureFunction(exposureStrategy);
}
return buildExposureFunction(exposureStrategy);
};
exports.resolveExposureFunction = resolveExposureFunction;
//# sourceMappingURL=ExposureFunction.js.map