From f31b3e1d99b4f81c423d23f5dc0fe3c43e32b1ea Mon Sep 17 00:00:00 2001 From: Sergey Shishkin Date: Sat, 22 Jul 2023 13:25:45 +0200 Subject: [PATCH] fix: component exports --- package-lock.json | 20 +++++++++++++++++-- packages/astro-pagefind/package.json | 6 +++++- .../astro-pagefind/src/components/Search.d.ts | 1 + .../astro-pagefind/src/components/Search.ts | 3 +++ packages/astro-pagefind/src/index.ts | 4 ---- packages/astro-pagefind/tsconfig.json | 2 +- packages/example/astro.config.ts | 4 ++++ packages/example/src/env.d.ts | 1 + packages/example/src/layouts/Main.astro | 2 +- packages/example/src/pages/search.astro | 2 +- packages/example/tsconfig.json | 3 ++- 11 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 packages/astro-pagefind/src/components/Search.d.ts create mode 100644 packages/astro-pagefind/src/components/Search.ts create mode 100644 packages/example/src/env.d.ts diff --git a/package-lock.json b/package-lock.json index 6f4f2af..e267113 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2530,7 +2530,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/dom-view-transitions/-/dom-view-transitions-1.0.1.tgz", "integrity": "sha512-A9S1ijj/4MX06I1W/6on8lhaYyq1Ir7gaOvfllW1o4RzVWW88HAeqX0pUx9VgOLnNpdiGeUW2CTkg18p5LWIrA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@types/eslint": { "version": "8.44.0", @@ -3320,6 +3321,7 @@ "resolved": "https://registry.npmjs.org/astro/-/astro-2.9.1.tgz", "integrity": "sha512-cY+ilz7zbKx21QA4LRJtE49NakkhUVh6kU9LqNMThz/Fqv1Rkz0uJBWIUJfJqpOmqnpFEW2G245gF4+bUA7aRQ==", "dev": true, + "peer": true, "dependencies": { "@astrojs/compiler": "^1.6.0", "@astrojs/internal-helpers": "^0.1.1", @@ -3474,6 +3476,7 @@ "resolved": "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz", "integrity": "sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==", "dev": true, + "peer": true, "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.1", @@ -3497,6 +3500,7 @@ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", "integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==", "dev": true, + "peer": true, "engines": { "node": ">=12.20.0" } @@ -3506,6 +3510,7 @@ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", "dev": true, + "peer": true, "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, @@ -3518,6 +3523,7 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "peer": true, "dependencies": { "yallist": "^4.0.0" }, @@ -3530,6 +3536,7 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", "dev": true, + "peer": true, "engines": { "node": ">=12" }, @@ -3542,6 +3549,7 @@ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", "dev": true, + "peer": true, "dependencies": { "path-key": "^4.0.0" }, @@ -3557,6 +3565,7 @@ "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", "dev": true, + "peer": true, "dependencies": { "mimic-fn": "^4.0.0" }, @@ -3572,6 +3581,7 @@ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", "dev": true, + "peer": true, "dependencies": { "yocto-queue": "^1.0.0" }, @@ -3587,6 +3597,7 @@ "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", "dev": true, + "peer": true, "engines": { "node": ">=12" }, @@ -3599,6 +3610,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "peer": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -3614,6 +3626,7 @@ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", "dev": true, + "peer": true, "engines": { "node": ">=12" }, @@ -3625,13 +3638,15 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/astro/node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", "dev": true, + "peer": true, "engines": { "node": ">=12.20" }, @@ -8805,6 +8820,7 @@ "resolved": "https://registry.npmjs.org/network-information-types/-/network-information-types-0.1.1.tgz", "integrity": "sha512-mLXNafJYOkiJB6IlF727YWssTRpXitR+tKSLyA5VAdBi3SOvLf5gtizHgxf241YHPWocnAO/fAhVrB/68tPHDw==", "dev": true, + "peer": true, "peerDependencies": { "typescript": ">= 3.0.0" } diff --git a/packages/astro-pagefind/package.json b/packages/astro-pagefind/package.json index ba33ce6..d14e46a 100644 --- a/packages/astro-pagefind/package.json +++ b/packages/astro-pagefind/package.json @@ -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" diff --git a/packages/astro-pagefind/src/components/Search.d.ts b/packages/astro-pagefind/src/components/Search.d.ts new file mode 100644 index 0000000..79c6b36 --- /dev/null +++ b/packages/astro-pagefind/src/components/Search.d.ts @@ -0,0 +1 @@ +export { default } from "./Search.ts"; diff --git a/packages/astro-pagefind/src/components/Search.ts b/packages/astro-pagefind/src/components/Search.ts new file mode 100644 index 0000000..8322546 --- /dev/null +++ b/packages/astro-pagefind/src/components/Search.ts @@ -0,0 +1,3 @@ +// TODO: figure out how to avoid this: +// @ts-expect-error +export { default } from "./Search.astro"; diff --git a/packages/astro-pagefind/src/index.ts b/packages/astro-pagefind/src/index.ts index 7b80926..9805d68 100644 --- a/packages/astro-pagefind/src/index.ts +++ b/packages/astro-pagefind/src/index.ts @@ -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"; diff --git a/packages/astro-pagefind/tsconfig.json b/packages/astro-pagefind/tsconfig.json index 405ec05..6e382a7 100644 --- a/packages/astro-pagefind/tsconfig.json +++ b/packages/astro-pagefind/tsconfig.json @@ -4,6 +4,6 @@ "moduleResolution": "bundler", "baseUrl": "." }, - "include": ["src/", "./*.ts", "./*.json", "./*.cjs"], + "include": ["src/", "./*.cjs"], "exclude": ["node_modules"] } diff --git a/packages/example/astro.config.ts b/packages/example/astro.config.ts index f844bfc..b87137a 100644 --- a/packages/example/astro.config.ts +++ b/packages/example/astro.config.ts @@ -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", diff --git a/packages/example/src/env.d.ts b/packages/example/src/env.d.ts new file mode 100644 index 0000000..f964fe0 --- /dev/null +++ b/packages/example/src/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/example/src/layouts/Main.astro b/packages/example/src/layouts/Main.astro index 71f611c..719a23e 100644 --- a/packages/example/src/layouts/Main.astro +++ b/packages/example/src/layouts/Main.astro @@ -1,5 +1,5 @@ --- -import { Search } from "astro-pagefind"; +import Search from "astro-pagefind/components/Search"; --- diff --git a/packages/example/src/pages/search.astro b/packages/example/src/pages/search.astro index 9c0dcd5..834d671 100644 --- a/packages/example/src/pages/search.astro +++ b/packages/example/src/pages/search.astro @@ -1,5 +1,5 @@ --- -import { Search } from "astro-pagefind"; +import Search from "astro-pagefind/components/Search"; export const prerender = false; diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.json index 8b8049d..e1c023b 100644 --- a/packages/example/tsconfig.json +++ b/packages/example/tsconfig.json @@ -2,11 +2,12 @@ "extends": "astro/tsconfigs/strictest", "compilerOptions": { "moduleResolution": "bundler", + "exactOptionalPropertyTypes": false, "baseUrl": ".", "paths": { "~/*": ["src/*"] } }, - "include": ["src/", "./*.ts"], + "include": ["src/"], "exclude": ["node_modules"] }