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

Fixed node imports incompatibility #286

Merged
merged 2 commits into from
Jun 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
6 changes: 6 additions & 0 deletions .changeset/nervous-pandas-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@vinxi/react-server": patch
"vinxi": patch
---

Swapped all virtual #vinxi references to $vinxi to be compatible with node imports
2 changes: 1 addition & 1 deletion examples/vanilla/trpc/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function trpcRouter({ plugins = () => [] } = {}) {
target: "server",
plugins: () => [
input(
"#vinxi/trpc/router",
"$vinxi/trpc/router",
fileURLToPath(new URL("./app/server.ts", import.meta.url)),
),
],
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla/trpc/handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import appRouter from "#vinxi/trpc/router";
import appRouter from "$vinxi/trpc/router";
import { createHTTPHandler } from "@trpc/server/adapters/standalone";
import { fromNodeMiddleware } from "vinxi/http";

Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla/trpc/trpc.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "#vinxi/trpc/router" {
declare module "$vinxi/trpc/router" {
const x: any;
export default x;
}
4 changes: 2 additions & 2 deletions packages/vinxi-react-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function appEntry() {
return config("alias", {
resolve: {
alias: {
"#vinxi/app": join(process.cwd(), "app", "app.tsx"),
"$vinxi/app": join(process.cwd(), "app", "app.tsx"),
},
},
});
Expand Down Expand Up @@ -48,7 +48,7 @@ export function defineConfig() {
config("other", {
resolve: {
alias: {
"#vinxi/app/client": fileURLToPath(
"$vinxi/app/client": fileURLToPath(
new URL("./app/client.ts", import.meta.url),
),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi-react-server/rsc-handler.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import App from "#vinxi/app";
import App from "$vinxi/app";
import { renderAsset } from "@vinxi/react";
import { Suspense } from "react";
import { eventHandler } from "vinxi/http";
Expand Down
16 changes: 8 additions & 8 deletions packages/vinxi/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ export async function createBuild(app, buildConfig) {
},
// minify: process.env.MINIFY !== "false" ?? true,
plugins: [
"#vinxi/prod-app",
"$vinxi/prod-app",
fileURLToPath(new URL("./app-fetch.js", import.meta.url)),
fileURLToPath(new URL("./app-manifest.js", import.meta.url)),
"#vinxi/chunks",
"$vinxi/chunks",
...(app.config.server.plugins ?? []),
],
buildDir: ".vinxi",
Expand Down Expand Up @@ -133,7 +133,7 @@ export async function createBuild(app, buildConfig) {
return [
{
route: router.base.length === 1 ? "/" : `${router.base}`,
handler: `#vinxi/spa/${router.name}`,
handler: `$vinxi/spa/${router.name}`,
middleware: true,
},
];
Expand Down Expand Up @@ -173,7 +173,7 @@ export async function createBuild(app, buildConfig) {
appConfigFiles: [],
imports: false,
virtual: {
"#vinxi/prod-app": () => {
"$vinxi/prod-app": () => {
const config = {
...app.config,
routers: app.config.routers.map((router) => {
Expand Down Expand Up @@ -242,7 +242,7 @@ export async function createBuild(app, buildConfig) {
...app.config.routers
.filter((router) => router.type === "spa")
.reduce((virtuals, router) => {
virtuals[`#vinxi/spa/${router.name}`] = () => {
virtuals[`$vinxi/spa/${router.name}`] = () => {
const indexHtml = readFileSync(
join(router.outDir, router.base, "index.html"),
"utf-8",
Expand All @@ -257,7 +257,7 @@ export async function createBuild(app, buildConfig) {
};
return virtuals;
}, {}),
"#vinxi/chunks": () => chunksServerVirtualModule()(app),
"$vinxi/chunks": () => chunksServerVirtualModule()(app),

...(Object.fromEntries(
Object.entries(app.config.server?.virtual ?? {}).map(([k, v]) => [
Expand Down Expand Up @@ -511,7 +511,7 @@ const routerModePlugin = {
[handlerModule(router)]: ({ config }) => {
invariant(
config.router.type === "client",
"#vinxi/handler is only supported in client mode",
"$vinxi/handler is only supported in client mode",
);
return `import * as mod from "${join(
config.router.root,
Expand Down Expand Up @@ -547,7 +547,7 @@ const routerModePlugin = {
[handlerModule(router)]: ({ config }) => {
invariant(
config.router.type === "http",
"#vinxi/handler is only supported in handler mode",
"$vinxi/handler is only supported in handler mode",
);

if (config.router.middleware) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export function handlerModule(
? isAbsolute(router.handler)
? router.handler
: join(router.root, router.handler)
: `#vinxi/handler/${router.name}`;
: `$vinxi/handler/${router.name}`;
}
2 changes: 1 addition & 1 deletion packages/vinxi/lib/router-dev-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ROUTER_MODE_DEV_PLUGINS = {
const router = config.router;
invariant(
router.handler,
"#vinxi/handler is only supported in handler mode",
"$vinxi/handler is only supported in handler mode",
);

if (router.middleware) {
Expand Down