Skip to content

Commit

Permalink
rename to serverOnlyPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
Dudek-AMS committed Jul 21, 2024
1 parent 5ce8f2d commit 7e78a4e
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion documentation/docs/30-advanced/50-server-only-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/exports/vite/graph_analysis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? []
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/')]
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
serverProtectedPaths: [/\/private-boom\//]
serverOnlyPaths: [/\/private-boom\//]
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
};

Expand Down
6 changes: 3 additions & 3 deletions packages/kit/test/build-errors/server-only.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand All @@ -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'),
Expand Down
14 changes: 7 additions & 7 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1835,7 +1835,7 @@ declare module '@sveltejs/kit' {
export type NumericRange<TStart extends number, TEnd extends number> = Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>;
export const VERSION: string;
class HttpError_1 {

constructor(status: number, body: {
message: string;
} extends App.Error ? (App.Error | string | undefined) : App.Error);
Expand All @@ -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;
Expand Down Expand Up @@ -2187,11 +2187,11 @@ declare module '$app/server' {

declare module '$app/stores' {
export function getStores(): {

page: typeof page;

navigating: typeof navigating;

updated: typeof updated;
};
/**
Expand Down Expand Up @@ -2299,4 +2299,4 @@ declare module '$service-worker' {
export const version: string;
}

//# sourceMappingURL=index.d.ts.map
//# sourceMappingURL=index.d.ts.map

0 comments on commit 7e78a4e

Please sign in to comment.