Skip to content

Commit 3da8b3c

Browse files
committed
chore(optimizer): remove unused vendorRoots
Now they are only used to add noExternal to the vite config
1 parent 83ff79d commit 3da8b3c

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

packages/qwik/src/optimizer/src/plugins/plugin.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export function createPlugin(optimizerOptions: OptimizerOptions = {}) {
9595
insightsManifest: null,
9696
manifestOutput: null,
9797
transformedModuleOutput: null,
98-
vendorRoots: [],
9998
scope: null,
10099
devTools: {
101100
imageDevTools: true,
@@ -286,7 +285,6 @@ export function createPlugin(optimizerOptions: OptimizerOptions = {}) {
286285
opts.transformedModuleOutput = updatedOpts.transformedModuleOutput;
287286
}
288287

289-
opts.vendorRoots = updatedOpts.vendorRoots ? updatedOpts.vendorRoots : [];
290288
opts.scope = updatedOpts.scope ?? null;
291289

292290
if (typeof updatedOpts.resolveQwikBuild === 'boolean') {
@@ -617,11 +615,7 @@ export function createPlugin(optimizerOptions: OptimizerOptions = {}) {
617615
const dir = parsedPathId.dir;
618616
const base = parsedPathId.base;
619617
const ext = parsedPathId.ext.toLowerCase();
620-
if (
621-
ext in TRANSFORM_EXTS ||
622-
TRANSFORM_REGEX.test(pathId) ||
623-
insideRoots(ext, dir, opts.srcDir, opts.vendorRoots)
624-
) {
618+
if (ext in TRANSFORM_EXTS || TRANSFORM_REGEX.test(pathId)) {
625619
/** Strip client|server code from qwik server|client, but not in lib/test */
626620
const strip = opts.target === 'client' || opts.target === 'ssr';
627621
const normalizedID = normalizePath(pathId);
@@ -899,21 +893,6 @@ export const makeNormalizePath = (sys: OptimizerSystem) => (id: string) => {
899893
return id;
900894
};
901895

902-
const insideRoots = (ext: string, dir: string, srcDir: string | null, vendorRoots: string[]) => {
903-
if (ext !== '.js') {
904-
return false;
905-
}
906-
if (srcDir != null && dir.startsWith(srcDir)) {
907-
return true;
908-
}
909-
for (const root of vendorRoots) {
910-
if (dir.startsWith(root)) {
911-
return true;
912-
}
913-
}
914-
return false;
915-
};
916-
917896
function isAdditionalFile(mod: TransformModule) {
918897
return mod.isEntry || mod.hook;
919898
}
@@ -994,6 +973,7 @@ export interface QwikPluginOptions {
994973
entryStrategy?: EntryStrategy;
995974
rootDir?: string;
996975
tsconfigFileNames?: string[];
976+
/** @deprecated No longer used */
997977
vendorRoots?: string[];
998978
manifestOutput?: ((manifest: QwikManifest) => Promise<void> | void) | null;
999979
manifestInput?: QwikManifest | null;
@@ -1024,7 +1004,8 @@ export interface QwikPluginOptions {
10241004
lint?: boolean;
10251005
}
10261006

1027-
export interface NormalizedQwikPluginOptions extends Required<QwikPluginOptions> {
1007+
export interface NormalizedQwikPluginOptions
1008+
extends Omit<Required<QwikPluginOptions>, 'vendorRoots'> {
10281009
input: string[] | { [entry: string]: string };
10291010
}
10301011

packages/qwik/src/optimizer/src/plugins/vite.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
159159

160160
const shouldFindVendors =
161161
!qwikViteOpts.disableVendorScan && (target !== 'lib' || viteCommand === 'serve');
162-
const vendorRoots = shouldFindVendors ? await findQwikRoots(sys, sys.cwd()) : [];
163162
viteAssetsDir = viteConfig.build?.assetsDir;
164163
const useAssetsDir = target === 'client' && !!viteAssetsDir && viteAssetsDir !== '_astro';
165164
const pluginOpts: QwikPluginOptions = {
@@ -173,7 +172,6 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
173172
tsconfigFileNames: qwikViteOpts.tsconfigFileNames,
174173
resolveQwikBuild: true,
175174
transformedModuleOutput: qwikViteOpts.transformedModuleOutput,
176-
vendorRoots: [...(qwikViteOpts.vendorRoots ?? []), ...vendorRoots.map((v) => v.path)],
177175
outDir: viteConfig.build?.outDir,
178176
assetsDir: useAssetsDir ? viteAssetsDir : undefined,
179177
devTools: qwikViteOpts.devTools,
@@ -287,6 +285,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
287285
clientDevInput = qwikPlugin.normalizePath(clientDevInput);
288286
}
289287

288+
const vendorRoots = shouldFindVendors ? await findQwikRoots(sys, sys.cwd()) : [];
290289
const vendorIds = vendorRoots.map((v) => v.id);
291290
const isDevelopment = buildMode === 'development';
292291
const qDevKey = 'globalThis.qDev';
@@ -935,6 +934,8 @@ interface QwikVitePluginCommonOptions {
935934
* List of directories to recursively search for Qwik components or Vendors.
936935
*
937936
* Default `[]`
937+
*
938+
* @deprecated No longer used. Instead, any imported file with `.qwik.` in the name is processed.
938939
*/
939940
vendorRoots?: string[];
940941
/**

0 commit comments

Comments
 (0)