UNPKG

@communities-webruntime/services

Version:

If you would like to run Lightning Web Runtime without the CLI, we expose some of our programmatic APIs available in Node.js. If you're looking for the CLI documentation [you can find that here](https://www.npmjs.com/package/@communities-webruntime/cli).

44 lines 1.4 kB
"use strict"; /** @hidden */ /** * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ Object.defineProperty(exports, "__esModule", { value: true }); const metadata_service_1 = require("../metadata/metadata-service"); const LABEL_PREFIX = '@salesforce/label/'; /** * Return the value of a label given its id of the form * @salesforce/label/section.name, or `undefined` if the label * cannot be found. */ function getLabelValue(id) { if (id.startsWith(LABEL_PREFIX)) { const labels = metadata_service_1.MetadataService.getLabels(); const [section, name] = id.split('/')[2].split('.'); if (labels[section]) { return labels[section][name]; } } return undefined; } /** * Rollup plugin to load labels from labels.json */ function labelsPlugin() { return { name: 'rollup-plugin-salesforce-labels', load(id) { const label = getLabelValue(id); return (label && `export default ${JSON.stringify(label)};`) || null; }, resolveId(id) { const label = getLabelValue(id); return (label && id) || null; }, }; } exports.default = labelsPlugin; //# sourceMappingURL=rollup-plugin-salesforce-labels.js.map