Skip to content

Commit 7f46dca

Browse files
committed
feat: 0.8.0
1 parent be25589 commit 7f46dca

23 files changed

+88
-24
lines changed

.github/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
## [0.8.0] - 16-05-2021
4+
5+
- feat: add minimal support for importmap rollup plugin
6+
37
## [0.7.0] - 16-05-2021
48

59
- feat: add `run` CLI command

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build ci fmt fmt-check lint test
22

3-
FILES_TO_FORMAT = ./src/ ./deps.ts ./mod.ts ./version.ts
3+
FILES_TO_FORMAT = ./src/ ./deps.ts ./mod.ts ./version.ts ./examples
44

55
build:
66
@deno run -A --unstable --reload mod.ts

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Luath can be used either through a command line interface (CLI):
4444

4545
```bash
4646
# Install Luath
47-
deno install -fqA --unstable --no-check https://deno.land/x/luath@0.7.0/luath.ts
47+
deno install -fqA --unstable --no-check https://deno.land/x/luath@0.8.0/luath.ts
4848

4949
# Serve the example
5050
luath serve ./examples/vanilla
@@ -59,13 +59,13 @@ luath run ./examples/vanilla
5959
Or through it's JavaScript API:
6060

6161
```ts
62-
import { server } from "https://deno.land/x/luath@0.7.0/mod.ts";
62+
import { server } from "https://deno.land/x/luath@0.8.0/mod.ts";
6363

6464
await server({ root: "./examples/vanilla" });
6565
```
6666

6767
```ts
68-
import { build } from "https://deno.land/x/luath@0.7.0/mod.ts";
68+
import { build } from "https://deno.land/x/luath@0.8.0/mod.ts";
6969

7070
await build({ root: "./examples/vanilla" });
7171
```

docs/_data/luath.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version: "0.7.0"
1+
current_version: "0.8.0"

docs/apis.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ lang: en
1212
<h3><code>server: (options?: LuathOptions) => Promise</code></h3>
1313
<p>Create a Luath server with custom options. Resolves to an <a href="https://github.com/asos-craigmorten/opine"><code>opine</code></a> server.</p>
1414
<p>For example:</p>
15-
<pre><code>import { server } from "https://deno.land/x/luath@0.7.0/mod.ts";
15+
<pre><code>import { server } from "https://deno.land/x/luath@0.8.0/mod.ts";
1616
<br />import { plugins } from "./plugins.ts";
1717
<br />await server({ root: Deno.cwd(), server: { port: 4000 }, plugins });</code></pre>
1818
<h3><code>build: (options?: LuathOptions) => Promise</code></h3>
1919
<p>Builds the production assets.</p>
2020
<p>For example:</p>
21-
<pre><code>import { build } from "https://deno.land/x/luath@0.7.0/mod.ts";
21+
<pre><code>import { build } from "https://deno.land/x/luath@0.8.0/mod.ts";
2222
<br />import { plugins } from "./plugins.ts";
2323
<br />await build({ root: Deno.cwd(), plugins });</code></pre>
2424
</section>

docs/guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ lang: en
1818
<section class="subsection">
1919
<h2 id="running-your-first-luath-project">Running Your First Luath Project</h2>
2020
<p>Install the Luath CLI using <a href="https://deno.land/">Deno</a>:</p>
21-
<pre><code>$ deno install -fqA --unstable https://deno.land/x/luath@0.7.0/luath.ts</code></pre>
21+
<pre><code>$ deno install -fqA --unstable https://deno.land/x/luath@0.8.0/luath.ts</code></pre>
2222
<p>Then follow any prompts from the Deno command. For example, you may need to add the Deno bin directory to your path:</p>
2323
<pre><code>$ export PATH="$HOME/.deno/bin:$PATH"</code></pre>
2424
<p>You are now set to use Luath. Let's try it out with one of the Luath repo examples:</p>
@@ -39,7 +39,7 @@ lang: en
3939
<pre><code>$ luath --help
4040

4141
Usage: luath [root:string]
42-
Version: v0.7.0
42+
Version: v0.8.0
4343

4444
Description:
4545

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ lang: en
99
<img src="images/favicon.png" alt="Deno zooming through the lighting storm that is front-end development" class="logo" />
1010
<div class="title"><a href="/luath/" class="luath">Luath</a><span><a href="https://github.com/cmorten/luath/blob/main/.github/CHANGELOG.md" class="version">{{ site.data.luath.current_version }}</a></span></div>
1111
<p class="description">Fast front-end development tooling in <a href="https://deno.land/">Deno</a>.</p>
12-
<pre><code>$ deno install -fqA --unstable https://deno.land/x/luath@0.7.0/luath.ts</code></pre>
12+
<pre><code>$ deno install -fqA --unstable https://deno.land/x/luath@0.8.0/luath.ts</code></pre>
1313
<div><a href="/luath/guide" class="primary get-started">Get Started</a></div>
1414
</section>
1515
</main>

examples/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- deno-fmt-ignore-file -->
12
# Examples
23

34
| Name | Description |
@@ -19,7 +20,7 @@ To run an example:
1920
2. Install the Luath CLI:
2021

2122
```bash
22-
deno install -fqA --unstable --no-check https://deno.land/x/luath@0.7.0/luath.ts
23+
deno install -fqA --unstable --no-check https://deno.land/x/luath@0.8.0/luath.ts
2324
```
2425

2526
3. Then run the desired example by navigating to the directory and running the appropriate Luath `serve` command. E.g.

examples/react/.vscode/settings.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"deno.enable": true,
3+
"deno.unstable": true,
4+
"deno.importMap": "./importmap.dev.json",
5+
"[typescript]": {
6+
"editor.defaultFormatter": "denoland.vscode-deno"
7+
},
8+
"[typescriptreact]": {
9+
"editor.defaultFormatter": "denoland.vscode-deno"
10+
},
11+
"editor.defaultFormatter": "denoland.vscode-deno"
12+
}

examples/react/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- deno-fmt-ignore-file -->
12
# react
23

34
A React example using the Luath plugin for [React Fast Refresh](https://www.npmjs.com/package/react-refresh).

examples/react/import_map.dev.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"react": "https://esm.sh/react@17.0.2?dev",
4+
"react-dom": "https://esm.sh/react-dom@17.0.2?dev"
5+
}
6+
}

examples/react/import_map.prod.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"react": "https://esm.sh/react@17.0.2",
4+
"react-dom": "https://esm.sh/react-dom@17.0.2"
5+
}
6+
}

examples/react/luath.config.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import { luathPluginReactRefresh } from "../../mod.ts";
2+
import { rollupImportMapPlugin } from "https://deno.land/x/drollup@2.42.3+0.17.1/plugins/importmap/mod.ts";
23

3-
export default ({ command }: { command: string }) =>
4-
command === "serve"
5-
? {
6-
plugins: [luathPluginReactRefresh()],
4+
export default ({ command }: { command: string }) => {
5+
switch (command) {
6+
case "serve": {
7+
return {
8+
plugins: [
9+
rollupImportMapPlugin({ maps: "./import_map.dev.json" }),
10+
luathPluginReactRefresh(),
11+
],
12+
};
713
}
8-
: {};
14+
case "build": {
15+
return {
16+
plugins: [
17+
rollupImportMapPlugin({ maps: "./import_map.prod.json" }),
18+
],
19+
};
20+
}
21+
case "run": {
22+
return {};
23+
}
24+
}
25+
};

examples/react/src/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "https://esm.sh/react@17.0.2?dev";
1+
import React from "react";
22
import { Title } from "./title.tsx";
33
import { List } from "./list.tsx";
44

examples/react/src/list.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "https://esm.sh/react@17.0.2?dev";
1+
import React from "react";
22
import styles from "./list.css";
33

44
const doggos = [...new Array(12)].map((_, index) => ({

examples/react/src/main.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference lib="dom" />
2-
import React from "https://esm.sh/react@17.0.2?dev";
3-
import ReactDOM from "https://esm.sh/react-dom@17.0.2?dev";
2+
import React from "react";
3+
import ReactDOM from "react-dom";
44
import { App } from "./app.tsx";
55

66
ReactDOM.render(

examples/react/src/title.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "https://esm.sh/react@17.0.2?dev";
1+
import React from "react";
22
import styles from "./title.css";
33

44
export const Title = () => {

examples/vanilla/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- deno-fmt-ignore-file -->
12
# Vanilla
23

34
A no-framework "vanilla" example demonstrating CSS, JSON and image imports with

examples/vanilla/src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference lib="dom" />
2+
// deno-lint-ignore-file ban-ts-comment
23
// @ts-nocheck
34
import metadata from "./metadata.json";
45
import icon from "../public/icon.png";

src/isBareImportSpecifier.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const isBareImportSpecifier = (address: string) => {
2+
if (
3+
address.startsWith("/") || address.startsWith("./") ||
4+
address.startsWith("../") ||
5+
address.startsWith("http://") || address.startsWith("https://") ||
6+
address.startsWith("file://")
7+
) {
8+
return false;
9+
}
10+
11+
return true;
12+
};

src/middlewares/transform/bundle.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { lmr, LMR_JS_PATH_IMPORT } from "../../plugins/lmr.ts";
2121
import { esbuildTsx } from "../../plugins/esbuild/mod.ts";
2222
import { isImportUrl } from "../isImport.ts";
2323
import { isPublicFile } from "./isPublicFile.ts";
24+
import { isBareImportSpecifier } from "../../isBareImportSpecifier.ts";
2425
import { getEntryChunk } from "./getEntryChunk.ts";
2526
import { getCssAsset } from "./getCssAsset.ts";
2627

@@ -100,7 +101,7 @@ export async function bundle(
100101
esbuildTsx(),
101102
lmr(moduleGraph, rootDir),
102103
] as Plugin[],
103-
external: () => true,
104+
external: (source) => !isBareImportSpecifier(source),
104105
onwarn() {},
105106
treeshake: false,
106107
});

src/plugins/lmr.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { stripUrl } from "../stripUrl.ts";
1212
import { isHttpUrl } from "../isHttpUrl.ts";
1313
import { isMetaImport } from "../isMetaImport.ts";
1414
import { isLuathImport } from "../isLuathImport.ts";
15+
import { isBareImportSpecifier } from "../isBareImportSpecifier.ts";
1516
import { isHot } from "./isHot.ts";
1617

1718
export const LMR_JS_PATH_IMPORT = "/$luath/client.js";
@@ -51,7 +52,8 @@ export function lmr(moduleGraph: ModuleGraph, rootDir: string) {
5152
);
5253

5354
if (
54-
!isMetaImport(rawUrl) && !isHttpUrl(rawUrl) && !isLuathImport(rawUrl)
55+
!isMetaImport(rawUrl) && !isHttpUrl(rawUrl) &&
56+
!isLuathImport(rawUrl) && !isBareImportSpecifier(rawUrl)
5557
) {
5658
const mod = moduleGraph.get(
5759
pathToId(resolve(dirname(id), rawUrl), rootDir),

version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = "0.7.0";
1+
export const version = "0.8.0";

0 commit comments

Comments
 (0)