UNPKG

@omnia/tooling-vue

Version:

Used to bundle and serve manifests web component that build on Vue framework.

57 lines (54 loc) 2.72 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const loaderUtils = require("loader-utils"); const fx_models_1 = require("@omnia/fx-models"); const $ = tslib_1.__importStar(require("../variables")); function processManifests(manifestPaths) { $.composers.ManifestRegistry.clearState(); for (let p of manifestPaths) { $.composers.ManifestRegistry.setCurrentManifestPath(p); //ts-node will compile and execute the manifest ts, and component will reister in CompositionRegistry try { require(p); } catch (e) { console.log(e); } $.composers.ManifestRegistry.setCurrentManifestPath(); } //We need to delete the require cache for *.manifest.ts //or else the code will be cached the next time this runs Object.keys(require.cache).forEach((id) => { if (/\manifest.ts$/.test(id)) { delete require.cache[id]; } }); } function default_1(contents, context) { this.cacheable(false); const options = loaderUtils.getOptions(this); // We must run this only once, the code in the rest of the manfiests will be removed from the output bundle. if (options.manifestPaths[0] === this.resourcePath) { processManifests(options.manifestPaths); let localizeObject = $.composers.getLocalizations(); $.composers.ManifestRegistry.clearState(); return ` var OmniaContext = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["a5a89056-b5f5-475d-8518-a1f55090379d"]("97786ea9-4861-48bd-8a57-eae9bbdb4892").OmniaContext; var container = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["` + fx_models_1.OmniaResourceManifests.Fx.toString() + `"]("97786ea9-4861-48bd-8a57-eae9bbdb4892").ServiceContainer; var omniaCtx = container.createInstance(OmniaContext); var localizationStore = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["a5a89056-b5f5-475d-8518-a1f55090379d"]("5e618f4d-d014-414e-a681-89e34cbeda0f").LocalizationStore; var currentCulture = omniaCtx.language.toLowerCase(); var loc = JSON.parse('${JSON.stringify(localizeObject).replace(/'/g, "\\'").replace(/\\"/g, "\\\\\"")}'); localizationStore.instance.mutations.merge.commit(loc['en-us'] || {}); // add default english localizationStore.instance.mutations.merge.commit(loc[currentCulture] || {}); if (module.hot) { module.hot.accept(); } `; } else return ""; } exports.default = default_1; ;