Skip to content

fix: avoid relying on Node specifics within compiler #14314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-adults-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: avoid relying on Node specifics within compiler
16 changes: 12 additions & 4 deletions packages/svelte/src/compiler/validate-options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import process from 'node:process';

/** @import { ModuleCompileOptions, ValidatedModuleCompileOptions, CompileOptions, ValidatedCompileOptions } from '#compiler' */
import * as e from './errors.js';
import * as w from './warnings.js';
Expand All @@ -13,9 +11,19 @@ import * as w from './warnings.js';
const common = {
filename: string('(unknown)'),

// default to process.cwd() where it exists to replicate svelte4 behavior
// default to process.cwd() where it exists to replicate svelte4 behavior (and make Deno work with this as well)
// see https://github.com/sveltejs/svelte/blob/b62fc8c8fd2640c9b99168f01b9d958cb2f7574f/packages/svelte/src/compiler/compile/Component.js#L211
rootDir: string(typeof process !== 'undefined' ? process.cwd?.() : undefined),
/* eslint-disable */
rootDir: string(
typeof process !== 'undefined'
? process.cwd?.()
: // @ts-expect-error
typeof Deno !== 'undefined'
? // @ts-expect-error
Deno.cwd()
: undefined
),
/* eslint-enable */

dev: boolean(false),

Expand Down
Loading