Skip to content

Commit

Permalink
fix: add Node polyfills to fix Next.js support (#1946)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts authored Aug 19, 2023
1 parent 97c5504 commit a92f2aa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
1 change: 1 addition & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"acorn-jsx": "^5.3.2",
"assert-never": "^1.2.1",
"axios": "^1.4.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
"exclusive-promises": "^1.0.3",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
Expand Down
5 changes: 5 additions & 0 deletions core/src/vite/vite-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { decodePreviewableId } from "@previewjs/analyzer-api";
import type { PreviewConfig } from "@previewjs/config";
import type { Reader } from "@previewjs/vfs";
import type { Alias } from "@rollup/plugin-alias";
import { polyfillNode } from "esbuild-plugin-polyfill-node";
import express from "express";
import fs from "fs-extra";
import type { Server } from "http";
Expand Down Expand Up @@ -288,6 +289,10 @@ export class ViteManager {
base: "/preview/",
optimizeDeps: {
entries: [],
esbuildOptions: {
// @ts-expect-error incompatible esbuild versions?
plugins: [polyfillNode()],
},
},
server: {
middlewareMode: true,
Expand Down
71 changes: 38 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a92f2aa

Please sign in to comment.