Skip to content

Commit

Permalink
JSX refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott authored and matthewp committed Aug 9, 2023
1 parent 65c3549 commit 18e0b0e
Show file tree
Hide file tree
Showing 32 changed files with 674 additions and 687 deletions.
7 changes: 7 additions & 0 deletions .changeset/cool-feet-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/solid-js': major
---

New `include` and `exclude` config options

The Solid integration now has new `include` and `exclude` config options. Use these if you want to use Solid alongside another JSX framework; include specifies files to be compiled for Solid and `exclude` does the opposite.
7 changes: 7 additions & 0 deletions .changeset/large-countries-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/preact': major
---

New `include` and `exclude` config options

The Preact integration now has new `include` and `exclude` config options. Use these if you want to use Preact alongside another JSX framework; include specifies files to be compiled for Preact and `exclude` does the opposite.
25 changes: 25 additions & 0 deletions .changeset/perfect-horses-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'astro': major
---

JSX refactor

JSX in Astro has been refactored to better support each framework. In order to support multiple JSX frameworks at the same time, new `include` and `exclude` config options have been added to each integration to control which files to target. For example:

```js
export default defineConfig({
integrations: [
preact({
include: ['**/preact/*']
}),
react({
include: ['**/react/*']
}),
solid({
include: ['**/solid/*'],
}),
]
});
```

This config is only needed in projects that use multiple JSX frameworks; if only using one no config is needed.
9 changes: 9 additions & 0 deletions .changeset/slimy-carrots-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@astrojs/react': major
---

Support for React Refresh

The React integration now fully supports React Refresh and is backed by `@vitejs/plugin-react`.

Also included in this change are new `include` and `exclude` config options. Use these if you want to use React alongside another JSX framework; include specifies files to be compiled for React and `exclude` does the opposite.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"astro-benchmark": "workspace:*"
},
"devDependencies": {
"@astrojs/check": "^0.1.0",
"@babel/plugin-transform-react-jsx": "^7.22.5",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@types/node": "^18.16.18",
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/core/build/plugins/plugin-renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin {
exports.push(`export const renderers = [${rendererItems}];`);

return `${imports.join('\n')}\n${exports.join('\n')}`;
} else {
return `export const renderers = [];`;
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, AstroSettings } from '../../@types/astro';
import { getContentPaths } from '../../content/index.js';
import jsxRenderer from '../../jsx/renderer.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
import { getDefaultClientDirectives } from '../client-directive/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
Expand Down Expand Up @@ -96,7 +95,7 @@ export function createBaseSettings(config: AstroConfig): AstroSettings {
},
},
],
renderers: [jsxRenderer],
renderers: [],
scripts: [],
clientDirectives: getDefaultClientDirectives(),
watchFiles: [],
Expand Down
6 changes: 4 additions & 2 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
import envVitePlugin from '../vite-plugin-env/index.js';
import astroHeadPlugin from '../vite-plugin-head/index.js';
import htmlVitePlugin from '../vite-plugin-html/index.js';
import mdxVitePlugin from '../vite-plugin-mdx/index.js';
import { astroInjectEnvTsPlugin } from '../vite-plugin-inject-env-ts/index.js';
import astroIntegrationsContainerPlugin from '../vite-plugin-integrations-container/index.js';
import jsxVitePlugin from '../vite-plugin-jsx/index.js';
import astroLoadFallbackPlugin from '../vite-plugin-load-fallback/index.js';
import markdownVitePlugin from '../vite-plugin-markdown/index.js';
import astroScannerPlugin from '../vite-plugin-scanner/index.js';
Expand Down Expand Up @@ -121,7 +121,8 @@ export async function createVite(
envVitePlugin({ settings }),
markdownVitePlugin({ settings, logging }),
htmlVitePlugin(),
jsxVitePlugin({ settings, logging }),
// jsxVitePlugin({ settings, logging }),
mdxVitePlugin({ settings, logging }),
astroPostprocessVitePlugin(),
astroIntegrationsContainerPlugin({ settings, logging }),
astroScriptsPageSSRPlugin({ settings }),
Expand All @@ -134,6 +135,7 @@ export async function createVite(
vitePluginSSRManifest(),
settings.config.experimental.assets ? [astroAssetsPlugin({ settings, logging, mode })] : [],
astroTransitions({ config: settings.config }),

],
publicDir: fileURLToPath(settings.config.publicDir),
root: fileURLToPath(settings.config.root),
Expand Down
251 changes: 0 additions & 251 deletions packages/astro/src/vite-plugin-jsx/index.ts

This file was deleted.

Loading

0 comments on commit 18e0b0e

Please sign in to comment.