0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

nit: use node: prefix everywhere (#7692)

* nit: use `node:` prefix everywhere

* nit: fs/promises too

* test: workaround issue in node builtin detection
This commit is contained in:
Erika 2023-07-18 02:17:59 +02:00 committed by GitHub
parent cc0f81c040
commit f14e48098a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
150 changed files with 283 additions and 286 deletions

View file

@ -1,5 +1,5 @@
import { build } from 'esbuild'; import { build } from 'esbuild';
import { existsSync } from 'fs'; import { existsSync } from 'node:fs';
const CLIENT_RUNTIME_PATH = 'packages/astro/src/runtime/client/'; const CLIENT_RUNTIME_PATH = 'packages/astro/src/runtime/client/';
@ -27,13 +27,13 @@ export default async function checkBundleSize({ github, context }) {
return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed' return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed'
}); });
if (clientRuntimeFiles.length === 0) return; if (clientRuntimeFiles.length === 0) return;
const table = [ const table = [
'| File | Old Size | New Size | Change |', '| File | Old Size | New Size | Change |',
'| ---- | -------- | -------- | ------ |', '| ---- | -------- | -------- | ------ |',
]; ];
const output = await bundle(clientRuntimeFiles); const output = await bundle(clientRuntimeFiles);
for (let [filename, { oldSize, newSize, sourceFile }] of Object.entries(output)) { for (let [filename, { oldSize, newSize, sourceFile }] of Object.entries(output)) {
filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename) ? `client:${filename}` : filename; filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename) ? `client:${filename}` : filename;
const prefix = (newSize - oldSize) === 0 ? '' : (newSize - oldSize) > 0 ? '+ ' : '- '; const prefix = (newSize - oldSize) === 0 ? '' : (newSize - oldSize) > 0 ? '+ ' : '- ';
@ -60,7 +60,7 @@ ${table.join('\n')}`,
} }
async function bundle(files) { async function bundle(files) {
const { metafile } = await build({ const { metafile } = await build({
entryPoints: [...files.map(({ filename }) => filename), ...files.map(({ filename }) => `main/${filename}`).filter(f => existsSync(f))], entryPoints: [...files.map(({ filename }) => filename), ...files.map(({ filename }) => `main/${filename}`).filter(f => existsSync(f))],
bundle: true, bundle: true,

View file

@ -1,4 +1,4 @@
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { execaCommand } from 'execa'; import { execaCommand } from 'execa';
import { markdownTable } from 'markdown-table'; import { markdownTable } from 'markdown-table';
import { astroBin, calculateStat } from './_util.js'; import { astroBin, calculateStat } from './_util.js';

View file

@ -1,7 +1,7 @@
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import { execaCommand } from 'execa'; import { execaCommand } from 'execa';
import { markdownTable } from 'markdown-table'; import { markdownTable } from 'markdown-table';
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { astroBin } from './_util.js'; import { astroBin } from './_util.js';
/** @typedef {Record<string, import('../../packages/astro/src/core/config/timer').Stat>} AstroTimerStat */ /** @typedef {Record<string, import('../../packages/astro/src/core/config/timer').Stat>} AstroTimerStat */

View file

@ -1,12 +1,12 @@
import fs from 'fs/promises';
import http from 'http';
import path from 'path';
import { fileURLToPath } from 'url';
import { execaCommand } from 'execa'; import { execaCommand } from 'execa';
import { waitUntilBusy } from 'port-authority';
import { markdownTable } from 'markdown-table'; import { markdownTable } from 'markdown-table';
import { renderFiles } from '../make-project/render-default.js'; import fs from 'node:fs/promises';
import http from 'node:http';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { waitUntilBusy } from 'port-authority';
import { calculateStat } from '../make-project/_util.js'; import { calculateStat } from '../make-project/_util.js';
import { renderFiles } from '../make-project/render-default.js';
import { astroBin } from './_util.js'; import { astroBin } from './_util.js';
const port = 4322; const port = 4322;

View file

@ -1,9 +1,9 @@
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import autocannon from 'autocannon'; import autocannon from 'autocannon';
import { execaCommand } from 'execa'; import { execaCommand } from 'execa';
import { waitUntilBusy } from 'port-authority';
import { markdownTable } from 'markdown-table'; import { markdownTable } from 'markdown-table';
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { waitUntilBusy } from 'port-authority';
import pb from 'pretty-bytes'; import pb from 'pretty-bytes';
import { astroBin } from './_util.js'; import { astroBin } from './_util.js';

View file

@ -1,7 +1,7 @@
import fs from 'fs/promises';
import path from 'path';
import { pathToFileURL } from 'url';
import mri from 'mri'; import mri from 'mri';
import fs from 'node:fs/promises';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
const args = mri(process.argv.slice(2)); const args = mri(process.argv.slice(2));

View file

@ -1,4 +1,4 @@
import fs from 'fs/promises'; import fs from 'node:fs/promises';
import { loremIpsum } from './_util.js'; import { loremIpsum } from './_util.js';
/** /**

View file

@ -1,4 +1,4 @@
import fs from 'fs/promises'; import fs from 'node:fs/promises';
import { loremIpsumHtml, loremIpsumMd } from './_util.js'; import { loremIpsumHtml, loremIpsumMd } from './_util.js';
// Map of files to be generated and tested for rendering. // Map of files to be generated and tested for rendering.

View file

@ -1,4 +1,4 @@
import fs from 'fs/promises'; import fs from 'node:fs/promises';
import { loremIpsum } from './_util.js'; import { loremIpsum } from './_util.js';
/** /**

View file

@ -1,5 +1,5 @@
import type { CreatePreviewServer } from 'astro'; import type { CreatePreviewServer } from 'astro';
import { createServer } from 'http'; import { createServer } from 'node:http';
import enableDestroy from 'server-destroy'; import enableDestroy from 'server-destroy';
const preview: CreatePreviewServer = async function ({ serverEntrypoint, host, port }) { const preview: CreatePreviewServer = async function ({ serverEntrypoint, host, port }) {

View file

@ -1,7 +1,7 @@
import { polyfill } from '@astrojs/webapi'; import { polyfill } from '@astrojs/webapi';
import type { SSRManifest } from 'astro'; import type { SSRManifest } from 'astro';
import { NodeApp } from 'astro/app/node'; import { NodeApp } from 'astro/app/node';
import type { IncomingMessage, ServerResponse } from 'http'; import type { IncomingMessage, ServerResponse } from 'node:http';
polyfill(globalThis, { polyfill(globalThis, {
exclude: 'window document', exclude: 'window document',

View file

@ -1,6 +1,6 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import react from "@astrojs/react"; import react from "@astrojs/react";
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
export default defineConfig({ export default defineConfig({
integrations: [astroClientClickDirective(), astroClientPasswordDirective(), react()], integrations: [astroClientClickDirective(), astroClientPasswordDirective(), react()],

View file

@ -1,6 +1,6 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind'; import tailwind from '@astrojs/tailwind';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({

View file

@ -1,4 +1,4 @@
const path = require('path'); const path = require('node:path');
module.exports = { module.exports = {
content: [path.join(__dirname, 'src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}')], content: [path.join(__dirname, 'src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}')],

View file

@ -1,6 +1,6 @@
import fs from 'fs/promises'; import { expect, test as testBase } from '@playwright/test';
import path from 'path'; import fs from 'node:fs/promises';
import { test as testBase, expect } from '@playwright/test'; import path from 'node:path';
import { loadFixture as baseLoadFixture } from '../test/test-utils.js'; import { loadFixture as baseLoadFixture } from '../test/test-utils.js';
export const isWindows = process.platform === 'win32'; export const isWindows = process.platform === 'win32';

View file

@ -1,6 +1,6 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { loadFixture } from '../test/test-utils.js'; import { loadFixture } from '../test/test-utils.js';
import { generatePosts } from './scripts/generate-posts.mjs'; import { generatePosts } from './scripts/generate-posts.mjs';
import yargs from 'yargs-parser'; import yargs from 'yargs-parser';

View file

@ -1,5 +1,5 @@
import fs from 'fs'; import fs from 'node:fs';
import path from 'path'; import path from 'node:path';
const NUM_POSTS = 10; const NUM_POSTS = 10;
const POSTS_DIR = './src/content/posts.generated'; const POSTS_DIR = './src/content/posts.generated';

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import fs from 'node:fs';
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/languages/'); const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/languages/');

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import fs from 'node:fs';
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/themes/'); const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/themes/');

View file

@ -8,8 +8,8 @@ import type {
ShikiConfig, ShikiConfig,
} from '@astrojs/markdown-remark'; } from '@astrojs/markdown-remark';
import type * as babel from '@babel/core'; import type * as babel from '@babel/core';
import type { OutgoingHttpHeaders } from 'http'; import type { OutgoingHttpHeaders } from 'node:http';
import type { AddressInfo } from 'net'; import type { AddressInfo } from 'node:net';
import type * as rollup from 'rollup'; import type * as rollup from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver'; import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite'; import type * as vite from 'vite';

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -1,6 +1,6 @@
import { cpus } from 'node:os';
import { fileURLToPath } from 'node:url';
import { isMainThread } from 'node:worker_threads'; import { isMainThread } from 'node:worker_threads';
import { cpus } from 'os';
import { fileURLToPath } from 'url';
import type { ImageOutputFormat } from '../../../types.js'; import type { ImageOutputFormat } from '../../../types.js';
import { getModuleURL } from './emscripten-utils.js'; import { getModuleURL } from './emscripten-utils.js';
import type { Operation } from './image.js'; import type { Operation } from './image.js';

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -41,13 +41,13 @@ var Module = (function () {
var nodePath var nodePath
if (ENVIRONMENT_IS_NODE) { if (ENVIRONMENT_IS_NODE) {
if (ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = require('path').dirname(scriptDirectory) + '/' scriptDirectory = require('node:path').dirname(scriptDirectory) + '/'
} else { } else {
scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/' scriptDirectory = dirname(getModuleURL(import.meta.url)) + '/'
} }
read_ = function shell_read(filename, binary) { read_ = function shell_read(filename, binary) {
if (!nodeFS) nodeFS = require('fs') if (!nodeFS) nodeFS = require('node:fs')
if (!nodePath) nodePath = require('path') if (!nodePath) nodePath = require('node:path')
filename = nodePath['normalize'](filename) filename = nodePath['normalize'](filename)
return nodeFS['readFileSync'](filename, binary ? null : 'utf8') return nodeFS['readFileSync'](filename, binary ? null : 'utf8')
} }

View file

@ -1,4 +1,4 @@
import { basename, extname } from 'path'; import { basename, extname } from 'node:path';
import { removeQueryString } from '../../core/path.js'; import { removeQueryString } from '../../core/path.js';
import { shorthash } from '../../runtime/server/shorthash.js'; import { shorthash } from '../../runtime/server/shorthash.js';
import { isESMImportedImage } from '../internal.js'; import { isESMImportedImage } from '../internal.js';

View file

@ -1,5 +1,5 @@
import * as fs from "fs"; import * as fs from "node:fs";
import * as path from "path"; import * as path from "node:path";
import Queue from "../queue/queue.js"; import Queue from "../queue/queue.js";
import { detector } from "./detector.js"; import { detector } from "./detector.js";
import { typeHandlers, type imageType } from "./types.js"; import { typeHandlers, type imageType } from "./types.js";

View file

@ -1,6 +1,6 @@
// based on http://www.compix.com/fileformattif.htm // based on http://www.compix.com/fileformattif.htm
// TO-DO: support big-endian as well // TO-DO: support big-endian as well
import * as fs from 'fs' import * as fs from 'node:fs'
import { readUInt } from '../readUInt.js' import { readUInt } from '../readUInt.js'
import type { IImage } from './interface' import type { IImage } from './interface'

View file

@ -1,13 +1,13 @@
import boxen from 'boxen'; import boxen from 'boxen';
import { diffWords } from 'diff'; import { diffWords } from 'diff';
import { execa } from 'execa'; import { execa } from 'execa';
import fsMod, { existsSync, promises as fs } from 'fs';
import { bold, cyan, dim, green, magenta, red, yellow } from 'kleur/colors'; import { bold, cyan, dim, green, magenta, red, yellow } from 'kleur/colors';
import fsMod, { existsSync, promises as fs } from 'node:fs';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import ora from 'ora'; import ora from 'ora';
import path from 'path';
import preferredPM from 'preferred-pm'; import preferredPM from 'preferred-pm';
import prompts from 'prompts'; import prompts from 'prompts';
import { fileURLToPath, pathToFileURL } from 'url';
import type yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import { loadTSConfig, resolveConfigPath } from '../../core/config/index.js'; import { loadTSConfig, resolveConfigPath } from '../../core/config/index.js';
import { import {

View file

@ -5,12 +5,12 @@ import {
} from '@astrojs/language-server'; } from '@astrojs/language-server';
import type { FSWatcher } from 'chokidar'; import type { FSWatcher } from 'chokidar';
import glob from 'fast-glob'; import glob from 'fast-glob';
import fs from 'fs';
import { bold, dim, red, yellow } from 'kleur/colors'; import { bold, dim, red, yellow } from 'kleur/colors';
import { createRequire } from 'module'; import { createRequire } from 'module';
import fs from 'node:fs';
import { join } from 'node:path'; import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import ora from 'ora'; import ora from 'ora';
import { fileURLToPath, pathToFileURL } from 'url';
import type { Arguments as Flags } from 'yargs-parser'; import type { Arguments as Flags } from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro'; import type { AstroSettings } from '../../@types/astro';
import type { LogOptions } from '../../core/logger/core.js'; import type { LogOptions } from '../../core/logger/core.js';

View file

@ -12,7 +12,7 @@ import {
yellow, yellow,
} from 'kleur/colors'; } from 'kleur/colors';
import stringWidth from 'string-width'; import stringWidth from 'string-width';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
export function printDiagnostic(filePath: string, text: string, diag: Diagnostic): string { export function printDiagnostic(filePath: string, text: string, diag: Diagnostic): string {
let result = []; let result = [];

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import fs from 'node:fs';
import type yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import { resolveConfigPath, resolveFlags } from '../../core/config/index.js'; import { resolveConfigPath, resolveFlags } from '../../core/config/index.js';
import devServer from '../../core/dev/index.js'; import devServer from '../../core/dev/index.js';

View file

@ -1,6 +1,6 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import fs from 'fs';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import fs from 'node:fs';
import type { Arguments as Flags } from 'yargs-parser'; import type { Arguments as Flags } from 'yargs-parser';
import { ZodError } from 'zod'; import { ZodError } from 'zod';
import { createSettings, openConfig, resolveConfigPath } from '../core/config/index.js'; import { createSettings, openConfig, resolveConfigPath } from '../core/config/index.js';

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import fs from 'node:fs';
import type yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import type { LogOptions } from '../../core/logger/core.js'; import type { LogOptions } from '../../core/logger/core.js';
import { syncCli } from '../../core/sync/index.js'; import { syncCli } from '../../core/sync/index.js';

View file

@ -22,7 +22,7 @@ export function getViteConfig(inlineConfig: UserConfig) {
{ runHookConfigSetup, runHookConfigDone }, { runHookConfigSetup, runHookConfigDone },
{ astroContentListenPlugin }, { astroContentListenPlugin },
] = await Promise.all([ ] = await Promise.all([
import('fs'), import('node:fs'),
import('vite'), import('vite'),
import('../core/logger/node.js'), import('../core/logger/node.js'),
import('../core/config/index.js'), import('../core/config/index.js'),

View file

@ -2,7 +2,7 @@ import * as devalue from 'devalue';
import type fsMod from 'node:fs'; import type fsMod from 'node:fs';
import { extname } from 'node:path'; import { extname } from 'node:path';
import type { PluginContext } from 'rollup'; import type { PluginContext } from 'rollup';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'node:url';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import type { import type {
AstroConfig, AstroConfig,

View file

@ -1,9 +1,9 @@
import type { RouteData } from '../../@types/astro'; import type { RouteData } from '../../@types/astro';
import type { SerializedSSRManifest, SSRManifest } from './types'; import type { SerializedSSRManifest, SSRManifest } from './types';
import * as fs from 'fs'; import * as fs from 'node:fs';
import { IncomingMessage } from 'http'; import { IncomingMessage } from 'node:http';
import { TLSSocket } from 'tls'; import { TLSSocket } from 'node:tls';
import { deserializeManifest } from './common.js'; import { deserializeManifest } from './common.js';
import { App, type MatchOptions } from './index.js'; import { App, type MatchOptions } from './index.js';

View file

@ -1,5 +1,5 @@
import npath from 'path'; import npath from 'node:path';
import { fileURLToPath, pathToFileURL } from 'url'; import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, RouteType } from '../../@types/astro'; import type { AstroConfig, RouteType } from '../../@types/astro';
import { appendForwardSlash } from '../../core/path.js'; import { appendForwardSlash } from '../../core/path.js';

View file

@ -1,7 +1,7 @@
import type { GetModuleInfo } from 'rollup'; import type { GetModuleInfo } from 'rollup';
import crypto from 'crypto'; import crypto from 'node:crypto';
import npath from 'path'; import npath from 'node:path';
import type { AstroSettings } from '../../@types/astro'; import type { AstroSettings } from '../../@types/astro';
import { viteID } from '../util.js'; import { viteID } from '../util.js';
import { getTopLevelPages } from './graph.js'; import { getTopLevelPages } from './graph.js';

View file

@ -1,8 +1,8 @@
import fs from 'fs';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import { bgGreen, black, cyan, dim, green, magenta } from 'kleur/colors'; import { bgGreen, black, cyan, dim, green, magenta } from 'kleur/colors';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import type { OutputAsset, OutputChunk } from 'rollup'; import type { OutputAsset, OutputChunk } from 'rollup';
import { fileURLToPath } from 'url';
import type { import type {
AstroConfig, AstroConfig,
AstroSettings, AstroSettings,
@ -41,8 +41,8 @@ import { callEndpoint, throwIfRedirectNotAllowed } from '../endpoint/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js';
import { debug, info } from '../logger/core.js'; import { debug, info } from '../logger/core.js';
import { import {
getRedirectLocationOrThrow,
RedirectSinglePageBuiltModule, RedirectSinglePageBuiltModule,
getRedirectLocationOrThrow,
routeIsRedirect, routeIsRedirect,
} from '../redirects/index.js'; } from '../redirects/index.js';
import { createEnvironment, createRenderContext, tryRenderPage } from '../render/index.js'; import { createEnvironment, createRenderContext, tryRenderPage } from '../render/index.js';

View file

@ -1,6 +1,6 @@
import fs from 'fs';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import { performance } from 'perf_hooks'; import fs from 'node:fs';
import { performance } from 'node:perf_hooks';
import type * as vite from 'vite'; import type * as vite from 'vite';
import type yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import type { AstroConfig, AstroSettings, ManifestData, RuntimeMode } from '../../@types/astro'; import type { AstroConfig, AstroSettings, ManifestData, RuntimeMode } from '../../@types/astro';

View file

@ -1,11 +1,10 @@
import { teardown } from '@astrojs/compiler'; import { teardown } from '@astrojs/compiler';
import * as eslexer from 'es-module-lexer'; import * as eslexer from 'es-module-lexer';
import glob from 'fast-glob'; import glob from 'fast-glob';
import fs from 'fs';
import { bgGreen, bgMagenta, black, dim } from 'kleur/colors'; import { bgGreen, bgMagenta, black, dim } from 'kleur/colors';
import { extname } from 'node:path'; import fs from 'node:fs';
import path from 'path'; import path, { extname } from 'node:path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import * as vite from 'vite'; import * as vite from 'vite';
import type { RouteData } from '../../@types/astro'; import type { RouteData } from '../../@types/astro';
import { import {

View file

@ -3,7 +3,7 @@ import type { ResolvedConfig } from 'vite';
import type { AstroConfig } from '../../@types/astro'; import type { AstroConfig } from '../../@types/astro';
import { transform } from '@astrojs/compiler'; import { transform } from '@astrojs/compiler';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { normalizePath } from 'vite'; import { normalizePath } from 'vite';
import { AggregateError, AstroError, CompilerError } from '../errors/errors.js'; import { AggregateError, AstroError, CompilerError } from '../errors/errors.js';
import { AstroErrorData } from '../errors/index.js'; import { AstroErrorData } from '../errors/index.js';

View file

@ -1,5 +1,5 @@
import type { TransformOptions } from '@astrojs/compiler'; import type { TransformOptions } from '@astrojs/compiler';
import fs from 'fs'; import fs from 'node:fs';
import { preprocessCSS, type ResolvedConfig } from 'vite'; import { preprocessCSS, type ResolvedConfig } from 'vite';
import { AstroErrorData, CSSError, positionAt } from '../errors/index.js'; import { AstroErrorData, CSSError, positionAt } from '../errors/index.js';

View file

@ -1,10 +1,10 @@
import type { Arguments as Flags } from 'yargs-parser'; import type { Arguments as Flags } from 'yargs-parser';
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro'; import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro';
import fs from 'fs';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import path from 'path'; import fs from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'url'; import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { AstroError, AstroErrorData } from '../errors/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js';
import { mergeConfig } from './merge.js'; import { mergeConfig } from './merge.js';
import { createRelativeSchema } from './schema.js'; import { createRelativeSchema } from './schema.js';

View file

@ -3,7 +3,7 @@ import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki'; import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro'; import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro';
import type { OutgoingHttpHeaders } from 'http'; import type { OutgoingHttpHeaders } from 'node:http';
import { BUNDLED_THEMES } from 'shiki'; import { BUNDLED_THEMES } from 'shiki';
import { z } from 'zod'; import { z } from 'zod';
import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js'; import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js';

View file

@ -1,6 +1,6 @@
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'url'; import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro'; import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro';
import { getContentPaths } from '../../content/index.js'; import { getContentPaths } from '../../content/index.js';
import jsxRenderer from '../../jsx/renderer.js'; import jsxRenderer from '../../jsx/renderer.js';

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import fs from 'node:fs';
// Type used by `bench-memory.js` // Type used by `bench-memory.js`
export interface Stat { export interface Stat {

View file

@ -1,6 +1,6 @@
import { deepmerge } from 'deepmerge-ts'; import { deepmerge } from 'deepmerge-ts';
import { existsSync } from 'fs'; import { existsSync } from 'node:fs';
import { join } from 'path'; import { join } from 'node:path';
import * as tsr from 'tsconfig-resolver'; import * as tsr from 'tsconfig-resolver';
export const defaultTSConfig: tsr.TsConfigJson = { extends: 'astro/tsconfigs/base' }; export const defaultTSConfig: tsr.TsConfigJson = { extends: 'astro/tsconfigs/base' };

View file

@ -1,5 +1,5 @@
import type fsType from 'fs'; import type fsType from 'node:fs';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'node:url';
import { createServer, type ViteDevServer } from 'vite'; import { createServer, type ViteDevServer } from 'vite';
import loadFallbackPlugin from '../../vite-plugin-load-fallback/index.js'; import loadFallbackPlugin from '../../vite-plugin-load-fallback/index.js';
import { debug } from '../logger/core.js'; import { debug } from '../logger/core.js';

View file

@ -1,8 +1,8 @@
import type { AstroSettings } from '../@types/astro'; import type { AstroSettings } from '../@types/astro';
import type { LogOptions } from './logger/core'; import type { LogOptions } from './logger/core';
import nodeFs from 'fs'; import nodeFs from 'node:fs';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import * as vite from 'vite'; import * as vite from 'vite';
import { crawlFrameworkPkgs } from 'vitefu'; import { crawlFrameworkPkgs } from 'vitefu';
import astroAssetsPlugin from '../assets/vite-plugin-assets.js'; import astroAssetsPlugin from '../assets/vite-plugin-assets.js';

View file

@ -1,8 +1,8 @@
import type * as http from 'http'; import type * as http from 'node:http';
import type { AddressInfo } from 'net'; import type { AddressInfo } from 'node:net';
import type { AstroSettings, AstroUserConfig } from '../../@types/astro'; import type { AstroSettings, AstroUserConfig } from '../../@types/astro';
import nodeFs from 'fs'; import nodeFs from 'node:fs';
import * as vite from 'vite'; import * as vite from 'vite';
import { import {
runHookConfigDone, runHookConfigDone,

View file

@ -1,6 +1,6 @@
import type http from 'http';
import { cyan } from 'kleur/colors'; import { cyan } from 'kleur/colors';
import type { AddressInfo } from 'net'; import type http from 'node:http';
import type { AddressInfo } from 'node:net';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import type * as vite from 'vite'; import type * as vite from 'vite';
import type yargs from 'yargs-parser'; import type yargs from 'yargs-parser';

View file

@ -1,6 +1,6 @@
import * as fs from 'fs'; import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { getHighlighter } from 'shiki'; import { getHighlighter } from 'shiki';
import { fileURLToPath } from 'url';
import type { ErrorPayload } from 'vite'; import type { ErrorPayload } from 'vite';
import type { ModuleLoader } from '../../module-loader/index.js'; import type { ModuleLoader } from '../../module-loader/index.js';
import { AstroErrorData } from '../errors-data.js'; import { AstroErrorData } from '../errors-data.js';

View file

@ -1,6 +1,6 @@
import fs from 'fs'; import fs from 'node:fs';
import path from 'path'; import path from 'node:path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { appendForwardSlash } from '../path.js'; import { appendForwardSlash } from '../path.js';
const isWindows = process.platform === 'win32'; const isWindows = process.platform === 'win32';
@ -63,7 +63,7 @@ export function emptyDir(_dir: URL, skip?: Set<string>): void {
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies. copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR

View file

@ -1,7 +1,7 @@
import debugPackage from 'debug'; import debugPackage from 'debug';
import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors'; import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors';
import * as readline from 'readline'; import * as readline from 'node:readline';
import { Writable } from 'stream'; import { Writable } from 'node:stream';
import stringWidth from 'string-width'; import stringWidth from 'string-width';
import { dateTimeFormat, error, info, warn } from './core.js'; import { dateTimeFormat, error, info, warn } from './core.js';

View file

@ -1,5 +1,5 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'node:events';
import type * as fs from 'fs'; import type * as fs from 'node:fs';
import type { TypedEventEmitter } from '../../@types/typed-emitter'; import type { TypedEventEmitter } from '../../@types/typed-emitter';
// This is a generic interface for a module loader. In the astro cli this is // This is a generic interface for a module loader. In the astro cli this is

View file

@ -1,4 +1,4 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'node:events';
import type * as vite from 'vite'; import type * as vite from 'vite';
import type { ModuleLoader, ModuleLoaderEventEmitter } from './loader'; import type { ModuleLoader, ModuleLoaderEventEmitter } from './loader';

View file

@ -1,6 +1,6 @@
import { cyan } from 'kleur/colors'; import { cyan } from 'kleur/colors';
import { createRequire } from 'module'; import { createRequire } from 'module';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'node:url';
import type { Arguments } from 'yargs-parser'; import type { Arguments } from 'yargs-parser';
import type { AstroSettings, PreviewModule, PreviewServer } from '../../@types/astro'; import type { AstroSettings, PreviewModule, PreviewServer } from '../../@types/astro';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js'; import { runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js';

View file

@ -1,7 +1,7 @@
import type http from 'http'; import type http from 'node:http';
import { fileURLToPath } from 'node:url';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import enableDestroy from 'server-destroy'; import enableDestroy from 'server-destroy';
import { fileURLToPath } from 'url';
import { preview, type PreviewServer as VitePreviewServer } from 'vite'; import { preview, type PreviewServer as VitePreviewServer } from 'vite';
import type { AstroSettings } from '../../@types/astro'; import type { AstroSettings } from '../../@types/astro';
import type { LogOptions } from '../logger/core'; import type { LogOptions } from '../logger/core';

View file

@ -1,5 +1,5 @@
import fs from 'fs'; import fs from 'node:fs';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import type { AstroSettings } from '../../@types/astro.js'; import type { AstroSettings } from '../../@types/astro.js';
import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js'; import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js';

View file

@ -1,6 +1,6 @@
import type { ModuleLoader, ModuleNode } from '../../module-loader/index'; import type { ModuleLoader, ModuleNode } from '../../module-loader/index';
import npath from 'path'; import npath from 'node:path';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js'; import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js';
import { unwrapId } from '../../util.js'; import { unwrapId } from '../../util.js';
import { isCSSRequest } from './util.js'; import { isCSSRequest } from './util.js';

View file

@ -1,4 +1,4 @@
import type { IncomingHttpHeaders } from 'http'; import type { IncomingHttpHeaders } from 'node:http';
import type { LogOptions } from './logger/core'; import type { LogOptions } from './logger/core';
import { warn } from './logger/core.js'; import { warn } from './logger/core.js';

View file

@ -8,10 +8,10 @@ import type {
} from '../../../@types/astro'; } from '../../../@types/astro';
import type { LogOptions } from '../../logger/core'; import type { LogOptions } from '../../logger/core';
import nodeFs from 'fs';
import { createRequire } from 'module'; import { createRequire } from 'module';
import path from 'path'; import nodeFs from 'node:fs';
import { fileURLToPath } from 'url'; import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { getPrerenderDefault } from '../../../prerender/utils.js'; import { getPrerenderDefault } from '../../../prerender/utils.js';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js'; import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js';
import { warn } from '../../logger/core.js'; import { warn } from '../../logger/core.js';

View file

@ -1,6 +1,6 @@
import fs from 'fs'; import fs from 'node:fs';
import path from 'path'; import path from 'node:path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { normalizePath } from 'vite'; import { normalizePath } from 'vite';
import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro'; import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro';
import { isServerLikeOutput } from '../prerender/utils.js'; import { isServerLikeOutput } from '../prerender/utils.js';

View file

@ -1,6 +1,6 @@
import { bold } from 'kleur/colors'; import { bold } from 'kleur/colors';
import type { AddressInfo } from 'net';
import fs from 'node:fs'; import fs from 'node:fs';
import type { AddressInfo } from 'node:net';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import type { InlineConfig, ViteDevServer } from 'vite'; import type { InlineConfig, ViteDevServer } from 'vite';
import type { import type {

View file

@ -1,7 +1,7 @@
import type * as vite from 'vite'; import type * as vite from 'vite';
import type { AstroSettings } from '../@types/astro'; import type { AstroSettings } from '../@types/astro';
import * as fs from 'fs'; import * as fs from 'node:fs';
import { warn, type LogOptions } from '../core/logger/core.js'; import { warn, type LogOptions } from '../core/logger/core.js';
import notFoundTemplate, { subpathNotUsedTemplate } from '../template/4xx.js'; import notFoundTemplate, { subpathNotUsedTemplate } from '../template/4xx.js';
import { log404 } from './common.js'; import { log404 } from './common.js';

View file

@ -1,4 +1,4 @@
import type fs from 'fs'; import type fs from 'node:fs';
import type * as vite from 'vite'; import type * as vite from 'vite';
import type { AstroSettings, ManifestData, SSRManifest } from '../@types/astro'; import type { AstroSettings, ManifestData, SSRManifest } from '../@types/astro';
import { patchOverlay } from '../core/errors/overlay.js'; import { patchOverlay } from '../core/errors/overlay.js';

View file

@ -1,4 +1,4 @@
import type http from 'http'; import type http from 'node:http';
import type { ManifestData, SSRManifest } from '../@types/astro'; import type { ManifestData, SSRManifest } from '../@types/astro';
import type { DevelopmentEnvironment } from '../core/render/dev/index'; import type { DevelopmentEnvironment } from '../core/render/dev/index';
import type { DevServerController } from './controller'; import type { DevServerController } from './controller';

View file

@ -1,4 +1,4 @@
import type http from 'http'; import type http from 'node:http';
import type { ErrorWithMetadata } from '../core/errors/index.js'; import type { ErrorWithMetadata } from '../core/errors/index.js';
import type { ModuleLoader } from '../core/module-loader/index'; import type { ModuleLoader } from '../core/module-loader/index';

View file

@ -1,5 +1,5 @@
import type http from 'http';
import mime from 'mime'; import mime from 'mime';
import type http from 'node:http';
import type { ComponentInstance, ManifestData, RouteData, SSRManifest } from '../@types/astro'; import type { ComponentInstance, ManifestData, RouteData, SSRManifest } from '../@types/astro';
import { attachToResponse } from '../core/cookies/index.js'; import { attachToResponse } from '../core/cookies/index.js';
import { call as callEndpoint } from '../core/endpoint/dev/index.js'; import { call as callEndpoint } from '../core/endpoint/dev/index.js';

View file

@ -1,4 +1,4 @@
import path from 'path'; import path from 'node:path';
import { normalizePath, type Plugin as VitePlugin, type ResolvedConfig } from 'vite'; import { normalizePath, type Plugin as VitePlugin, type ResolvedConfig } from 'vite';
import type { AstroSettings } from '../@types/astro'; import type { AstroSettings } from '../@types/astro';

View file

@ -1,5 +1,5 @@
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import type * as vite from 'vite'; import type * as vite from 'vite';
import { loadEnv } from 'vite'; import { loadEnv } from 'vite';
import type { AstroConfig, AstroSettings } from '../@types/astro'; import type { AstroConfig, AstroSettings } from '../@types/astro';

View file

@ -11,7 +11,7 @@ import type { PluginMetadata } from '../vite-plugin-astro/types';
import babel from '@babel/core'; import babel from '@babel/core';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import path from 'path'; import path from 'node:path';
import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from '../content/index.js'; import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from '../content/index.js';
import { astroEntryPrefix } from '../core/build/plugins/plugin-component-entry.js'; import { astroEntryPrefix } from '../core/build/plugins/plugin-component-entry.js';
import { error } from '../core/logger/core.js'; import { error } from '../core/logger/core.js';

View file

@ -1,5 +1,5 @@
import nodeFs from 'fs'; import nodeFs from 'node:fs';
import npath from 'path'; import npath from 'node:path';
import type * as vite from 'vite'; import type * as vite from 'vite';
import { slash } from '../core/path.js'; import { slash } from '../core/path.js';
@ -15,7 +15,7 @@ export default function loadFallbackPlugin({
root, root,
}: LoadFallbackPluginParams): vite.Plugin[] | false { }: LoadFallbackPluginParams): vite.Plugin[] | false {
// Only add this plugin if a custom fs implementation is provided. // Only add this plugin if a custom fs implementation is provided.
// Also check for `fs.default` because `import * as fs from 'fs'` will // Also check for `fs.default` because `import * as fs from 'node:fs'` will
// export as so, which only it's `.default` would === `nodeFs`. // export as so, which only it's `.default` would === `nodeFs`.
// @ts-expect-error check default // @ts-expect-error check default
if (!fs || fs === nodeFs || fs.default === nodeFs) { if (!fs || fs === nodeFs || fs.default === nodeFs) {

View file

@ -1,5 +1,5 @@
import ancestor from 'common-ancestor-path'; import ancestor from 'common-ancestor-path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import type { AstroConfig } from '../@types/astro'; import type { AstroConfig } from '../@types/astro';
import { import {
appendExtension, appendExtension,

View file

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import os from 'node:os';
import { loadFixture } from './test-utils.js'; import { loadFixture } from './test-utils.js';
import os from 'os';
// TODO: fix these tests on macOS // TODO: fix these tests on macOS
const isMacOS = os.platform() === 'darwin'; const isMacOS = os.platform() === 'darwin';

View file

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as fs from 'node:fs';
import { loadFixture } from './test-utils.js'; import { loadFixture } from './test-utils.js';
import * as fs from 'fs';
describe('outDir set to project root', async () => { describe('outDir set to project root', async () => {
/** @type {import('./test-utils').Fixture} */ /** @type {import('./test-utils').Fixture} */

View file

@ -1,6 +1,6 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind'; import tailwind from '@astrojs/tailwind';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
export default defineConfig({ export default defineConfig({
integrations: [ integrations: [

View file

@ -1,6 +1,6 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind'; import tailwind from '@astrojs/tailwind';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({

View file

@ -1,6 +1,6 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind'; import tailwind from '@astrojs/tailwind';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({

View file

@ -1,7 +1,7 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind'; import tailwind from '@astrojs/tailwind';
import mdx from '@astrojs/mdx'; import mdx from '@astrojs/mdx';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({

View file

@ -1,4 +1,4 @@
const path = require('path'); const path = require('node:path');
module.exports = { module.exports = {
content: [path.join(__dirname, 'src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}')], content: [path.join(__dirname, 'src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}')],

View file

@ -1,6 +1,6 @@
// TODO: unskip this test // TODO: unskip this test
// import { expect } from 'chai'; // import { expect } from 'chai';
// import { fileURLToPath } from 'url'; // import { fileURLToPath } from 'node:url';
// import { createRouteManifest } from '../dist/core/routing/index.js'; // import { createRouteManifest } from '../dist/core/routing/index.js';
// import { validateConfig } from '../dist/core/config.js'; // import { validateConfig } from '../dist/core/config.js';

View file

@ -1,8 +1,8 @@
import { expect } from 'chai'; import { expect } from 'chai';
import net from 'node:net';
import { File, FormData } from 'undici'; import { File, FormData } from 'undici';
import testAdapter from './test-adapter.js'; import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js'; import { loadFixture } from './test-utils.js';
import net from 'net';
describe('API routes in SSR', () => { describe('API routes in SSR', () => {
/** @type {import('./test-utils').Fixture} */ /** @type {import('./test-utils').Fixture} */

View file

@ -50,12 +50,12 @@ export default function (
return super.render(request, routeData, locals); return super.render(request, routeData, locals);
} }
} }
export function createExports(manifest) { export function createExports(manifest) {
return { return {
manifest, manifest,
createApp: (streaming) => new MyApp(manifest, streaming) createApp: (streaming) => new MyApp(manifest, streaming)
}; };
} }
`; `;

View file

@ -1,21 +1,21 @@
import { polyfill } from '@astrojs/webapi'; import { polyfill } from '@astrojs/webapi';
import { execa } from 'execa'; import { execa } from 'execa';
import fastGlob from 'fast-glob'; import fastGlob from 'fast-glob';
import fs from 'fs'; import fs from 'node:fs';
import os from 'os'; import os from 'node:os';
import { fileURLToPath } from 'node:url';
import stripAnsi from 'strip-ansi'; import stripAnsi from 'strip-ansi';
import { fileURLToPath } from 'url'; import { check } from '../dist/cli/check/index.js';
import { sync } from '../dist/core/sync/index.js';
import build from '../dist/core/build/index.js'; import build from '../dist/core/build/index.js';
import { RESOLVED_SPLIT_MODULE_ID } from '../dist/core/build/plugins/plugin-ssr.js';
import { getVirtualModulePageNameFromPath } from '../dist/core/build/plugins/util.js';
import { makeSplitEntryPointFileName } from '../dist/core/build/static-build.js';
import { openConfig } from '../dist/core/config/config.js'; import { openConfig } from '../dist/core/config/config.js';
import { createSettings } from '../dist/core/config/index.js'; import { createSettings } from '../dist/core/config/index.js';
import dev from '../dist/core/dev/index.js'; import dev from '../dist/core/dev/index.js';
import { nodeLogDestination } from '../dist/core/logger/node.js'; import { nodeLogDestination } from '../dist/core/logger/node.js';
import preview from '../dist/core/preview/index.js'; import preview from '../dist/core/preview/index.js';
import { check } from '../dist/cli/check/index.js'; import { sync } from '../dist/core/sync/index.js';
import { getVirtualModulePageNameFromPath } from '../dist/core/build/plugins/util.js';
import { RESOLVED_SPLIT_MODULE_ID } from '../dist/core/build/plugins/plugin-ssr.js';
import { makeSplitEntryPointFileName } from '../dist/core/build/static-build.js';
// polyfill WebAPIs to globalThis for Node v12, Node v14, and Node v16 // polyfill WebAPIs to globalThis for Node v12, Node v14, and Node v16
polyfill(globalThis, { polyfill(globalThis, {

View file

@ -2,7 +2,7 @@ import { resolveConfig } from 'vite';
import { expect } from 'chai'; import { expect } from 'chai';
import { cachedCompilation } from '../../../dist/core/compile/index.js'; import { cachedCompilation } from '../../../dist/core/compile/index.js';
import { AggregateError } from '../../../dist/core/errors/index.js'; import { AggregateError } from '../../../dist/core/errors/index.js';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'node:url';
describe('astro/src/core/compile', () => { describe('astro/src/core/compile', () => {
describe('Invalid CSS', () => { describe('Invalid CSS', () => {

View file

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { defaultLogging } from '../test-utils.js'; import { defaultLogging } from '../test-utils.js';
import { openConfig } from '../../../dist/core/config/index.js'; import { openConfig } from '../../../dist/core/config/index.js';

View file

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { loadTSConfig, updateTSConfigForFramework } from '../../../dist/core/config/index.js'; import { loadTSConfig, updateTSConfigForFramework } from '../../../dist/core/config/index.js';
import * as path from 'path'; import * as path from 'node:path';
import * as tsr from 'tsconfig-resolver'; import * as tsr from 'tsconfig-resolver';
const cwd = fileURLToPath(new URL('../../fixtures/tsconfig-handling/', import.meta.url)); const cwd = fileURLToPath(new URL('../../fixtures/tsconfig-handling/', import.meta.url));

View file

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { validateConfig } from '../../../dist/core/config/config.js'; import { validateConfig } from '../../../dist/core/config/config.js';
import { createSettings } from '../../../dist/core/config/index.js'; import { createSettings } from '../../../dist/core/config/index.js';
import { sync as _sync } from '../../../dist/core/sync/index.js'; import { sync as _sync } from '../../../dist/core/sync/index.js';

View file

@ -1,11 +1,11 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as cheerio from 'cheerio'; import * as cheerio from 'cheerio';
import os from 'os'; import os from 'node:os';
import { runInContainer } from '../../../dist/core/dev/index.js';
import { createFsWithFallback, createRequestAndResponse } from '../test-utils.js';
import mdx from '../../../../integrations/mdx/dist/index.js'; import mdx from '../../../../integrations/mdx/dist/index.js';
import { attachContentServerListeners } from '../../../dist/content/server-listeners.js'; import { attachContentServerListeners } from '../../../dist/content/server-listeners.js';
import { runInContainer } from '../../../dist/core/dev/index.js';
import { createFsWithFallback, createRequestAndResponse } from '../test-utils.js';
const root = new URL('../../fixtures/content/', import.meta.url); const root = new URL('../../fixtures/content/', import.meta.url);

View file

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as cheerio from 'cheerio'; import * as cheerio from 'cheerio';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { import {
createContainerWithAutomaticRestart, createContainerWithAutomaticRestart,
@ -30,7 +30,7 @@ describe('dev container restarts', () => {
</html> </html>
`, `,
'/astro.config.mjs': ` '/astro.config.mjs': `
`, `,
}, },
root root

View file

@ -3,7 +3,7 @@ import { expect } from 'chai';
import { createFs } from '../test-utils.js'; import { createFs } from '../test-utils.js';
import { createRouteManifest } from '../../../dist/core/routing/manifest/create.js'; import { createRouteManifest } from '../../../dist/core/routing/manifest/create.js';
import { createDefaultDevSettings } from '../../../dist/core/config/index.js'; import { createDefaultDevSettings } from '../../../dist/core/config/index.js';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { defaultLogging } from '../test-utils.js'; import { defaultLogging } from '../test-utils.js';
const root = new URL('../../fixtures/alias/', import.meta.url); const root = new URL('../../fixtures/alias/', import.meta.url);

View file

@ -1,7 +1,7 @@
// @ts-check // @ts-check
import { createFs, createRequestAndResponse, defaultLogging } from '../test-utils.js'; import { createFs, createRequestAndResponse, defaultLogging } from '../test-utils.js';
import { createRouteManifest, matchAllRoutes } from '../../../dist/core/routing/index.js'; import { createRouteManifest, matchAllRoutes } from '../../../dist/core/routing/index.js';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { createViteLoader } from '../../../dist/core/module-loader/vite.js'; import { createViteLoader } from '../../../dist/core/module-loader/vite.js';
import { createDevelopmentEnvironment } from '../../../dist/core/render/dev/environment.js'; import { createDevelopmentEnvironment } from '../../../dist/core/render/dev/environment.js';
import { expect } from 'chai'; import { expect } from 'chai';

View file

@ -1,14 +1,14 @@
import { EventEmitter } from 'events';
import { Volume } from 'memfs'; import { Volume } from 'memfs';
import httpMocks from 'node-mocks-http'; import httpMocks from 'node-mocks-http';
import { EventEmitter } from 'node:events';
import realFS from 'node:fs'; import realFS from 'node:fs';
import npath from 'path'; import npath from 'node:path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'node:url';
import { unixify } from './correct-path.js';
import { getDefaultClientDirectives } from '../../dist/core/client-directive/index.js'; import { getDefaultClientDirectives } from '../../dist/core/client-directive/index.js';
import { nodeLogDestination } from '../../dist/core/logger/node.js';
import { createEnvironment } from '../../dist/core/render/index.js'; import { createEnvironment } from '../../dist/core/render/index.js';
import { RouteCache } from '../../dist/core/render/route-cache.js'; import { RouteCache } from '../../dist/core/render/route-cache.js';
import { nodeLogDestination } from '../../dist/core/logger/node.js'; import { unixify } from './correct-path.js';
/** @type {import('../../src/core/logger/core').LogOptions} */ /** @type {import('../../src/core/logger/core').LogOptions} */
export const defaultLogging = { export const defaultLogging = {
@ -99,7 +99,7 @@ export function createFsWithFallback(json, root) {
/** /**
* *
* @param {import('../../src/core/dev/container').Container} container * @param {import('../../src/core/dev/container').Container} container
* @param {typeof import('fs')} fs * @param {typeof import('node:fs')} fs
* @param {string} shortPath * @param {string} shortPath
* @param {'change'} eventType * @param {'change'} eventType
*/ */

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import { resolveConfig } from 'vite'; import { resolveConfig } from 'vite';
import { cachedFullCompilation } from '../../../dist/vite-plugin-astro/compile.js'; import { cachedFullCompilation } from '../../../dist/vite-plugin-astro/compile.js';
import { init, parse } from 'es-module-lexer'; import { init, parse } from 'es-module-lexer';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'node:url';
const viteConfig = await resolveConfig({ configFile: false }, 'serve'); const viteConfig = await resolveConfig({ configFile: false }, 'serve');

View file

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import fs from 'fs';
import { execa } from 'execa'; import { execa } from 'execa';
import fs from 'node:fs';
import { git } from '../dist/index.js'; import { git } from '../dist/index.js';
import { setup } from './utils.js'; import { setup } from './utils.js';

Some files were not shown because too many files have changed in this diff Show more