Skip to content

Commit

Permalink
Merge branch 'main' into markdoc-typographer
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored Jul 17, 2024
2 parents 5544677 + 3b94324 commit b5b5034
Show file tree
Hide file tree
Showing 55 changed files with 1,360 additions and 1,261 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-spies-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Avoids targeting all files in the `src/` directory for eager optimization by Vite. After this change, only JSX, Vue, Svelte, and Astro components get scanned for early optimization.
5 changes: 5 additions & 0 deletions .changeset/few-candles-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/preact': patch
---

Swap out `preact-ssr-prepass` for `renderToStringAsync` from `preact-render-to-string`
5 changes: 5 additions & 0 deletions .changeset/giant-lies-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes prerendering not removing unused dynamic imported chunks
5 changes: 5 additions & 0 deletions .changeset/proud-singers-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes `astro dev --open` unexpected behavior that spawns a new tab every time a config file is saved
5 changes: 5 additions & 0 deletions .changeset/wise-cameras-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves `astro:env` invalid variables errors
2 changes: 1 addition & 1 deletion examples/framework-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/preact": "^3.5.0",
"@preact/signals": "^1.2.3",
"@preact/signals": "^1.3.0",
"astro": "^4.11.5",
"preact": "^10.22.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/starlog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"astro": "^4.11.5",
"sass": "^1.77.6",
"sass": "^1.77.8",
"sharp": "^0.33.3"
}
}
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"autoprefixer": "^10.4.19",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4"
"tailwindcss": "^3.4.5"
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@
"astro-benchmark": "workspace:*"
},
"devDependencies": {
"@astrojs/check": "^0.7.0",
"@astrojs/check": "^0.8.1",
"@biomejs/biome": "1.8.1",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.6",
"@changesets/cli": "^2.27.7",
"@eslint/eslintrc": "^3.1.0",
"@types/node": "^18.17.8",
"esbuild": "^0.21.5",
"eslint": "^9.6.0",
"eslint": "^9.7.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-regexp": "^2.6.0",
"globby": "^14.0.2",
"only-allow": "^1.2.1",
"organize-imports-cli": "^0.10.0",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.0",
"tiny-glob": "^0.2.9",
"turbo": "^1.13.4",
"typescript": "~5.5.2",
"typescript-eslint": "^7.14.1"
"typescript": "~5.5.3",
"typescript-eslint": "^7.16.1"
},
"pnpm": {
"packageExtensions": {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/fixtures/actions-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.7.0",
"@astrojs/check": "^0.8.1",
"@astrojs/db": "workspace:*",
"@astrojs/node": "workspace:*",
"@astrojs/react": "workspace:*",
Expand All @@ -19,6 +19,6 @@
"astro": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.5.2"
"typescript": "^5.5.3"
}
}
4 changes: 2 additions & 2 deletions packages/astro/e2e/fixtures/actions-react-19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.7.0",
"@astrojs/check": "^0.8.1",
"@astrojs/db": "workspace:*",
"@astrojs/node": "workspace:*",
"@astrojs/react": "workspace:*",
Expand All @@ -19,7 +19,7 @@
"astro": "workspace:*",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "19.0.0-rc-fb9a90fa48-20240614",
"typescript": "^5.5.2"
"typescript": "^5.5.3"
},
"overrides": {
"@types/react": "npm:types-react",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/error-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"astro": "workspace:*",
"sass": "^1.77.6"
"sass": "^1.77.8"
}
}
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"preact": "^10.22.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sass": "^1.77.6",
"sass": "^1.77.8",
"solid-js": "^1.8.18",
"svelte": "^4.2.18",
"vue": "^3.4.31"
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/hmr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"devDependencies": {
"astro": "workspace:*",
"sass": "^1.77.6"
"sass": "^1.77.8"
}
}
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"astro": "workspace:*",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4"
"tailwindcss": "^3.4.5"
}
}
36 changes: 18 additions & 18 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,21 @@
"test:node": "astro-scripts test \"test/**/*.test.js\""
},
"dependencies": {
"@astrojs/compiler": "^2.8.1",
"@astrojs/compiler": "^2.8.2",
"@astrojs/internal-helpers": "workspace:*",
"@astrojs/markdown-remark": "workspace:*",
"@astrojs/telemetry": "workspace:*",
"@babel/core": "^7.24.7",
"@babel/generator": "^7.24.7",
"@babel/parser": "^7.24.7",
"@babel/core": "^7.24.9",
"@babel/generator": "^7.24.10",
"@babel/parser": "^7.24.8",
"@babel/plugin-transform-react-jsx": "^7.24.7",
"@babel/traverse": "^7.24.7",
"@babel/types": "^7.24.7",
"@babel/traverse": "^7.24.8",
"@babel/types": "^7.24.9",
"@types/babel__core": "^7.20.5",
"@types/cookie": "^0.6.0",
"acorn": "^8.12.0",
"acorn": "^8.12.1",
"aria-query": "^5.3.0",
"axobject-query": "^4.0.0",
"axobject-query": "^4.1.0",
"boxen": "^8.0.0",
"chokidar": "^3.6.0",
"ci-info": "^4.0.0",
Expand Down Expand Up @@ -167,22 +167,22 @@
"magic-string": "^0.30.10",
"mrmime": "^2.0.0",
"ora": "^8.0.1",
"p-limit": "^5.0.0",
"p-limit": "^6.1.0",
"p-queue": "^8.0.1",
"path-to-regexp": "^6.2.2",
"preferred-pm": "^3.1.3",
"preferred-pm": "^4.0.0",
"prompts": "^2.4.2",
"rehype": "^13.0.1",
"semver": "^7.6.2",
"shiki": "^1.10.0",
"shiki": "^1.10.3",
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"tsconfck": "^3.1.1",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.1",
"vite": "^5.3.2",
"vfile": "^6.0.2",
"vite": "^5.3.4",
"vitefu": "^0.2.5",
"which-pm": "^2.2.0",
"which-pm": "^3.0.0",
"yargs-parser": "^21.1.1",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.1"
Expand All @@ -191,8 +191,8 @@
"sharp": "^0.33.3"
},
"devDependencies": {
"@astrojs/check": "^0.7.0",
"@playwright/test": "^1.45.0",
"@astrojs/check": "^0.8.1",
"@playwright/test": "^1.45.2",
"@types/aria-query": "^5.0.4",
"@types/babel__generator": "^7.6.8",
"@types/babel__traverse": "^7.20.6",
Expand Down Expand Up @@ -226,8 +226,8 @@
"rehype-slug": "^6.0.0",
"rehype-toc": "^3.0.2",
"remark-code-titles": "^0.1.2",
"rollup": "^4.18.0",
"sass": "^1.77.6",
"rollup": "^4.18.1",
"sass": "^1.77.8",
"srcset-parse": "^1.1.0",
"undici": "^6.19.2",
"unified": "^11.0.5"
Expand Down
4 changes: 3 additions & 1 deletion packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,12 @@ export class App {
}
const pathname = this.#getPathnameFromRequest(request);
const defaultStatus = this.#getDefaultStatusCode(routeData, pathname);
const mod = await this.#pipeline.getModuleForRoute(routeData);

let response;
try {
// Load route module. We also catch its error here if it fails on initialization
const mod = await this.#pipeline.getModuleForRoute(routeData);

const renderContext = RenderContext.create({
pipeline: this.#pipeline,
locals,
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/plugins/plugin-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function vitePluginPages(opts: StaticBuildOptions, internals: BuildInternals): V
for (const pageData of pageDatas) {
const resolvedPage = await this.resolve(pageData.moduleSpecifier);
if (resolvedPage) {
imports.push(`const page = () => import(${JSON.stringify(pageData.moduleSpecifier)});`);
exports.push(`export { page }`);
imports.push(`import * as _page from ${JSON.stringify(pageData.moduleSpecifier)};`);
exports.push(`export const page = () => _page`);

imports.push(`import { renderers } from "${RENDERERS_MODULE_ID}";`);
exports.push(`export { renderers };`);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function getNonPrerenderOnlyChunks(bundle: Rollup.OutputBundle, internals: Build
const prerenderOnlyEntryChunks = new Set<Rollup.OutputChunk>();
const nonPrerenderOnlyEntryChunks = new Set<Rollup.OutputChunk>();
for (const chunk of chunks) {
if (chunk.type === 'chunk' && (chunk.isEntry || chunk.isDynamicEntry)) {
if (chunk.type === 'chunk' && chunk.isEntry) {
// See if this entry chunk is prerendered, if so, skip it
if (chunk.facadeModuleId?.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
const pageDatas = getPagesFromVirtualModulePageName(
Expand Down
9 changes: 2 additions & 7 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ export async function createVite(
customLogger: createViteLogger(logger, settings.config.vite.logLevel),
appType: 'custom',
optimizeDeps: {
// Scan all files within `srcDir` except for known server-code (e.g endpoints)
entries: [
`${srcDirPattern}!(pages)/**/*`, // All files except for pages
`${srcDirPattern}pages/**/!(*.js|*.mjs|*.ts|*.mts)`, // All pages except for endpoints
`${srcDirPattern}pages/**/_*.{js,mjs,ts,mts}`, // Remaining JS/TS files prefixed with `_` (not endpoints)
`${srcDirPattern}pages/**/_*/**/*.{js,mjs,ts,mts}`, // Remaining JS/TS files within directories prefixed with `_` (not endpoints)
],
// Scan for component code within `srcDir`
entries: [`${srcDirPattern}**/*.{jsx,tsx,vue,svelte,html,astro}`],
exclude: ['astro', 'node-fetch'],
},
plugins: [
Expand Down
15 changes: 14 additions & 1 deletion packages/astro/src/core/dev/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,22 @@ export async function createContainer({
base,
server: { host, headers, open: serverOpen },
} = settings.config;

// serverOpen = true, isRestart = false
// when astro dev --open command is run the first time
// expected behavior: spawn a new tab
// ------------------------------------------------------
// serverOpen = true, isRestart = true
// when config file is saved
// expected behavior: do not spawn a new tab
// ------------------------------------------------------
// Non-config files don't reach this point
const isServerOpenURL = typeof serverOpen == 'string' && !isRestart;
const isServerOpenBoolean = serverOpen && !isRestart;

// Open server to the correct path. We pass the `base` here as we didn't pass the
// base to the initial Vite config
const open = typeof serverOpen == 'string' ? serverOpen : serverOpen ? base : false;
const open = isServerOpenURL ? serverOpen : isServerOpenBoolean ? base : false;

// The client entrypoint for renderers. Since these are imported dynamically
// we need to tell Vite to preoptimize them.
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ export const RouteNotFound = {
export const EnvInvalidVariables = {
name: 'EnvInvalidVariables',
title: 'Invalid Environment Variables',
message: (variables: string) =>
`The following environment variables do not match the data type and/or properties defined in \`experimental.env.schema\`:\n\n${variables}\n`,
message: (errors: Array<string>) =>
`The following environment variables defined in \`experimental.env.schema\` are invalid:\n\n${errors.map((err) => `- ${err}`).join('\n')}\n`,
} satisfies ErrorData;

/**
Expand Down
Loading

0 comments on commit b5b5034

Please sign in to comment.