feat: add build.target option (#1798)
This commit is contained in:
@@ -229,3 +229,34 @@ Deno.test(
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Deno.test("pass target options", async () => {
|
||||
const fixture = path.join(Deno.cwd(), "tests", "fixture_build_target");
|
||||
const out = await new Deno.Command(Deno.execPath(), {
|
||||
args: [
|
||||
"run",
|
||||
"-A",
|
||||
path.join(fixture, "dev.ts"),
|
||||
"build",
|
||||
],
|
||||
env: {
|
||||
GITHUB_SHA: "__BUILD_ID__",
|
||||
DENO_DEPLOYMENT_ID: "__BUILD_ID__",
|
||||
FRESH_TEST_TARGET: "es2015",
|
||||
},
|
||||
stdin: "null",
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
}).output();
|
||||
|
||||
const { stdout, stderr } = getStdOutput(out);
|
||||
const txt = await Deno.readTextFile(
|
||||
path.join(fixture, "_fresh", "island-counter_default.js"),
|
||||
);
|
||||
|
||||
assertNotMatch(
|
||||
txt,
|
||||
/\?\?/,
|
||||
`Asset contained ?? despite target es2015\n\n${stdout}\n${stderr}`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"lock": false,
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.15.1",
|
||||
"preact/": "https://esm.sh/preact@10.15.1/",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.0",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env -S deno run -A --watch=static/,routes/
|
||||
|
||||
import dev from "$fresh/dev.ts";
|
||||
|
||||
await dev(import.meta.url, "./main.ts", {
|
||||
build: {
|
||||
target: Deno.env.get("FRESH_TEST_TARGET"),
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
// DO NOT EDIT. This file is generated by Fresh.
|
||||
// This file SHOULD be checked into source version control.
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $0 from "./routes/index.tsx";
|
||||
import * as $$0 from "./islands/Counter.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $0,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$0,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
};
|
||||
|
||||
export default manifest;
|
||||
@@ -0,0 +1,4 @@
|
||||
export default function Counter(props: { text?: string }) {
|
||||
const text = props.text ?? "check output";
|
||||
return <h1>{text}</h1>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import routes from "./fresh.gen.ts";
|
||||
|
||||
await start(routes);
|
||||
@@ -0,0 +1,5 @@
|
||||
import Counter from "../islands/Counter.tsx";
|
||||
|
||||
export default function Home() {
|
||||
return <Counter />;
|
||||
}
|
||||
Reference in New Issue
Block a user