From bb0607d70e7a6825664c82c51e114c6297589e39 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Tue, 28 Nov 2023 13:57:14 -1000 Subject: [PATCH] Add back the stuff for the source build. This was done manually because I believe 12.2 was on a branch that never had it. --- package-lock.json | 4 ++-- package.json | 6 ++++-- tool/build.js | 9 ++++++++- tool/read-package-json.js | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 tool/read-package-json.js diff --git a/package-lock.json b/package-lock.json index e256b7b22c..491814fff3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "replicache", + "name": "@rocicorp/replicache", "version": "12.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "replicache", + "name": "@rocicorp/replicache", "version": "12.2.2", "license": "https://roci.dev/terms.html", "bin": { diff --git a/package.json b/package.json index 278ad01138..9048f4ae89 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "replicache", + "name": "@rocicorp/replicache", "description": "Realtime sync for any backend stack", "version": "12.2.2", "repository": "github:rocicorp/replicache", @@ -73,7 +73,9 @@ "out/cli.js", "out/replicache.d.ts", "out/replicache.cjs", - "out/replicache.js" + "out/replicache.cjs.map", + "out/replicache.js", + "out/replicache.js.map" ], "eslintConfig": { "extends": "@rocicorp/eslint-config" diff --git a/tool/build.js b/tool/build.js index e4cde03941..5ec28a3a63 100644 --- a/tool/build.js +++ b/tool/build.js @@ -2,6 +2,7 @@ import * as esbuild from 'esbuild'; import {makeDefine} from './make-define.js'; +import {readPackageJSON} from './read-package-json.js'; const forBundleSizeDashboard = process.argv.includes('--bundle-sizes'); const perf = process.argv.includes('--perf'); @@ -53,6 +54,7 @@ async function buildReplicache(options) { outfile: 'out/replicache.' + ext, entryPoints: ['src/mod.ts'], define: await makeDefine(mode, dd31), + sourcemap: true, }); } @@ -81,6 +83,11 @@ async function buildCLI() { }); } +async function isRocicorpPackage() { + const packageJSON = await readPackageJSON(); + return packageJSON.name.startsWith('@rocicorp/'); +} + if (perf) { await buildMJS({mode: 'release'}); } else if (forBundleSizeDashboard) { @@ -94,7 +101,7 @@ if (perf) { ]); } else { let opts = {}; - if (debug) { + if (debug || (await isRocicorpPackage())) { opts = {minify: false}; } await Promise.all([buildMJS(opts), buildCJS(opts), buildCLI()]); diff --git a/tool/read-package-json.js b/tool/read-package-json.js new file mode 100644 index 0000000000..0c199bc5ca --- /dev/null +++ b/tool/read-package-json.js @@ -0,0 +1,18 @@ +// @ts-check + +import {readFile} from 'fs/promises'; + +/** + * @typedef {{ + * [key: string]: any; + * name: string; + * version: string; + * }} PackageJSON + */ + +/** @returns {Promise} */ +export async function readPackageJSON() { + const url = new URL('../package.json', import.meta.url); + const s = await readFile(url, 'utf-8'); + return JSON.parse(s); +}