Skip to content

Commit

Permalink
fix: component exports
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkin committed Jul 22, 2023
1 parent 5bcfe85 commit f31b3e1
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 11 deletions.
20 changes: 18 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: 5 additions & 1 deletion packages/astro-pagefind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./components/Search": "./src/components/Search.astro"
"./components/Search": {
"types": "./src/components/Search.d.ts",
"import": "./src/components/Search.ts",
"default": "./src/components/Search.ts"
}
},
"files": [
"src"
Expand Down
1 change: 1 addition & 0 deletions packages/astro-pagefind/src/components/Search.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Search.ts";
3 changes: 3 additions & 0 deletions packages/astro-pagefind/src/components/Search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// TODO: figure out how to avoid this:
// @ts-expect-error
export { default } from "./Search.astro";
4 changes: 0 additions & 4 deletions packages/astro-pagefind/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
import { default as pagefind } from "./pagefind.js";
export default pagefind;

// TODO: figure out how to avoid this:
// @ts-expect-error
export { default as Search } from "./components/Search.astro";
2 changes: 1 addition & 1 deletion packages/astro-pagefind/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"moduleResolution": "bundler",
"baseUrl": "."
},
"include": ["src/", "./*.ts", "./*.json", "./*.cjs"],
"include": ["src/", "./*.cjs"],
"exclude": ["node_modules"]
}
4 changes: 4 additions & 0 deletions packages/example/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import pagefind from "astro-pagefind";
import node from "@astrojs/node";

export default defineConfig({
base: "/something/",
output: "hybrid",
build: {
format: "file",
},
integrations: [pagefind()],
adapter: node({
mode: "standalone",
Expand Down
1 change: 1 addition & 0 deletions packages/example/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
2 changes: 1 addition & 1 deletion packages/example/src/layouts/Main.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { Search } from "astro-pagefind";
import Search from "astro-pagefind/components/Search";
---

<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion packages/example/src/pages/search.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { Search } from "astro-pagefind";
import Search from "astro-pagefind/components/Search";
export const prerender = false;
Expand Down
3 changes: 2 additions & 1 deletion packages/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"moduleResolution": "bundler",
"exactOptionalPropertyTypes": false,
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
}
},
"include": ["src/", "./*.ts"],
"include": ["src/"],
"exclude": ["node_modules"]
}

0 comments on commit f31b3e1

Please sign in to comment.