File tree Expand file tree Collapse file tree 9 files changed +102
-43
lines changed
Expand file tree Collapse file tree 9 files changed +102
-43
lines changed Original file line number Diff line number Diff line change 3232 "@previewjs/vfs" : " ^2.1.4" ,
3333 "assert-never" : " ^1.3.0" ,
3434 "axios" : " ^1.7.9" ,
35- "esbuild-plugin-polyfill-node" : " ^0.3.0" ,
3635 "exclusive-promises" : " ^1.0.3" ,
3736 "express" : " ^4.21.2" ,
3837 "fs-extra" : " ^11.2.0" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import type {
1111 ReaderListenerInfo ,
1212} from "@previewjs/vfs" ;
1313import type { Alias } from "@rollup/plugin-alias" ;
14- import { polyfillNode } from "esbuild-plugin-polyfill-node" ;
1514import { exclusivePromiseRunner } from "exclusive-promises" ;
1615import express from "express" ;
1716import fs from "fs-extra" ;
@@ -369,14 +368,6 @@ export class ViteManager {
369368 ...config . vite ,
370369 configFile : false ,
371370 root : this . options . rootDir ,
372- optimizeDeps : {
373- entries : [ ] ,
374- esbuildOptions : {
375- // TODO: Remove this annotation once upgraded to Vite 5.
376- // @ts -ignore incompatible esbuild versions with Vite 4
377- plugins : [ polyfillNode ( ) ] ,
378- } ,
379- } ,
380371 server : {
381372 middlewareMode : true ,
382373 hmr : {
@@ -428,6 +419,7 @@ export class ViteManager {
428419 define : {
429420 __filename : undefined ,
430421 __dirname : undefined ,
422+ process : undefined ,
431423 ...frameworkPluginViteConfig . define ,
432424 ...existingViteConfig ?. config . define ,
433425 ...config . vite ?. define ,
Original file line number Diff line number Diff line change 3030 "@previewjs/storybook-helpers" : " ^6.0.1" ,
3131 "@previewjs/type-analyzer" : " ^10.1.5" ,
3232 "@previewjs/vfs" : " ^2.1.4" ,
33+ "esbuild-plugin-polyfill-node" : " ^0.3.0" ,
3334 "typescript" : " ^5.7.2"
3435 },
3536 "devDependencies" : {
Original file line number Diff line number Diff line change 11import type { Component , Story } from "@previewjs/analyzer-api" ;
22import type { FrameworkPluginFactory } from "@previewjs/core" ;
33import { createTypeAnalyzer } from "@previewjs/type-analyzer" ;
4+ import { polyfillNode } from "esbuild-plugin-polyfill-node" ;
45import path from "path" ;
56import ts from "typescript" ;
67import url from "url" ;
@@ -65,6 +66,11 @@ const preactFrameworkPlugin: FrameworkPluginFactory = {
6566 } ,
6667 viteConfig : ( configuredPlugins ) => {
6768 return {
69+ optimizeDeps : {
70+ esbuildOptions : {
71+ plugins : [ polyfillNode ( ) ] ,
72+ } ,
73+ } ,
6874 resolve : {
6975 alias : {
7076 react : "preact/compat" ,
Original file line number Diff line number Diff line change 2424 },
2525 "dependencies" : {
2626 "@previewjs/analyzer-react" : " ^0.1.11" ,
27- "@vitejs/plugin-react" : " ^4.3.4"
27+ "@vitejs/plugin-react" : " ^4.3.4" ,
28+ "esbuild-plugin-polyfill-node" : " ^0.3.0"
2829 },
2930 "devDependencies" : {
3031 "@playwright/test" : " ^1.49.1" ,
Original file line number Diff line number Diff line change 11import { createAnalyzer } from "@previewjs/analyzer-react" ;
22import type { FrameworkPluginFactory } from "@previewjs/core" ;
33import react from "@vitejs/plugin-react" ;
4+ import { polyfillNode } from "esbuild-plugin-polyfill-node" ;
45import path from "path" ;
56import url from "url" ;
67import { reactImportsPlugin } from "./react-js-imports-plugin.js" ;
@@ -41,6 +42,11 @@ const reactFrameworkPlugin: FrameworkPluginFactory = {
4142 plugin . name . startsWith ( "vite:react-" )
4243 ) ;
4344 return {
45+ optimizeDeps : {
46+ esbuildOptions : {
47+ plugins : dependencies [ "next" ] ? [ polyfillNode ( ) ] : [ ] ,
48+ } ,
49+ } ,
4450 resolve : {
4551 alias : {
4652 "react-native" : "react-native-web" ,
Original file line number Diff line number Diff line change 3131 "@previewjs/type-analyzer" : " ^10.1.5" ,
3232 "@previewjs/vfs" : " ^2.1.4" ,
3333 "@sveltejs/vite-plugin-svelte" : " ^5.0.2" ,
34+ "esbuild-plugin-polyfill-node" : " ^0.3.0" ,
3435 "fs-extra" : " ^11.2.0" ,
3536 "svelte" : " ^5.10.0" ,
3637 "typescript" : " ^5.7.2" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { FrameworkPluginFactory } from "@previewjs/core";
33import { createTypeAnalyzer } from "@previewjs/type-analyzer" ;
44import type sveltekit from "@sveltejs/kit" ;
55import { svelte } from "@sveltejs/vite-plugin-svelte" ;
6+ import { polyfillNode } from "esbuild-plugin-polyfill-node" ;
67import fs from "fs-extra" ;
78import path from "path" ;
89import url from "url" ;
@@ -74,6 +75,11 @@ const svelteFrameworkPlugin: FrameworkPluginFactory = {
7475 } ;
7576 } ,
7677 viteConfig : ( configuredPlugins ) => ( {
78+ optimizeDeps : {
79+ esbuildOptions : {
80+ plugins : [ polyfillNode ( ) ] ,
81+ } ,
82+ } ,
7783 ...( isSvelteKit
7884 ? {
7985 define : {
You can’t perform that action at this time.
0 commit comments