Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3243647aa1 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/cli",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/cli.ts",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/core",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/crypto-web",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/dashboard",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/files",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/inbox-server",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/inbox",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/key-transparency",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/keychain",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/observability",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/observer",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/proto",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/recovery",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/sdk",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/server",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/storage-encrypted",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/storage-indexeddb",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/storage-postgres",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/storage-sqlite",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/streams",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/transfer",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/transport-bridge",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/transport-webrtc",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/transport",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shade/widgets",
|
||||
"version": "4.11.0",
|
||||
"version": "4.11.1",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -99,10 +99,23 @@ async function main() {
|
||||
const pkgJson = JSON.parse(originalPkgJson);
|
||||
console.log(`→ ${pkgJson.name}@${pkgJson.version}`);
|
||||
|
||||
try {
|
||||
// Phase 1 — build. Leave `main`/`types`/`exports` pointing at `src/`
|
||||
// so `tsc` can resolve cross-package `@shade/*` imports through
|
||||
// workspace source (`dist/` doesn't exist yet for sibling packages
|
||||
// when their package.json points there). We ship pre-built artefacts
|
||||
// so strict-mode consumers (Cyndr et al.) don't recompile our source.
|
||||
await $`cd ${pkgDir} && rm -rf dist && bunx tsc -p tsconfig.json`.quiet();
|
||||
|
||||
// Phase 2 — rewrite package.json for the publish surface. Swap entry
|
||||
// points to `dist/`, drop `workspace:*` for real versions, ensure
|
||||
// `files: ["dist"]` so npm pack ships only the built artefacts.
|
||||
// Restored from `originalPkgJson` in the `finally` block at the end.
|
||||
rewriteWorkspaceSpecs(pkgJson, versionByName);
|
||||
rewriteEntryPointsForDist(pkgJson);
|
||||
ensureFilesIncludesDist(pkgJson);
|
||||
writeFileSync(pkgJsonPath, `${JSON.stringify(pkgJson, null, 2)}\n`);
|
||||
|
||||
try {
|
||||
if (dryRun) {
|
||||
await $`cd ${pkgDir} && bun pm pack --dry-run`.quiet();
|
||||
} else {
|
||||
@@ -159,6 +172,55 @@ function rewriteWorkspaceSpecs(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap `src/*.ts` references in `main`, `types`, and every `exports.<subpath>`
|
||||
* entry over to `dist/*.{js,d.ts}` for the duration of the publish. The
|
||||
* in-repo `package.json` is restored from `originalPkgJson` after pack so
|
||||
* the source-pointing form survives in git.
|
||||
*
|
||||
* Why this lives at publish time instead of permanently: tooling that runs
|
||||
* before any build (`tsc --noEmit`, IDE hover, the workspace dev loop) needs
|
||||
* `main` to point at source so cross-package imports resolve without a
|
||||
* forced build pass. Shipping dist-only is a consumer-facing concern.
|
||||
*/
|
||||
function rewriteEntryPointsForDist(pkgJson: Record<string, unknown>): void {
|
||||
if (typeof pkgJson.main === 'string') {
|
||||
pkgJson.main = pkgJson.main.replace(/^src\//, 'dist/').replace(/\.ts$/, '.js');
|
||||
}
|
||||
if (typeof pkgJson.types === 'string') {
|
||||
pkgJson.types = pkgJson.types.replace(/^src\//, 'dist/').replace(/\.ts$/, '.d.ts');
|
||||
}
|
||||
if (pkgJson.exports !== undefined) {
|
||||
pkgJson.exports = mapExportsForDist(pkgJson.exports);
|
||||
}
|
||||
}
|
||||
|
||||
function mapExportsForDist(node: unknown, isTypesCondition = false): unknown {
|
||||
if (typeof node === 'string') {
|
||||
if (!node.startsWith('./src/')) return node;
|
||||
return node
|
||||
.replace(/^\.\/src\//, './dist/')
|
||||
.replace(/\.ts$/, isTypesCondition ? '.d.ts' : '.js');
|
||||
}
|
||||
if (node === null || typeof node !== 'object' || Array.isArray(node)) {
|
||||
return node;
|
||||
}
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const [key, value] of Object.entries(node as Record<string, unknown>)) {
|
||||
out[key] = mapExportsForDist(value, key === 'types' || isTypesCondition);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function ensureFilesIncludesDist(pkgJson: Record<string, unknown>): void {
|
||||
const files = pkgJson['files'];
|
||||
if (Array.isArray(files)) {
|
||||
if (!files.includes('dist')) files.push('dist');
|
||||
} else {
|
||||
pkgJson['files'] = ['dist'];
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user