Skip to content

Commit

Permalink
fix: umd core build (QwikDev#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Mar 1, 2023
1 parent 94f8ff8 commit 8db17e4
Show file tree
Hide file tree
Showing 24 changed files with 166 additions and 86 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "qwik-monorepo",
"version": "0.20.0",
"version": "0.20.1",
"scripts": {
"build": "tsm scripts/index.ts --tsc --build --qwikcity --api --platform-binding-wasm-copy",
"build.vite": "tsm scripts/index.ts --tsc --build --qwikcity --platform-binding-wasm-copy",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.20.0",
"version": "0.20.1",
"description": "Interactive CLI for create Qwik projects and adding features.",
"bin": "./create-qwik.cjs",
"main": "./index.cjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"@algolia/autocomplete-shared": "1.7.4",
"@algolia/client-search": "4.14.3",
"@builder.io/partytown": "0.7.5",
"@builder.io/qwik": "BuilderIO/qwik-build#8db8f9a63f9738c1d175a6341e4519605f5f2439",
"@builder.io/qwik-city": "0.4.0",
"@builder.io/qwik": "0.20.0",
"@builder.io/qwik-city": "0.5.2",
"@builder.io/sdk-qwik": "0.1.10",
"@docsearch/css": "3.3.3",
"@types/prismjs": "^1.26.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/docs/src/repl/worker/repl-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export const loadDependencies = async (options: ReplInputOptions) => {
depResponse(cache, 'prettier', PRETTIER_VERSION, '/parser-html.js'),
]);

self.qwikBuild = {
isServer: true,
isBrowser: false,
isDev: false,
};

if (!isSameQwikVersion(self.qwikCore?.version, version)) {
await exec(cache, QWIK_PKG_NAME, version, '/core.cjs');
if (self.qwikCore) {
Expand Down
17 changes: 17 additions & 0 deletions packages/docs/src/repl/worker/repl-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ 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';
}
Expand Down Expand Up @@ -57,6 +60,20 @@ 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') {
const cache = await caches.open(QWIK_REPL_DEPS_CACHE);
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/repl/worker/repl-service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ self.oninstall = (ev) => {
self.onactivate = () => self.clients.claim();

export interface ReplGlobalApi {
qwikBuild?: typeof import('@builder.io/qwik/build');
qwikCore?: typeof import('@builder.io/qwik');
qwikOptimizer?: typeof import('@builder.io/qwik/optimizer');
qwikServer?: typeof import('@builder.io/qwik/server');
Expand Down
7 changes: 5 additions & 2 deletions packages/docs/src/routes/community/groups/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ and spread your love for innovation!

### Newsletters

- <GroupLink link="https://qwiknewsletter.com">Qwikly Newsletter - Weekly news about Qwik</GroupLink>
- <GroupLink link="https://qwiknewsletter.com">
Qwikly Newsletter - Weekly news about Qwik
</GroupLink>

### Global Communities

Expand Down Expand Up @@ -60,4 +62,5 @@ and spread your love for innovation!

#### United Kingdom

- <MeetupLogo /><GroupLink link="https://www.meetup.com/qwik-london/">Qwik London Meetup Group</GroupLink>
- <MeetupLogo />
<GroupLink link="https://www.meetup.com/qwik-london/">Qwik London Meetup Group</GroupLink>
46 changes: 32 additions & 14 deletions packages/docs/src/routes/docs/advanced/vite/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ contributors:
---

# Vite
Qwik leverages [Vite](https://vitejs.dev/) to provide a fast development experience. Vite is a build tool that serves your code via native ES Modules during development.

Qwik leverages [Vite](https://vitejs.dev/) to provide a fast development experience. Vite is a build tool that serves your code via native ES Modules during development.
This means that it doesn't need to bundle your code or transpile it to work in the browser. It also comes with lightning fast hot module replacement (HMR) that updates your browser instantly when you make changes to your code.

## Configuration

After scaffolding a new Qwik project, you'll find a `vite.config.js` file in the root of your project. This is where you can configure Vite.

## Plugins

Qwik comes with two plugins that make it easy to use Vite with Qwik and Qwik City.

```js
import { defineConfig } from "vite";
import { qwikCity } from "@builder.io/qwik-city/vite";
import { qwikVite } from "@builder.io/qwik/optimizer";
import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig } from 'vite';
import { qwikCity } from '@builder.io/qwik-city/vite';
import { qwikVite } from '@builder.io/qwik/optimizer';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig(() => {
return {
plugins: [
qwikCity(),
qwikVite(),
tsconfigPaths(),
],
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
};
});
```

### `qwikVite()`

To modify the configuration, you can pass an object to the `qwikVite` function. Possible options are:

#### `debug`

```js
/**
* Prints verbose Qwik plugin debug logs.
Expand All @@ -43,6 +45,7 @@ debug?: boolean;
```

#### `entryStrategy`

```js
/**
* The Qwik entry strategy to use while bundling for production.
Expand All @@ -53,6 +56,7 @@ entryStrategy?: EntryStrategy;
```

#### `srcDir`

```js
/**
* The source directory to find all the Qwik components. Since Qwik
Expand All @@ -64,6 +68,7 @@ srcDir?: string;
```

#### `vendorRoots`

```js
/**
* List of directories to recursively search for Qwik components or Vendors.
Expand All @@ -73,6 +78,7 @@ vendorRoots?: string[];
```

#### `client`

```js
client?: {
/**
Expand All @@ -99,10 +105,11 @@ client?: {
*/
manifestOutput?: (manifest: QwikManifest) => Promise<void> | void;
};
```
```

#### `ssr`
```js

```js
ssr?: {
/**
* The entry point for the SSR renderer. This file should export
Expand All @@ -128,6 +135,7 @@ ssr?: {
```

#### `optimizerOptions`

```js
/**
* Options for the Qwik optimizer.
Expand All @@ -137,6 +145,7 @@ optimizerOptions?: OptimizerOptions;
```

#### `transformedModuleOutput`

```js
/**
* Hook that's called after the build and provides all of the transformed
Expand All @@ -148,6 +157,7 @@ transformedModuleOutput?:
```

#### `devTools`

```js
devTools?: {
/**
Expand All @@ -162,9 +172,11 @@ devTools?: {
```

### `qwikCity()`

To modify the configuration, you can pass an object to the `qwikCity` function. Possible options are:

#### `routesDir`

```js
/**
* Directory of the `routes`. Defaults to `src/routes`.
Expand All @@ -173,6 +185,7 @@ routesDir?: string;
```

#### `serverPluginsDir`

```js
/**
* Directory of the `server plugins`. Defaults to `src/server-plugins`.
Expand All @@ -181,6 +194,7 @@ serverPluginsDir?: string;
```

#### `basePathname`

```js
/**
* The base pathname is used to create absolute URL paths up to
Expand All @@ -191,6 +205,7 @@ basePathname?: string;
```

#### `trailingSlash`

```js
/**
* Ensure a trailing slash ends page urls. Defaults to `true`.
Expand All @@ -200,14 +215,16 @@ trailingSlash?: boolean;
```

#### `mdxPlugins`

```js
/**
* Enable or disable MDX plugins included by default in qwik-city.
*/
mdxPlugins?: MdxPlugins;
```
```

#### `mdx`

```js
/**
* MDX Options https://mdxjs.com/
Expand All @@ -216,4 +233,5 @@ mdx?: any;
```

## Troubleshooting
Before creating an issue on the Qwik repository please check the `Troubleshooting` section of the [Vite documentation](https://vitejs.dev/guide/troubleshooting.html) and make sure you're using the recommended version.

Before creating an issue on the Qwik repository please check the `Troubleshooting` section of the [Vite documentation](https://vitejs.dev/guide/troubleshooting.html) and make sure you're using the recommended version.
32 changes: 18 additions & 14 deletions packages/docs/src/routes/docs/cheat/best-practices/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ Instead => `useOn()` methods
**Best Practice**:

```ts
useBrowserVisibleTask$(()=> {
const listener = (event)=> {
const mouseEvent = event as MouseEvent
console.log(mouseEvent.x, mouseEvent.y);
}
document.addEventListener('mousemove', listener);

return ()=> {document.removeEventListener('mousemove', listener)}
})
useBrowserVisibleTask$(() => {
const listener = (event) => {
const mouseEvent = event as MouseEvent;
console.log(mouseEvent.x, mouseEvent.y);
};
document.addEventListener('mousemove', listener);

return () => {
document.removeEventListener('mousemove', listener);
};
});
```

**Why is above a problem**:
Expand All @@ -38,11 +40,14 @@ Not to mention it requires the extra effort for you to manually clean up the lis
**Do this instead**:

```ts
useOnDocument('mousemove', $((event)=> {
useOnDocument(
'mousemove',
$((event) => {
const mouseEvent = event as MouseEvent;
console.log(mouseEvent.x, mouseEvent.y)
console.log(mouseEvent.x, mouseEvent.y);
// No manual clean up required!
}))
})
);
```

> NOTE: Similar hooks exist for window and individual components.
Expand Down Expand Up @@ -93,11 +98,10 @@ When using the `if typeof window !== "undefined"` pattern you'll soon find it wi
const location = useLocation();

if (location.href.includes('foo')) {
// Do the thing
// Do the thing
}
//OR
doTheThing(location.query);

```

## EXCEPTION
Expand Down
1 change: 0 additions & 1 deletion packages/docs/src/routes/docs/components/context/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ This method is used to get the value of `Context` which is **provided** by Paren

```tsx
export const Children = component$(() => {

const qwikCityObject = useContext(QwikCityContext);
const plainArray = useContext(PlainArrayContext);
const appName = useContext(AppNameContext);
Expand Down
1 change: 0 additions & 1 deletion packages/docs/src/routes/docs/components/styles/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ body {
}
```


Check our [the integration docs](../../../integrations/integration/postcss) for more information.

## Why not inline styles using the `<style>` tag?
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/src/routes/docs/concepts/progressive/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contributors:

Progressive is about downloading code according to the application's needs, without eagerly downloading the entire code base.

This connects us to the [core principle](../../think-qwik/index.mdx) of Qwik which focuses on delaying **the loading** and execution of JavaScript for as long as possible. Qwik needs to break up the application into many lazy loadable chunks to achieve that.
This connects us to the [core principle](../../think-qwik/index.mdx) of Qwik which focuses on delaying **the loading** and execution of JavaScript for as long as possible. Qwik needs to break up the application into many lazy loadable chunks to achieve that.

## Current state-of-the-art

Expand Down Expand Up @@ -53,7 +53,7 @@ In Qwik everything is lazy-loadable:
- Component on render - initialization block and render block
- Component on watch - side-effects, only downloaded if inputs change
- Listeners - only downloaded on interaction
- Styles - only downloaded if the server did not already provide them
- Styles - only downloaded if the server did not already provide them

Lazy-loading is a core property of the framework and not an afterthought.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ contributors:
- RATIU5
- manucorporat
- adamdbradley

---

# Reactivity
Expand Down
11 changes: 9 additions & 2 deletions packages/docs/src/routes/docs/overview/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@ Qwik is a new kind of web framework that can deliver instant loading web applica
</div>
<div class="card">
<h3>Instant-on</h3>
<p>Unlike other frameworks, Qwik is resumable which means Qwik applications require 0 hydration. This allows Qwik apps to have instant-on interactivity, regardless of size or complexity</p>
<p>
Unlike other frameworks, Qwik is resumable which means Qwik applications require 0 hydration.
This allows Qwik apps to have instant-on interactivity, regardless of size or complexity
</p>
</div>
<div class="card">
<h3>Optimized for speed</h3>
<p>Qwik has unprecedented performance, offering sub-second full page loads even on mobile devices. Qwik achieves this by delivering pure HTML, and incrementally loading JS only as-needed.</p>
<p>
Qwik has unprecedented performance, offering sub-second full page loads even on mobile
devices. Qwik achieves this by delivering pure HTML, and incrementally loading JS only
as-needed.
</p>
</div>
</div>
Loading

0 comments on commit 8db17e4

Please sign in to comment.