Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Uses svelte-package instead of plain tsc.
Standalone: cd packages/tinyland-stores && pnpm build
"""

load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@tummycrypt_tinyland_stores_npm//:defs.bzl", "npm_link_all_packages")
load("@tummycrypt_tinyland_stores_npm//:vitest/package_json.bzl", vitest_bin = "bin")
load("@tummycrypt_tinyland_stores_npm//:@sveltejs/package/package_json.bzl", svelte_package = "bin")
load("@tummycrypt_tinyland_stores_npm//:svelte-check/package_json.bzl", svelte_check = "bin")

# =============================================================================
Expand Down Expand Up @@ -41,8 +40,23 @@ npm_link_package(
src = "@tummycrypt_tinyland_a11y_engine//:pkg",
)

svelte_package.svelte_package_binary(
# Self-anchoring svelte-package wrapper (TIN-1721). The raw
# svelte_package.svelte_package_binary resolved `-i src` relative to
# process.cwd(), which rules_js sets to $(BINDIR) with no chdir. That works when
# stores is the ROOT package (standalone `bazel build //:pkg`, src at
# $(BINDIR)/src) but breaks when stores is an EXTERNAL registry module under RBE
# (src lands at $(BINDIR)/external/<repo>+/src while cwd stays $(BINDIR), so
# `-i src` misses). build-svelte.mjs chdir's to its own copied-to-bin package dir
# (import.meta.url) before delegating to @sveltejs/package, so `-i src` / `-o dist`
# resolve correctly in both layouts.
js_binary(
name = "svelte_package",
entry_point = "build-svelte.mjs",
data = [
":node_modules/@sveltejs/package",
":node_modules/typescript",
":node_modules/svelte",
],
visibility = ["//visibility:public"],
)

Expand Down Expand Up @@ -110,7 +124,7 @@ npm_package(
":tinyland_stores",
],
package = "@tummycrypt/tinyland-stores",
version = "0.3.0",
version = "0.3.1",
visibility = ["//visibility:public"],
)

Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module(
name = "tummycrypt_tinyland_stores",
version = "0.3.0",
version = "0.3.1",
compatibility_level = 1,
)

Expand Down
16 changes: 16 additions & 0 deletions build-svelte.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node
// Anchor cwd to THIS script's package dir so `-i src` / `-o dist` resolve whether
// this module is built standalone (root pkg) or as an external Bazel registry dep
// (bin/external/<repo>/) under RBE. import.meta.url points at the copied-to-bin
// location alongside src/, package.json, dist/.
import { register, createRequire } from 'node:module';
import { pathToFileURL, fileURLToPath } from 'node:url';
import { join, dirname } from 'node:path';
process.chdir(dirname(fileURLToPath(import.meta.url)));
const require = createRequire(import.meta.url);
const tsUrl = pathToFileURL(require.resolve('typescript/lib/typescript.js')).href;
register('data:text/javascript,' + encodeURIComponent(
`export function resolve(s,c,n){if(s==='typescript')return{url:'${tsUrl}',shortCircuit:true};return n(s,c);}`
));
const pkgDir = dirname(require.resolve('@sveltejs/package/package.json'));
await import(pathToFileURL(join(pkgDir, 'svelte-package.js')).href);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tummycrypt/tinyland-stores",
"version": "0.3.0",
"version": "0.3.1",
"description": "Svelte 5 reactive stores for authentication, theming, CSRF, observability, and accessibility state management",
"type": "module",
"license": "Zlib AND LicenseRef-Tinyland-Proprietary",
Expand Down
Loading