[next] Add preact/compat renderer (#1668)

* feat: add preact/compat entry for `@astrojs/renderer-preact`

* Update index.js
This commit is contained in:
Nate Moore 2021-10-27 08:18:42 -07:00 committed by GitHub
parent 7f74388896
commit bd2ac13753
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/renderer-preact': minor
---
Add `@astrojs/renderer-preact/compat` entry point

View file

@ -0,0 +1,31 @@
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'],
},
};
},
};

View file

@ -5,6 +5,7 @@
"exports": { "exports": {
".": "./index.js", ".": "./index.js",
"./*": "./*", "./*": "./*",
"./compat": "./compat/index.js",
"./client.js": "./client.js", "./client.js": "./client.js",
"./server.js": "./server.js", "./server.js": "./server.js",
"./package.json": "./package.json" "./package.json": "./package.json"