Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
dist
dist-ssr
*.local
coverage
coverage
.vitest/
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ For GitHub Actions, consider using [`voidzero-dev/setup-vp`](https://github.com/

- [ ] Run `vp install` after pulling remote changes and before getting started.
- [ ] Run `vp check` and `vp test` to validate changes.

<!--VITE PLUS END-->
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ To access a service in your components or other services, you can use the `useSe

```jsx
import { useService } from "solid-services";

import AuthService from "./services/auth";

export default function LogoutComponent() {
Expand Down Expand Up @@ -123,6 +124,7 @@ For example, to expose a specific service to a sub-registry, you can set the `ex

```jsx
import { ServiceRegistry } from "solid-services";

import AuthService from "./services/auth";

export default function App() {
Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/solid-services.js",
"require": "./dist/solid-services.cjs"
"import": {
"types": "./dist/types/index.d.ts",
"default": "./dist/solid-services.js"
},
"require": {
"types": "./dist/types/index.d.cts",
"default": "./dist/solid-services.cjs"
}
}
},
"publishConfig": {
Expand All @@ -47,7 +52,8 @@
"@solid-primitives/rootless": "^1.5.3"
},
"devDependencies": {
"@vitest/ui": "^4.1.4",
"@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:",
"release-it": "^19.2.4",
"solid-js": "^1.9.12",
"typescript": "^6.0.2",
Expand Down
1,598 changes: 1,146 additions & 452 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
catalog:
vite: npm:@voidzero-dev/vite-plus-core@latest
vitest: npm:@voidzero-dev/vite-plus-test@latest
vite-plus: latest
vite: npm:@voidzero-dev/vite-plus-core@1.1.0
vitest: 5.0.3
vite-plus: 1.1.0
"@vitest/ui": 5.0.3
"@vitest/coverage-v8": 5.0.3
overrides:
vite: "catalog:"
vitest: "catalog:"
vite@*: "catalog:"
vitest@*: "catalog:"
peerDependencyRules:
allowAny:
- vite
Expand Down
10 changes: 7 additions & 3 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createContext, createComponent, useContext, type FlowComponent } from "solid-js";
import { createContext, createComponent, useContext } from "solid-js";

import { createRegistry, type ServiceInitializer } from "#src/registry.ts";
import type { Registry } from "#src/registry.ts";
Expand All @@ -23,7 +23,9 @@ export type RegistryProviderProps = {
* Prefer using {@link useRegistry} or {@link ServiceRegistry} over reading
* this context directly.
*/
export const ServiceRegistryContext = createContext<Registry>();
export const ServiceRegistryContext: import("solid-js", {
with: { "resolution-mode": "import" },
}).Context<Registry | undefined> = createContext<Registry>();

/**
* Provider component that creates a new {@link Registry} and makes it
Expand All @@ -32,7 +34,9 @@ export const ServiceRegistryContext = createContext<Registry>();
* Wrap your application (or a subtree) with this component to scope
* services to that part of the tree.
*/
export const ServiceRegistry: FlowComponent<RegistryProviderProps> = (props) => {
export const ServiceRegistry: import("solid-js", {
with: { "resolution-mode": "import" },
}).FlowComponent<RegistryProviderProps> = (props) => {
let registry: Registry | undefined;

return createComponent(ServiceRegistryContext.Provider, {
Expand Down
13 changes: 13 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ export default defineConfig({
fmt: { sortImports: {}, sortPackageJson: {} },
lint: { options: { typeAware: true, typeCheck: true } },
pack: {
entry: ["src/index.ts"],
format: ["esm", "cjs"],
outputOptions: (options, format) => ({
...options,
entryFileNames: (chunk) =>
chunk.name.endsWith(".d")
? `types/index.d.${format === "es" ? "ts" : "cts"}`
: `solid-services.${format === "es" ? "js" : "cjs"}`,
}),
deps: {
// rootless only exports an ESM entry; bundle it for CommonJS consumers.
alwaysBundle: ["@solid-primitives/rootless"],
},
sourcemap: true,
},
resolve: {
Expand Down