Skip to content

Commit e0ecf93

Browse files
authored
Remove-import-meta-glob-eager-true (#928)
* chore(website): remove import.meta.glob eager true * chore(website): comment out vite config trick to se chunk names
1 parent b19a887 commit e0ecf93

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

apps/component-tests/src/components/showcase-test/component-imports.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { isDev } from '@builder.io/qwik/build';
32

43
// The below `/src/routes/docs/**/**/examples/*.tsx` patterns are here so that import.meta.glob works both for styled and headless routes.
54
// For example:
@@ -11,7 +10,6 @@ function createMetaGlobComponents() {
1110
'../../../../website/src/routes/docs/**/**/examples/*.tsx',
1211
{
1312
import: 'default',
14-
eager: isDev ? false : true,
1513
},
1614
);
1715

apps/website/src/components/code-snippet/code-snippet.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { PropsOf, component$, useSignal, useTask$ } from '@builder.io/qwik';
22
import { useLocation } from '@builder.io/qwik-city';
3-
import { isDev } from '@builder.io/qwik/build';
43
import { Highlight } from '../highlight/highlight';
54

65
// The below `/src/routes/docs/**/**/snippets/*.tsx` pattern is here so that import.meta.glob works both for styled and headless routes.
@@ -12,7 +11,6 @@ import { Highlight } from '../highlight/highlight';
1211
const codeSnippets: any = import.meta.glob('/src/routes/docs/**/**/snippets/*', {
1312
query: '?raw',
1413
import: 'default',
15-
eager: isDev ? false : true,
1614
});
1715

1816
type CodeSnippetProps = PropsOf<'div'> & {
@@ -30,9 +28,7 @@ export const CodeSnippet = component$<CodeSnippetProps>(({ name }) => {
3028
const codeSnippetSig = useSignal<string>();
3129

3230
useTask$(async () => {
33-
codeSnippetSig.value = isDev
34-
? await codeSnippets[snippetPath]() // We need to call `await codeSnippets[snippetPath]()` in development as it is `eager:false`
35-
: codeSnippets[snippetPath]; // We need to directly access the `codeSnippets[snippetPath]` expression in preview/production as it is `eager:true`
31+
codeSnippetSig.value = await codeSnippets[snippetPath](); // We need to call `await codeSnippets[snippetPath]()` in development as it is `eager:false`
3632
});
3733

3834
return (

apps/website/src/components/showcase/component-imports.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { isDev } from '@builder.io/qwik/build';
2-
31
// The below `/src/routes/docs/**/**/examples/*.tsx` patterns are here so that import.meta.glob works both for styled and headless routes.
42
// For example:
53
// /src/routes/docs/components/styled/modal/examples/hero.tsx
@@ -10,7 +8,6 @@ export const metaGlobComponents: Record<string, any> = import.meta.glob(
108
'/src/routes/docs/**/**/examples/*.tsx',
119
{
1210
import: 'default',
13-
eager: isDev ? false : true,
1411
},
1512
);
1613

@@ -20,6 +17,5 @@ export const rawComponents: Record<string, any> = import.meta.glob(
2017
{
2118
query: '?raw',
2219
import: 'default',
23-
eager: isDev ? false : true,
2420
},
2521
);

apps/website/src/components/showcase/showcase.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component, component$, useSignal, useTask$ } from '@builder.io/qwik';
22
import { useLocation } from '@builder.io/qwik-city';
3-
import { isDev } from '@builder.io/qwik/build';
43
import { Tabs } from '@qwik-ui/headless';
54
import { Highlight } from '../highlight/highlight';
65
import { metaGlobComponents, rawComponents } from './component-imports';
@@ -20,12 +19,8 @@ export const Showcase = component$<ShowcaseProps>(({ name, ...props }) => {
2019

2120
useTask$(async () => {
2221
// eslint-disable-next-line qwik/valid-lexical-scope
23-
MetaGlobComponentSig.value = isDev
24-
? await metaGlobComponents[componentPath]() // We need to call `await metaGlobComponents[componentPath]()` in development as it is `eager:false`
25-
: metaGlobComponents[componentPath]; // We need to directly access the `metaGlobComponents[componentPath]` expression in preview/production as it is `eager:true`
26-
componentCodeSig.value = isDev
27-
? await rawComponents[componentPath]()
28-
: rawComponents[componentPath];
22+
MetaGlobComponentSig.value = await metaGlobComponents[componentPath](); // We need to call `await metaGlobComponents[componentPath]()` in development as it is `eager:false`
23+
componentCodeSig.value = await rawComponents[componentPath]();
2924
});
3025

3126
return (

apps/website/vite.config.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ import { qwikNxVite } from 'qwik-nx/plugins';
44
import { defineConfig } from 'vite';
55
import tsconfigPaths from 'vite-tsconfig-paths';
66
import { recmaProvideComponents } from './recma-provide-components';
7-
import { isDev } from '@builder.io/qwik/build';
87

98
export default defineConfig(async () => {
109
const { default: rehypePrettyCode } = await import('rehype-pretty-code');
1110
const { visit } = await import('unist-util-visit');
1211

13-
let output: any = {};
14-
if (!isDev) {
15-
// Client-specific configuration
16-
output = {
17-
// Customize the client build structure
18-
entryFileNames: ({ name }: any) => {
19-
if (name.startsWith('entry')) {
20-
return '[name].js';
21-
}
22-
return `build/[name]-[hash].js`;
23-
},
24-
chunkFileNames: () => {
25-
return `build/[name]-[hash].js`;
26-
},
27-
assetFileNames: `build/[name]-[hash].[ext]`,
28-
};
29-
}
12+
// commented out as doesn't seem to work with import.meta.glob eager:false in preview
13+
// let output: any = {};
14+
// if (!isDev) {
15+
// // Client-specific configuration
16+
// output = {
17+
// // Customize the client build structure
18+
// entryFileNames: ({ name }: any) => {
19+
// if (name.startsWith('entry')) {
20+
// return '[name].mjs';
21+
// }
22+
// return `[name]-[hash].js`;
23+
// },
24+
// chunkFileNames: () => {
25+
// return `[name]-[hash].js`;
26+
// },
27+
// assetFileNames: `build/[name]-[hash].[ext]`,
28+
// };
29+
// }
3030

3131
return {
3232
plugins: [
@@ -96,7 +96,7 @@ export default defineConfig(async () => {
9696
build: {
9797
target: 'es2022',
9898
rollupOptions: {
99-
output,
99+
// output,
100100
},
101101
},
102102
preview: {

0 commit comments

Comments
 (0)