Skip to content

Commit 1c83fdf

Browse files
Rich-Harrisjycouet
andauthored
chore: simplify runes option (#1039)
Co-authored-by: jycouet <jycouet@gmail.com>
1 parent 916f9b7 commit 1c83fdf

5 files changed

Lines changed: 13 additions & 36 deletions

File tree

.changeset/lucky-dragons-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
chore: simplify `runes` option

packages/sv/src/cli/tests/snapshots/create-only/svelte.config.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import adapter from '@sveltejs/adapter-auto';
2-
import { relative, sep } from 'node:path';
32

43
/** @type {import('@sveltejs/kit').Config} */
54
const config = {
65
compilerOptions: {
7-
// defaults to rune mode for the project, except for `node_modules`. Can be removed in svelte 6.
8-
runes: ({ filename }) => {
9-
const relativePath = relative(import.meta.dirname, filename);
10-
const pathSegments = relativePath.toLowerCase().split(sep);
11-
const isExternalLibrary = pathSegments.includes('node_modules');
12-
13-
return isExternalLibrary ? undefined : true;
14-
}
6+
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
7+
runes: ({ filename }) => (filename.split(/[/\\]/).includes('node_modules') ? undefined : true)
158
},
169
kit: {
1710
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.

packages/sv/src/cli/tests/snapshots/create-with-all-addons/svelte.config.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { mdsvex } from 'mdsvex';
22
import adapter from '@sveltejs/adapter-node';
3-
import { relative, sep } from 'node:path';
43

54
/** @type {import('@sveltejs/kit').Config} */
65
const config = {
76
compilerOptions: {
8-
// defaults to rune mode for the project, except for `node_modules`. Can be removed in svelte 6.
9-
runes: ({ filename }) => {
10-
const relativePath = relative(import.meta.dirname, filename);
11-
const pathSegments = relativePath.toLowerCase().split(sep);
12-
const isExternalLibrary = pathSegments.includes('node_modules');
13-
14-
return isExternalLibrary ? undefined : true;
15-
}
7+
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
8+
runes: ({ filename }) => filename.split(/[/\\]/).includes('node_modules') ? undefined : true
169
},
1710
kit: { adapter: adapter() },
1811
preprocess: [mdsvex({ extensions: ['.svx', '.md'] })],

packages/sv/src/create/shared/+typescript/svelte.config.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import adapter from '@sveltejs/adapter-auto';
2-
import { relative, sep } from 'node:path';
32

43
/** @type {import('@sveltejs/kit').Config} */
54
const config = {
65
compilerOptions: {
7-
// defaults to rune mode for the project, except for `node_modules`. Can be removed in svelte 6.
8-
runes: ({ filename }) => {
9-
const relativePath = relative(import.meta.dirname, filename);
10-
const pathSegments = relativePath.toLowerCase().split(sep);
11-
const isExternalLibrary = pathSegments.includes('node_modules');
12-
13-
return isExternalLibrary ? undefined : true;
14-
}
6+
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
7+
runes: ({ filename }) => (filename.split(/[/\\]/).includes('node_modules') ? undefined : true)
158
},
169
kit: {
1710
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.

packages/sv/src/create/shared/-typescript/svelte.config.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import adapter from '@sveltejs/adapter-auto';
2-
import { relative, sep } from 'node:path';
32

43
/** @type {import('@sveltejs/kit').Config} */
54
const config = {
65
compilerOptions: {
7-
// defaults to rune mode for the project, except for `node_modules`. Can be removed in svelte 6.
8-
runes: ({ filename }) => {
9-
const relativePath = relative(import.meta.dirname, filename);
10-
const pathSegments = relativePath.toLowerCase().split(sep);
11-
const isExternalLibrary = pathSegments.includes('node_modules');
12-
13-
return isExternalLibrary ? undefined : true;
14-
}
6+
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
7+
runes: ({ filename }) => (filename.split(/[/\\]/).includes('node_modules') ? undefined : true)
158
},
169
kit: {
1710
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.

0 commit comments

Comments
 (0)