Skip to content

Commit

Permalink
Add back the stuff for the source build.
Browse files Browse the repository at this point in the history
This was done manually because I believe 12.2 was on a branch that never had it.
  • Loading branch information
aboodman committed Dec 8, 2023
1 parent a08e115 commit bb0607d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "replicache",
"name": "@rocicorp/replicache",
"description": "Realtime sync for any backend stack",
"version": "12.2.2",
"repository": "github:rocicorp/replicache",
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion tool/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -53,6 +54,7 @@ async function buildReplicache(options) {
outfile: 'out/replicache.' + ext,
entryPoints: ['src/mod.ts'],
define: await makeDefine(mode, dd31),
sourcemap: true,
});
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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()]);
Expand Down
18 changes: 18 additions & 0 deletions tool/read-package-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @ts-check

import {readFile} from 'fs/promises';

/**
* @typedef {{
* [key: string]: any;
* name: string;
* version: string;
* }} PackageJSON
*/

/** @returns {Promise<PackageJSON>} */
export async function readPackageJSON() {
const url = new URL('../package.json', import.meta.url);
const s = await readFile(url, 'utf-8');
return JSON.parse(s);
}

0 comments on commit bb0607d

Please sign in to comment.