Skip to content

Commit

Permalink
chore: change all qwik/build imports to qwik
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens committed Dec 7, 2024
1 parent a885570 commit 5eb90ef
Show file tree
Hide file tree
Showing 43 changed files with 52 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { DocSearchHit } from './types';
import { identity } from './utils';
import { clearStalled, setStalled } from './utils/stalledControl';
import { AIButton } from './result';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';

export type ModalTranslations = Partial<{
searchBox: SearchBoxTranslations;
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/components/qwik-gpt/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component$, useComputed$, useSignal } from '@builder.io/qwik';
// import { qwikGPT, rateResponse } from './search';
import { CodeBlock } from '../code-block/code-block';
// import { isBrowser } from '@builder.io/qwik/build';
// import { isBrowser } from '@builder.io/qwik';
import snarkdown from 'snarkdown';

const snarkdownEnhanced = (md: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/repl/monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { EditorProps, EditorStore } from './editor';
import type { ReplStore } from './types';
import { getColorPreference } from '../components/theme-toggle/theme-toggle';
import { bundled, getNpmCdnUrl } from './bundled';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';
// We cannot use this, it causes the repl to use imports
// import { QWIK_REPL_DEPS_CACHE } from './worker/repl-constants';
const QWIK_REPL_DEPS_CACHE = 'QwikReplDeps';
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/repl/repl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ReplDetailPanel } from './repl-detail-panel';
import { getReplVersion } from './repl-version';
import { updateReplOutput } from './repl-output-update';
import { QWIK_PKG_NAME, bundled, getNpmCdnUrl } from './bundled';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export const Repl = component$((props: ReplProps) => {
useStyles$(styles);
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/repl/worker/repl-service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ self.oninstall = (ev) => {
self.onactivate = () => self.clients.claim();

export interface ReplGlobalApi {
qwikBuild?: typeof import('@builder.io/qwik/build');
qwikBuild?: typeof import('@builder.io/qwik');
qwikCore?: typeof import('@builder.io/qwik');
qwikOptimizer?: typeof import('@builder.io/qwik/optimizer');
qwikServer?: typeof import('@builder.io/qwik/server');
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $, component$, useOn, useSignal, useStore, useTask$ } from '@builder.io/qwik';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import { toSnakeCase } from '../../utils/utils';

// TODO: load the content of these files using fs instead of importing them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useSignal,
useTask$,
} from '@builder.io/qwik';
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';

const metaGlobComponents: Record<string, any> = import.meta.glob(
'/src/routes/demo/cookbook/glob-import/examples/*',
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/demo/tasks/track-fn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export default component$(() => {
const isUppercase = useSignal(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export default component$(() => {
const text = useSignal('Initial text');
Expand Down
3 changes: 1 addition & 2 deletions packages/docs/src/routes/demo/tasks/track/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { component$, useSignal, useTask$, isServer } from '@builder.io/qwik';

export default component$(() => {
const text = useSignal('Initial text');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ During SSR, each component will wait until all tasks are completed before output
<CodeSandbox src="/src/routes/demo/tasks/track/index.tsx" style={{ height: '6em' }} >
```tsx
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export default component$(() => {
const text = useSignal('Initial text');
Expand Down Expand Up @@ -237,7 +237,7 @@ const delay = (time: number) => new Promise((res) => setTimeout(res, time));
>
> - The `useTask$()` blocks rendering until it completes. If you don't want to block rendering, make sure that the task is resolved, and run the delay work on a separate unconnected promise. In this example, we don't await `delay()` because it would block rendering.
> Sometimes it is required to only run code either in the server or in the client. This can be achieved by using the `isServer` and `isBrowser` booleans exported from `@builder.io/qwik/build` as shown above.
> Sometimes it is required to only run code either in the server or in the client. This can be achieved by using the `isServer` and `isBrowser` booleans exported from `@builder.io/qwik` as shown above.

### `track()` as a function
Expand All @@ -247,7 +247,7 @@ In the above example, `track()` was used to track a specific signal. However, `t
<CodeSandbox src="/src/routes/demo/tasks/track-fn/index.tsx" style={{ height: '6em' }} >
```tsx
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export default component$(() => {
const isUppercase = useSignal(false);
Expand Down Expand Up @@ -338,7 +338,7 @@ Sometimes a task needs to run only on the browser and after rendering, in that c
> <CodeSandbox src="/src/routes/demo/tasks/track-server-guard/index.tsx" style={{ height: '6em' }}>
> ```tsx
> import { component$, useSignal, useTask$ } from '@builder.io/qwik';
> import { isServer } from '@builder.io/qwik/build';
> import { isServer } from '@builder.io/qwik';
>
> export default component$(() => {
> const text = useSignal('Initial text');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ src/
```typescript title="src/routes/[email protected]"
import type { RequestHandler } from "@builder.io/qwik-city";
import { isDev } from "@builder.io/qwik/build";
import { isDev } from "@builder.io/qwik";

export const onRequest: RequestHandler = event => {
if (isDev) return; // Will not return CSP headers in dev mode
Expand Down Expand Up @@ -79,7 +79,7 @@ import {
ServiceWorkerRegister,
} from "@builder.io/qwik-city";
import { RouterHead } from "./components/router-head/router-head";
import { isDev } from "@builder.io/qwik/build";
import { isDev } from "@builder.io/qwik";

import "./global.css";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ If you want to access browser APIs, such as `window`, `document`, `localStorage`

```tsx
import { component$, useTask$, useVisibleTask$, useSignal } from '@builder.io/qwik';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';

export default component$(() => {
const ref = useSignal<Element>();
Expand Down Expand Up @@ -667,7 +667,7 @@ Sometimes you need to run code only on the server, such as fetching data or acce
```tsx
import { component$, useTask$ } from '@builder.io/qwik';
import { server$, routeLoader$ } from '@builder.io/qwik/qwik-city';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';


export const useGetProducts = routeLoader$((requestEvent) => {
Expand Down Expand Up @@ -729,7 +729,7 @@ The `server$()` is a special way to declare functions that only run on the serve

### `isServer` & `isBrowser` conditionals

Instead of `if(typeof window !== 'undefined')`, it is recommended to use the `isServer` and `isBrowser` boolean helpers exported from `@builder.io/qwik/build` to ensure your code only runs in the browser. They contain slightly more robust checks to better detect the browser environment.
Instead of `if(typeof window !== 'undefined')`, it is recommended to use the `isServer` and `isBrowser` boolean helpers exported from `@builder.io/qwik` to ensure your code only runs in the browser. They contain slightly more robust checks to better detect the browser environment.

Here is the source code for reference:

Expand All @@ -746,7 +746,7 @@ export const isServer: boolean = !isBrowser;
Here is how you import these for reference:

```tsx
import {isServer, isBrowser} from '@builder.io/qwik/build';
import {isServer, isBrowser} from '@builder.io/qwik';

// inside component$

Expand Down
4 changes: 2 additions & 2 deletions packages/docs/src/routes/docs/cookbook/glob-import/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The problem with `import.meta.glob` in Qwik, is that it currently either works i

The reason for this behavior, is that `import.meta.glob` with `eager.false` breaks the production bundle as it creates lazy-loadable chunks that Qwik doesn't know how to handle. On the other hand, `eager:true` seemingly fixes the issue as it allows Qwik to normally bundle the files, but it also slows down the development server - especially when you import a lot of heavy components with it.

As a workaround for now, you can use the build time `isDev` boolean from `"@builder.io/qwik/build"`:
As a workaround for now, you can use the build time `isDev` boolean from `"@builder.io/qwik"`:

<CodeSandbox src="/src/routes/demo/cookbook/glob-import/">
```tsx
Expand All @@ -58,7 +58,7 @@ import {
useSignal,
useTask$,
} from '@builder.io/qwik';
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';

const metaGlobComponents: Record<string, any> = import.meta.glob(
'/src/examples/*',
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/examples/[...id]/index!.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import exampleSections, { type ExampleApp } from '@examples-data';
import type { ReplAppInput } from '../../../repl/types';
import { type DocumentHead, useLocation } from '@builder.io/qwik-city';
import { PanelToggle } from '../../../components/panel-toggle/panel-toggle';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import { createPlaygroundShareUrl, parsePlaygroundShareUrl } from '../../../repl/repl-share-url';

export default component$(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { component$, useTask$, useStore, useStyles$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';
import HackerNewsCSS from './hacker-news.css?inline';

export const HackerNews = component$(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/playground/index!.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import playgroundApp from '@playground-data';
import type { ReplAppInput } from '../../repl/types';
import { createPlaygroundShareUrl, parsePlaygroundShareUrl } from '../../repl/repl-share-url';
import { PanelToggle } from '../../components/panel-toggle/panel-toggle';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';

export default component$(() => {
useStyles$(styles);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { component$, useSignal, useTask$ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export const InsideTask = component$(() => {
const mySig = useSignal(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/insights/src/db/logging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';

const LOG_TIMING: boolean = isDev;

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type RequestEvent,
type RequestEventCommon,
} from '@builder.io/qwik-city';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';
import { parseString, splitCookiesString } from 'set-cookie-parser';

export type GetSessionResult = Promise<{ data: Session | null; cookie: any }>;
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/src/runtime/src/client-navigate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import type { NavigationType, ScrollState } from './types';
import { isSamePath, toPath } from './utils';
import { PREFETCHED_NAVIGATE_PATHS } from './constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/src/runtime/src/link-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getClientNavPath, shouldPrefetchData, shouldPrefetchSymbols } from './u
import { loadClientData } from './use-endpoint';
import { useLocation, useNavigate } from './use-functions';
import { prefetchSymbols } from './client-navigate';
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';

/** @public */
export const Link = component$<LinkProps>((props) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/src/runtime/src/qwik-city-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
_waitUntilRendered,
type QRL,
} from '@builder.io/qwik';
import { isBrowser, isDev, isServer } from '@builder.io/qwik/build';
import { isBrowser, isDev, isServer } from '@builder.io/qwik';
import * as qwikCity from '@qwik-city-plan';
import { CLIENT_DATA_CACHE } from './constants';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/src/runtime/src/server-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import type {
} from './types';
import { useAction, useLocation, useQwikCityEnv } from './use-functions';

import { isDev, isServer } from '@builder.io/qwik/build';
import { isDev, isServer } from '@builder.io/qwik';

import type { FormSubmitCompletedDetail } from './form-component';

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/src/runtime/src/spa-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ClientSPAWindow } from './qwik-city-component';
import type { ScrollHistoryState } from './scroll-restoration';
import type { ScrollState } from './types';

import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';
import { event$ } from '@builder.io/qwik';

// TODO Dedupe handler code from here and QwikCityProvider?
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/src/react/qwikify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useStylesScoped$,
} from '@builder.io/qwik';

import { isBrowser, isServer } from '@builder.io/qwik/build';
import { isBrowser, isServer } from '@builder.io/qwik';
import type { Root } from 'react-dom/client';
import type { FunctionComponent as ReactFC } from 'react';
import * as client from './client';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/src/react/server-render.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type QRL, type Signal, Slot, SSRRaw, SSRStream } from '@builder.io/qwik';
import { getHostProps, mainExactProps, getReactProps } from './slot';
import { renderToString } from 'react-dom/server';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';

export async function renderFromServer(
Host: any,
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/src/react/slot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $, useOn, useOnDocument, useSignal } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';
import { Component, createContext, createElement, createRef } from 'react';
import type { QwikifyOptions, QwikifyProps } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/components/prefetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';
import { _jsxC } from '../internal';
import type { JSXNode } from '@builder.io/qwik/jsx-runtime';
import { useServerData } from '../use/use-env-data';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/platform/platform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isServer } from '@builder.io/qwik/build';
import { isServer } from '@builder.io/qwik';
import { qError, QError_qrlMissingChunk, QError_qrlMissingContainer } from '../error/error';
import { getSymbolHash } from '../qrl/qrl-class';
import type { QwikElement } from '../render/dom/virtual-element';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/render/dom/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
type VirtualElement,
} from './virtual-element';

import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import {
getProxyTarget,
getSubscriptionManager,
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/render/jsx/jsx-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isPromise } from '../../util/promises';
import { SkipRender } from './utils.public';
import { EMPTY_OBJ } from '../../util/flyweight';
import { _IMMUTABLE } from '../../internal';
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import { assertString } from '../../error/assert';
import { static_subtree } from '../execute-component';
import type { JsxChild } from 'typescript';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/util/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isBrowser } from '@builder.io/qwik/build';
import { isBrowser } from '@builder.io/qwik';
import { qTest } from './qdev';

export const emitEvent = (
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/server/render.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SnapshotResult } from '@builder.io/qwik';
import { _pauseFromContexts, _renderSSR, Fragment, jsx, type JSXNode } from '@builder.io/qwik';
import { isDev } from '@builder.io/qwik/build';
import { isDev } from '@builder.io/qwik';
import type { QContext } from '../core/state/context';
import { QInstance } from '../core/util/markers';
import { getValidManifest } from '../optimizer/src/manifest';
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/e2e/src/components/build-variables/build.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { component$, useSignal, useTask$ } from "@builder.io/qwik";
import { isBrowser, isServer } from "@builder.io/qwik/build";
import * as build from "@builder.io/qwik/build";
import { isBrowser, isServer } from "@builder.io/qwik";
import * as build from "@builder.io/qwik";

export const BuildVariables = component$(() => {
const json = useSignal("");
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/e2e/src/components/mount/mount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { component$, useStore, useTask$ } from "@builder.io/qwik";
import { delay } from "../async/async";
import { isServer } from "@builder.io/qwik/build";
import { isServer } from "@builder.io/qwik";

export const MountRoot = component$(() => {
const internal = useStore(
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/e2e/src/components/render/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type JSXOutput,
} from "@builder.io/qwik";
import { delay } from "../streaming/demo";
import { isServer } from "@builder.io/qwik/build";
import { isServer } from "@builder.io/qwik";

export const Render = component$(() => {
const rerender = useSignal(0);
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/e2e/src/components/signals/signals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TestCStr,
TestCWithFlag,
} from "./utils/utils";
import { isBrowser } from "@builder.io/qwik/build";
import { isBrowser } from "@builder.io/qwik";

export const Signals = component$(() => {
const rerender = useSignal(0);
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/e2e/src/components/toggle/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useContext,
useTask$,
} from "@builder.io/qwik";
import { isBrowser, isServer } from "@builder.io/qwik/build";
import { isBrowser, isServer } from "@builder.io/qwik";

export const CTX = createContextId<{ message: string; count: number }>(
"toggle",
Expand Down
Loading

0 comments on commit 5eb90ef

Please sign in to comment.