Skip to content
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

fix: add node: prefix and import instead of using globals #12641

Merged
merged 4 commits into from
Sep 17, 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
12 changes: 12 additions & 0 deletions .changeset/smart-buttons-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@sveltejs/adapter-auto": patch
"@sveltejs/adapter-netlify": patch
"@sveltejs/adapter-node": patch
"@sveltejs/adapter-static": patch
"@sveltejs/adapter-vercel": patch
"create-svelte": patch
"@sveltejs/enhanced-img": patch
"@sveltejs/kit": patch
---

fix: import `node:process` instead of using globals
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default [
'packages/adapter-static/test/apps/*/build',
'packages/adapter-cloudflare/files',
'packages/adapter-netlify/files',
'packages/adapter-node/files',
'packages/adapter-node/files'
]
},
{
Expand All @@ -27,6 +27,7 @@ export default [
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/require-await': 'error',
'n/prefer-global/process': ['error', 'never']
},
ignores: [
'packages/adapter-node/rollup.config.js',
Expand Down
2 changes: 2 additions & 0 deletions packages/adapter-auto/adapters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import process from 'node:process';

// List of adapters to check for. `version` is used to pin the installed adapter version and should point
// to the latest version of the adapter that is compatible with adapter-auto's current peerDependency version of SvelteKit.
export const adapters = [
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-auto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { resolve } from 'import-meta-resolve';
import { adapters } from './adapters.js';
import { dirname, join } from 'node:path';
import { existsSync } from 'node:fs';
import process from 'node:process';

/** @type {Record<string, (name: string, version: string) => string>} */
const commands = {
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync }
import { dirname, join, resolve, posix } from 'node:path';
import { fileURLToPath } from 'node:url';
import { builtinModules } from 'node:module';
import process from 'node:process';
import esbuild from 'esbuild';
import toml from '@iarna/toml';

Expand Down
1 change: 1 addition & 0 deletions packages/adapter-netlify/src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './shims';
import { Server } from '0SERVER';
import { split_headers } from './headers.js';
import { createReadableStream } from '@sveltejs/kit/node';
import process from 'node:process';

/**
* @param {import('@sveltejs/kit').SSRManifest} manifest
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-node/src/env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global ENV_PREFIX */
import process from 'node:process';

const expected = new Set([
'SOCKET_PATH',
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'SHIMS';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import sirv from 'sirv';
import { fileURLToPath } from 'node:url';
import { parse as polka_url_parser } from '@polka/url';
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
import { handler } from 'HANDLER';
import { env } from 'ENV';
import polka from 'polka';
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-static/platforms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import process from 'node:process';

/**
* @typedef {{
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-static/test/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { devices } from '@playwright/test';
import process from 'node:process';

/** @type {import('@playwright/test').PlaywrightTestConfig} */
export const config = {
Expand Down
2 changes: 2 additions & 0 deletions packages/adapter-vercel/files/edge.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable n/prefer-global/process --
Vercel Edge Runtime does not support node:process */
import { Server } from 'SERVER';
import { manifest } from 'MANIFEST';

Expand Down
1 change: 1 addition & 0 deletions packages/adapter-vercel/files/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { installPolyfills } from '@sveltejs/kit/node/polyfills';
import { getRequest, setResponse, createReadableStream } from '@sveltejs/kit/node';
import { Server } from 'SERVER';
import { manifest } from 'MANIFEST';
import process from 'node:process';

installPolyfills();

Expand Down
1 change: 1 addition & 0 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { nodeFileTrace } from '@vercel/nft';
import esbuild from 'esbuild';
Expand Down
1 change: 1 addition & 0 deletions packages/create-svelte/bin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import * as p from '@clack/prompts';
import { bold, cyan, grey, yellow } from 'kleur/colors';
import { create } from './index.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { create } from '../index.js';

const repo = process.argv[2];
Expand Down
1 change: 1 addition & 0 deletions packages/create-svelte/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';

/** @param {string} dir */
Expand Down
1 change: 1 addition & 0 deletions packages/enhanced-img/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import process from 'node:process';
import { imagetools } from 'vite-imagetools';
import { image } from './preprocessor.js';

Expand Down
1 change: 1 addition & 0 deletions packages/kit/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { load_config } from './src/core/config/index.js';
import glob from 'tiny-glob/sync.js';
import fs from 'node:fs';
import process from 'node:process';

try {
const cwd = process.env.INIT_CWD ?? process.cwd();
Expand Down
1 change: 1 addition & 0 deletions packages/kit/scripts/cp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { copy } from '../src/utils/filesystem.js';
import process from 'node:process';

const [src, dest] = process.argv.slice(2);

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import colors from 'kleur';
import sade from 'sade';
import { load_config } from './core/config/index.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/config/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import * as url from 'node:url';
import options from './options.js';

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { assert, expect, test } from 'vitest';
import { validate_config, load_config } from './index.js';
import process from 'node:process';

const __filename = fileURLToPath(import.meta.url);
const __dirname = join(__filename, '..');
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'node:path';
import process from 'node:process';

/** @typedef {import('./types.js').Validator} Validator */

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/sync/create_manifest_data/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import colors from 'kleur';
import { lookup } from 'mrmime';
import { list_files, runtime_directory } from '../../utils.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/sync/write_server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import process from 'node:process';
import { hash } from '../../runtime/hash.js';
import { posixify, resolve_entry } from '../../utils/filesystem.js';
import { s } from '../../utils/misc.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/sync/write_tsconfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import colors from 'kleur';
import { posixify } from '../../utils/filesystem.js';
import { write_if_changed } from './utils.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/sync/write_types/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import MagicString from 'magic-string';
import { posixify, rimraf, walk } from '../../../utils/filesystem.js';
import { compact } from '../../../utils/array.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import colors from 'kleur';
import { posixify, to_fs } from '../utils/filesystem.js';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/exports/vite/dev/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { URL } from 'node:url';
import { AsyncLocalStorage } from 'node:async_hooks';
import colors from 'kleur';
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';

import colors from 'kleur';

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/utils/fork.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url';
import { Worker, parentPort } from 'node:worker_threads';
import process from 'node:process';

/**
* Runs a task in a subprocess so any dangling stuff gets killed upon completion.
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/utils/import.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as imr from 'import-meta-resolve';
import process from 'node:process';
import { pathToFileURL } from 'node:url';

/**
Expand Down
1 change: 1 addition & 0 deletions packages/kit/test/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import http from 'node:http';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { test as base, devices } from '@playwright/test';

Expand Down
1 change: 1 addition & 0 deletions packages/migrate/bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
import fs from 'node:fs';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import colors from 'kleur';

Expand Down
1 change: 1 addition & 0 deletions packages/migrate/migrations/package/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import colors from 'kleur';
import path from 'node:path';
import process from 'node:process';
import prompts from 'prompts';
import { pathToFileURL } from 'node:url';
import { bail, check_git } from '../../utils.js';
Expand Down
1 change: 1 addition & 0 deletions packages/migrate/migrations/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import colors from 'kleur';
import path from 'node:path';
import process from 'node:process';
import prompts from 'prompts';
import glob from 'tiny-glob/sync.js';
import { pathToFileURL } from 'node:url';
Expand Down
1 change: 1 addition & 0 deletions packages/migrate/migrations/self-closing-tags/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import colors from 'kleur';
import fs from 'node:fs';
import process from 'node:process';
import prompts from 'prompts';
import glob from 'tiny-glob/sync.js';
import { remove_self_closing_tags } from './migrate.js';
Expand Down
1 change: 1 addition & 0 deletions packages/migrate/migrations/svelte-4/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import colors from 'kleur';
import fs from 'node:fs';
import process from 'node:process';
import prompts from 'prompts';
import glob from 'tiny-glob/sync.js';
import { bail, check_git, update_js_file, update_svelte_file } from '../../utils.js';
Expand Down
1 change: 1 addition & 0 deletions packages/migrate/migrations/sveltekit-2/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import colors from 'kleur';
import fs from 'node:fs';
import process from 'node:process';
import prompts from 'prompts';
import semver from 'semver';
import glob from 'tiny-glob/sync.js';
Expand Down
1 change: 1 addition & 0 deletions packages/migrate/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import MagicString from 'magic-string';
import { execFileSync, execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import semver from 'semver';
import ts from 'typescript';

Expand Down
1 change: 1 addition & 0 deletions packages/package/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import process from 'node:process';
import colors from 'kleur';
import sade from 'sade';
import { load_config } from './config.js';
Expand Down
1 change: 1 addition & 0 deletions packages/package/src/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import process from 'node:process';
import fs from 'node:fs';
import url from 'node:url';

Expand Down
1 change: 1 addition & 0 deletions packages/package/test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import process from 'node:process';
import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

Expand Down
Loading