Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions packages/astro/src/content/vite-plugin-content-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { extname } from 'node:path';
import { pathToFileURL } from 'node:url';
import * as devalue from 'devalue';
import type { PluginContext } from 'rollup';
import { isRunnableDevEnvironment, type Plugin, type RunnableDevEnvironment } from 'vite';
import type { Plugin, RunnableDevEnvironment } from 'vite';
import { getProxyCode } from '../assets/utils/proxy.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
Expand Down Expand Up @@ -158,9 +158,6 @@ export const _internal = {
}
},
configureServer(viteServer) {
if (!isRunnableDevEnvironment(viteServer.environments.ssr)) {
return;
}
viteServer.watcher.on('all', async (event, entry) => {
if (CHOKIDAR_MODIFIED_EVENTS.includes(event)) {
const environment = viteServer.environments.ssr;
Expand Down
5 changes: 1 addition & 4 deletions packages/astro/src/core/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { performance } from 'node:perf_hooks';
import { green } from 'kleur/colors';
import { gt, major, minor, patch } from 'semver';
import type * as vite from 'vite';
import { isRunnableDevEnvironment } from 'vite';
import { getDataStoreFile, globalContentLayer } from '../../content/content-layer.js';
import { attachContentServerListeners } from '../../content/index.js';
import { MutableDataStore } from '../../content/mutable-data-store.js';
Expand Down Expand Up @@ -96,9 +95,7 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevS
if (!store) {
logger.error('content', 'Failed to create data store');
}
if (isRunnableDevEnvironment(restart.container.viteServer.environments.ssr)) {
await attachContentServerListeners(restart.container);
}
await attachContentServerListeners(restart.container);

const config = globalContentConfigObserver.get();
if (config.status === 'error') {
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/vite-plugin-app/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export class AstroServerPipeline extends Pipeline {
logger,
manifest,
settings,
}: Pick<AstroServerPipeline, 'loader' | 'logger' | 'manifest' | 'settings'>

}: Pick<AstroServerPipeline, 'loader' | 'logger' | 'manifest' | 'settings'>,
) {
const pipeline = new AstroServerPipeline(loader, logger, manifest, settings);
pipeline.routesList = manifestData;
Expand Down
10 changes: 2 additions & 8 deletions packages/astro/src/vite-plugin-head/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ModuleInfo } from 'rollup';
import type * as vite from 'vite';
import { type DevEnvironment, isRunnableDevEnvironment } from 'vite';
import type { DevEnvironment } from 'vite';
import { getParentModuleInfos, getTopLevelPageModuleInfos } from '../core/build/graph.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js';
Expand Down Expand Up @@ -48,9 +48,6 @@ export default function configHeadVitePlugin(): vite.Plugin {
enforce: 'pre',
apply: 'serve',
configureServer(server) {
if (!isRunnableDevEnvironment(server.environments.ssr)) {
return;
}
environment = server.environments.ssr;
},
resolveId(source, importer) {
Expand All @@ -63,7 +60,7 @@ export default function configHeadVitePlugin(): vite.Plugin {
if (result) {
let info = this.getModuleInfo(result.id);
const astro = info && getAstroMetadata(info);
if (astro && isRunnableDevEnvironment(environment)) {
if (astro) {
if (astro.propagation === 'self' || astro.propagation === 'in-tree') {
propagateMetadata.call(this, importer, 'propagation', 'in-tree');
}
Expand All @@ -77,9 +74,6 @@ export default function configHeadVitePlugin(): vite.Plugin {
}
},
transform(source, id) {
if (!isRunnableDevEnvironment(environment)) {
return;
}
// TODO This could probably be removed now that this is handled in resolveId
let info = this.getModuleInfo(id);
if (info && getAstroMetadata(info)?.containsHead) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
import cloudflare from '@astrojs/cloudflare';
import { defineConfig } from 'astro/config';

import mdx from '@astrojs/mdx';
import { fileURLToPath } from 'node:url';

export default defineConfig({
adapter: cloudflare({
workerEntryPoint: {
path: 'src/worker.ts',
}
},
imageService: 'cloudflare',
}),
vite: {
resolve: {
alias: {
'@images': fileURLToPath(new URL('./images', import.meta.url)),
},
},
},
integrations: [mdx()],
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"@astrojs/mdx": "^4.3.5",
"astro": "workspace:*"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

<h2 data-components-export-applied="true"><slot /></h2>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<style>h3 { margin: 1rem }</style>
<h3><slot /></h3>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
import { CollectionEntry, getCollection } from 'astro:content';
import H3 from './H3.astro'
// Test for recursive `getCollection()` calls
const blog = await getCollection('blog');

type Props = {
content: CollectionEntry<'blog'>['data'];
};

const {
content: { title },
} = Astro.props;
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>With Layout Prop</title>
</head>
<body data-layout-prop="true">
<h1>{title}</h1>
<H3>H3 inserted in the layout</H3>
<nav>
<ul>
{blog.map((post) => (
<li>
<a href={post.slug}>{post.data.title}</a>
</li>
))}
</ul>
</nav>
<slot />
</body>
</html>

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p id="update-me">Script didn't update me :(</p>

<p id="update-me-inline">Inline script didn't update me :(</p>

<script>
document.querySelector('#update-me').innerText = 'Updated client-side with script!';
</script>

<script is:inline data-is-inline>
document.querySelector('#update-me-inline').innerText = 'Updated client-side with inline script!';
</script>
Loading
Loading