@@ -5,7 +5,6 @@ import type {
5
5
GlobalInjections ,
6
6
Optimizer ,
7
7
OptimizerOptions ,
8
- OptimizerSystem ,
9
8
QwikManifest ,
10
9
TransformModule ,
11
10
} from '../types' ;
@@ -25,7 +24,6 @@ import {
25
24
type NormalizedQwikPluginOptions ,
26
25
type QwikBuildMode ,
27
26
type QwikBuildTarget ,
28
- type QwikPackages ,
29
27
type QwikPluginOptions ,
30
28
} from './plugin' ;
31
29
import { createRollupError , normalizeRollupOutputOptions } from './rollup' ;
@@ -96,7 +94,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
96
94
async config ( viteConfig , viteEnv ) {
97
95
await qwikPlugin . init ( ) ;
98
96
99
- const sys = qwikPlugin . getSys ( ) ;
100
97
const path = qwikPlugin . getPath ( ) ;
101
98
102
99
let target : QwikBuildTarget ;
@@ -149,8 +146,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
149
146
if ( input && typeof input === 'string' ) {
150
147
input = [ input ] ;
151
148
}
152
- const shouldFindVendors =
153
- ! qwikViteOpts . disableVendorScan && ( target !== 'lib' || viteCommand === 'serve' ) ;
154
149
viteAssetsDir = viteConfig . build ?. assetsDir ;
155
150
const useAssetsDir = target === 'client' && ! ! viteAssetsDir && viteAssetsDir !== '_astro' ;
156
151
const pluginOpts : QwikPluginOptions = {
@@ -208,8 +203,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
208
203
clientDevInput = qwikPlugin . normalizePath ( clientDevInput ) ;
209
204
}
210
205
211
- const vendorRoots = shouldFindVendors ? await findQwikRoots ( sys , sys . cwd ( ) ) : [ ] ;
212
- const vendorIds = vendorRoots . map ( ( v ) => v . id ) ;
213
206
const isDevelopment = buildMode === 'development' ;
214
207
const qDevKey = 'globalThis.qDev' ;
215
208
const qTestKey = 'globalThis.qTest' ;
@@ -221,17 +214,11 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
221
214
222
215
const updatedViteConfig : UserConfig = {
223
216
ssr : {
224
- noExternal : [
225
- QWIK_CORE_ID ,
226
- QWIK_CORE_INTERNAL_ID ,
227
- QWIK_CORE_SERVER ,
228
- QWIK_BUILD_ID ,
229
- ...vendorIds ,
230
- ] ,
217
+ noExternal : [ QWIK_CORE_ID , QWIK_CORE_INTERNAL_ID , QWIK_CORE_SERVER , QWIK_BUILD_ID ] ,
231
218
} ,
232
219
envPrefix : [ 'VITE_' , 'PUBLIC_' ] ,
233
220
resolve : {
234
- dedupe : [ ...DEDUPE , ... vendorIds ] ,
221
+ dedupe : [ ...DEDUPE ] ,
235
222
conditions : buildMode === 'production' && target === 'client' ? [ 'min' ] : [ ] ,
236
223
alias : {
237
224
'@builder.io/qwik' : '@qwik.dev/core' ,
@@ -264,8 +251,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
264
251
QWIK_JSX_DEV_RUNTIME_ID ,
265
252
QWIK_BUILD_ID ,
266
253
QWIK_CLIENT_MANIFEST_ID ,
267
- // Sadly we can't specify **/*.qwik.*, so we need to specify each one
268
- ...vendorIds ,
269
254
// v1 imports, they are removed during transform but vite doesn't know that
270
255
'@builder.io/qwik' ,
271
256
'@builder.io/qwik-city' ,
@@ -714,90 +699,6 @@ export async function render(document, rootNode, opts) {
714
699
}` ;
715
700
}
716
701
717
- async function findDepPkgJsonPath ( sys : OptimizerSystem , dep : string , parent : string ) {
718
- const fs : typeof import ( 'fs' ) = await sys . dynamicImport ( 'node:fs' ) ;
719
- let root = parent ;
720
- while ( root ) {
721
- const pkg = sys . path . join ( root , 'node_modules' , dep , 'package.json' ) ;
722
- try {
723
- await fs . promises . access ( pkg ) ;
724
- // use 'node:fs' version to match 'vite:resolve' and avoid realpath.native quirk
725
- // https://github.com/sveltejs/vite-plugin-svelte/issues/525#issuecomment-1355551264
726
- return fs . promises . realpath ( pkg ) ;
727
- } catch {
728
- //empty
729
- }
730
- const nextRoot = sys . path . dirname ( root ) ;
731
- if ( nextRoot === root ) {
732
- break ;
733
- }
734
- root = nextRoot ;
735
- }
736
- return undefined ;
737
- }
738
-
739
- const findQwikRoots = async (
740
- sys : OptimizerSystem ,
741
- packageJsonDir : string
742
- ) : Promise < QwikPackages [ ] > => {
743
- const paths = new Map < string , string > ( ) ;
744
- if ( sys . env === 'node' || sys . env === 'bun' ) {
745
- const fs : typeof import ( 'fs' ) = await sys . dynamicImport ( 'node:fs' ) ;
746
- let prevPackageJsonDir : string | undefined ;
747
- do {
748
- try {
749
- const data = await fs . promises . readFile ( sys . path . join ( packageJsonDir , 'package.json' ) , {
750
- encoding : 'utf-8' ,
751
- } ) ;
752
-
753
- try {
754
- const packageJson = JSON . parse ( data ) ;
755
- const dependencies = packageJson [ 'dependencies' ] ;
756
- const devDependencies = packageJson [ 'devDependencies' ] ;
757
-
758
- const packages : string [ ] = [ ] ;
759
- if ( typeof dependencies === 'object' ) {
760
- packages . push ( ...Object . keys ( dependencies ) ) ;
761
- }
762
- if ( typeof devDependencies === 'object' ) {
763
- packages . push ( ...Object . keys ( devDependencies ) ) ;
764
- }
765
-
766
- const basedir = sys . cwd ( ) ;
767
- await Promise . all (
768
- packages . map ( async ( id ) => {
769
- const pkgJsonPath = await findDepPkgJsonPath ( sys , id , basedir ) ;
770
- if ( pkgJsonPath ) {
771
- const pkgJsonContent = await fs . promises . readFile ( pkgJsonPath , 'utf-8' ) ;
772
- const pkgJson = JSON . parse ( pkgJsonContent ) ;
773
- const qwikPath = pkgJson [ 'qwik' ] ;
774
- if ( ! qwikPath ) {
775
- return ;
776
- }
777
- // Support multiple paths
778
- const allPaths = Array . isArray ( qwikPath ) ? qwikPath : [ qwikPath ] ;
779
- for ( const p of allPaths ) {
780
- paths . set (
781
- await fs . promises . realpath ( sys . path . resolve ( sys . path . dirname ( pkgJsonPath ) , p ) ) ,
782
- id
783
- ) ;
784
- }
785
- }
786
- } )
787
- ) ;
788
- } catch ( e ) {
789
- console . error ( e ) ;
790
- }
791
- } catch {
792
- // ignore errors if package.json not found
793
- }
794
- prevPackageJsonDir = packageJsonDir ;
795
- packageJsonDir = sys . path . dirname ( packageJsonDir ) ;
796
- } while ( packageJsonDir !== prevPackageJsonDir ) ;
797
- }
798
- return Array . from ( paths ) . map ( ( [ path , id ] ) => ( { path, id } ) ) ;
799
- } ;
800
-
801
702
export const isNotNullable = < T > ( v : T ) : v is NonNullable < T > => {
802
703
return v != null ;
803
704
} ;
0 commit comments