Skip to content

Commit 94471ca

Browse files
authored
fix: avoid relying on Node specifics within compiler (#14314)
fixes #14294
1 parent 1f0700f commit 94471ca

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.changeset/strange-adults-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: avoid relying on Node specifics within compiler

packages/svelte/src/compiler/validate-options.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import process from 'node:process';
2-
31
/** @import { ModuleCompileOptions, ValidatedModuleCompileOptions, CompileOptions, ValidatedCompileOptions } from '#compiler' */
42
import * as e from './errors.js';
53
import * as w from './warnings.js';
@@ -13,9 +11,19 @@ import * as w from './warnings.js';
1311
const common = {
1412
filename: string('(unknown)'),
1513

16-
// default to process.cwd() where it exists to replicate svelte4 behavior
14+
// default to process.cwd() where it exists to replicate svelte4 behavior (and make Deno work with this as well)
1715
// see https://github.com/sveltejs/svelte/blob/b62fc8c8fd2640c9b99168f01b9d958cb2f7574f/packages/svelte/src/compiler/compile/Component.js#L211
18-
rootDir: string(typeof process !== 'undefined' ? process.cwd?.() : undefined),
16+
/* eslint-disable */
17+
rootDir: string(
18+
typeof process !== 'undefined'
19+
? process.cwd?.()
20+
: // @ts-expect-error
21+
typeof Deno !== 'undefined'
22+
? // @ts-expect-error
23+
Deno.cwd()
24+
: undefined
25+
),
26+
/* eslint-enable */
1927

2028
dev: boolean(false),
2129

0 commit comments

Comments
 (0)