From 7d5fb3083a428c4b045d7845138efdb40e1ebad8 Mon Sep 17 00:00:00 2001 From: Adam Coster <28758057+adam-coster@users.noreply.github.com> Date: Mon, 30 May 2022 07:56:47 -0500 Subject: [PATCH] Update adapter entrypoint typings to be NodeNext/ESNext-compatible. (#5111) * update adapter entrypoint typings to be NodeNext-compatible (closes #5110) * Create lemon-timers-deliver.md * Update lemon-timers-deliver.md Co-authored-by: Rich Harris --- .changeset/lemon-timers-deliver.md | 11 +++++++++++ packages/adapter-auto/index.d.ts | 3 +-- packages/adapter-auto/index.js | 2 +- packages/adapter-cloudflare-workers/index.d.ts | 3 +-- packages/adapter-cloudflare-workers/index.js | 2 +- packages/adapter-cloudflare/index.d.ts | 3 +-- packages/adapter-cloudflare/index.js | 2 +- packages/adapter-netlify/index.d.ts | 4 +--- packages/adapter-netlify/index.js | 2 +- packages/adapter-node/index.d.ts | 3 +-- packages/adapter-node/index.js | 2 +- packages/adapter-static/index.d.ts | 3 +-- packages/adapter-static/index.js | 2 +- packages/adapter-vercel/index.d.ts | 3 +-- packages/adapter-vercel/index.js | 2 +- 15 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 .changeset/lemon-timers-deliver.md diff --git a/.changeset/lemon-timers-deliver.md b/.changeset/lemon-timers-deliver.md new file mode 100644 index 000000000000..14ed6fc11069 --- /dev/null +++ b/.changeset/lemon-timers-deliver.md @@ -0,0 +1,11 @@ +--- +"@sveltejs/adapter-auto": patch +"@sveltejs/adapter-cloudflare-workers": patch +"@sveltejs/adapter-cloudflare": patch +"@sveltejs/adapter-netlify": patch +"@sveltejs/adapter-node": patch +"@sveltejs/adapter-static": patch +"@sveltejs/adapter-vercel": patch +--- + +Update adapter entrypoint typings to be NodeNext/ESNext-compatible diff --git a/packages/adapter-auto/index.d.ts b/packages/adapter-auto/index.d.ts index 62aee0f1eaa9..90af12a05cc1 100644 --- a/packages/adapter-auto/index.d.ts +++ b/packages/adapter-auto/index.d.ts @@ -1,4 +1,3 @@ import { Adapter } from '@sveltejs/kit'; -declare function plugin(): Adapter; -export = plugin; +export default function plugin(): Adapter; diff --git a/packages/adapter-auto/index.js b/packages/adapter-auto/index.js index 00fd70751890..3278347a6dd5 100644 --- a/packages/adapter-auto/index.js +++ b/packages/adapter-auto/index.js @@ -1,6 +1,6 @@ import { adapters } from './adapters.js'; -/** @type {import('./index')} */ +/** @type {import('./index').default} */ let fn; for (const candidate of adapters) { diff --git a/packages/adapter-cloudflare-workers/index.d.ts b/packages/adapter-cloudflare-workers/index.d.ts index 62aee0f1eaa9..90af12a05cc1 100644 --- a/packages/adapter-cloudflare-workers/index.d.ts +++ b/packages/adapter-cloudflare-workers/index.d.ts @@ -1,4 +1,3 @@ import { Adapter } from '@sveltejs/kit'; -declare function plugin(): Adapter; -export = plugin; +export default function plugin(): Adapter; diff --git a/packages/adapter-cloudflare-workers/index.js b/packages/adapter-cloudflare-workers/index.js index 6257c75f9909..cb822fdad067 100644 --- a/packages/adapter-cloudflare-workers/index.js +++ b/packages/adapter-cloudflare-workers/index.js @@ -14,7 +14,7 @@ import { fileURLToPath } from 'url'; * }} WranglerConfig */ -/** @type {import('.')} */ +/** @type {import('.').default} */ export default function (options = {}) { return { name: '@sveltejs/adapter-cloudflare-workers', diff --git a/packages/adapter-cloudflare/index.d.ts b/packages/adapter-cloudflare/index.d.ts index 62aee0f1eaa9..90af12a05cc1 100644 --- a/packages/adapter-cloudflare/index.d.ts +++ b/packages/adapter-cloudflare/index.d.ts @@ -1,4 +1,3 @@ import { Adapter } from '@sveltejs/kit'; -declare function plugin(): Adapter; -export = plugin; +export default function plugin(): Adapter; diff --git a/packages/adapter-cloudflare/index.js b/packages/adapter-cloudflare/index.js index d79e65807257..134d6c29690b 100644 --- a/packages/adapter-cloudflare/index.js +++ b/packages/adapter-cloudflare/index.js @@ -3,7 +3,7 @@ import { posix } from 'path'; import { fileURLToPath } from 'url'; import * as esbuild from 'esbuild'; -/** @type {import('.')} */ +/** @type {import('.').default} */ export default function (options = {}) { return { name: '@sveltejs/adapter-cloudflare', diff --git a/packages/adapter-netlify/index.d.ts b/packages/adapter-netlify/index.d.ts index df05aec1d7b1..6bdc8db882dc 100644 --- a/packages/adapter-netlify/index.d.ts +++ b/packages/adapter-netlify/index.d.ts @@ -1,5 +1,3 @@ import { Adapter } from '@sveltejs/kit'; -declare function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter; - -export = plugin; +export default function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter; diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js index 774db538a5eb..5d372ffe7eb4 100644 --- a/packages/adapter-netlify/index.js +++ b/packages/adapter-netlify/index.js @@ -34,7 +34,7 @@ const edge_set_in_env_var = process.env.NETLIFY_SVELTEKIT_USE_EDGE === 'true' || process.env.NETLIFY_SVELTEKIT_USE_EDGE === '1'; -/** @type {import('.')} */ +/** @type {import('.').default} */ export default function ({ split = false, edge = edge_set_in_env_var } = {}) { return { name: '@sveltejs/adapter-netlify', diff --git a/packages/adapter-node/index.d.ts b/packages/adapter-node/index.d.ts index 09411ffabb98..2252dfde937c 100644 --- a/packages/adapter-node/index.d.ts +++ b/packages/adapter-node/index.d.ts @@ -10,5 +10,4 @@ interface AdapterOptions { envPrefix?: string; } -declare function plugin(options?: AdapterOptions): Adapter; -export = plugin; +export default function plugin(options?: AdapterOptions): Adapter; diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 3eb6038a11cf..baccdcbb2a6c 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -9,7 +9,7 @@ const pipe = promisify(pipeline); const files = fileURLToPath(new URL('./files', import.meta.url).href); -/** @type {import('.')} */ +/** @type {import('.').default} */ export default function (opts = {}) { // TODO remove for 1.0 // @ts-expect-error diff --git a/packages/adapter-static/index.d.ts b/packages/adapter-static/index.d.ts index 0611ec0b776c..c105d33484ef 100644 --- a/packages/adapter-static/index.d.ts +++ b/packages/adapter-static/index.d.ts @@ -7,5 +7,4 @@ interface AdapterOptions { precompress?: boolean; } -declare function plugin(options?: AdapterOptions): Adapter; -export = plugin; +export default function plugin(options?: AdapterOptions): Adapter; diff --git a/packages/adapter-static/index.js b/packages/adapter-static/index.js index cb5a05d1d780..f846ea81b331 100644 --- a/packages/adapter-static/index.js +++ b/packages/adapter-static/index.js @@ -6,7 +6,7 @@ import zlib from 'zlib'; const pipe = promisify(pipeline); -/** @type {import('.')} */ +/** @type {import('.').default} */ export default function ({ pages = 'build', assets = pages, fallback, precompress = false } = {}) { return { name: '@sveltejs/adapter-static', diff --git a/packages/adapter-vercel/index.d.ts b/packages/adapter-vercel/index.d.ts index 1566ac142b82..49e4f9661985 100644 --- a/packages/adapter-vercel/index.d.ts +++ b/packages/adapter-vercel/index.d.ts @@ -6,5 +6,4 @@ type Options = { split?: boolean; }; -declare function plugin(options?: Options): Adapter; -export = plugin; +export default function plugin(options?: Options): Adapter; diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index 23e0070736c7..ea8a6fac8e8b 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -83,7 +83,7 @@ const redirects = { const files = fileURLToPath(new URL('./files', import.meta.url).href); -/** @type {import('.')} **/ +/** @type {import('.').default} **/ export default function ({ external = [], edge, split } = {}) { return { name: '@sveltejs/adapter-vercel',