Skip to content

Commit

Permalink
chore: add node: prefix to node builtin modules (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyco130 authored Feb 24, 2023
1 parent 208db72 commit d7a1d32
Show file tree
Hide file tree
Showing 22 changed files with 288 additions and 181 deletions.
10 changes: 5 additions & 5 deletions ci/ci.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { describe, test, expect, beforeAll, afterAll } from "vitest";
import puppeteer from "puppeteer";
import path from "path";
import fs from "fs";
import { spawn, ChildProcess } from "child_process";
import path from "node:path";
import fs from "node:fs";
import { spawn, ChildProcess } from "node:child_process";
import fetch from "node-fetch";
import { promisify } from "util";
import { promisify } from "node:util";
import psTree from "ps-tree";
import { kill } from "process";
import { kill } from "node:process";

const TEST_HOST = "http://localhost:3000";

Expand Down
6 changes: 3 additions & 3 deletions examples/fastify-vite-plugin-ssr/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import viteDevServer from "vavite/http-dev-server";
import Fastify, { FastifyInstance } from "fastify";
import FastifyStatic from "@fastify/static";
import { AddressInfo } from "net";
import { AddressInfo } from "node:net";
import { renderPage } from "vite-plugin-ssr";
import { fileURLToPath } from "url";
import { IncomingMessage, ServerResponse } from "http";
import { fileURLToPath } from "node:url";
import { IncomingMessage, ServerResponse } from "node:http";

startServer();

Expand Down
2 changes: 1 addition & 1 deletion examples/fastify/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Fastify, { RouteHandlerMethod } from "fastify";
import viteDevServer from "vavite/vite-dev-server";
import { IncomingMessage, ServerResponse } from "http";
import { IncomingMessage, ServerResponse } from "node:http";

const fastify = Fastify({
// Your Fastify options go here.
Expand Down
2 changes: 1 addition & 1 deletion examples/hapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Hapi, { Lifecycle } from "@hapi/hapi";
import viteDevServer from "vavite/vite-dev-server";
import { IncomingMessage, ServerResponse } from "http";
import { IncomingMessage, ServerResponse } from "node:http";

// This is an optional optimization to load routes lazily so that
// when reloadOn option is set to "static-deps-change",
Expand Down
3 changes: 1 addition & 2 deletions examples/nestjs-vite-plugin-ssr/server/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NestFactory } from "@nestjs/core";
import type { Express } from "express";
import { IncomingMessage, ServerResponse } from "http";
import viteDevServer from "vavite/vite-dev-server";
import { IncomingMessage, ServerResponse } from "node:http";
import { AppModule } from "./app.module";

bootstrap();
Expand Down
4 changes: 2 additions & 2 deletions examples/nestjs-vite-plugin-ssr/server/vps.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DynamicModule, Inject, Module, OnModuleInit } from "@nestjs/common";
import { HttpAdapterHost } from "@nestjs/core";
import type { NextFunction, Request, Response } from "express";
import path, { join } from "path";
import { fileURLToPath } from "url";
import path, { join } from "node:path";
import { fileURLToPath } from "node:url";
import { renderPage } from "vite-plugin-ssr";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const OPTIONS = Symbol.for("vite-plugin-ssr.options");
Expand Down
3 changes: 1 addition & 2 deletions examples/nestjs/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NestFactory } from "@nestjs/core";
import type { Express } from "express";
import { IncomingMessage, ServerResponse } from "http";
import viteDevServer from "vavite/vite-dev-server";
import { IncomingMessage, ServerResponse } from "node:http";
import { AppModule } from "./app.module";

bootstrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-standalone/handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IncomingMessage, ServerResponse } from "http";
import type { IncomingMessage, ServerResponse } from "node:http";

export default function handler(
req: IncomingMessage,
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"eslint": "^8.31.0",
"sirv": "^2.0.2",
"tsup": "^6.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig({
Then create an `handler.ts` (or `.js`) file in the root of your project that default exports a function that takes `(req, res, next)` and handles the request. For example:

```ts
import type { IncomingMessage, ServerResponse } from "http";
import type { IncomingMessage, ServerResponse } from "node:http";
import type { SirvOptions } from "@vavite/connect";

export default function handler(
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/entry-standalone-with-sirv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServer } from "http";
import { createServer } from "node:http";
import sirv, { RequestHandler, Options } from "sirv";

let handleExports: {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/entry-standalone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServer } from "http";
import { createServer } from "node:http";
// @ts-expect-error: This is a virtual module
// eslint-disable-next-line import/no-unresolved
import handler from "/virtual:vavite-connect-handler";
Expand Down
8 changes: 4 additions & 4 deletions packages/connect/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin, UserConfig } from "vite";
import path from "path";
import url from "url";
import path from "node:path";
import url from "node:url";

const dirname =
typeof __dirname === "undefined"
Expand Down Expand Up @@ -150,8 +150,8 @@ export default function vaviteConnect(
];
}

import type { Stats } from "fs";
import type { IncomingMessage, ServerResponse } from "http";
import type { Stats } from "node:fs";
import type { IncomingMessage, ServerResponse } from "node:http";

type Arrayable<T> = T | T[];

Expand Down
2 changes: 1 addition & 1 deletion packages/expose-vite-dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"@types/node": "^18.11.18",
"eslint": "^8.31.0",
"tsup": "^6.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/expose-vite-dev-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Plugin, SSROptions, UserConfig, ViteDevServer } from "vite";
import crypto from "crypto";
import crypto from "node:crypto";

export default function vaviteDevServerPlugin(): Plugin {
let dev: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/multibuild-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"eslint": "^8.31.0",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/multibuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"eslint": "^8.31.0",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/reloader/http-dev-server.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Server } from "http";
import { Server } from "node:http";

declare const httpDevServer: Server | undefined;
export default httpDevServer;
2 changes: 1 addition & 1 deletion packages/reloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"@types/node": "^18.11.18",
"eslint": "^8.31.0",
"tsup": "^6.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/reloader/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IncomingMessage, ServerResponse } from "http";
import crypto from "crypto";
import { IncomingMessage, ServerResponse } from "node:http";
import crypto from "node:crypto";
import type {
ConfigEnv,
Logger,
Expand Down
2 changes: 1 addition & 1 deletion packages/vavite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"vite": ">=2.8.1"
},
"devDependencies": {
"@cyco130/eslint-config": "^2.1.2",
"@cyco130/eslint-config": "^3.0.1",
"@types/node": "^18.11.18",
"eslint": "^8.31.0",
"sirv": "^2.0.2",
Expand Down
Loading

0 comments on commit d7a1d32

Please sign in to comment.