Skip to content

Commit

Permalink
Merge pull request #6979 from QwikDev/v2-merge-main
Browse files Browse the repository at this point in the history
chore(v2): merge main into build/v2
  • Loading branch information
wmertens authored Oct 15, 2024
2 parents 103581c + 4381105 commit 3b5d6d9
Show file tree
Hide file tree
Showing 32 changed files with 592 additions and 406 deletions.
6 changes: 6 additions & 0 deletions .changeset/ninety-planets-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@builder.io/qwik-city': patch
'@builder.io/qwik': patch
---

FIX: `vite` is now a peer dependency of `qwik` and `qwik-city`, so that there can be no duplicate imports. This should not have consequences, since all apps also directly depend on `vite`.
5 changes: 5 additions & 0 deletions .changeset/unlucky-experts-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

Allow setting `linkFetchPriority` for modulepreload links in the prefetch strategy. Also fix the links in dev mode
12 changes: 6 additions & 6 deletions flake.lock

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"dependencies": [
"@playwright/test"
],
"pinVersion": "1.40.0"
"pinVersion": "1.47.0"
},
{
"label": "use exact version numbers for devDependencies",
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/components/footer/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const linkColumns = [
{ title: 'Tutorial', href: `${baseUrl}/ecosystem/#courses` },
{ title: 'Presentations', href: `${baseUrl}/ecosystem/#presentations` },
{ title: 'Community', href: `${baseUrl}/ecosystem/#community` },
{ title: 'Press', href: `${baseUrl}/press` },
],
];

Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/repl/repl-output-modules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ReplOutputModules = component$(({ outputs, headerText }: ReplOutput
class={{ 'in-view': selectedPath.value === o.path }}
preventdefault:click
key={o.path}
title={o.path}
>
{o.path}
</a>
Expand Down
6 changes: 5 additions & 1 deletion packages/docs/src/repl/repl-output-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const ReplOutputPanel = component$(({ input, store }: ReplOutputPanelProp
const diagnosticsLen = useComputed$(
() => store.diagnostics.length + store.monacoDiagnostics.length
);
const clientBundlesNoCore = useComputed$(() =>
// Qwik Core is not interesting and is large, slowing down the UI
store.clientBundles.filter((b) => !b.path.endsWith('qwikCore.js'))
);

return (
<div class="repl-panel repl-output-panel">
Expand Down Expand Up @@ -113,7 +117,7 @@ export const ReplOutputPanel = component$(({ input, store }: ReplOutputPanelProp
) : null}

{store.selectedOutputPanel === 'clientBundles' ? (
<ReplOutputModules headerText="/build/" outputs={store.clientBundles} />
<ReplOutputModules headerText="/build/" outputs={clientBundlesNoCore.value} />
) : null}

{store.selectedOutputPanel === 'serverModules' ? (
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/repl/repl-output-symbols.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const ReplOutputSymbols = component$(({ outputs }: ReplOutputSymbolsProps
}}
class={{ 'in-view': selectedPath.value === o.path }}
preventdefault:click
title={o.segment?.canonicalFilename}
>
{o.segment?.canonicalFilename}
</a>
Expand Down
7 changes: 6 additions & 1 deletion packages/docs/src/repl/repl-output-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export const updateReplOutput = async (store: ReplStore, result: ReplResult) =>
deepUpdate(store.transformedModules, result.transformedModules);
deepUpdate(store.clientBundles, result.clientBundles);
deepUpdate(store.ssrModules, result.ssrModules);
deepUpdate(store.events, result.events);
if (
result.events.length !== store.events.length ||
result.events.some((ev, i) => ev?.start !== store.events[i]?.start)
) {
store.events = result.events;
}

if (store.selectedOutputPanel === 'diagnostics' && store.monacoDiagnostics.length === 0) {
store.selectedOutputPanel = 'app';
Expand Down
5 changes: 1 addition & 4 deletions packages/docs/src/repl/worker/app-bundle-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const appBundleClient = async (

const rollupInputOpts: InputOptions = {
input: entry.path,
cache: self.rollupCache,
plugins: [
replCss(options),
self.qwikOptimizer?.qwikRollup(qwikRollupClientOpts),
Expand Down Expand Up @@ -71,8 +70,6 @@ export const appBundleClient = async (

const bundle = await self.rollup?.rollup(rollupInputOpts);
if (bundle) {
self.rollupCache = bundle.cache;

const generated = await bundle.generate({
sourcemap: false,
});
Expand All @@ -96,7 +93,7 @@ export const appBundleClient = async (
})
);

// clear out old cache
// clear out old results cache
// no need to wait
cache.keys().then((keys) => {
if (keys.length > 500) {
Expand Down
29 changes: 7 additions & 22 deletions packages/docs/src/repl/worker/repl-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
name: 'repl-resolver',

resolveId(id, importer) {
// Entry point
if (!importer) {
return id;
}
Expand All @@ -25,12 +26,10 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
) {
return '\0qwikCore';
}
if (id === '@builder.io/qwik/build') {
return '\0qwikBuild';
}
if (id === '@builder.io/qwik/server') {
return '\0qwikServer';
}
// Simple relative file resolution
if (id.startsWith('./')) {
const extensions = ['', '.tsx', '.ts'];
id = id.slice(1);
Expand All @@ -41,10 +40,6 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
}
}
}
return {
id,
external: true,
};
},

async load(id) {
Expand All @@ -59,20 +54,6 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
if (id === '\0qwikServer') {
return getRuntimeBundle('qwikServer');
}
if (id === '\0qwikBuild') {
return `
export const isServer = true;
export const isBrowser = false;
export const isDev = false;
`;
}
}
if (id === '\0qwikBuild') {
return `
export const isServer = false;
export const isBrowser = true;
export const isDev = false;
`;
}
if (id === '\0qwikCore') {
if (options.buildMode === 'production') {
Expand All @@ -88,7 +69,11 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
}
throw new Error(`Unable to load Qwik core`);
}
return null;

// We're the fallback, we know all the files
if (/\.[jt]sx?$/.test(id)) {
throw new Error(`load: unknown module ${id}`);
}
},
};
};
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik-server/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}
],
"kind": "Interface",
"content": "```typescript\nexport interface PrefetchImplementation \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[linkInsert?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'js-append' \\| 'html-append' \\| null\n\n\n</td><td>\n\n_(Optional)_ `js-append`<!-- -->: Use JS runtime to create each `<link>` and append to the body.\n\n`html-append`<!-- -->: Render each `<link>` within html, appended at the end of the body.\n\n\n</td></tr>\n<tr><td>\n\n[linkRel?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'prefetch' \\| 'preload' \\| 'modulepreload' \\| null\n\n\n</td><td>\n\n_(Optional)_ Value of the `<link rel=\"...\">` attribute when link is used. Defaults to `prefetch` if links are inserted.\n\n\n</td></tr>\n<tr><td>\n\n[prefetchEvent?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'always' \\| null\n\n\n</td><td>\n\n_(Optional)_ Dispatch a `qprefetch` event with detail data containing the bundles that should be prefetched. The event dispatch script will be inlined into the document's HTML so any listeners of this event should already be ready to handle the event.\n\nThis implementation will inject a script similar to:\n\n```\n<script type=\"module\">\n document.dispatchEvent(new CustomEvent(\"qprefetch\", { detail:{ \"bundles\": [...] } }))\n</script>\n```\nBy default, the `prefetchEvent` implementation will be set to `always`<!-- -->.\n\n\n</td></tr>\n<tr><td>\n\n[workerFetchInsert?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'always' \\| 'no-link-support' \\| null\n\n\n</td><td>\n\n_(Optional)_ `always`<!-- -->: Always include the worker fetch JS runtime.\n\n`no-link-support`<!-- -->: Only include the worker fetch JS runtime when the browser doesn't support `<link>` prefetch/preload/modulepreload.\n\n\n</td></tr>\n</tbody></table>",
"content": "```typescript\nexport interface PrefetchImplementation \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[linkFetchPriority?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'auto' \\| 'low' \\| 'high' \\| null\n\n\n</td><td>\n\n_(Optional)_ Value of the `<link fetchpriority=\"...\">` attribute when link is used. Defaults to `null` if links are inserted.\n\n\n</td></tr>\n<tr><td>\n\n[linkInsert?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'js-append' \\| 'html-append' \\| null\n\n\n</td><td>\n\n_(Optional)_ `js-append`<!-- -->: Use JS runtime to create each `<link>` and append to the body.\n\n`html-append`<!-- -->: Render each `<link>` within html, appended at the end of the body.\n\n\n</td></tr>\n<tr><td>\n\n[linkRel?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'prefetch' \\| 'preload' \\| 'modulepreload' \\| null\n\n\n</td><td>\n\n_(Optional)_ Value of the `<link rel=\"...\">` attribute when link is used. Defaults to `prefetch` if links are inserted.\n\n\n</td></tr>\n<tr><td>\n\n[prefetchEvent?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'always' \\| null\n\n\n</td><td>\n\n_(Optional)_ Dispatch a `qprefetch` event with detail data containing the bundles that should be prefetched. The event dispatch script will be inlined into the document's HTML so any listeners of this event should already be ready to handle the event.\n\nThis implementation will inject a script similar to:\n\n```\n<script type=\"module\">\n document.dispatchEvent(new CustomEvent(\"qprefetch\", { detail:{ \"bundles\": [...] } }))\n</script>\n```\nBy default, the `prefetchEvent` implementation will be set to `always`<!-- -->.\n\n\n</td></tr>\n<tr><td>\n\n[workerFetchInsert?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'always' \\| 'no-link-support' \\| null\n\n\n</td><td>\n\n_(Optional)_ `always`<!-- -->: Always include the worker fetch JS runtime.\n\n`no-link-support`<!-- -->: Only include the worker fetch JS runtime when the browser doesn't support `<link>` prefetch/preload/modulepreload.\n\n\n</td></tr>\n</tbody></table>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/server/types.ts",
"mdFile": "qwik.prefetchimplementation.md"
},
Expand Down
15 changes: 15 additions & 0 deletions packages/docs/src/routes/api/qwik-server/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ Description
</th></tr></thead>
<tbody><tr><td>

[linkFetchPriority?](#)

</td><td>

</td><td>

'auto' \| 'low' \| 'high' \| null

</td><td>

_(Optional)_ Value of the `<link fetchpriority="...">` attribute when link is used. Defaults to `null` if links are inserted.

</td></tr>
<tr><td>

[linkInsert?](#)

</td><td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function (opts: RenderToStreamOptions) {
| `prefetchEvent` | Dispatch a `qprefetch` event with `detail` data containing the urls that should be prefetched. The event dispatch script will be inlined into the document's HTML. By default, the `prefetchEvent` implementation will be set to `always`. |
| `linkInsert` | Insert the `<link>` element into the document. When using `html-append`, it will render each `<link>` directly within the html, appended at the end of the body. Using the `js-append` option, it will instead insert some JavaScript, which creates the elements at runtime and appends them at the end of the body. |
| `linkRel` | This option is used to define the [`rel` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types) of the `<link>` element. When the `linkInsert` option is used, the default is `prefetch`. Other options include `preload` and `modulepreload`. |
| `linkFetchPriority` | This option is used to define the [`fetchpriority` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#fetchpriority) of the `<link>` element. When the `linkInsert` option is used, the default is `null`. Other options include `low`, `high` and `auto`.
| `workerFetchInsert` | Prefetch urls by calling a `fetch()` for each module, with the goal of populating the network cache. |

#### Dispatched Prefetch Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default component$(() => {
</CodeSandbox>

> The `component$` function, marked by the trailing `$`, enables the Optimizer to split components into separate chunks.
This allows each chunk to be loaded independently as needed, rather than loading all components whenever the parent component is loaded.
This allows each chunk to be loaded independently as needed, rather than loading all components whenever the parent component is loaded.
> Note: index.tsx, layout.tsx in routes folder, root.tsx and all entry files need **export default**. For other components you can use export const and export function.
### Composing Components
Expand Down Expand Up @@ -113,13 +113,13 @@ export default component$(() => {

## Props

Props are used to pass data from the parent into the component. Data passed via props is accessible via the `props` argument to the `component$` function.
Props are used to pass data from the parent into the component. Data passed via props is accessible via the `props` argument to the `component$` function.

Props are shallowly immutable, meaning primitive data types (strings, numbers, booleans) cannot be changed once passed. However, internal elements of reference types (objects, arrays, functions) can be changed despite the reference itself being immutable.

To change primitive props data in the parent component from the child component, use signals. When updating data locally within the child component a signal is not necessary, destructure the props and use the values to define new local variables.

The two examples below show a component `Item` that declares optional `name`, `quantity`, `description`, and `price` props.
The two examples below show a component `Item` that declares optional `name`, `quantity`, `description`, and `price` props.

In the first example, primitive data types are passed via props. The `price` prop is passed as a signal and can be changed from the parent component. `quantity` is passed as a number value that is used to define a new signal in `Item` that can be reactively updated locally. Alternatively, if quantity did not need to be reactive it could be defined as a normal variable instead of a signal.

Expand Down Expand Up @@ -500,14 +500,14 @@ Note the `string extends C`, this is only true when TypeScript cannot infer the
- [`$()`](../../advanced/qrl/index.mdx) - creates a QRL
- [`noSerialize()`](/docs/components/state/#noserialize)
- `useErrorBoundary()`
- [`qwikVite()`](../../advanced/vite/index.mdx#qwikvite) - entry point for qwik with vite

### Components

- [`<Slot>`](../slots/index.mdx) - declares a content projection slot
- `<SSRStreamBlock>` - declares a stream block
- `<SSRStream>` - declares a stream
- `<Fragment>` - declares a JSX fragment

## See Also

- [Inline components](../overview/index.mdx#inline-components)
3 changes: 2 additions & 1 deletion packages/docs/src/routes/docs/(qwikcity)/qwikcity/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ While Qwik focuses on the Component API, Qwik City provides APIs that support co
- [middleware](/docs/middleware/): A centralized way to perform cross-cutting concerns such as authentication, security, caching, redirects, and logging.
- [server$](/docs/server$/): A simple way to execute logic on the server.
- [cache](/docs/caching/): Control caching of your content.
- [env variables](/docs/env-variables/): API to manage reading environment variables, commonly used for keys, in a platform independent way.
- [env variables](/docs/guides/env-variables/): API to manage reading environment variables, commonly used for keys, in a platform independent way.
- Supports both Server Side Rendering (SSR) for fully dynamic sites as well as Static Site Generation (SSG) to be hosted on static web servers and CDNs.
- [`vite`](/docs/(qwik)/advanced/vite/index.mdx#qwikcity) - entry point & configuration for Qwik City.

> Qwik¹ City²
>
Expand Down
Loading

0 comments on commit 3b5d6d9

Please sign in to comment.