[next] Add preact/compat
renderer (#1668)
* feat: add preact/compat entry for `@astrojs/renderer-preact` * Update index.js
This commit is contained in:
parent
7f74388896
commit
bd2ac13753
3 changed files with 37 additions and 0 deletions
5
.changeset/twenty-maps-listen.md
Normal file
5
.changeset/twenty-maps-listen.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/renderer-preact': minor
|
||||
---
|
||||
|
||||
Add `@astrojs/renderer-preact/compat` entry point
|
31
packages/renderers/renderer-preact/compat/index.js
Normal file
31
packages/renderers/renderer-preact/compat/index.js
Normal 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'],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -5,6 +5,7 @@
|
|||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*",
|
||||
"./compat": "./compat/index.js",
|
||||
"./client.js": "./client.js",
|
||||
"./server.js": "./server.js",
|
||||
"./package.json": "./package.json"
|
||||
|
|
Loading…
Reference in a new issue