diff --git a/tools/src/main/js/bundler/bundle-schemas.js b/tools/src/main/js/bundler/bundle-schemas.js index 4e947307..9143c2b4 100644 --- a/tools/src/main/js/bundler/bundle-schemas.js +++ b/tools/src/main/js/bundler/bundle-schemas.js @@ -342,9 +342,13 @@ async function bundleSchemas(modelsDirectory, rootSchemaPath, options = {}) { } } + // Write bundled (pretty) version console.log('\nWriting bundled schema...'); - const prettyJson = JSON.stringify(finalSchema, null, 2); + const prettyJson = JSON.stringify({ + ...finalSchema, + "$id": new URL(bundledFilename, finalSchema['$id']).toString() + }, null, 2); await fs.writeFile(bundledPath, prettyJson); const bundledStats = await fs.stat(bundledPath); const bundledSizeKB = (bundledStats.size / 1024).toFixed(2); @@ -353,7 +357,10 @@ async function bundleSchemas(modelsDirectory, rootSchemaPath, options = {}) { // Write minified version console.log('Writing minified schema...'); const minifiedSchema = removeComments(finalSchema, true); - const minifiedJson = JSON.stringify(minifiedSchema); + const minifiedJson = JSON.stringify({ + ...minifiedSchema, + "$id": new URL(minifiedFilename, finalSchema['$id']).toString() + }); // Verify it's a single line const lineCount = minifiedJson.split('\n').length; @@ -397,4 +404,4 @@ if (require.main === module) { .catch(err => process.exit(1)); } -module.exports = { bundleSchemas }; \ No newline at end of file +module.exports = { bundleSchemas };