UNPKG

parcel-plugin-valory

Version:
32 lines 1.22 kB
"use strict"; const path_1 = require("path"); const TSAsset = require("parcel-bundler/src/assets/TypeScriptAsset"); class ValoryBundle extends TSAsset { constructor() { super(...arguments); this.isValoryEntry = false; } async pretransform() { const config = await this.getConfig(["valory.json"]); this.isValoryEntry = (path_1.join(process.cwd(), config.sourceEntrypoint) === this.name); if (this.isValoryEntry) { this.contents = this.buildRequireBlock(config) + this.contents; } await super.pretransform(); } buildRequireBlock(config) { const dir = path_1.dirname(this.name); const absoluteCompswag = path_1.join(process.cwd(), ".compswag"); const relativeRoutes = "./generatedRoutes"; const relativeCompswag = path_1.relative(dir, absoluteCompswag); // console.log(relativeRoutes, relativeCompswag); return ` require("valory-runtime").Valory.CompileLibOverride = { generatedRoutes: require("${relativeRoutes}"), compswag: require("${relativeCompswag}") }; `; } } module.exports = ValoryBundle; //# sourceMappingURL=valoryBundle.js.map