Skip to content

Commit

Permalink
docs(changeset): use pathe everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Sep 25, 2023
1 parent 9f785d3 commit c223ab6
Show file tree
Hide file tree
Showing 24 changed files with 41 additions and 32 deletions.
8 changes: 8 additions & 0 deletions .changeset/two-feet-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@vinxi/react-server": patch
"@vinxi/plugin-references": patch
"@vinxi/solid-start": patch
"vinxi": patch
---

use pathe everywhere
2 changes: 1 addition & 1 deletion frameworks/solid-start/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { join } from "path";
import { createApp, resolve } from "vinxi";
import {
BaseFileSystemRouter,
analyzeModule,
cleanPath,
} from "vinxi/fs-router";
import { join } from "vinxi/path";
import { config } from "vinxi/plugins/config";
import solid from "vite-plugin-solid";

Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi-react-server/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { references } from "@vinxi/plugin-references";
import reactRefresh from "@vitejs/plugin-react";
import { join } from "path";
import { fileURLToPath } from "url";
import { createApp } from "vinxi";
import { join } from "vinxi/path";
import { config } from "vinxi/plugins/config";

export function defineConfig() {
Expand Down
7 changes: 2 additions & 5 deletions packages/vinxi-references/chunks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from "fs";
import { join } from "path";
import { join } from "vinxi/path";

function getChunks(app, routerName, modIndex) {
const router = app.getRouter(routerName);
Expand All @@ -12,10 +12,7 @@ function getChunks(app, routerName, modIndex) {
([name, chunk]) => chunk.file.startsWith("c_") && name !== router.handler,
)
.map(([name, chunk], index) => {
const chunkPath = join(router.outDir, router.base, chunk.file).replace(
/\\/g,
"/",
);
const chunkPath = join(router.outDir, router.base, chunk.file);
return `
import * as mod_${index}_${modIndex} from '${chunkPath}';
chunks['${chunk.file}'] = mod_${index}_${modIndex}
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi-references/client-components.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from "fs";
import { join } from "path";
import { join } from "vinxi/path";

import { SERVER_REFERENCES_MANIFEST, hash } from "./constants.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi-references/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from "fs";
import { join } from "path";
import { join } from "vinxi/path";

import { CLIENT_REFERENCES_MANIFEST, hash } from "./constants.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/bin/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import mri from "mri";
import { resolve } from "pathe";

import { loadApp } from "../lib/load-app.js";
import { resolve } from "../lib/path.js";

async function main() {
const args = mri(process.argv.slice(2));
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/app-router-mode.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { join } from "pathe";
import * as v from "zod";

import { isMainThread } from "node:worker_threads";

import invariant from "./invariant.js";
import { join } from "./path.js";
import { resolve } from "./resolve.js";

export { v };
Expand Down
8 changes: 4 additions & 4 deletions packages/vinxi/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "h3";
import { createRequire } from "module";
import { build, copyPublicAssets, createNitro } from "nitropack";
import { join, relative } from "pathe";

import { writeFileSync } from "node:fs";
import { pathToFileURL } from "node:url";
Expand All @@ -17,6 +16,7 @@ import { createIncomingMessage, createServerResponse } from "./http-stream.js";
import invariant from "./invariant.js";
import { consola, withLogger } from "./logger.js";
import { createSPAManifest } from "./manifest/spa-manifest.js";
import { join, relative } from "./path.js";
import { config } from "./plugins/config.js";
import { manifest } from "./plugins/manifest.js";
import { routes } from "./plugins/routes.js";
Expand All @@ -34,7 +34,7 @@ const require = createRequire(import.meta.url);
*/
export async function createBuild(app, buildConfig) {
const { existsSync, promises: fsPromises, readFileSync } = await import("fs");
const { join } = await import("pathe");
const { join } = await import("./path.js");
const { fileURLToPath } = await import("url");
for (const router of app.config.routers) {
if (existsSync(router.outDir)) {
Expand Down Expand Up @@ -544,7 +544,7 @@ function handerBuild() {
"Invalid router",
);
const { builtinModules } = await import("module");
const { join } = await import("pathe");
const { join } = await import("./path.js");
const input = await getEntries(inlineConfig.router);
return {
build: {
Expand Down Expand Up @@ -583,7 +583,7 @@ function browserBuild() {
inlineConfig.router && inlineConfig.router.mode !== "static",
"Invalid router",
);
const { join } = await import("pathe");
const { join } = await import("./path.js");
return {
build: {
rollupOptions: {
Expand Down
1 change: 0 additions & 1 deletion packages/vinxi/lib/fs-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import esbuild from "esbuild";
import fg from "fast-glob";
import fs from "fs";
import micromatch from "micromatch";
import os from "os";
import { posix } from "path";
import { pathToRegexp } from "path-to-regexp";

Expand Down
3 changes: 1 addition & 2 deletions packages/vinxi/lib/manifest/client-manifest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference types="vite/client" />
/// <reference types="./client" />
import { join } from "pathe";

import { invariant } from "../invariant";
import { join } from "../path.js";

const manifest = new Proxy(
{},
Expand Down
3 changes: 2 additions & 1 deletion packages/vinxi/lib/manifest/collect-styles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";

import { isBuiltin } from "node:module";
import { join, resolve } from "pathe";

import { join, resolve } from "../path.js";

async function getViteModuleNode(vite, file, ssr) {
if (file.startsWith("node:") || isBuiltin(file)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/vinxi/lib/manifest/dev-server-manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isAbsolute, join, relative } from "pathe";

import invariant from "../invariant.js";
import { isAbsolute, join, relative } from "../path.js";
import findStylesInModuleGraph from "./collect-styles.js";

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/vinxi/lib/manifest/prod-server-manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { join, relative } from "pathe";

import invariant from "../invariant.js";
import { join, relative } from "../path.js";
import findAssetsInViteManifest from "./vite-manifest.js";

/** @typedef {import("../app.js").App & { config: { buildManifest: { [key:string]: any } }}} ProdApp */
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/manifest/spa-manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { log } from "console";
import { join, relative } from "pathe";

import { join, relative } from "../path.js";
import { createViteManifest } from "./create-vite-manifest.js";
import findAssetsInViteManifest from "./vite-manifest.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/nitro-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "h3";
// import httpProxy from "http-proxy";
import { listen } from "listhen";
import { resolve } from "pathe";
import { servePlaceholder } from "serve-placeholder";
import serveStatic from "serve-static";
import { joinURL } from "ufo";
Expand All @@ -21,6 +20,7 @@ import {
import { WebSocketServer } from "ws";

import { createServerResponse } from "./http-stream.js";
import { resolve } from "./path.js";

// import { createVFSHandler } from './vfs'
// import defaultErrorHandler from './error'
Expand Down
1 change: 1 addition & 0 deletions packages/vinxi/lib/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "pathe";
3 changes: 2 additions & 1 deletion packages/vinxi/lib/plugins/fs-watcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from "node:url";
import { normalize } from "pathe";

import { normalize } from "../path.js";

/**
*
Expand Down
3 changes: 2 additions & 1 deletion packages/vinxi/lib/plugins/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { relative } from "pathe";
import { fileURLToPath } from "node:url";

import { relative } from "../path.js";

/**
*
* @returns {import("../vite-dev.d.ts").Plugin}
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/plugins/virtual.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, resolve } from "pathe";
import { dirname, resolve } from "../path.js";

const PREFIX = "\0virtual:";

Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/resolve.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isAbsolute, join, relative } from "pathe";
import { isAbsolute, join, relative } from "./path.js";

/**
* @template {string | undefined} T
Expand Down
3 changes: 1 addition & 2 deletions packages/vinxi/lib/router-dev-plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { join } from "pathe";

import { devEntries } from "./dev-server.js";
import invariant from "./invariant.js";
import { join } from "./path.js";
import { config } from "./plugins/config.js";
import { css } from "./plugins/css.js";
import { fileSystemWatcher } from "./plugins/fs-watcher.js";
Expand Down
6 changes: 6 additions & 0 deletions packages/vinxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
},
"./plugins/virtual": {
"import": "./lib/plugins/virtual.js"
},
"./path": {
"import": "./lib/path.js"
}
},
"typesVersions": {
Expand Down Expand Up @@ -91,6 +94,9 @@
],
"plugins/virtual": [
"./dist/types/lib/plugins/virtual.d.ts"
],
"path": [
"./dist/types/lib/path.d.ts"
]
}
},
Expand Down
1 change: 0 additions & 1 deletion test/templates/react/app.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import reactRefresh from "@vitejs/plugin-react";
import { join } from "path";
import { createApp, resolve } from "vinxi";
import {
BaseFileSystemRouter,
Expand Down

0 comments on commit c223ab6

Please sign in to comment.