diff --git a/documentation/docs/30-advanced/50-server-only-modules.md b/documentation/docs/30-advanced/50-server-only-modules.md index 339eea6ebe64..d15c724225ed 100644 --- a/documentation/docs/30-advanced/50-server-only-modules.md +++ b/documentation/docs/30-advanced/50-server-only-modules.md @@ -25,7 +25,7 @@ You can make your own modules server-only in three ways: const config = { ..., kit: { - serverProtectedPaths: [ + serverOnlyPaths: [ '/home/user/app/src/lib/components/server', /\/server\//, (path) => path.includes('/server/') diff --git a/packages/kit/src/core/config/options.js b/packages/kit/src/core/config/options.js index 72dc34ac672c..bf7537270eb1 100644 --- a/packages/kit/src/core/config/options.js +++ b/packages/kit/src/core/config/options.js @@ -258,7 +258,7 @@ const options = object( }) }), - serverProtectedPaths: validate([], (input, keypath) => { + serverOnlyPaths: validate([], (input, keypath) => { if (!Array.isArray(input)) { throw new Error(`${keypath} must be an array of strings, regexp or functions`); } diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 0fe0d03d206c..e6166b20ff80 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -611,7 +611,7 @@ export interface KitConfig { * Items must be type of string, RegExp or a function that takes the filename and returns a boolean. If the function returns true, the file must not be imported to client side code. * @default [] */ - serverProtectedPaths?: (string | RegExp | ((id: string) => boolean | undefined))[]; + serverOnlyPaths?: (string | RegExp | ((id: string) => boolean | undefined))[]; serviceWorker?: { /** * Whether to automatically register the service worker, if it exists. diff --git a/packages/kit/src/exports/vite/graph_analysis/index.js b/packages/kit/src/exports/vite/graph_analysis/index.js index c680022cf5ac..c7f625296939 100644 --- a/packages/kit/src/exports/vite/graph_analysis/index.js +++ b/packages/kit/src/exports/vite/graph_analysis/index.js @@ -49,7 +49,7 @@ export function module_guard(context, { cwd, lib }) { cwd: posixify(cwd), node_modules: posixify(path.join(cwd, 'node_modules')), server: posixify(path.join(lib, 'server')), - svelte_config: svelte_config.kit.serverProtectedPaths ?? [] + svelte_config: svelte_config.kit.serverOnlyPaths ?? [] }; /** diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 0e220a7d237e..0f0e09a9c96f 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -394,7 +394,7 @@ async function kit({ svelte_config }) { cwd: normalized_cwd, node_modules: vite.normalizePath(path.resolve('node_modules')), server: vite.normalizePath(path.join(normalized_lib, 'server')), - svelte_config: svelte_config.kit.serverProtectedPaths ?? [] + svelte_config: svelte_config.kit.serverOnlyPaths ?? [] }) ) { const relative = normalize_id(id, normalized_lib, normalized_cwd); diff --git a/packages/kit/test/build-errors/apps/server-only-module-config-function/svelte.config.js b/packages/kit/test/build-errors/apps/server-only-module-config-function/svelte.config.js index 8b149c3320b1..201e90981c56 100644 --- a/packages/kit/test/build-errors/apps/server-only-module-config-function/svelte.config.js +++ b/packages/kit/test/build-errors/apps/server-only-module-config-function/svelte.config.js @@ -7,7 +7,7 @@ const __dirname = path.dirname(__filename); /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { - serverProtectedPaths: [() => undefined, (filename) => filename.includes('/private-boom/')] + serverOnlyPaths: [() => undefined, (filename) => filename.includes('/private-boom/')] } }; diff --git a/packages/kit/test/build-errors/apps/server-only-module-config-regexp/svelte.config.js b/packages/kit/test/build-errors/apps/server-only-module-config-regexp/svelte.config.js index 1664be137211..3e4cd00800b2 100644 --- a/packages/kit/test/build-errors/apps/server-only-module-config-regexp/svelte.config.js +++ b/packages/kit/test/build-errors/apps/server-only-module-config-regexp/svelte.config.js @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'; /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { - serverProtectedPaths: [/\/private-boom\//] + serverOnlyPaths: [/\/private-boom\//] } }; diff --git a/packages/kit/test/build-errors/apps/server-only-module-config-string/svelte.config.js b/packages/kit/test/build-errors/apps/server-only-module-config-string/svelte.config.js index 857f31b97a9d..e8c44923a726 100644 --- a/packages/kit/test/build-errors/apps/server-only-module-config-string/svelte.config.js +++ b/packages/kit/test/build-errors/apps/server-only-module-config-string/svelte.config.js @@ -7,7 +7,7 @@ const __dirname = path.dirname(__filename); /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { - serverProtectedPaths: [__dirname + '/src/private-boom'] + serverOnlyPaths: [__dirname + '/src/private-boom'] } }; diff --git a/packages/kit/test/build-errors/server-only.spec.js b/packages/kit/test/build-errors/server-only.spec.js index 278806aa9d6a..65f680230a6f 100644 --- a/packages/kit/test/build-errors/server-only.spec.js +++ b/packages/kit/test/build-errors/server-only.spec.js @@ -70,7 +70,7 @@ test('$lib/server/* is not dynamically importable from the client', () => { throw new Error(); }); -test('serverProtectedPaths string is not importable from the client', () => { +test('serverOnlyPaths string is not importable from the client', () => { try { execSync('pnpm build', { cwd: path.join(process.cwd(), 'apps/server-only-module-config-string'), @@ -87,7 +87,7 @@ test('serverProtectedPaths string is not importable from the client', () => { throw new Error(); }); -test('serverProtectedPaths RegExp is not importable from the client', () => { +test('serverOnlyPaths RegExp is not importable from the client', () => { try { execSync('pnpm build', { cwd: path.join(process.cwd(), 'apps/server-only-module-config-regexp'), @@ -104,7 +104,7 @@ test('serverProtectedPaths RegExp is not importable from the client', () => { throw new Error(); }); -test('serverProtectedPaths function is not importable from the client', () => { +test('serverOnlyPaths function is not importable from the client', () => { try { execSync('pnpm build', { cwd: path.join(process.cwd(), 'apps/server-only-module-config-function'), diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 9a10f9cd6fe4..08b53dfdab74 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -593,7 +593,7 @@ declare module '@sveltejs/kit' { * Items must be type of string, RegExp or a function that takes the filename and returns a boolean. If the function returns true, the file must not be imported to client side code. * @default [] */ - serverProtectedPaths?: (string|RegExp|((id:string)=>boolean|undefined))[]; + serverOnlyPaths?: (string|RegExp|((id:string)=>boolean|undefined))[]; serviceWorker?: { /** * Whether to automatically register the service worker, if it exists. @@ -1835,7 +1835,7 @@ declare module '@sveltejs/kit' { export type NumericRange = Exclude, LessThan>; export const VERSION: string; class HttpError_1 { - + constructor(status: number, body: { message: string; } extends App.Error ? (App.Error | string | undefined) : App.Error); @@ -1844,7 +1844,7 @@ declare module '@sveltejs/kit' { toString(): string; } class Redirect_1 { - + constructor(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, location: string); status: 301 | 302 | 303 | 307 | 308 | 300 | 304 | 305 | 306; location: string; @@ -2187,11 +2187,11 @@ declare module '$app/server' { declare module '$app/stores' { export function getStores(): { - + page: typeof page; - + navigating: typeof navigating; - + updated: typeof updated; }; /** @@ -2299,4 +2299,4 @@ declare module '$service-worker' { export const version: string; } -//# sourceMappingURL=index.d.ts.map \ No newline at end of file +//# sourceMappingURL=index.d.ts.map