惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
美团技术团队
Security Latest
Security Latest
月光博客
月光博客
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
N
News | PayPal Newsroom
T
Tailwind CSS Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Webroot Blog
Webroot Blog
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
云风的 BLOG
云风的 BLOG
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
Attack and Defense Labs
Attack and Defense Labs
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
C
Cisco Blogs
P
Proofpoint News Feed
N
News and Events Feed by Topic
S
SegmentFault 最新的问题
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
NISL@THU
NISL@THU
P
Palo Alto Networks Blog
GbyAI
GbyAI
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Heimdal Security Blog
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog
Schneier on Security
Schneier on Security
T
The Exploit Database - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
Arctic Wolf

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno Zero-config Debugging with Deno and OpenTelemetry | Deno Exploring Art with TypeScript, Jupyter, Polars, and Observable Plot | Deno Deno v Oracle Update 3: Fighting the JavaScript Trademark | Deno Build a custom RAG AI agent in TypeScript and Jupyter | Deno How to get deep traces in your Node.js backend with OTel and Deno | Deno toranoana.deno #20 登録受付中(2025年3月14日) | Deno Node just added TypeScript support. What does that mean for Deno? | Deno The Dino 🦕, the Llama 🦙, and the Whale 🐋 | Deno Publish a lint rule, get a prize | Deno Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite | Deno If you're not using npm specifiers, you're doing it wrong | Deno How Deno's documentation is evolving | Deno Oracle justified its JavaScript trademark with Node.js—now it wants that ignored | Deno Introducing the JSR open governance board | Deno Intro to Wasm in Deno | Deno Announcing OpenAI on JSR | Deno Deno in 2024 | Deno Goodbye WinterCG, welcome WinterTC | Deno Build a SolidJS app with Deno | Deno Run your Next.js SSR app on Deno Deploy | Deno Solve Advent of Code 2024 with Deno and Win Prizes! | Deno Deno v. Oracle: Canceling the JavaScript Trademark | Deno Deno 2.1: Wasm Imports and other enhancements | Deno Build a Typesafe API with tRPC and Deno | Deno Self-contained Executable Programs with Deno Compile | Deno Build a Database App with Drizzle ORM and Deno | Deno Introducing your new JavaScript package manager: Deno | Deno Announcing Growthbook on JSR | Deno Build an Astro site with Deno | Deno How to convert CommonJS to ESM | Deno Announcing Deno 2 | Deno The Final Touches: What’s New In v2.0.0-rc.10 | Deno Announcing Stable V8 Bindings for Rust | Deno Deno 2.0 Release Candidate | Deno Secure, efficient private npm registries with Cloudsmith and Deno | Deno Painting the Plane as We Fly It: Designing JSR | Deno Introducing Web Cache API support on Deno Deploy | Deno Deno 1.46: The Last 1.x Release | Deno Protect your cloud spend with new Deno Deploy spend limits | Deno What we got wrong about HTTP imports | Deno Benchmarking AWS Lambda Cold Starts Across JavaScript Runtimes | Deno Announcing Supabase on JSR | Deno Deno 1.45: Workspace and Monorepo Support | Deno Introducing KV Backup for Deno Subhosting | Deno A Gentle Intro to TypeScript | Deno Announcing Hono on JSR | Deno How We Made the Deno Language Server Ten Times Faster | Deno How the Guardian uses Deno to audit accessibility and performance across their 2.7 million articles | Deno Introducing More Flexible Domain Association for Deno Subhosting | Deno The stabilization process of the Standard Library has begun | Deno Deno 1.44: Private npm registries, improved Node.js compat, and performance boosts | Deno How we built a secure, performant, multi-tenant cloud platform to run untrusted code | Deno The Deno Standard Library is now available on JSR | Deno How to document your JavaScript package | Deno Your Low Code Solution Needs an Escape Hatch | Deno Deno 1.43: Improved Language Server performance | Deno How Slack used Deno to save months of engineering effort in launching their new platform | Deno JSR Is Not Another Package Manager | Deno Announcing the Hookdeck SDK on JSR | Deno Announcing the Neon Serverless Driver on JSR | Deno An intro to TSConfig for JavaScript Developers | Deno How we built JSR | Deno How Netlify used Deno Subhosting to build a successful edge functions product | Deno Introducing Simpler Project Creation in Deno Deploy | Deno Deno 1.42: Better dependency management with JSR | Deno Introducing deployctl, the command line interface for Deno Deploy | Deno Introducing JSR - the JavaScript Registry | Deno How to add Monaco to a Next.js app and securely run untrusted user code | Deno Survey Results and Roadmap | Deno Deno 1.41: smaller deno compile binaries | Deno
Fresh 1.1 - automatic JSX, plugins, DevTools, and more | Deno
Luca Casonat · 2022-09-08 · via Deno

Fresh is a new full stack web framework for Deno. By default, web pages built with Fresh send zero JavaScript to the client. The framework has no build step which allows for an order of magnitude improvement in development experience and deployment times.

Today we are releasing the next significant version of Fresh. Version 1.1 brings a lot of important improvements that make Fresh easier to use, faster, and generally more useful. Some highlights of this release:

  • Automatic JSX
  • Plugins
    • Official twind plugin
  • Preact Signals support
  • Preact DevTools support
  • Explicit rendering of 404 pages
  • Stacked middleware
  • Experimental Deno.serve support
  • Showcase & “Made with Fresh” badges

To create a new Fresh project, you can run:

$ deno run -A -r https://fresh.deno.dev my-app

To update your project to the latest version of Fresh run the update script from the root of your project:

$ deno run -A -r https://fresh.deno.dev/update .

In addition to updating Fresh and it’s dependencies, this script can also apply codemods to your codebase to keep it up to date with the latest recommendations for Fresh projects. Also view the Concepts: Updating documentation page.

Automatic JSX

New projects are now set up to use automatic mode JSX by default. This means that you do not need the /** @jsx h */ pragma and import { h } from "preact"; at the top of all of your files anymore. This is a major improvement in developer experience and removes a common source of errors for new users.

- /** @jsx h */
- import { h } from "preact";

  export default function AboutPage() {
    return (
      <main>
        <h1>About</h1>
        <p>This is the about page.</p>
      </main>
    );
  }

Existing projects can be updated to use automatic mode using the codemod in the Fresh update script. Alternatively it can be manually enabled by adding the following lines to the deno.json file in the root of your project:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  }
}

After doing this, you must remove all /** @jsx h */ pragmas and import { h } from "preact"; imports from your JSX/TSX files. Automatic and non automatic mode can not be mixed in the same project.

Plugins

Plugins are a new way to extend Fresh’s functionality without requiring intrusive changes in Fresh itself. Right now plugins can only be used to orchestrate rendering and inject styles and scripts into the rendered HTML. This is useful for styling frameworks like twind. This could also be used to do things like inject a Google Analytics script into the page, or globally load a web component.

Plugins are defined through the plugins property in the options bag passed to the start function in your main.ts file.

This is just the first iteration of plugins. Future versions will add more hooks that plugins can use to extend Fresh’s functionality. Plugins will be able to add new routes, middleware, and islands to a project in the future.

Documentation for plugins is available in the Concepts: Plugins documentation page.

As of now only a single official plugin is available. More plugins will be added in the future as the capabilities of the plugin system expand.

Official twind plugin

Twind is a small Tailwind-in-JS implementation that can generate CSS just-in-time based on the classes used in your JSX. Previous versions of Fresh had a option to automatically configure Twind for you during project initialization, but this resulted in significant amounts of boilerplate.

With the new plugin system, we are now providing a first-party Fresh plugin for Twind. This plugin automatically configures Twind for you to minimize boilerplate in your project. Using it is as simple as:

  // main.ts
  import { start } from "$fresh/server.ts";
  import manifest from "./fresh.gen.ts";

+ import twindPlugin from "$fresh/plugins/twind.ts";
+ import twindConfig from "./twind.config.js";

  await start(manifest, {
+   plugins: [
+     twindPlugin(twindConfig),
+   ],
  });

With this new plugin, using Twind classes in your project becomes even simpler. Previously you had to import the tw function from the twind module and wrap all your class names in it. Now you can just specify the class names directly in the JSX component, and the plugin will take care of the rest.

  // pages/index.tsx
- import { tw } from "@twind";

  export default function IndexPage() {
    return (
-     <h1 class={tw`text-4xl font-bold`}>Hello, world!</h1>
+     <h1 class="text-4xl font-bold">Hello, world!</h1>
    );
  }

With the new plugin, Twind also works more reliably during client side renders and is able to better resolve conflicts between server and client rendered style sheets.

The project initialization script has been updated to use the new Twind plugin, and now also generates all required files to be able to use the Twind VSCode extension.

The update script can be used to update your project to use the new Twind plugin via a codemod.

Preact Signals support

New Fresh projects are now automatically set up to use the new Preact Signals. Signals are a new reactive state management primitive for Preact. They are designed to be much faster than hooks and context, while simultaneously being much more ergonomic.

Here is an example of the basic “counter” component using signals instead of hooks.

import { useSignal } from "@preact/signals";
import { Button } from "../components/Button.tsx";

interface CounterProps {
  start: number;
}

export default function Counter(props: CounterProps) {
  const count = useSignal(props.start);
  return (
    <div>
      <p>{count}</p>
      <button onClick={() => count.value--}>-1</button>
      <button onClick={() => count.value++}>+1</button>
    </div>
  );
}

Signals also provide an excellent way to manage shared state across multiple islands in your Fresh project. Check out the Fresh with Signals demo to see how this works.

For existing projects the updater script will automatically add the @preact/signals dependency to your import map. You can also manually add the dependency to your import map - just make sure to also update preact-render-to-string to >=5.2.3.

You can now use the Preact DevTools extension available for Chrome, Firefox, and Edge to inspect the component tree of your Fresh project.

This is a great way to debug issues with your islands and understand how Preact is rendering your components.

To make use of this feature no additional configuration is required. Just update to the latest version of Fresh and install the Preact DevTools extension for your browser.

This feature is only available during development. In production the Preact DevTools integration is not available. This is done to reduce the amount of JavaScript that is shipped to clients.

Thank you to Marvin Hagemeister for contributing this feature, and improving the Preact DevTools support for island based hydration.

Explicit rendering of 404 pages

It is now possible to explicitly render the 404 page from a route handler. This can be useful if you want to render the 404 page depending on the result of a database query, or if you do more complex routing in your route handler.

To render a 404 page, just call ctx.renderNotFound() from your route handler instead of calling ctx.render() or returning a custom Response object. Just like with ctx.render() you can modify the returned Response object before it is sent to the client.



export const handler: Handlers = {
  GET(req, ctx) {
    const url = new URL(req.url);
    const id = url.searchParams.get("id");
    if (!id) return ctx.renderNotFound(); 
    return ctx.render({ id });
  },
};

Thank you to Steven Yung for contributing this feature.

Stacked middleware

It is now possible to have multiple middleware functions for a single middleware route. This is useful if you have multiple different middleware functions that should all be applied for a given matcher. This is achieved by exporting an array from the middleware file instead of a single function.

Here is an example of a middleware module that contains two middleware functions: one to do logging and one to add timing headers to the response.



export const handler = [
  timing,
  logging,
];

async function timing(
  _req: Request,
  ctx: MiddlewareHandlerContext,
): Promise<Response> {
  const start = performance.now();
  const res = await ctx.next();
  const end = performance.now();
  const dur = (end - start).toFixed(1);
  res.headers.set("Server-Timing", `handler;dur=${dur}`);
  return res;
}

async function logging(
  req: Request,
  ctx: MiddlewareHandlerContext,
): Promise<Response> {
  const res = await ctx.next();
  console.log(`${req.method} ${req.url} ${res.status}`);
  return res;
}

Thank you to @ahuigo for contributing this feature.

Experimental Deno.serve support

Deno v1.25 added a new very high performance HTTP server to Deno. You can read more about it in the Deno 1.25 release notes. It is only available in Deno v1.25 and later when running with the --unstable flag.

This version of Fresh adds experimental support for using the new Deno.serve API instead of the existing std/http server. Deno.serve is not yet stable, so you should not use it in production. Deno.serve is also not available on Deno Deploy, because it is still experimental.

To enable the new server you must specify experimentalDenoServe: true in the options bag passed to the start() method in your main.ts file.

Showcase & “Made with Fresh” badges

The Fresh homepage now has a showcase section where you can find a list of projects that are using Fresh. If you have a project using Fresh, please add it to the list!

In addition to the showcase, we are now also providing a “Made with Fresh” badge that you can add to your website or project README. The badge is also available in a dark variant.

Made with Fresh

Made with Fresh(dark)

Follow these instructions to add the badge to your project: https://github.com/denoland/fresh#badges