remove unused renderers (#3063)
This commit is contained in:
parent
6c6e947740
commit
771127ea29
53 changed files with 8 additions and 1983 deletions
14
.github/labeler.yml
vendored
14
.github/labeler.yml
vendored
|
@ -19,22 +19,22 @@ markdown:
|
|||
- packages/markdown/**
|
||||
|
||||
renderer:
|
||||
- packages/renderers/**
|
||||
- packages/integrations/**
|
||||
|
||||
framework-lit:
|
||||
- packages/renderers/renderer-lit/**
|
||||
- packages/integrations/lit/**
|
||||
|
||||
framework-preact:
|
||||
- packages/renderers/renderer-preact/**
|
||||
- packages/integrations/preact/**
|
||||
|
||||
framework-react:
|
||||
- packages/renderers/renderer-react/**
|
||||
- packages/integrations/react/**
|
||||
|
||||
framework-solid:
|
||||
- packages/renderers/renderer-solid/**
|
||||
- packages/integrations/solid/**
|
||||
|
||||
framework-svelte:
|
||||
- packages/renderers/renderer-svelte/**
|
||||
- packages/integrations/svelte/**
|
||||
|
||||
framework-vue:
|
||||
- packages/renderers/renderer-vue/**
|
||||
- packages/integrations/vue/**
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
"workspaces": [
|
||||
"compiled/*",
|
||||
"packages/markdown/*",
|
||||
"packages/renderers/*",
|
||||
"packages/integrations/*",
|
||||
"packages/*",
|
||||
"examples/*",
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/renderer-solid": "workspace:*"
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# Astro Renderers
|
||||
|
||||
Astro is designed to support your favorite UI frameworks. [React][react], [Svelte][svelte], [Vue][vue], and [Preact][preact] are all built-in to Astro and supported out of the box. No configuration is needed to enable these.
|
||||
|
||||
For adding additional frameworks (or your own custom one), please refer to [the full documentation][renderer-docs].
|
||||
|
||||
[preact]: https://npm.im/@astrojs/renderer-preact
|
||||
[react]: https://npm.im/@astrojs/renderer-react
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
||||
[svelte]: https://npm.im/@astrojs/renderer-svelte
|
||||
[vue]: https://npm.im/@astrojs/renderer-vue
|
1
packages/renderers/renderer-lit/.gitignore
vendored
1
packages/renderers/renderer-lit/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
node_modules/
|
|
@ -1,55 +0,0 @@
|
|||
# @astrojs/renderer-lit
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2370](https://github.com/withastro/astro/pull/2370) [`a7967530`](https://github.com/withastro/astro/commit/a7967530dfe9cfab5d6d866c8d2bcba9c47de39c) Thanks [@matthewp](https://github.com/matthewp)! - Makes the renderer compatible with the static build
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ec01d1b4: renderer-lit will bind to properties rather than attributes fixing certain binding issues
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 806dcd8d: Update Lit renderer to use v2 release
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
|
@ -1,16 +0,0 @@
|
|||
async function polyfill() {
|
||||
const { hydrateShadowRoots } = await import(
|
||||
'@webcomponents/template-shadowroot/template-shadowroot.js'
|
||||
);
|
||||
hydrateShadowRoots(document.body);
|
||||
}
|
||||
|
||||
const polyfillCheckEl = new DOMParser()
|
||||
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
|
||||
includeShadowRoots: true,
|
||||
})
|
||||
.querySelector('p');
|
||||
|
||||
if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) {
|
||||
polyfill();
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
import 'lit/experimental-hydrate-support.js';
|
|
@ -1,37 +0,0 @@
|
|||
// NOTE: @lit-labs/ssr uses syntax incompatible with anything < Node v13.9.0.
|
||||
// Throw an error if using that Node version.
|
||||
|
||||
const NODE_VERSION = parseFloat(process.versions.node);
|
||||
if (NODE_VERSION < 13.9) {
|
||||
throw new Error(
|
||||
`Package @lit-labs/ssr requires Node version v13.9 or higher. Please update Node to use @astrojs/renderer-lit`
|
||||
);
|
||||
}
|
||||
|
||||
export default {
|
||||
name: '@astrojs/renderer-lit',
|
||||
server: './server.js',
|
||||
polyfills: ['./client-shim.js'],
|
||||
hydrationPolyfills: ['./hydration-support.js'],
|
||||
viteConfig() {
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'@astrojs/renderer-lit/client-shim.js',
|
||||
'@astrojs/renderer-lit/hydration-support.js',
|
||||
'@webcomponents/template-shadowroot/template-shadowroot.js',
|
||||
'lit/experimental-hydrate-support.js',
|
||||
],
|
||||
exclude: ['@astrojs/renderer-lit/server.js'],
|
||||
},
|
||||
ssr: {
|
||||
external: [
|
||||
'lit-element/lit-element.js',
|
||||
'@lit-labs/ssr/lib/install-global-dom-shim.js',
|
||||
'@lit-labs/ssr/lib/render-lit-html.js',
|
||||
'@lit-labs/ssr/lib/lit-element-renderer.js',
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-lit",
|
||||
"version": "0.4.0",
|
||||
"description": "Use Lit components within Astro",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-lit"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./server.js": "./server.js",
|
||||
"./client-shim.js": "./client-shim.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lit-labs/ssr": "^2.1.0",
|
||||
"@webcomponents/template-shadowroot": "^0.1.0",
|
||||
"lit": "^2.2.2"
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
# Astro Lit Renderer
|
||||
|
||||
This is a plugin for [Astro](https://astro.build/) apps that enables server-side rendering of custom elements build with [Lit](https://lit.dev/).
|
||||
|
||||
Server-side rendering uses [Declarative Shadow DOM](https://web.dev/declarative-shadow-dom/), a new web technology that allows custom elements to be rendered to HTML with __0 JavaScript__.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-lit` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-lit
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-lit'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
If you're familiar with Astro then you already know that you can import components into your templates and use them. What's different about custom elements is you can use the *tag name* directly.
|
||||
|
||||
Astro needs to know which tag is associated with which component script. We expose this through exporting a `tagName` variable from the component script. It looks like this:
|
||||
|
||||
__src/components/my-element.js__
|
||||
|
||||
```js
|
||||
import { LitElement, html } from 'lit';
|
||||
|
||||
export const tagName = 'my-element';
|
||||
|
||||
class MyElement extends LitElement {
|
||||
render() {
|
||||
return html` <p>Hello world! From my-element</p> `;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define(tagName, MyElement);
|
||||
```
|
||||
|
||||
> Note that exporting the `tagName` is __required__ if you want to use the tag name in your templates. Otherwise you can export and use the constructor, like with non custom element frameworks.
|
||||
|
||||
In your Astro template import this component as a side-effect and use the element.
|
||||
|
||||
__src/pages/index.astro__
|
||||
|
||||
```astro
|
||||
---
|
||||
import '../components/my-element.js';
|
||||
---
|
||||
|
||||
<my-element></my-element>
|
||||
```
|
||||
|
||||
> Note that Lit requires browser globals such as `HTMLElement` and `customElements` to be present. For this reason the Lit renderer shims the server with these globals so Lit can run. You *might* run into libraries that work incorrectly because of this.
|
||||
|
||||
### Polyfills & Hydration
|
||||
|
||||
The renderer automatically handles adding appropriate polyfills for support in browsers that don't have Declarative Shadow DOM. The polyfill is about *1.5kB*. If the browser does support Declarative Shadow DOM then less than 250 bytes are loaded (to feature detect support).
|
||||
|
||||
Hydration is also handled automatically. You can use the same hydration directives such as `client:load`, `client:idle` and `client:visible` as you can with other libraries that Astro supports.
|
||||
|
||||
```astro
|
||||
---
|
||||
import '../components/my-element.js';
|
||||
---
|
||||
|
||||
<my-element client:visible />
|
||||
```
|
||||
|
||||
The above will only load the element's JavaScript when the user has scrolled it into view. Since it is server rendered they will not see any jank; it will load and hydrate transparently.
|
||||
|
||||
## More Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,5 +0,0 @@
|
|||
import { installWindowOnGlobal } from '@lit-labs/ssr/lib/dom-shim.js';
|
||||
installWindowOnGlobal();
|
||||
|
||||
window.global = window;
|
||||
document.getElementsByTagName = () => [];
|
|
@ -1,72 +0,0 @@
|
|||
import './server-shim.js';
|
||||
import '@lit-labs/ssr/lib/render-lit-html.js';
|
||||
import { LitElementRenderer } from '@lit-labs/ssr/lib/lit-element-renderer.js';
|
||||
|
||||
function isCustomElementTag(name) {
|
||||
return typeof name === 'string' && /-/.test(name);
|
||||
}
|
||||
|
||||
function getCustomElementConstructor(name) {
|
||||
if (typeof customElements !== 'undefined' && isCustomElementTag(name)) {
|
||||
return customElements.get(name) || null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function isLitElement(Component) {
|
||||
const Ctr = getCustomElementConstructor(Component);
|
||||
return !!(Ctr && Ctr._$litElement$);
|
||||
}
|
||||
|
||||
async function check(Component, _props, _children) {
|
||||
// Lit doesn't support getting a tagName from a Constructor at this time.
|
||||
// So this must be a string at the moment.
|
||||
return !!(await isLitElement(Component));
|
||||
}
|
||||
|
||||
function* render(tagName, attrs, children) {
|
||||
const instance = new LitElementRenderer(tagName);
|
||||
|
||||
// LitElementRenderer creates a new element instance, so copy over.
|
||||
const Ctr = getCustomElementConstructor(tagName);
|
||||
for (let [name, value] of Object.entries(attrs)) {
|
||||
// check if this is a reactive property
|
||||
if (name in Ctr.prototype) {
|
||||
instance.setProperty(name, value);
|
||||
} else {
|
||||
instance.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
instance.connectedCallback();
|
||||
|
||||
yield `<${tagName}`;
|
||||
yield* instance.renderAttributes();
|
||||
yield `>`;
|
||||
const shadowContents = instance.renderShadow({});
|
||||
if (shadowContents !== undefined) {
|
||||
yield '<template shadowroot="open">';
|
||||
yield* shadowContents;
|
||||
yield '</template>';
|
||||
}
|
||||
yield children || ''; // don’t print “undefined” as string
|
||||
yield `</${tagName}>`;
|
||||
}
|
||||
|
||||
async function renderToStaticMarkup(Component, props, children) {
|
||||
let tagName = Component;
|
||||
|
||||
let out = '';
|
||||
for (let chunk of render(tagName, props, children)) {
|
||||
out += chunk;
|
||||
}
|
||||
|
||||
return {
|
||||
html: out,
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,119 +0,0 @@
|
|||
# @astrojs/renderer-preact
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.5.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2170](https://github.com/withastro/astro/pull/2170) [`5af24efb`](https://github.com/withastro/astro/commit/5af24efb3493b8f5b6a8f980c792455c7dc34eb5) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Fix preact 10.6 regression by pinning to preact 10.5
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2078](https://github.com/withastro/astro/pull/2078) [`ac3e8702`](https://github.com/withastro/astro/commit/ac3e870280e983a7977da79b6eec0568d38d8420) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix behavior of renderers when no children are passed in
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.3.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3cd1458a: Bugfix: Bundled CSS missing files on Windows
|
||||
|
||||
## 0.3.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f7e86150: Fix an issue where preact component UI wouldn't update on hydrate
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Switches to [the new JSX Transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) originally introduced for React v17. This also leverages the new `jsxTransformOptions` options for renderers.
|
||||
|
||||
This change also removes the need for importing your Framework's `jsxFactory` directly, which means you can wave goodbye to `import React from "react";` and `import { h } from "preact";`.
|
||||
|
||||
> **If you are using mutliple frameworks** and a file doesn't reference `react` or `preact`, Astro might not be able to locate the correct renderer! You can add a pragma comment like `/** @jsxImportSource preact */` to the top of your file. Alternatively, just import the JSX pragma as you traditionally would have.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- bd18e14: Update `check` logic to exclude false-positives from SolidJS
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Switches to [the new JSX Transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) originally introduced for React v17. This also leverages the new `jsxTransformOptions` options for renderers.
|
||||
|
||||
This change also removes the need for importing your Framework's `jsxFactory` directly, which means you can wave goodbye to `import React from "react";` and `import { h } from "preact";`.
|
||||
|
||||
> **If you are using mutliple frameworks** and a file doesn't reference `react` or `preact`, Astro might not be able to locate the correct renderer! You can add a pragma comment like `/** @jsxImportSource preact */` to the top of your file. Alternatively, just import the JSX pragma as you traditionally would have.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- bd18e14: Update `check` logic to exclude false-positives from SolidJS
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0abd251: Allows renderers to provide knownEntrypoint config values
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9d4a40f: Fixes bug with using arrow function components
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ab2972b: Update package.json engines for esm support
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
||||
|
||||
## 0.1.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
|
@ -1,31 +0,0 @@
|
|||
# @astrojs/renderer-preact
|
||||
|
||||
This is a plugin for [Astro][astro] apps that enables server-side rendering of Preact components.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-preact` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-preact
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-preact'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,8 +0,0 @@
|
|||
import { h, render } from 'preact';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
export default (element) => (Component, props, children) =>
|
||||
render(
|
||||
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
|
||||
element
|
||||
);
|
|
@ -1,36 +0,0 @@
|
|||
export default {
|
||||
name: '@astrojs/renderer-preact/compat',
|
||||
client: '../client.js',
|
||||
server: '../server.js',
|
||||
jsxImportSource: 'react',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
return {
|
||||
plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact/compat' })],
|
||||
};
|
||||
},
|
||||
viteConfig() {
|
||||
return {
|
||||
alias: {
|
||||
react: 'preact/compat',
|
||||
'react-dom': 'preact/compat',
|
||||
},
|
||||
resolve: {
|
||||
dedupe: ['react', 'react-dom'],
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'@astrojs/renderer-preact/client.js',
|
||||
'preact/compat',
|
||||
'preact/compat/jsx-runtime',
|
||||
'preact-render-to-string',
|
||||
],
|
||||
},
|
||||
ssr: {
|
||||
external: ['preact-render-to-string'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
export default {
|
||||
name: '@astrojs/renderer-preact',
|
||||
client: './client.js',
|
||||
server: './server.js',
|
||||
jsxImportSource: 'preact',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
return {
|
||||
plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact' })],
|
||||
};
|
||||
},
|
||||
viteConfig() {
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'@astrojs/renderer-preact/client.js',
|
||||
'preact',
|
||||
'preact/jsx-runtime',
|
||||
'preact-render-to-string',
|
||||
],
|
||||
exclude: ['@astrojs/renderer-preact/server.js'],
|
||||
},
|
||||
ssr: {
|
||||
external: ['preact-render-to-string'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-preact",
|
||||
"description": "Use Preact components within Astro",
|
||||
"version": "0.5.0",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-preact"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./compat": "./compat/index.js",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-react-jsx": "^7.17.3",
|
||||
"preact": "^10.7.1",
|
||||
"preact-render-to-string": "^5.1.21"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
import { h, Component as BaseComponent } from 'preact';
|
||||
import render from 'preact-render-to-string';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
function check(Component, props, children) {
|
||||
if (typeof Component !== 'function') return false;
|
||||
|
||||
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
|
||||
return BaseComponent.isPrototypeOf(Component);
|
||||
}
|
||||
|
||||
try {
|
||||
const { html } = renderToStaticMarkup(Component, props, children);
|
||||
if (typeof html !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// There are edge cases (SolidJS) where Preact *might* render a string,
|
||||
// but components would be <undefined></undefined>
|
||||
|
||||
return !/\<undefined\>/.test(html);
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function renderToStaticMarkup(Component, props, children) {
|
||||
const html = render(
|
||||
h(Component, props, children != null ? h(StaticHtml, { value: children }) : children)
|
||||
);
|
||||
return { html };
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
import { h } from 'preact';
|
||||
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a wrapper `div` to render that content as VNodes.
|
||||
*
|
||||
* As a bonus, we can signal to Preact that this subtree is
|
||||
* entirely static and will never change via `shouldComponentUpdate`.
|
||||
*/
|
||||
const StaticHtml = ({ value }) => {
|
||||
if (!value) return null;
|
||||
return h('astro-fragment', { dangerouslySetInnerHTML: { __html: value } });
|
||||
};
|
||||
|
||||
/**
|
||||
* This tells Preact to opt-out of re-rendering this subtree,
|
||||
* In addition to being a performance optimization,
|
||||
* this also allows other frameworks to attach to `children`.
|
||||
*
|
||||
* See https://preactjs.com/guide/v8/external-dom-mutations
|
||||
*/
|
||||
StaticHtml.shouldComponentUpdate = () => false;
|
||||
|
||||
export default StaticHtml;
|
|
@ -1,123 +0,0 @@
|
|||
# @astrojs/renderer-react
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.5.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2369](https://github.com/withastro/astro/pull/2369) [`20eaddb2`](https://github.com/withastro/astro/commit/20eaddb2a723253c7fbde3e56955a549bdf3f342) Thanks [@matthewp](https://github.com/matthewp)! - Fix for using the React renderer with the static build
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2078](https://github.com/withastro/astro/pull/2078) [`ac3e8702`](https://github.com/withastro/astro/commit/ac3e870280e983a7977da79b6eec0568d38d8420) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix behavior of renderers when no children are passed in
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.3.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3cd1458a: Bugfix: Bundled CSS missing files on Windows
|
||||
|
||||
## 0.3.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 756e3769: Fixes detect to allow rendering React.PureComponents
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Switches to [the new JSX Transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) originally introduced for React v17. This also leverages the new `jsxTransformOptions` options for renderers.
|
||||
|
||||
This change also removes the need for importing your Framework's `jsxFactory` directly, which means you can wave goodbye to `import React from "react";` and `import { h } from "preact";`.
|
||||
|
||||
> **If you are using mutliple frameworks** and a file doesn't reference `react` or `preact`, Astro might not be able to locate the correct renderer! You can add a pragma comment like `/** @jsxImportSource preact */` to the top of your file. Alternatively, just import the JSX pragma as you traditionally would have.
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Switches to [the new JSX Transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) originally introduced for React v17. This also leverages the new `jsxTransformOptions` options for renderers.
|
||||
|
||||
This change also removes the need for importing your Framework's `jsxFactory` directly, which means you can wave goodbye to `import React from "react";` and `import { h } from "preact";`.
|
||||
|
||||
> **If you are using mutliple frameworks** and a file doesn't reference `react` or `preact`, Astro might not be able to locate the correct renderer! You can add a pragma comment like `/** @jsxImportSource preact */` to the top of your file. Alternatively, just import the JSX pragma as you traditionally would have.
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1e01251: Fixes bug with React renderer that would not hydrate correctly
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 21dc28c: Add react-dom as a knownEntrypoint (speeds up astro startup)
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0abd251: Allows renderers to provide knownEntrypoint config values
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9d4a40f: Fixes bug with using arrow function components
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ab2972b: Update package.json engines for esm support
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
||||
|
||||
## 0.1.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
|
@ -1,31 +0,0 @@
|
|||
# @astrojs/renderer-react
|
||||
|
||||
This is a plugin for [Astro][astro] apps that enables server-side rendering of React components.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-react` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-react
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-react'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,15 +0,0 @@
|
|||
import { createElement } from 'react';
|
||||
import { hydrate } from 'react-dom';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
export default (element) => (Component, props, children) =>
|
||||
hydrate(
|
||||
createElement(
|
||||
Component,
|
||||
{ ...props, suppressHydrationWarning: true },
|
||||
children != null
|
||||
? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
|
||||
: children
|
||||
),
|
||||
element
|
||||
);
|
|
@ -1,42 +0,0 @@
|
|||
export default {
|
||||
name: '@astrojs/renderer-react',
|
||||
client: './client.js',
|
||||
server: './server.js',
|
||||
jsxImportSource: 'react',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
return {
|
||||
plugins: [
|
||||
jsx(
|
||||
{},
|
||||
{
|
||||
runtime: 'automatic',
|
||||
importSource: '@astrojs/renderer-react',
|
||||
}
|
||||
),
|
||||
],
|
||||
};
|
||||
},
|
||||
viteConfig() {
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'@astrojs/renderer-react/client.js',
|
||||
'react',
|
||||
'react/jsx-runtime',
|
||||
'react/jsx-dev-runtime',
|
||||
'react-dom',
|
||||
],
|
||||
exclude: ['@astrojs/renderer-react/server.js'],
|
||||
},
|
||||
resolve: {
|
||||
dedupe: ['react', 'react-dom'],
|
||||
},
|
||||
ssr: {
|
||||
external: ['react-dom/server.js'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,8 +0,0 @@
|
|||
// This module is a simple wrapper around react/jsx-runtime so that
|
||||
// it can run in Node ESM. 'react' doesn't declare this module as an export map
|
||||
// So we have to use the .js. The .js is not added via the babel automatic JSX transform
|
||||
// hence this module as a workaround.
|
||||
import jsxr from 'react/jsx-runtime.js';
|
||||
const { jsx, jsxs, Fragment } = jsxr;
|
||||
|
||||
export { jsx, jsxs, Fragment };
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-react",
|
||||
"description": "Use React components within Astro",
|
||||
"version": "0.5.0",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-react"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json",
|
||||
"./jsx-runtime": "./jsx-runtime.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-react-jsx": "^7.17.3",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/server.js';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
const reactTypeof = Symbol.for('react.element');
|
||||
|
||||
function errorIsComingFromPreactComponent(err) {
|
||||
return (
|
||||
err.message &&
|
||||
(err.message.startsWith("Cannot read property '__H'") ||
|
||||
err.message.includes("(reading '__H')"))
|
||||
);
|
||||
}
|
||||
|
||||
function check(Component, props, children) {
|
||||
// Note: there are packages that do some unholy things to create "components".
|
||||
// Checking the $$typeof property catches most of these patterns.
|
||||
if (typeof Component === 'object') {
|
||||
const $$typeof = Component['$$typeof'];
|
||||
return $$typeof && $$typeof.toString().slice('Symbol('.length).startsWith('react');
|
||||
}
|
||||
if (typeof Component !== 'function') return false;
|
||||
|
||||
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
|
||||
return React.Component.isPrototypeOf(Component) || React.PureComponent.isPrototypeOf(Component);
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let isReactComponent = false;
|
||||
function Tester(...args) {
|
||||
try {
|
||||
const vnode = Component(...args);
|
||||
if (vnode && vnode['$$typeof'] === reactTypeof) {
|
||||
isReactComponent = true;
|
||||
}
|
||||
} catch (err) {
|
||||
if (!errorIsComingFromPreactComponent(err)) {
|
||||
error = err;
|
||||
}
|
||||
}
|
||||
|
||||
return React.createElement('div');
|
||||
}
|
||||
|
||||
renderToStaticMarkup(Tester, props, children, {});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return isReactComponent;
|
||||
}
|
||||
|
||||
function renderToStaticMarkup(Component, props, children, metadata) {
|
||||
delete props['class'];
|
||||
const vnode = React.createElement(Component, {
|
||||
...props,
|
||||
children: children != null ? React.createElement(StaticHtml, { value: children }) : undefined,
|
||||
});
|
||||
let html;
|
||||
if (metadata && metadata.hydrate) {
|
||||
html = ReactDOM.renderToString(vnode);
|
||||
} else {
|
||||
html = ReactDOM.renderToStaticMarkup(vnode);
|
||||
}
|
||||
return { html };
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
import { createElement as h } from 'react';
|
||||
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a wrapper `div` to render that content as VNodes.
|
||||
*
|
||||
* As a bonus, we can signal to React that this subtree is
|
||||
* entirely static and will never change via `shouldComponentUpdate`.
|
||||
*/
|
||||
const StaticHtml = ({ value }) => {
|
||||
if (!value) return null;
|
||||
return h('astro-fragment', {
|
||||
suppressHydrationWarning: true,
|
||||
dangerouslySetInnerHTML: { __html: value },
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This tells React to opt-out of re-rendering this subtree,
|
||||
* In addition to being a performance optimization,
|
||||
* this also allows other frameworks to attach to `children`.
|
||||
*
|
||||
* See https://preactjs.com/guide/v8/external-dom-mutations
|
||||
*/
|
||||
StaticHtml.shouldComponentUpdate = () => false;
|
||||
|
||||
export default StaticHtml;
|
|
@ -1,95 +0,0 @@
|
|||
# @astrojs/renderer-solid
|
||||
|
||||
## 0.4.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [`815d62f1`](https://github.com/withastro/astro/commit/815d62f151a36fef7d09590d4962ca71bda61b32) Thanks [@FredKSchott](https://github.com/FredKSchott)! - no changes.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3003](https://github.com/withastro/astro/pull/3003) [`13b782f4`](https://github.com/withastro/astro/commit/13b782f421871af36978f29154c715c66739d475) Thanks [@ryansolid](https://github.com/ryansolid)! - Improve nested hydration with Solid
|
||||
|
||||
## 0.4.1-beta.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3003](https://github.com/withastro/astro/pull/3003) [`13b782f4`](https://github.com/withastro/astro/commit/13b782f421871af36978f29154c715c66739d475) Thanks [@ryansolid](https://github.com/ryansolid)! - Improve nested hydration with Solid
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2359](https://github.com/withastro/astro/pull/2359) [`f482c626`](https://github.com/withastro/astro/commit/f482c626a6e3472052d13cb0d348323ef4e822a8) Thanks [@toSayNothing](https://github.com/toSayNothing)! - fix renderer-solid
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2078](https://github.com/withastro/astro/pull/2078) [`ac3e8702`](https://github.com/withastro/astro/commit/ac3e870280e983a7977da79b6eec0568d38d8420) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix behavior of renderers when no children are passed in
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.2.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3cd1458a: Bugfix: Bundled CSS missing files on Windows
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Initial release
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- bef5103: Uses Solid's `render` function to render our components on the client.
|
||||
|
||||
## 0.1.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- bef5103: Uses Solid's `render` function to render our components on the client.
|
||||
|
||||
## 0.1.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- bd18e14: Initial release
|
|
@ -1,31 +0,0 @@
|
|||
# @astrojs/renderer-solid
|
||||
|
||||
This is a plugin for [Astro][astro] apps that enables server-side rendering of SolidJS components.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-solid` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-solid
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-solid'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,25 +0,0 @@
|
|||
import { sharedConfig } from 'solid-js';
|
||||
import { hydrate, createComponent } from 'solid-js/web';
|
||||
|
||||
export default (element) => (Component, props, childHTML) => {
|
||||
let children;
|
||||
hydrate(
|
||||
() =>
|
||||
createComponent(Component, {
|
||||
...props,
|
||||
get children() {
|
||||
if (childHTML != null) {
|
||||
// hydrating
|
||||
if (sharedConfig.context) children = element.querySelector('astro-fragment');
|
||||
|
||||
if (children == null) {
|
||||
children = document.createElement('astro-fragment');
|
||||
children.innerHTML = childHTML;
|
||||
}
|
||||
}
|
||||
return children;
|
||||
},
|
||||
}),
|
||||
element
|
||||
);
|
||||
};
|
|
@ -1,49 +0,0 @@
|
|||
export default {
|
||||
name: '@astrojs/renderer-solid',
|
||||
client: './client.js',
|
||||
server: './server.js',
|
||||
jsxImportSource: 'solid-js',
|
||||
jsxTransformOptions: async ({ ssr }) => {
|
||||
const [{ default: solid }] = await Promise.all([import('babel-preset-solid')]);
|
||||
const options = {
|
||||
presets: [solid({}, { generate: ssr ? 'ssr' : 'dom', hydratable: true })],
|
||||
plugins: [],
|
||||
};
|
||||
|
||||
return options;
|
||||
},
|
||||
viteConfig(options) {
|
||||
// https://github.com/solidjs/vite-plugin-solid
|
||||
|
||||
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
|
||||
const replaceDev = options.mode === 'development' || options.command === 'serve';
|
||||
|
||||
const nestedDeps = [
|
||||
'solid-js',
|
||||
'solid-js/web',
|
||||
'solid-js/store',
|
||||
'solid-js/html',
|
||||
'solid-js/h',
|
||||
];
|
||||
|
||||
return {
|
||||
/**
|
||||
* We only need esbuild on .ts or .js files.
|
||||
* .tsx & .jsx files are handled by us
|
||||
*/
|
||||
esbuild: { include: /\.ts$/ },
|
||||
resolve: {
|
||||
conditions: ['solid', ...(replaceDev ? ['development'] : [])],
|
||||
dedupe: nestedDeps,
|
||||
alias: [{ find: /^solid-refresh$/, replacement: '/@solid-refresh' }],
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: nestedDeps,
|
||||
exclude: ['@astrojs/renderer-solid/server.js'],
|
||||
},
|
||||
ssr: {
|
||||
external: ['babel-preset-solid'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-solid",
|
||||
"version": "0.4.2",
|
||||
"description": "Use Solid components within Astro",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-solid"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-preset-solid": "^1.3.13",
|
||||
"solid-js": "^1.3.14"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
import { renderToString, ssr, createComponent } from 'solid-js/web';
|
||||
|
||||
function check(Component, props, children) {
|
||||
if (typeof Component !== 'function') return false;
|
||||
try {
|
||||
const { html } = renderToStaticMarkup(Component, props, children);
|
||||
return typeof html === 'string';
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function renderToStaticMarkup(Component, props, children) {
|
||||
const html = renderToString(() =>
|
||||
createComponent(Component, {
|
||||
...props,
|
||||
// In Solid SSR mode, `ssr` creates the expected structure for `children`.
|
||||
// In Solid client mode, `ssr` is just a stub.
|
||||
children: children != null ? ssr(`<astro-fragment>${children}</astro-fragment>`) : children,
|
||||
})
|
||||
);
|
||||
return {
|
||||
html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>`,
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,12 +0,0 @@
|
|||
import { ssr } from 'solid-js/web';
|
||||
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a wrapper `astro-fragment` to render that content as VNodes.
|
||||
*/
|
||||
const StaticHtml = ({ innerHTML }) => {
|
||||
if (!innerHTML) return null;
|
||||
return ssr(`<astro-fragment>${innerHTML}</astro-fragment>`);
|
||||
};
|
||||
|
||||
export default StaticHtml;
|
|
@ -1,109 +0,0 @@
|
|||
# @astrojs/renderer-svelte
|
||||
|
||||
## 0.5.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2807](https://github.com/withastro/astro/pull/2807) [`79282163`](https://github.com/withastro/astro/commit/79282163e229bfe332b1221be3099f751b05807b) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Remove "PostCSS configuration was not passed or is invalid" error when using the Svelte renderer
|
||||
|
||||
## 0.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2722](https://github.com/withastro/astro/pull/2722) [`0d37f8e0`](https://github.com/withastro/astro/commit/0d37f8e0a51ac7bcf9e108151828b733bbba6e94) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Temporarily revert [#2715](https://github.com/withastro/astro/pull/2715) to fix `.svelte` files breaking in the static build.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2715](https://github.com/withastro/astro/pull/2715) [`5f91e007`](https://github.com/withastro/astro/commit/5f91e007cbbb3a5ff7322964d811844b0921db61) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Internally, we'll now use Vite to preprocess assets rather than pulling in `svelte-preprocess`.
|
||||
|
||||
> This removes the default warnings about missing `postcss-load-config`
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2300](https://github.com/withastro/astro/pull/2300) [`34486676`](https://github.com/withastro/astro/commit/344866762c3a96b92bd754cf3706db73e2d74647) Thanks [@moritzlaube](https://github.com/moritzlaube)! - Update Svelte to 3.44.3 to get rid of console warning that component receives an unexpected slot "default".
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2216](https://github.com/withastro/astro/pull/2216) [`b8c821a0`](https://github.com/withastro/astro/commit/b8c821a0743ed004691eae0eea471a368d2fa35f) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Pin `@sveltejs/vite-plugin-svelte` to `1.0.0-next.30` for now
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2078](https://github.com/withastro/astro/pull/2078) [`ac3e8702`](https://github.com/withastro/astro/commit/ac3e870280e983a7977da79b6eec0568d38d8420) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix behavior of renderers when no children are passed in
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4cec1256: Add TypeScript, Sass support to Svelte
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.2.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3cd1458a: Bugfix: Bundled CSS missing files on Windows
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ab2972b: Update package.json engines for esm support
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c9d833e: Fixed a bug that was preventing SSR from working
|
||||
|
||||
## 0.1.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
|
@ -1,31 +0,0 @@
|
|||
# @astrojs/renderer-svelte
|
||||
|
||||
This is a plugin for [Astro][astro] apps that enables server-side rendering of Svelte components.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-svelte` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-svelte
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-svelte'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,21 +0,0 @@
|
|||
<script>
|
||||
/**
|
||||
* Why do we need a wrapper component?
|
||||
*
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a way to render that content.
|
||||
*
|
||||
* Rather than passing a magical prop which needs special
|
||||
* handling, using this wrapper allows Svelte users to just
|
||||
* use `<slot />` like they would for any other component.
|
||||
*/
|
||||
const { __astro_component: Component, __astro_children, ...props } = $$props;
|
||||
</script>
|
||||
|
||||
<svelte:component this={Component} {...props}>
|
||||
{#if __astro_children != null}
|
||||
<astro-fragment>
|
||||
{@html __astro_children}
|
||||
</astro-fragment>
|
||||
{/if}
|
||||
</svelte:component>
|
|
@ -1,19 +0,0 @@
|
|||
/* App.svelte generated by Svelte v3.38.2 */
|
||||
import { create_ssr_component, missing_component, validate_component } from 'svelte/internal';
|
||||
|
||||
const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
||||
const { __astro_component: Component, __astro_children, ...props } = $$props;
|
||||
const children = {};
|
||||
if (__astro_children != null) {
|
||||
children.default = () => `<astro-fragment>${__astro_children}</astro-fragment>`;
|
||||
}
|
||||
|
||||
return `${validate_component(Component || missing_component, 'svelte:component').$$render(
|
||||
$$result,
|
||||
Object.assign(props),
|
||||
{},
|
||||
children
|
||||
)}`;
|
||||
});
|
||||
|
||||
export default App;
|
|
@ -1,14 +0,0 @@
|
|||
import SvelteWrapper from './Wrapper.svelte';
|
||||
|
||||
export default (target) => {
|
||||
return (component, props, children) => {
|
||||
delete props['class'];
|
||||
try {
|
||||
new SvelteWrapper({
|
||||
target,
|
||||
props: { __astro_component: component, __astro_children: children, ...props },
|
||||
hydrate: true,
|
||||
});
|
||||
} catch (e) {}
|
||||
};
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
import preprocess from 'svelte-preprocess';
|
||||
|
||||
export default {
|
||||
name: '@astrojs/renderer-svelte',
|
||||
client: './client.js',
|
||||
server: './server.js',
|
||||
viteConfig({ mode }) {
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: ['@astrojs/renderer-svelte/client.js', 'svelte', 'svelte/internal'],
|
||||
exclude: ['@astrojs/renderer-svelte/server.js'],
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
emitCss: true,
|
||||
compilerOptions: { dev: mode === 'development', hydratable: true },
|
||||
preprocess: [
|
||||
preprocess({
|
||||
less: true,
|
||||
sass: { renderSync: true },
|
||||
scss: { renderSync: true },
|
||||
stylus: true,
|
||||
typescript: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-svelte",
|
||||
"version": "0.5.2",
|
||||
"description": "Use Svelte components within Astro",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-svelte"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.41",
|
||||
"svelte": "^3.47.0",
|
||||
"svelte-preprocess": "^4.10.5",
|
||||
"vite": "^2.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import SvelteWrapper from './Wrapper.svelte.ssr.js';
|
||||
|
||||
function check(Component) {
|
||||
return Component['render'] && Component['$$render'];
|
||||
}
|
||||
|
||||
async function renderToStaticMarkup(Component, props, children) {
|
||||
const { html } = SvelteWrapper.render({
|
||||
__astro_component: Component,
|
||||
__astro_children: children,
|
||||
...props,
|
||||
});
|
||||
return { html };
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,121 +0,0 @@
|
|||
# @astrojs/renderer-vue
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.4.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2563](https://github.com/withastro/astro/pull/2563) [`a907a73b`](https://github.com/withastro/astro/commit/a907a73b8cd14726d158ea460932f9cd8891923a) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Upgrade renderer dependencies for `vite@2.8.x`
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2202](https://github.com/withastro/astro/pull/2202) [`45cea6ae`](https://github.com/withastro/astro/commit/45cea6aec5a310fed4cb8da0d96670d6b99a2539) Thanks [@jonathantneal](https://github.com/jonathantneal)! - Officially drop support for Node v12. The minimum supported version is now Node v14.15+,
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2078](https://github.com/withastro/astro/pull/2078) [`ac3e8702`](https://github.com/withastro/astro/commit/ac3e870280e983a7977da79b6eec0568d38d8420) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix behavior of renderers when no children are passed in
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- e6aaeff5: Updated framework renderers for the v0.21.0 release of Astro. Assorted changes and a new renderer interface are included in this release.
|
||||
|
||||
## 0.2.0-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8986d33b: Improve error display
|
||||
|
||||
## 0.2.0-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3cd1458a: Bugfix: Bundled CSS missing files on Windows
|
||||
|
||||
## 0.2.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d84bfe71: Updates the renderers to confirm to the new renderer API.
|
||||
|
||||
## 0.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 31d06880: Expose name on host component for Vue devtools
|
||||
|
||||
## 0.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 97d37f8f: Update READMEs for all renderers
|
||||
|
||||
## 0.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1339d5e3: Bump Vue version to latest stable
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a1491cc6: Fix Vue components nesting
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fdb1c15: Revert #858
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1f79144: Exclude @vue/runtime-core from processing to fix Vue SSR for nested components
|
||||
|
||||
## 0.1.4-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1f79144: Exclude @vue/runtime-core from processing to fix Vue SSR for nested components
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0abd251: Allows renderers to provide knownEntrypoint config values
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ab2972b: Update package.json engines for esm support
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b1364af: Updates logging to display messages from Snowpack
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
||||
|
||||
## 0.1.0-next.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 643c880: Initial release
|
|
@ -1,31 +0,0 @@
|
|||
# @astrojs/renderer-vue
|
||||
|
||||
This is a plugin for [Astro][astro] apps that enables server-side rendering of Vue 3.x components.
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@astrojs/renderer-vue` and then add it to your `astro.config.mjs` in the `renderers` property:
|
||||
|
||||
```
|
||||
npm install @astrojs/renderer-vue
|
||||
```
|
||||
|
||||
__astro.config.mjs__
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ...
|
||||
|
||||
renderers: [
|
||||
// ...
|
||||
'@astrojs/renderer-vue'
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Astro Renderer Documentation][renderer-docs]
|
||||
|
||||
[astro]: https://astro.build
|
||||
[renderer-docs]: https://docs.astro.build/reference/renderer-reference
|
|
@ -1,14 +0,0 @@
|
|||
import { h, createSSRApp } from 'vue';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
export default (element) => (Component, props, children) => {
|
||||
delete props['class'];
|
||||
// Expose name on host component for Vue devtools
|
||||
const name = Component.name ? `${Component.name} Host` : undefined;
|
||||
const slots = {};
|
||||
if (children != null) {
|
||||
slots.default = () => h(StaticHtml, { value: children });
|
||||
}
|
||||
const app = createSSRApp({ name, render: () => h(Component, props, slots) });
|
||||
app.mount(element, true);
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
import vue from '@vitejs/plugin-vue';
|
||||
|
||||
export default {
|
||||
name: '@astrojs/renderer-vue',
|
||||
client: './client.js',
|
||||
server: './server.js',
|
||||
viteConfig() {
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: ['@astrojs/renderer-vue/client.js', 'vue'],
|
||||
exclude: ['@astrojs/renderer-vue/server.js'],
|
||||
},
|
||||
plugins: [vue()],
|
||||
ssr: {
|
||||
external: ['@vue/server-renderer'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"name": "@astrojs/renderer-vue",
|
||||
"version": "0.4.0",
|
||||
"description": "Use Vue components within Astro",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/renderers/renderer-vue"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vitejs/plugin-vue": "^2.3.1",
|
||||
"vite": "^2.9.1",
|
||||
"vue": "^3.2.31"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
import { h, createSSRApp } from 'vue';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
import StaticHtml from './static-html.js';
|
||||
|
||||
function check(Component) {
|
||||
return !!Component['ssrRender'];
|
||||
}
|
||||
|
||||
async function renderToStaticMarkup(Component, props, children) {
|
||||
const slots = {};
|
||||
if (children != null) {
|
||||
slots.default = () => h(StaticHtml, { value: children });
|
||||
}
|
||||
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
||||
const html = await renderToString(app);
|
||||
return { html };
|
||||
}
|
||||
|
||||
export default {
|
||||
check,
|
||||
renderToStaticMarkup,
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
import { h, defineComponent } from 'vue';
|
||||
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
* a wrapper `div` to render that content as VNodes.
|
||||
*
|
||||
* This is the Vue + JSX equivalent of using `<div v-html="value" />`
|
||||
*/
|
||||
const StaticHtml = defineComponent({
|
||||
props: {
|
||||
value: String,
|
||||
},
|
||||
setup({ value }) {
|
||||
if (!value) return () => null;
|
||||
return () => h('astro-fragment', { innerHTML: value });
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Other frameworks have `shouldComponentUpdate` in order to signal
|
||||
* that this subtree is entirely static and will not be updated
|
||||
*
|
||||
* Fortunately, Vue is smart enough to figure that out without any
|
||||
* help from us, so this just works out of the box!
|
||||
*/
|
||||
|
||||
export default StaticHtml;
|
183
pnpm-lock.yaml
183
pnpm-lock.yaml
|
@ -779,10 +779,8 @@ importers:
|
|||
|
||||
packages/astro/test/fixtures/astro-jsx:
|
||||
specifiers:
|
||||
'@astrojs/renderer-solid': workspace:*
|
||||
astro: workspace:*
|
||||
dependencies:
|
||||
'@astrojs/renderer-solid': link:../../../../renderers/renderer-solid
|
||||
astro: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/astro-markdown:
|
||||
|
@ -1460,66 +1458,6 @@ importers:
|
|||
'@types/prismjs': 1.26.0
|
||||
astro-scripts: link:../../../scripts
|
||||
|
||||
packages/renderers/renderer-lit:
|
||||
specifiers:
|
||||
'@lit-labs/ssr': ^2.1.0
|
||||
'@webcomponents/template-shadowroot': ^0.1.0
|
||||
lit: ^2.2.2
|
||||
dependencies:
|
||||
'@lit-labs/ssr': 2.1.0
|
||||
'@webcomponents/template-shadowroot': 0.1.0
|
||||
lit: 2.2.2
|
||||
|
||||
packages/renderers/renderer-preact:
|
||||
specifiers:
|
||||
'@babel/plugin-transform-react-jsx': ^7.17.3
|
||||
preact: ^10.7.1
|
||||
preact-render-to-string: ^5.1.21
|
||||
dependencies:
|
||||
'@babel/plugin-transform-react-jsx': 7.17.3
|
||||
preact: 10.7.1
|
||||
preact-render-to-string: 5.1.21_preact@10.7.1
|
||||
|
||||
packages/renderers/renderer-react:
|
||||
specifiers:
|
||||
'@babel/plugin-transform-react-jsx': ^7.17.3
|
||||
react: ^18.0.0
|
||||
react-dom: ^18.0.0
|
||||
dependencies:
|
||||
'@babel/plugin-transform-react-jsx': 7.17.3
|
||||
react: 18.0.0
|
||||
react-dom: 18.0.0_react@18.0.0
|
||||
|
||||
packages/renderers/renderer-solid:
|
||||
specifiers:
|
||||
babel-preset-solid: ^1.3.13
|
||||
solid-js: ^1.3.14
|
||||
dependencies:
|
||||
babel-preset-solid: 1.3.13
|
||||
solid-js: 1.3.14
|
||||
|
||||
packages/renderers/renderer-svelte:
|
||||
specifiers:
|
||||
'@sveltejs/vite-plugin-svelte': ^1.0.0-next.41
|
||||
svelte: ^3.47.0
|
||||
svelte-preprocess: ^4.10.5
|
||||
vite: ^2.9.1
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte': 1.0.0-next.41_svelte@3.47.0+vite@2.9.1
|
||||
svelte: 3.47.0
|
||||
svelte-preprocess: 4.10.5_svelte@3.47.0+typescript@4.6.3
|
||||
vite: 2.9.1
|
||||
|
||||
packages/renderers/renderer-vue:
|
||||
specifiers:
|
||||
'@vitejs/plugin-vue': ^2.3.1
|
||||
vite: ^2.9.1
|
||||
vue: ^3.2.31
|
||||
dependencies:
|
||||
'@vitejs/plugin-vue': 2.3.1_vite@2.9.1+vue@3.2.31
|
||||
vite: 2.9.1
|
||||
vue: 3.2.31
|
||||
|
||||
packages/webapi:
|
||||
specifiers:
|
||||
'@rollup/plugin-alias': ^3.1.9
|
||||
|
@ -1568,10 +1506,6 @@ importers:
|
|||
|
||||
scripts:
|
||||
specifiers:
|
||||
'@astrojs/renderer-preact': workspace:*
|
||||
'@astrojs/renderer-react': workspace:*
|
||||
'@astrojs/renderer-svelte': workspace:*
|
||||
'@astrojs/renderer-vue': workspace:*
|
||||
'@astrojs/webapi': workspace:*
|
||||
adm-zip: ^0.5.9
|
||||
arg: ^5.0.1
|
||||
|
@ -1581,10 +1515,6 @@ importers:
|
|||
svelte: ^3.47.0
|
||||
tar: ^6.1.11
|
||||
dependencies:
|
||||
'@astrojs/renderer-preact': link:../packages/renderers/renderer-preact
|
||||
'@astrojs/renderer-react': link:../packages/renderers/renderer-react
|
||||
'@astrojs/renderer-svelte': link:../packages/renderers/renderer-svelte
|
||||
'@astrojs/renderer-vue': link:../packages/renderers/renderer-vue
|
||||
'@astrojs/webapi': link:../packages/webapi
|
||||
adm-zip: 0.5.9
|
||||
arg: 5.0.1
|
||||
|
@ -3815,30 +3745,6 @@ packages:
|
|||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@sveltejs/vite-plugin-svelte/1.0.0-next.41_svelte@3.47.0+vite@2.9.1:
|
||||
resolution: {integrity: sha512-2kZ49mpi/YW1PIPvKaJNSSwIFgmw9QUf1+yaNa4U8yJD6AsfSHXAU3goscWbi1jfWnSg2PhvwAf+bvLCdp2F9g==}
|
||||
engines: {node: ^14.13.1 || >= 16}
|
||||
peerDependencies:
|
||||
diff-match-patch: ^1.0.5
|
||||
svelte: ^3.44.0
|
||||
vite: ^2.9.0
|
||||
peerDependenciesMeta:
|
||||
diff-match-patch:
|
||||
optional: true
|
||||
vite:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 4.2.0
|
||||
debug: 4.3.4
|
||||
kleur: 4.1.4
|
||||
magic-string: 0.26.1
|
||||
svelte: 3.47.0
|
||||
svelte-hmr: 0.14.11_svelte@3.47.0
|
||||
vite: 2.9.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@tootallnate/once/1.1.2:
|
||||
resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==}
|
||||
engines: {node: '>= 6'}
|
||||
|
@ -4343,20 +4249,6 @@ packages:
|
|||
'@unocss/scope': 0.15.6
|
||||
dev: true
|
||||
|
||||
/@vitejs/plugin-vue/2.3.1_vite@2.9.1+vue@3.2.31:
|
||||
resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
peerDependencies:
|
||||
vite: ^2.5.10
|
||||
vue: ^3.2.25
|
||||
peerDependenciesMeta:
|
||||
vite:
|
||||
optional: true
|
||||
dependencies:
|
||||
vite: 2.9.1
|
||||
vue: 3.2.31
|
||||
dev: false
|
||||
|
||||
/@vitejs/plugin-vue/2.3.1_vue@3.2.31:
|
||||
resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
@ -9677,57 +9569,6 @@ packages:
|
|||
typescript: 4.6.3
|
||||
dev: false
|
||||
|
||||
/svelte-preprocess/4.10.5_svelte@3.47.0+typescript@4.6.3:
|
||||
resolution: {integrity: sha512-VKXPRScCzAZqeBZOGq4LLwtNrAu++mVn7XvQox3eFDV7Ciq0Lg70Q8QWjH9iXF7J+pMlXhPsSFwpCb2E+hoeyA==}
|
||||
engines: {node: '>= 9.11.2'}
|
||||
requiresBuild: true
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.10.2
|
||||
coffeescript: ^2.5.1
|
||||
less: ^3.11.3 || ^4.0.0
|
||||
node-sass: '*'
|
||||
postcss: ^7 || ^8
|
||||
postcss-load-config: ^2.1.0 || ^3.0.0
|
||||
pug: ^3.0.0
|
||||
sass: ^1.26.8
|
||||
stylus: ^0.55.0
|
||||
sugarss: ^2.0.0
|
||||
svelte: ^3.23.0
|
||||
typescript: ^3.9.5 || ^4.0.0
|
||||
peerDependenciesMeta:
|
||||
'@babel/core':
|
||||
optional: true
|
||||
coffeescript:
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
node-sass:
|
||||
optional: true
|
||||
postcss:
|
||||
optional: true
|
||||
postcss-load-config:
|
||||
optional: true
|
||||
pug:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@types/pug': 2.0.6
|
||||
'@types/sass': 1.43.1
|
||||
detect-indent: 6.1.0
|
||||
magic-string: 0.25.9
|
||||
sorcery: 0.10.0
|
||||
strip-indent: 3.0.0
|
||||
svelte: 3.47.0
|
||||
typescript: 4.6.3
|
||||
dev: false
|
||||
|
||||
/svelte/3.47.0:
|
||||
resolution: {integrity: sha512-4JaJp3HEoTCGARRWZQIZDUanhYv0iyoHikklVHVLH9xFE9db22g4TDv7CPeNA8HD1JgjXI1vlhR1JZvvhaTu2Q==}
|
||||
engines: {node: '>= 8'}
|
||||
|
@ -10422,30 +10263,6 @@ packages:
|
|||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite/2.9.1:
|
||||
resolution: {integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==}
|
||||
engines: {node: '>=12.2.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
less: '*'
|
||||
sass: '*'
|
||||
stylus: '*'
|
||||
peerDependenciesMeta:
|
||||
less:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
dependencies:
|
||||
esbuild: 0.14.34
|
||||
postcss: 8.4.12
|
||||
resolve: 1.22.0
|
||||
rollup: 2.70.1
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
dev: false
|
||||
|
||||
/vite/2.9.1_sass@1.50.0:
|
||||
resolution: {integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==}
|
||||
engines: {node: '>=12.2.0'}
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
"astro-scripts": "./index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/renderer-preact": "workspace:*",
|
||||
"@astrojs/renderer-react": "workspace:*",
|
||||
"@astrojs/renderer-svelte": "workspace:*",
|
||||
"@astrojs/renderer-vue": "workspace:*",
|
||||
"@astrojs/webapi": "workspace:*",
|
||||
"adm-zip": "^0.5.9",
|
||||
"arg": "^5.0.1",
|
||||
|
|
Loading…
Reference in a new issue