Skip to content

Commit

Permalink
fix: exports and config (#83)
Browse files Browse the repository at this point in the history
* fix: clean up types and add module declarations

* fix: update lockfile

* fix: add prerelease support

* chore(release): 2.0.1-beta.1 [skip ci]

* fix: include declaration files in build

* chore(release): 2.0.1-beta.2 [skip ci]

* fix: more typing

* chore(release): 2.0.1-beta.3 [skip ci]

* remove tsconfig

* chore: tidy up

* fix: include module declaration in dist

* chore(release): 2.0.1-beta.4 [skip ci]

* fix: use referenece path to include module

* chore(release): 2.0.1-beta.5 [skip ci]

* fix: export types

* chore(release): 2.0.1-beta.6 [skip ci]

* fix: use named export

* fix: clean up type files

* chore: import order

* chore: move to src

* chore: adjust to new src folder

* fix: simplify example

* chore(release): 2.0.1-beta.7 [skip ci]

* fix: use mjs for esm

* fix: use named export

* chore(release): 2.0.1-beta.8 [skip ci]

* fix: rename plugin

* fix: trying different config

* chore(release): 2.0.1-beta.9 [skip ci]

* manually copy the dts

* fix: add client as peerdep

* chore(release): 2.0.1-beta.10 [skip ci]

* fix: remove dts from files

* chore(release): 2.0.1-beta.11 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.12 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.13 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.14 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.15 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.16 [skip ci]

* fix: config fix

* chore(release): 2.0.1-beta.17 [skip ci]

* fix: try including dts in chain

* chore(release): 2.0.1-beta.18 [skip ci]

* chore: add jsx to tsconfig

* fix: add @types

* chore(release): 2.0.1-beta.19 [skip ci]

* Revert "chore: add jsx to tsconfig"

This reverts commit 4e8e8e8.

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.20 [skip ci]

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.21 [skip ci]

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.22 [skip ci]

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.23 [skip ci]

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.24 [skip ci]

* fix: try env.d.ts strategy

* chore(release): 2.0.1-beta.25 [skip ci]

* fix: finalize env.d.ts strategy

* fix: fix exports

* chore(release): 2.0.1-beta.26 [skip ci]

* chore(release): 2.0.1-beta.26 [skip ci]

* chore: update config

* update config

* chore: update lock file

* fix: use named export

---------

Co-authored-by: semantic-release-bot <[email protected]>
  • Loading branch information
kmelve and semantic-release-bot authored Oct 12, 2023
1 parent bbb9f2c commit 48ab268
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion apps/example-ssr/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sanityIntegration from '@sanity/astro'
import { sanityIntegration } from '@sanity/astro'
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel/serverless';
import react from '@astrojs/react';
Expand Down
2 changes: 1 addition & 1 deletion apps/example/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sanityIntegration from "@sanity/astro";
import { sanityIntegration } from "@sanity/astro";
import { defineConfig } from "astro/config";
import react from '@astrojs/react';
import vercel from '@astrojs/vercel/serverless';
Expand Down
16 changes: 12 additions & 4 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions packages/sanity-astro/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ All notable changes to this project will be documented in this file. See

## [2.1.1](https://github.com/sanity-io/sanity-astro/compare/v2.1.0...v2.1.1) (2023-10-04)


### Bug Fixes

* **ci:** replace semantic-release with release-please ([fe20b74](https://github.com/sanity-io/sanity-astro/commit/fe20b7410b7f5837fad041b78b09a35229e95f51))
- **ci:** replace semantic-release with release-please ([fe20b74](https://github.com/sanity-io/sanity-astro/commit/fe20b7410b7f5837fad041b78b09a35229e95f51))

## [2.1.0](https://github.com/sanity-io/sanity-astro/compare/v2.0.0...v2.1.0) (2023-10-03)

Expand Down
13 changes: 6 additions & 7 deletions packages/sanity-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
},
"files": [
"dist",
"src/studio",
"module.d.ts"
],
"type": "module",
"main": "./dist/sanity-astro.mjs",
"module": "./dist/sanity-astro.js",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"module": "./dist/sanity-astro.mjs",
"module": "./dist/sanity-astro.js",
"default": "./dist/sanity-astro.mjs"
},
"./module": "./module.d.ts",
"./studio/studio-route.astro": "./dist/studio/studio-route.astro",
"./studio/studio-component": {
"types": "./dist/types/studio/studio-component.d.ts",
"module": "./dist/studio/studio-component.tsx",
"default": "./dist/studio/studio-component.tsx"
"./studio/studio-component.tsx": {
"types": "./src/studio/studio-component.tsx",
"default": "./src/studio/studio-component.tsx"
}
},
"types": "./dist/types/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/sanity-astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../module.d.ts" />
8 changes: 4 additions & 4 deletions packages/sanity-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { vitePluginSanityClient } from "./vite-plugin-sanity-client";
import { vitePluginSanityStudio } from "./vite-plugin-sanity-studio";
import type { ClientConfig } from "@sanity/client";

export type IntegrationOptions = ClientConfig & {
type IntegrationOptions = ClientConfig & {
studioBasePath?: string;
};

const defaultOptions: IntegrationOptions = {
apiVersion: "v2023-08-24",
};

export default function sanityIntegration(
options: IntegrationOptions,
export function sanityIntegration(
options: IntegrationOptions
): AstroIntegration {
const resolvedOptions = {
...defaultOptions,
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function sanityIntegration(
`
import { sanityClient } from "sanity:client";
globalThis.sanityClient = sanityClient;
`,
`
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity-astro/src/studio/studio-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Studio } from "sanity";

if (!config) {
throw new Error(
"[@sanity/astro]: Can't load Sanity Studio. Check that you've configured it in `sanity.config.js|ts`.",
"[@sanity/astro]: Can't load Sanity Studio. Check that you've configured it in `sanity.config.js|ts`."
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/sanity-astro/src/studio/studio-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import StudioRoute from "./studio-route.astro";
export default StudioRoute;
12 changes: 7 additions & 5 deletions packages/sanity-astro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"extends": "astro/tsconfigs/base",
"$schema": "https://json.schemastore.org/tsconfig",
"include": ["src/**/*"],
"exclude": ["node_modules/*", "./vite*.ts", "dist", "studio"],
"include": ["./*.astro", "./**/*.ts"],
"exclude": ["node_modules/*", "./vite*.ts", "dist"],
"compilerOptions": {
"skipLibCheck": true,
// Enable top-level await, and other modern ESM features.
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"baseUrl": "src",
"outDir": "./dist",
"declaration": true,
"declarationDir": "./dist",
"jsx": "preserve"
}
}
}
2 changes: 1 addition & 1 deletion packages/sanity-astro/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig(() => {
build: {
lib: {
entry: [path.resolve(__dirname, "src/index.ts")],
name: "sanityAstro",
name,
fileName: (format) => (format === "es" ? `${name}.mjs` : `${name}.js`),
},
},
Expand Down

0 comments on commit 48ab268

Please sign in to comment.