Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX refactor #7924

Merged
merged 26 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
18e0b0e
JSX refactor
FredKSchott Jul 23, 2023
2c204e0
Get preact/compat test to pass
matthewp Aug 9, 2023
8401c4e
Use include config
matthewp Aug 9, 2023
5cd28e2
Remove old astro flavored markdown test
matthewp Aug 9, 2023
3983f31
Move babel dep to preact
matthewp Aug 9, 2023
baecc56
Merge branch 'next' into new-jsx
matthewp Aug 9, 2023
b241603
Remove errant debugger
matthewp Aug 9, 2023
50ec972
Update lockfile
matthewp Aug 9, 2023
c28021c
Update the multi-framework example
matthewp Aug 9, 2023
7410098
Update e2e tests
matthewp Aug 9, 2023
0b86a52
Fix nested-in-vue tests
matthewp Aug 9, 2023
93134eb
Add back in astro check
matthewp Aug 9, 2023
59a1371
Merge branch 'next' into new-jsx
matthewp Aug 10, 2023
e392757
Update packages/astro/src/core/create-vite.ts
matthewp Aug 10, 2023
608450e
Update packages/astro/src/core/create-vite.ts
matthewp Aug 10, 2023
38a7cbe
Update packages/integrations/solid/src/index.ts
matthewp Aug 10, 2023
7f661b9
Update packages/integrations/solid/src/index.ts
matthewp Aug 10, 2023
b1fc1ae
Update .changeset/perfect-horses-tell.md
matthewp Aug 10, 2023
0712188
Move the comment about the include config
matthewp Aug 10, 2023
a057bb4
Remove redundant alias config
matthewp Aug 10, 2023
d49a82b
Use react's own preamble code
matthewp Aug 10, 2023
e07a4e5
Use the base for the preamble
matthewp Aug 10, 2023
4d2750b
Remove solid redundancy
matthewp Aug 10, 2023
66dd04e
Update .changeset/perfect-horses-tell.md
matthewp Aug 11, 2023
4b2cc14
Update based on review comments
matthewp Aug 11, 2023
7626af2
Oops
matthewp Aug 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
27 changes: 27 additions & 0 deletions .changeset/perfect-horses-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'astro': major
---

Astro's JSX handling has been refactored with better support for each framework.

Previously, Astro automatically scanned your components to determine which framework-specific transformations should be used. In practice, supporting advanced features like Fast Refresh with this approach proved difficult.

Now, Astro determines which framework to use with `include` and `exclude` config options where you can specify files and folders on a per-framework basis. When using multiple JSX frameworks in the same project, users should manually control which files belong to each framework using the `include` and `exclude` options.

```js
export default defineConfig({
// The `include` config is only needed in projects that use multiple JSX frameworks;
// if only using one no extra config is needed.
integrations: [
preact({
include: ['**/preact/*']
}),
react({
include: ['**/react/*']
}),
solid({
include: ['**/solid/*'],
}),
]
});
```
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.
8 changes: 7 additions & 1 deletion examples/framework-multiple/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
react({ include: ['**/react/*'] }),
svelte(),
vue(),
],
});
10 changes: 5 additions & 5 deletions examples/framework-multiple/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import '../styles/global.css';

// Component Imports
// For JSX components, all the common ways of exporting (under a namespace, specific export, default export etc) are supported!
import * as react from '../components/ReactCounter';
import { PreactCounter } from '../components/PreactCounter';
import SolidCounter from '../components/SolidCounter';
import * as react from '../components/react/ReactCounter';
import { PreactCounter } from '../components/preact/PreactCounter';
import SolidCounter from '../components/solid/SolidCounter';

import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.describe('Error display', () => {
const fileExists = astro.pathExists(absoluteFileUrl);

expect(fileExists).toBeTruthy();
expect(fileLocation).toMatch(/^components\/PreactRuntimeError.jsx/);
expect(fileLocation).toMatch(/^preact\/PreactRuntimeError.jsx/);
});

test('shows correct line when a style preprocess has an error', async ({ page, astro }) => {
Expand Down Expand Up @@ -105,7 +105,7 @@ test.describe('Error display', () => {
// Wait for page reload
page.waitForNavigation(),
// Edit the component file
astro.editFile('./src/components/SvelteSyntaxError.svelte', () => `<h1>No mismatch</h1>`),
astro.editFile('./src/components/svelte/SvelteSyntaxError.svelte', () => `<h1>No mismatch</h1>`),
]);

expect(await page.locator('vite-error-overlay').count()).toEqual(0);
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/e2e/fixtures/client-only/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
10 changes: 5 additions & 5 deletions packages/astro/e2e/fixtures/client-only/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import * as react from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import * as react from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.jsx';
import SolidCounter from '../components/solid/SolidCounter.jsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
10 changes: 8 additions & 2 deletions packages/astro/e2e/fixtures/errors/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ import vue from '@astrojs/vue';

// https://astro.build/config
export default defineConfig({
integrations: [react(), preact(), solid(), svelte(), vue()],
});
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import SvelteDirectiveError from '../components/SvelteDirectiveError.svelte';
import SvelteDirectiveError from '../components/svelte/SvelteDirectiveError.svelte';
---

<div>
<SvelteDirectiveError client:media />
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import SvelteDirectiveError from '../components/SvelteDirectiveError.svelte';
import SvelteDirectiveError from '../components/svelte/SvelteDirectiveError.svelte';
---

<div>
<SvelteDirectiveError client:loadm />
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import PreactRuntimeError from '../components/PreactRuntimeError.jsx';
import PreactRuntimeError from '../components/preact/PreactRuntimeError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import PreactSyntaxError from '../components/PreactSyntaxError.jsx';
import PreactSyntaxError from '../components/preact/PreactSyntaxError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import ReactRuntimeError from '../components/ReactRuntimeError.jsx';
import ReactRuntimeError from '../components/react/ReactRuntimeError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import ReactSyntaxError from '../components/ReactSyntaxError.jsx';
import ReactSyntaxError from '../components/react/ReactSyntaxError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import SolidRuntimeError from '../components/SolidRuntimeError.jsx';
import SolidRuntimeError from '../components/solid/SolidRuntimeError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import SolidSyntaxError from '../components/SolidSyntaxError.jsx';
import SolidSyntaxError from '../components/solid/SolidSyntaxError.jsx';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import SvelteRuntimeError from '../components/SvelteRuntimeError.svelte';
import SvelteRuntimeError from '../components/svelte/SvelteRuntimeError.svelte';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import SvelteSyntaxError from '../components/SvelteSyntaxError.svelte';
import SvelteSyntaxError from '../components/svelte/SvelteSyntaxError.svelte';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import VueRuntimeError from '../components/VueRuntimeError.vue';
import VueRuntimeError from '../components/vue/VueRuntimeError.vue';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import VueSyntaxError from '../components/VueSyntaxError.vue';
import VueSyntaxError from '../components/vue/VueSyntaxError.vue';
---

<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import '../styles/global.css';
// Component Imports
import { A, B as Renamed } from '../components';
import * as react from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import * as react from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.tsx';
import SolidCounter from '../components/solid/SolidCounter.tsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import ReactCounter from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import ReactCounter from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.tsx';
import SolidCounter from '../components/solid/SolidCounter.tsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/e2e/fixtures/nested-in-react/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import ReactCounter from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import ReactCounter from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.tsx';
import SolidCounter from '../components/solid/SolidCounter.tsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/e2e/fixtures/nested-in-solid/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import { Counter as ReactCounter } from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import { Counter as ReactCounter } from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.tsx';
import SolidCounter from '../components/solid/SolidCounter.tsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import { Counter as ReactCounter } from '../components/ReactCounter.jsx';
import { PreactCounter } from '../components/PreactCounter.tsx';
import SolidCounter from '../components/SolidCounter.tsx';
import VueCounter from '../components/VueCounter.vue';
import SvelteCounter from '../components/SvelteCounter.svelte';
import { Counter as ReactCounter } from '../components/react/ReactCounter.jsx';
import { PreactCounter } from '../components/preact/PreactCounter.tsx';
import SolidCounter from '../components/solid/SolidCounter.tsx';
import VueCounter from '../components/vue/VueCounter.vue';
import SvelteCounter from '../components/svelte/SvelteCounter.svelte';

// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/e2e/fixtures/nested-in-vue/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ import solid from '@astrojs/solid-js';
// https://astro.build/config
export default defineConfig({
// Enable many frameworks to support all different kinds of components.
integrations: [preact(), react(), svelte(), vue(), solid()],
integrations: [
react({ include: ['**/react/*'] }),
preact({ include: ['**/preact/*'] }),
solid({ include: ['**/solid/*'] }),
svelte(),
vue(),
],
});
Loading