summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/chatty-cows-attack.md5
-rw-r--r--.changeset/flat-radios-cheer.md5
-rw-r--r--.changeset/forty-coins-attend.md16
-rw-r--r--.changeset/light-apricots-sort.md7
-rw-r--r--.changeset/ninety-jars-swim.md5
-rw-r--r--.changeset/odd-swans-walk.md5
-rw-r--r--.changeset/perfect-dogs-turn.md5
-rw-r--r--.changeset/pre.json61
-rw-r--r--.changeset/small-radios-remain.md5
-rw-r--r--.changeset/sour-eggs-wink.md6
-rw-r--r--.changeset/swift-trainers-suffer.md5
-rw-r--r--.git-blame-ignore-revs2
-rw-r--r--.prettierrc.json2
-rw-r--r--.vscode/extensions.json7
-rw-r--r--examples/blog-multiple-authors/package.json6
-rw-r--r--examples/blog-multiple-authors/src/pages/posts/[...page].astro2
-rw-r--r--examples/blog/astro.config.mjs3
-rw-r--r--examples/blog/package.json6
-rw-r--r--examples/blog/src/styles/blog.css8
-rw-r--r--examples/component/demo/package.json2
-rw-r--r--examples/component/demo/src/pages/index.astro2
-rw-r--r--examples/component/package.json8
-rw-r--r--examples/docs/package.json6
-rw-r--r--examples/docs/src/components/Header/LanguageSelect.tsx15
-rw-r--r--examples/docs/src/components/Header/Search.tsx8
-rw-r--r--examples/docs/src/components/Header/SidebarToggle.tsx23
-rw-r--r--examples/docs/src/components/RightSidebar/TableOfContents.tsx6
-rw-r--r--examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx16
-rw-r--r--examples/docs/src/config.ts4
-rw-r--r--examples/docs/src/styles/theme.css8
-rw-r--r--examples/env-vars/package.json2
-rw-r--r--examples/framework-alpine/package.json2
-rw-r--r--examples/framework-lit/package.json2
-rw-r--r--examples/framework-multiple/package.json8
-rw-r--r--examples/framework-preact/package.json4
-rw-r--r--examples/framework-react/package.json4
-rw-r--r--examples/framework-solid/package.json2
-rw-r--r--examples/framework-svelte/package.json4
-rw-r--r--examples/framework-vue/package.json2
-rw-r--r--examples/integrations-playground/package.json14
-rw-r--r--examples/minimal/package.json2
-rw-r--r--examples/non-html-pages/package.json2
-rw-r--r--examples/portfolio/package.json6
-rw-r--r--examples/portfolio/src/components/Nav/index.jsx8
-rw-r--r--examples/ssr/package.json8
-rw-r--r--examples/ssr/src/api.ts6
-rw-r--r--examples/starter/package.json2
-rw-r--r--examples/starter/src/styles/global.css3
-rw-r--r--examples/starter/src/styles/home.css5
-rw-r--r--examples/subpath/astro.config.mjs4
-rw-r--r--examples/subpath/package.json6
-rw-r--r--examples/with-markdown-plugins/astro.config.mjs15
-rw-r--r--examples/with-markdown-plugins/package.json4
-rw-r--r--examples/with-markdown-shiki/astro.config.mjs20
-rw-r--r--examples/with-markdown-shiki/package.json4
-rw-r--r--examples/with-markdown/package.json10
-rw-r--r--examples/with-nanostores/package.json6
-rw-r--r--examples/with-nanostores/src/styles/global.css3
-rw-r--r--examples/with-nanostores/src/styles/home.css5
-rw-r--r--examples/with-tailwindcss/package.json4
-rw-r--r--examples/with-tailwindcss/src/components/Button.astro5
-rw-r--r--examples/with-vite-plugin-pwa/package.json2
-rw-r--r--package.json2
-rw-r--r--packages/astro-prism/internal.mjs30
-rw-r--r--packages/astro/CHANGELOG.md46
-rwxr-xr-xpackages/astro/astro.js12
-rw-r--r--packages/astro/package.json12
-rw-r--r--packages/astro/src/@types/astro.ts542
-rw-r--r--packages/astro/src/cli/check.ts14
-rw-r--r--packages/astro/src/cli/index.ts9
-rw-r--r--packages/astro/src/core/add/babel.ts3
-rw-r--r--packages/astro/src/core/add/index.ts143
-rw-r--r--packages/astro/src/core/add/wrapper.ts7
-rw-r--r--packages/astro/src/core/app/index.ts24
-rw-r--r--packages/astro/src/core/app/types.ts13
-rw-r--r--packages/astro/src/core/build/common.ts19
-rw-r--r--packages/astro/src/core/build/generate.ts56
-rw-r--r--packages/astro/src/core/build/index.ts126
-rw-r--r--packages/astro/src/core/build/internal.ts23
-rw-r--r--packages/astro/src/core/build/page-data.ts41
-rw-r--r--packages/astro/src/core/build/scan-based-build.ts89
-rw-r--r--packages/astro/src/core/build/static-build.ts35
-rw-r--r--packages/astro/src/core/build/types.d.ts9
-rw-r--r--packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts13
-rw-r--r--packages/astro/src/core/build/vite-plugin-ssr.ts15
-rw-r--r--packages/astro/src/core/config.ts273
-rw-r--r--packages/astro/src/core/create-vite.ts35
-rw-r--r--packages/astro/src/core/dev/index.ts34
-rw-r--r--packages/astro/src/core/endpoint/index.ts14
-rw-r--r--packages/astro/src/core/logger/core.ts10
-rw-r--r--packages/astro/src/core/logger/node.ts5
-rw-r--r--packages/astro/src/core/messages.ts82
-rw-r--r--packages/astro/src/core/preview/index.ts36
-rw-r--r--packages/astro/src/core/preview/util.ts10
-rw-r--r--packages/astro/src/core/render/core.ts49
-rw-r--r--packages/astro/src/core/render/dev/html.ts5
-rw-r--r--packages/astro/src/core/render/dev/index.ts119
-rw-r--r--packages/astro/src/core/render/paginate.ts30
-rw-r--r--packages/astro/src/core/render/result.ts43
-rw-r--r--packages/astro/src/core/render/route-cache.ts33
-rw-r--r--packages/astro/src/core/render/rss.ts38
-rw-r--r--packages/astro/src/core/render/sitemap.ts23
-rw-r--r--packages/astro/src/core/render/ssr-element.ts5
-rw-r--r--packages/astro/src/core/render/util.ts11
-rw-r--r--packages/astro/src/core/request.ts19
-rw-r--r--packages/astro/src/core/routing/manifest/create.ts40
-rw-r--r--packages/astro/src/core/routing/manifest/serialization.ts8
-rw-r--r--packages/astro/src/core/routing/validation.ts32
-rw-r--r--packages/astro/src/core/util.ts35
-rw-r--r--packages/astro/src/integrations/index.ts62
-rw-r--r--packages/astro/src/runtime/client/idle.ts6
-rw-r--r--packages/astro/src/runtime/client/load.ts6
-rw-r--r--packages/astro/src/runtime/client/media.ts6
-rw-r--r--packages/astro/src/runtime/client/only.ts6
-rw-r--r--packages/astro/src/runtime/client/visible.ts6
-rw-r--r--packages/astro/src/runtime/server/hydration.ts36
-rw-r--r--packages/astro/src/runtime/server/index.ts144
-rw-r--r--packages/astro/src/template/4xx.ts14
-rw-r--r--packages/astro/src/template/5xx.ts13
-rw-r--r--packages/astro/src/vite-plugin-astro-postprocess/index.ts12
-rw-r--r--packages/astro/src/vite-plugin-astro-server/index.ts58
-rw-r--r--packages/astro/src/vite-plugin-astro/compile.ts39
-rw-r--r--packages/astro/src/vite-plugin-astro/hmr.ts7
-rw-r--r--packages/astro/src/vite-plugin-astro/index.ts62
-rw-r--r--packages/astro/src/vite-plugin-astro/styles.ts14
-rw-r--r--packages/astro/src/vite-plugin-build-css/index.ts23
-rw-r--r--packages/astro/src/vite-plugin-build-html/extract-assets.ts21
-rw-r--r--packages/astro/src/vite-plugin-build-html/index.ts56
-rw-r--r--packages/astro/src/vite-plugin-build-html/util.ts19
-rw-r--r--packages/astro/src/vite-plugin-config-alias/index.ts38
-rw-r--r--packages/astro/src/vite-plugin-env/index.ts19
-rw-r--r--packages/astro/src/vite-plugin-integrations-container/index.ts6
-rw-r--r--packages/astro/src/vite-plugin-jsx/index.ts40
-rw-r--r--packages/astro/src/vite-plugin-markdown/index.ts42
-rw-r--r--packages/astro/src/vite-plugin-scripts/index.ts8
-rw-r--r--packages/astro/test/0-css.test.js41
-rw-r--r--packages/astro/test/astro-assets.test.js2
-rw-r--r--packages/astro/test/astro-attrs.test.js2
-rw-r--r--packages/astro/test/astro-basic.test.js6
-rw-r--r--packages/astro/test/astro-children.test.js12
-rw-r--r--packages/astro/test/astro-class-list.test.js2
-rw-r--r--packages/astro/test/astro-client-only.test.js2
-rw-r--r--packages/astro/test/astro-component-code.test.js16
-rw-r--r--packages/astro/test/astro-css-bundling-import.test.js2
-rw-r--r--packages/astro/test/astro-css-bundling.test.js11
-rw-r--r--packages/astro/test/astro-directives.test.js2
-rw-r--r--packages/astro/test/astro-doctype.test.js2
-rw-r--r--packages/astro/test/astro-dynamic.test.js2
-rw-r--r--packages/astro/test/astro-envs.test.js2
-rw-r--r--packages/astro/test/astro-expr.test.js2
-rw-r--r--packages/astro/test/astro-external-files.test.js2
-rw-r--r--packages/astro/test/astro-fallback.test.js2
-rw-r--r--packages/astro/test/astro-get-static-paths.test.js10
-rw-r--r--packages/astro/test/astro-global.test.js6
-rw-r--r--packages/astro/test/astro-markdown-drafts.test.js12
-rw-r--r--packages/astro/test/astro-markdown-plugins.test.js22
-rw-r--r--packages/astro/test/astro-markdown-shiki.test.js17
-rw-r--r--packages/astro/test/astro-markdown.test.js2
-rw-r--r--packages/astro/test/astro-pageDirectoryUrl.test.js8
-rw-r--r--packages/astro/test/astro-pages.test.js2
-rw-r--r--packages/astro/test/astro-pagination.test.js20
-rw-r--r--packages/astro/test/astro-partial-html.test.js2
-rw-r--r--packages/astro/test/astro-public.test.js4
-rw-r--r--packages/astro/test/astro-response.test.js2
-rw-r--r--packages/astro/test/astro-scripts.test.js2
-rw-r--r--packages/astro/test/astro-sitemap-rss.test.js67
-rw-r--r--packages/astro/test/astro-slots.test.js2
-rw-r--r--packages/astro/test/cli.test.js39
-rw-r--r--packages/astro/test/config-validate.test.js38
-rw-r--r--packages/astro/test/config.test.js61
-rw-r--r--packages/astro/test/custom-elements.test.js2
-rw-r--r--packages/astro/test/debug-component.test.js2
-rw-r--r--packages/astro/test/dev-routing.test.js30
-rw-r--r--packages/astro/test/errors.test.js2
-rw-r--r--packages/astro/test/fetch.test.js12
-rw-r--r--packages/astro/test/fixtures/astro-css-bundling/src/components/Nav.astro2
-rw-r--r--packages/astro/test/fixtures/astro-global/astro.config.mjs4
-rw-r--r--packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro2
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/langs/astro.config.mjs30
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/normal/astro.config.mjs7
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/themes-custom/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/themes-integrated/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/wrap-false/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/wrap-null/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown-shiki/wrap-true/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown/astro.config.mjs3
-rw-r--r--packages/astro/test/fixtures/astro-public/src/pages/index.astro6
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro4
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/components/NoHoistClassic.astro2
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/components/NoHoistModule.astro2
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/components/Widget.astro2
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/components/Widget2.astro2
-rw-r--r--packages/astro/test/fixtures/astro-scripts/src/pages/external.astro2
-rw-r--r--packages/astro/test/fixtures/config-path/config/my-config.mjs2
-rw-r--r--packages/astro/test/fixtures/markdown/astro.config.mjs5
-rw-r--r--packages/astro/test/fixtures/remote-css/src/components/CommonHead.astro4
-rw-r--r--packages/astro/test/fixtures/sass/package.json2
-rw-r--r--packages/astro/test/fixtures/static build/astro.config.mjs7
-rw-r--r--packages/astro/test/fixtures/static-build-page-url-format/astro.config.mjs9
-rw-r--r--packages/astro/test/fixtures/with-subpath-no-trailing-slash/astro.config.mjs4
-rw-r--r--packages/astro/test/legacy-build.test.js22
-rw-r--r--packages/astro/test/lit-element.test.js10
-rw-r--r--packages/astro/test/markdown.test.js2
-rw-r--r--packages/astro/test/page-level-styles.test.js2
-rw-r--r--packages/astro/test/postcss.test.js2
-rw-r--r--packages/astro/test/preact-component.test.js2
-rw-r--r--packages/astro/test/preview-routing.test.js89
-rw-r--r--packages/astro/test/react-component.test.js2
-rw-r--r--packages/astro/test/remote-css.test.js2
-rw-r--r--packages/astro/test/route-manifest.test.js483
-rw-r--r--packages/astro/test/sass.test.js2
-rw-r--r--packages/astro/test/slots-preact.test.js2
-rw-r--r--packages/astro/test/slots-react.test.js2
-rw-r--r--packages/astro/test/slots-solid.test.js2
-rw-r--r--packages/astro/test/slots-svelte.test.js2
-rw-r--r--packages/astro/test/slots-vue.test.js2
-rw-r--r--packages/astro/test/solid-component.test.js2
-rw-r--r--packages/astro/test/ssr-adapter-build-config.test.js71
-rw-r--r--packages/astro/test/ssr-api-route.test.js8
-rw-r--r--packages/astro/test/ssr-dynamic.test.js6
-rw-r--r--packages/astro/test/ssr-request.test.js8
-rw-r--r--packages/astro/test/static-build-code-component.test.js2
-rw-r--r--packages/astro/test/static-build-frameworks.test.js2
-rw-r--r--packages/astro/test/static-build-page-url-format.test.js4
-rw-r--r--packages/astro/test/static-build.test.js4
-rw-r--r--packages/astro/test/status-page.test.js2
-rw-r--r--packages/astro/test/svelte-component.test.js2
-rw-r--r--packages/astro/test/tailwindcss.test.js6
-rw-r--r--packages/astro/test/test-utils.js39
-rw-r--r--packages/astro/test/vue-component.test.js2
-rw-r--r--packages/create-astro/src/index.ts51
-rw-r--r--packages/create-astro/src/logger.ts7
-rw-r--r--packages/create-astro/test/create-astro.test.js14
-rw-r--r--packages/integrations/deno/CHANGELOG.md10
-rw-r--r--packages/integrations/deno/package.json2
-rw-r--r--packages/integrations/deno/test/fixtures/basics/astro.config.mjs4
-rw-r--r--packages/integrations/lit/client-shim.js10
-rw-r--r--packages/integrations/lit/client-shim.min.js16
-rw-r--r--packages/integrations/lit/src/index.ts12
-rw-r--r--packages/integrations/netlify/CHANGELOG.md6
-rw-r--r--packages/integrations/netlify/package.json2
-rw-r--r--packages/integrations/netlify/src/index.ts10
-rw-r--r--packages/integrations/partytown/CHANGELOG.md6
-rw-r--r--packages/integrations/partytown/package.json2
-rw-r--r--packages/integrations/partytown/src/index.ts13
-rw-r--r--packages/integrations/partytown/src/sirv.ts3
-rw-r--r--packages/integrations/preact/client.js6
-rw-r--r--packages/integrations/preact/package.json2
-rw-r--r--packages/integrations/preact/server.js4
-rw-r--r--packages/integrations/preact/src/index.ts7
-rw-r--r--packages/integrations/react/CHANGELOG.md6
-rw-r--r--packages/integrations/react/client-v17.js4
-rw-r--r--packages/integrations/react/client.js4
-rw-r--r--packages/integrations/react/package.json2
-rw-r--r--packages/integrations/react/server-v17.js6
-rw-r--r--packages/integrations/react/server.js6
-rw-r--r--packages/integrations/react/src/index.ts28
-rw-r--r--packages/integrations/react/static-html.js5
-rw-r--r--packages/integrations/sitemap/CHANGELOG.md12
-rw-r--r--packages/integrations/sitemap/README.md49
-rw-r--r--packages/integrations/sitemap/package.json2
-rw-r--r--packages/integrations/sitemap/src/index.ts39
-rw-r--r--packages/integrations/solid/server.js4
-rw-r--r--packages/integrations/svelte/Wrapper.svelte.ssr.js7
-rw-r--r--packages/integrations/svelte/package.json2
-rw-r--r--packages/integrations/svelte/server.js6
-rw-r--r--packages/integrations/tailwind/CHANGELOG.md10
-rw-r--r--packages/integrations/tailwind/README.md13
-rw-r--r--packages/integrations/tailwind/package.json10
-rw-r--r--packages/integrations/tailwind/src/index.ts43
-rw-r--r--packages/integrations/turbolinks/src/index.ts5
-rw-r--r--packages/integrations/vue/package.json2
-rw-r--r--packages/markdown/remark/CHANGELOG.md6
-rw-r--r--packages/markdown/remark/package.json2
-rw-r--r--packages/markdown/remark/src/index.ts24
-rw-r--r--packages/markdown/remark/src/rehype-islands.ts12
-rw-r--r--packages/markdown/remark/src/remark-prism.ts4
-rw-r--r--packages/markdown/remark/src/remark-shiki.ts20
-rw-r--r--packages/markdown/remark/src/remark-unwrap.ts10
-rw-r--r--packages/markdown/remark/src/types.ts1
-rw-r--r--packages/renderers/renderer-lit/client-shim.js10
-rw-r--r--packages/renderers/renderer-lit/index.js4
-rw-r--r--packages/renderers/renderer-preact/client.js6
-rw-r--r--packages/renderers/renderer-preact/compat/index.js7
-rw-r--r--packages/renderers/renderer-preact/index.js7
-rw-r--r--packages/renderers/renderer-preact/package.json2
-rw-r--r--packages/renderers/renderer-preact/server.js4
-rw-r--r--packages/renderers/renderer-react/client.js4
-rw-r--r--packages/renderers/renderer-react/index.js8
-rw-r--r--packages/renderers/renderer-react/server.js6
-rw-r--r--packages/renderers/renderer-react/static-html.js5
-rw-r--r--packages/renderers/renderer-solid/index.js8
-rw-r--r--packages/renderers/renderer-solid/server.js4
-rw-r--r--packages/renderers/renderer-svelte/Wrapper.svelte.ssr.js7
-rw-r--r--packages/renderers/renderer-svelte/package.json4
-rw-r--r--packages/renderers/renderer-svelte/server.js6
-rw-r--r--packages/renderers/renderer-vue/package.json4
-rw-r--r--pnpm-lock.yaml538
-rw-r--r--scripts/cmd/build.js16
-rw-r--r--scripts/cmd/copy.js4
-rw-r--r--scripts/memory/index.js10
-rwxr-xr-xscripts/notify/index.js29
-rw-r--r--scripts/package.json2
-rw-r--r--scripts/stats/index.js18
-rw-r--r--scripts/stats/stats.csv2
-rw-r--r--scripts/utils/svelte-plugin.js15
306 files changed, 3849 insertions, 2281 deletions
diff --git a/.changeset/chatty-cows-attack.md b/.changeset/chatty-cows-attack.md
deleted file mode 100644
index 7fe9fb8c2..000000000
--- a/.changeset/chatty-cows-attack.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': patch
----
-
-Allow components to return a Response
diff --git a/.changeset/flat-radios-cheer.md b/.changeset/flat-radios-cheer.md
deleted file mode 100644
index ab01d34dd..000000000
--- a/.changeset/flat-radios-cheer.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': patch
----
-
-`--experimental-ssr` now is only required when using a 3rd-party adapter
diff --git a/.changeset/forty-coins-attend.md b/.changeset/forty-coins-attend.md
deleted file mode 100644
index 467e520fd..000000000
--- a/.changeset/forty-coins-attend.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-"astro": minor
----
-
-Implement RFC [#0017](https://github.com/withastro/rfcs/blob/main/proposals/0017-markdown-content-redesign.md)
-
-- New Markdown API
-- New `Astro.glob()` API
-- **BREAKING CHANGE:** Removed `Astro.fetchContent()` (replaced by `Astro.glob()`)
-
-```diff
-// v0.25
-- let allPosts = Astro.fetchContent('./posts/*.md');
-// v0.26+
-+ let allPosts = await Astro.glob('./posts/*.md');
-```
diff --git a/.changeset/light-apricots-sort.md b/.changeset/light-apricots-sort.md
deleted file mode 100644
index 26a182a40..000000000
--- a/.changeset/light-apricots-sort.md
+++ /dev/null
@@ -1,7 +0,0 @@
----
-'astro': patch
----
-
-Improve `Astro.slots` API to support passing arguments to function-based slots.
-
-This allows for more ergonomic utility components that accept a callback function as a child.
diff --git a/.changeset/ninety-jars-swim.md b/.changeset/ninety-jars-swim.md
deleted file mode 100644
index dd7c79c13..000000000
--- a/.changeset/ninety-jars-swim.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@astrojs/react': minor
----
-
-Add support for React v18
diff --git a/.changeset/odd-swans-walk.md b/.changeset/odd-swans-walk.md
deleted file mode 100644
index 0c406d7e0..000000000
--- a/.changeset/odd-swans-walk.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': patch
----
-
-Fixes non-GET API routes in dev with Node 14
diff --git a/.changeset/perfect-dogs-turn.md b/.changeset/perfect-dogs-turn.md
deleted file mode 100644
index 61517d560..000000000
--- a/.changeset/perfect-dogs-turn.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': minor
----
-
-Implements the Astro.request RFC
diff --git a/.changeset/pre.json b/.changeset/pre.json
deleted file mode 100644
index 5b9fb8f21..000000000
--- a/.changeset/pre.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "mode": "pre",
- "tag": "next",
- "initialVersions": {
- "@example/blog": "0.0.1",
- "@example/blog-multiple-authors": "0.0.1",
- "@example/component": "0.0.1",
- "@example/my-component-demo": "0.0.1",
- "@example/my-component": "0.0.1",
- "@example/docs": "0.0.1",
- "@example/env-vars": "0.0.1",
- "@example/framework-alpine": "0.0.1",
- "@example/framework-lit": "0.0.1",
- "@example/framework-multiple": "0.0.1",
- "@example/framework-preact": "0.0.1",
- "@example/framework-react": "0.0.1",
- "@example/framework-solid": "0.0.1",
- "@example/framework-svelte": "0.0.1",
- "@example/framework-vue": "0.0.1",
- "@example/integrations-playground": "0.0.1",
- "@example/minimal": "0.0.1",
- "@example/non-html-pages": "0.0.1",
- "@example/portfolio": "0.0.1",
- "@example/ssr": "0.0.1",
- "@example/starter": "0.0.1",
- "@example/subpath": "0.0.1",
- "@example/with-markdown": "0.0.1",
- "@example/with-markdown-plugins": "0.0.2",
- "@example/with-markdown-shiki": "0.0.1",
- "@example/with-nanostores": "0.0.1",
- "@example/with-tailwindcss": "0.0.1",
- "@example/with-vite-plugin-pwa": "0.0.1",
- "astro": "0.25.4",
- "@astrojs/prism": "0.4.1",
- "@test/custom-element-renderer": "0.1.0",
- "@test/static-build-pkg": "0.0.0",
- "create-astro": "0.8.0",
- "@astrojs/lit": "0.0.2",
- "@astrojs/netlify": "0.0.2",
- "@astrojs/node": "0.0.2",
- "@astrojs/partytown": "0.0.2",
- "@astrojs/preact": "0.0.2",
- "@astrojs/react": "0.0.2",
- "@astrojs/sitemap": "0.0.2",
- "@astrojs/solid-js": "0.0.3",
- "@astrojs/svelte": "0.0.2",
- "@astrojs/tailwind": "0.0.2",
- "@astrojs/turbolinks": "0.0.2",
- "@astrojs/vue": "0.0.2",
- "@astrojs/markdown-remark": "0.7.0",
- "@astrojs/renderer-lit": "0.4.0",
- "@astrojs/renderer-preact": "0.5.0",
- "@astrojs/renderer-react": "0.5.0",
- "@astrojs/renderer-solid": "0.4.0",
- "@astrojs/renderer-svelte": "0.5.2",
- "@astrojs/renderer-vue": "0.4.0",
- "@astrojs/webapi": "0.11.0",
- "astro-scripts": "0.0.2"
- },
- "changesets": []
-}
diff --git a/.changeset/small-radios-remain.md b/.changeset/small-radios-remain.md
deleted file mode 100644
index d0747a700..000000000
--- a/.changeset/small-radios-remain.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': patch
----
-
-Update CLI error format and style
diff --git a/.changeset/sour-eggs-wink.md b/.changeset/sour-eggs-wink.md
deleted file mode 100644
index 5c2c0fc44..000000000
--- a/.changeset/sour-eggs-wink.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-'astro': patch
-'@astrojs/deno': patch
----
-
-Add a Deno adapter for SSR
diff --git a/.changeset/swift-trainers-suffer.md b/.changeset/swift-trainers-suffer.md
deleted file mode 100644
index c9f6fc9a8..000000000
--- a/.changeset/swift-trainers-suffer.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'astro': patch
----
-
-Fix for copying public when using SSR and not client JS
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index a3185bbac..495a5ff2e 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -1,2 +1,4 @@
# Switch to tabs (Use Accessible Indentation #2253)
6ddd7678ffb6598ae6e263706813cb5e94535f02
+# prettier config update
+1335797903a57716e9a02b0ffd8ca636b3883c62 \ No newline at end of file
diff --git a/.prettierrc.json b/.prettierrc.json
index d5bbca6c4..b0a1a2a07 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -1,5 +1,5 @@
{
- "printWidth": 180,
+ "printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 431773d2f..d8411afe0 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,4 +1,9 @@
{
- "recommendations": ["astro-build.astro-vscode", "esbenp.prettier-vscode", "editorconfig.editorconfig", "dbaeumer.vscode-eslint"],
+ "recommendations": [
+ "astro-build.astro-vscode",
+ "esbenp.prettier-vscode",
+ "editorconfig.editorconfig",
+ "dbaeumer.vscode-eslint"
+ ],
"unwantedRecommendations": []
}
diff --git a/examples/blog-multiple-authors/package.json b/examples/blog-multiple-authors/package.json
index 10ac77139..d92b692d7 100644
--- a/examples/blog-multiple-authors/package.json
+++ b/examples/blog-multiple-authors/package.json
@@ -10,10 +10,10 @@
},
"devDependencies": {
"@astrojs/preact": "^0.0.2",
- "astro": "^0.25.4",
- "sass": "^1.49.9"
+ "astro": "^0.26.0",
+ "sass": "^1.49.11"
},
"dependencies": {
- "preact": "^10.6.6"
+ "preact": "^10.7.0"
}
}
diff --git a/examples/blog-multiple-authors/src/pages/posts/[...page].astro b/examples/blog-multiple-authors/src/pages/posts/[...page].astro
index 7711a940c..f770aadb2 100644
--- a/examples/blog-multiple-authors/src/pages/posts/[...page].astro
+++ b/examples/blog-multiple-authors/src/pages/posts/[...page].astro
@@ -10,7 +10,7 @@ export async function getStaticPaths({ paginate, rss }) {
const sortedPosts = allPosts.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf());
// Generate an RSS feed from this collection of posts.
- // NOTE: This is disabled by default, since it requires `buildOptions.site` to be set in your "astro.config.mjs" file.
+ // NOTE: This is disabled by default, since it requires `site` to be set in your "astro.config.mjs" file.
// rss({
// title: 'Don’s Blog',
// description: 'An example blog on Astro',
diff --git a/examples/blog/astro.config.mjs b/examples/blog/astro.config.mjs
index e8f14324a..08916b1fe 100644
--- a/examples/blog/astro.config.mjs
+++ b/examples/blog/astro.config.mjs
@@ -4,7 +4,4 @@ import preact from '@astrojs/preact';
// https://astro.build/config
export default defineConfig({
integrations: [preact()],
- buildOptions: {
- site: 'https://example.com/',
- },
});
diff --git a/examples/blog/package.json b/examples/blog/package.json
index a817c7e67..f2127a1d4 100644
--- a/examples/blog/package.json
+++ b/examples/blog/package.json
@@ -9,10 +9,10 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4",
- "@astrojs/preact": "^0.0.2"
+ "@astrojs/preact": "^0.0.2",
+ "astro": "^0.26.0"
},
"dependencies": {
- "preact": "^10.6.6"
+ "preact": "^10.7.0"
}
}
diff --git a/examples/blog/src/styles/blog.css b/examples/blog/src/styles/blog.css
index 234e0162a..2a722d237 100644
--- a/examples/blog/src/styles/blog.css
+++ b/examples/blog/src/styles/blog.css
@@ -1,8 +1,10 @@
:root {
- --font-fallback: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
+ --font-fallback: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
+ Apple Color Emoji, Segoe UI Emoji;
--font-body: 'IBM Plex Sans', var(--font-fallback);
- --font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
- 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
+ --font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console',
+ 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
+ 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
--color-white: #fff;
--color-black: #000014;
diff --git a/examples/component/demo/package.json b/examples/component/demo/package.json
index 9b54773f6..bbac35c31 100644
--- a/examples/component/demo/package.json
+++ b/examples/component/demo/package.json
@@ -10,6 +10,6 @@
},
"devDependencies": {
"@example/my-component": "workspace:*",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/component/demo/src/pages/index.astro b/examples/component/demo/src/pages/index.astro
index 211c2f5e3..bfdf495a8 100644
--- a/examples/component/demo/src/pages/index.astro
+++ b/examples/component/demo/src/pages/index.astro
@@ -7,7 +7,7 @@ import * as Component from '@example/my-component';
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Welcome to Astro</title>
- <style global>
+ <style is:global>
h {
display: block;
font-size: 2em;
diff --git a/examples/component/package.json b/examples/component/package.json
index e7e63cb83..ea917ecf6 100644
--- a/examples/component/package.json
+++ b/examples/component/package.json
@@ -3,11 +3,11 @@
"version": "0.0.1",
"private": true,
"scripts": {
- "start": "astro --project-root demo dev",
- "build": "astro --project-root demo build",
- "serve": "astro --project-root demo preview"
+ "start": "astro --root demo dev",
+ "build": "astro --root demo build",
+ "serve": "astro --root demo preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/docs/package.json b/examples/docs/package.json
index e7cf7282a..84d9aee46 100644
--- a/examples/docs/package.json
+++ b/examples/docs/package.json
@@ -13,13 +13,13 @@
"@docsearch/css": "^3.0.0",
"@docsearch/react": "^3.0.0",
"@types/react": "^17.0.43",
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@astrojs/preact": "^0.0.2",
- "@astrojs/react": "^0.0.2",
- "astro": "^0.25.4"
+ "@astrojs/react": "^0.1.0",
+ "astro": "^0.26.0"
}
}
diff --git a/examples/docs/src/components/Header/LanguageSelect.tsx b/examples/docs/src/components/Header/LanguageSelect.tsx
index 7fd3af229..a895cc7cc 100644
--- a/examples/docs/src/components/Header/LanguageSelect.tsx
+++ b/examples/docs/src/components/Header/LanguageSelect.tsx
@@ -6,8 +6,19 @@ import { KNOWN_LANGUAGES, langPathRegex } from '../../languages';
const LanguageSelect: FunctionalComponent<{ lang: string }> = ({ lang }) => {
return (
<div class="language-select-wrapper">
- <svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 88.6 77.3" height="1.2em" width="1.2em">
- <path fill="currentColor" d="M61,24.6h7.9l18.7,51.6h-7.7l-5.4-15.5H54.3l-5.6,15.5h-7.2L61,24.6z M72.6,55l-8-22.8L56.3,55H72.6z" />
+ <svg
+ aria-hidden="true"
+ focusable="false"
+ role="img"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 88.6 77.3"
+ height="1.2em"
+ width="1.2em"
+ >
+ <path
+ fill="currentColor"
+ d="M61,24.6h7.9l18.7,51.6h-7.7l-5.4-15.5H54.3l-5.6,15.5h-7.2L61,24.6z M72.6,55l-8-22.8L56.3,55H72.6z"
+ />
<path
fill="currentColor"
d="M53.6,60.6c-10-4-16-9-22-14c0,0,1.3,1.3,0,0c-6,5-20,13-20,13l-4-6c8-5,10-6,19-13c-2.1-1.9-12-13-13-19h8 c4,9,10,14,10,14c10-8,10-19,10-19h8c0,0-1,13-12,24l0,0c5,5,10,9,19,13L53.6,60.6z M1.6,16.6h56v-8h-23v-7h-9v7h-24V16.6z"
diff --git a/examples/docs/src/components/Header/Search.tsx b/examples/docs/src/components/Header/Search.tsx
index ebc563c61..4d06ce00b 100644
--- a/examples/docs/src/components/Header/Search.tsx
+++ b/examples/docs/src/components/Header/Search.tsx
@@ -41,7 +41,13 @@ export default function Search() {
<>
<button type="button" ref={searchButtonRef} onClick={onOpen} className="search-input">
<svg width="24" height="24" fill="none">
- <path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
+ <path
+ d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
</svg>
<span>Search</span>
<span className="search-hint">
diff --git a/examples/docs/src/components/Header/SidebarToggle.tsx b/examples/docs/src/components/Header/SidebarToggle.tsx
index 90b180461..2be9dee9a 100644
--- a/examples/docs/src/components/Header/SidebarToggle.tsx
+++ b/examples/docs/src/components/Header/SidebarToggle.tsx
@@ -15,9 +15,26 @@ const MenuToggle: FunctionalComponent = () => {
}, [sidebarShown]);
return (
- <button type="button" aria-pressed={sidebarShown ? 'true' : 'false'} id="menu-toggle" onClick={() => setSidebarShown(!sidebarShown)}>
- <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
+ <button
+ type="button"
+ aria-pressed={sidebarShown ? 'true' : 'false'}
+ id="menu-toggle"
+ onClick={() => setSidebarShown(!sidebarShown)}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="1em"
+ height="1em"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M4 6h16M4 12h16M4 18h16"
+ />
</svg>
<span className="sr-only">Toggle sidebar</span>
</button>
diff --git a/examples/docs/src/components/RightSidebar/TableOfContents.tsx b/examples/docs/src/components/RightSidebar/TableOfContents.tsx
index 578d2aa98..537508ab4 100644
--- a/examples/docs/src/components/RightSidebar/TableOfContents.tsx
+++ b/examples/docs/src/components/RightSidebar/TableOfContents.tsx
@@ -33,7 +33,11 @@ const TableOfContents: FunctionalComponent<{ headers: any[] }> = ({ headers = []
{headers
.filter(({ depth }) => depth > 1 && depth < 4)
.map((header) => (
- <li class={`header-link depth-${header.depth} ${activeId === header.slug ? 'active' : ''}`.trim()}>
+ <li
+ class={`header-link depth-${header.depth} ${
+ activeId === header.slug ? 'active' : ''
+ }`.trim()}
+ >
<a href={`#${header.slug}`}>{header.text}</a>
</li>
))}
diff --git a/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx b/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx
index 6bdf45f02..a3f31288d 100644
--- a/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx
+++ b/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx
@@ -6,14 +6,26 @@ import './ThemeToggleButton.css';
const themes = ['light', 'dark'];
const icons = [
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="20"
+ height="20"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ >
<path
fillRule="evenodd"
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z"
clipRule="evenodd"
/>
</svg>,
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="20"
+ height="20"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ >
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" />
</svg>,
];
diff --git a/examples/docs/src/config.ts b/examples/docs/src/config.ts
index 174765d27..537723f43 100644
--- a/examples/docs/src/config.ts
+++ b/examples/docs/src/config.ts
@@ -7,7 +7,9 @@ export const SITE = {
export const OPEN_GRAPH = {
image: {
src: 'https://github.com/withastro/astro/blob/main/assets/social/banner.jpg?raw=true',
- alt: 'astro logo on a starry expanse of space,' + ' with a purple saturn-like planet floating in the right foreground',
+ alt:
+ 'astro logo on a starry expanse of space,' +
+ ' with a purple saturn-like planet floating in the right foreground',
},
twitter: 'astrodotbuild',
};
diff --git a/examples/docs/src/styles/theme.css b/examples/docs/src/styles/theme.css
index 830bed8dd..1dad9dc70 100644
--- a/examples/docs/src/styles/theme.css
+++ b/examples/docs/src/styles/theme.css
@@ -1,8 +1,10 @@
:root {
- --font-fallback: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
+ --font-fallback: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
+ Apple Color Emoji, Segoe UI Emoji;
--font-body: system-ui, var(--font-fallback);
- --font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
- 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
+ --font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console',
+ 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
+ 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
/*
* Variables with --color-base prefix define
diff --git a/examples/env-vars/package.json b/examples/env-vars/package.json
index e0011d2df..a0e0c7b51 100644
--- a/examples/env-vars/package.json
+++ b/examples/env-vars/package.json
@@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json
index 41fb3eca2..065c6ee49 100644
--- a/examples/framework-alpine/package.json
+++ b/examples/framework-alpine/package.json
@@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json
index 444d29ac6..50795de01 100644
--- a/examples/framework-lit/package.json
+++ b/examples/framework-lit/package.json
@@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/lit": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",
diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json
index 4328d130e..6b925d087 100644
--- a/examples/framework-multiple/package.json
+++ b/examples/framework-multiple/package.json
@@ -11,20 +11,20 @@
"devDependencies": {
"@astrojs/lit": "^0.0.2",
"@astrojs/preact": "^0.0.2",
- "@astrojs/react": "^0.0.2",
+ "@astrojs/react": "^0.1.0",
"@astrojs/solid-js": "^0.0.3",
"@astrojs/svelte": "^0.0.2",
"@astrojs/vue": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",
"lit": "^2.2.1",
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"solid-js": "^1.3.13",
- "svelte": "^3.46.4",
+ "svelte": "^3.46.6",
"vue": "^3.2.31"
}
}
diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json
index 5be07dd77..c3c78a2b2 100644
--- a/examples/framework-preact/package.json
+++ b/examples/framework-preact/package.json
@@ -10,9 +10,9 @@
},
"devDependencies": {
"@astrojs/preact": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
- "preact": "^10.6.6"
+ "preact": "^10.7.0"
}
}
diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json
index 4cdd93049..7744a8dba 100644
--- a/examples/framework-react/package.json
+++ b/examples/framework-react/package.json
@@ -9,8 +9,8 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/react": "^0.0.2",
- "astro": "^0.25.4"
+ "@astrojs/react": "^0.1.0",
+ "astro": "^0.26.0"
},
"dependencies": {
"react": "^18.0.0",
diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json
index 820bbee06..321c0afe2 100644
--- a/examples/framework-solid/package.json
+++ b/examples/framework-solid/package.json
@@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/solid-js": "^0.0.3",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
"solid-js": "^1.3.13"
diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json
index f7af94738..6278695f8 100644
--- a/examples/framework-svelte/package.json
+++ b/examples/framework-svelte/package.json
@@ -10,9 +10,9 @@
},
"devDependencies": {
"@astrojs/svelte": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
- "svelte": "^3.46.4"
+ "svelte": "^3.46.6"
}
}
diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json
index eeada1a5e..d803f48e3 100644
--- a/examples/framework-vue/package.json
+++ b/examples/framework-vue/package.json
@@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/vue": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
"vue": "^3.2.31"
diff --git a/examples/integrations-playground/package.json b/examples/integrations-playground/package.json
index 848bd2c4c..11ecd7eef 100644
--- a/examples/integrations-playground/package.json
+++ b/examples/integrations-playground/package.json
@@ -10,21 +10,21 @@
},
"devDependencies": {
"@astrojs/lit": "^0.0.2",
- "@astrojs/partytown": "^0.0.2",
- "@astrojs/react": "^0.0.2",
- "@astrojs/sitemap": "^0.0.2",
- "@astrojs/tailwind": "^0.0.2",
+ "@astrojs/partytown": "^0.1.0",
+ "@astrojs/react": "^0.1.0",
+ "@astrojs/sitemap": "^0.1.0",
+ "@astrojs/tailwind": "^0.1.0",
"@astrojs/turbolinks": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",
"lit": "^2.2.1",
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"solid-js": "^1.3.13",
- "svelte": "^3.46.4",
+ "svelte": "^3.46.6",
"vue": "^3.2.31"
}
}
diff --git a/examples/minimal/package.json b/examples/minimal/package.json
index 4adc0c827..c86dfb321 100644
--- a/examples/minimal/package.json
+++ b/examples/minimal/package.json
@@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json
index 27553f811..0f6a8b21c 100644
--- a/examples/non-html-pages/package.json
+++ b/examples/non-html-pages/package.json
@@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json
index ae5d52396..52b926656 100644
--- a/examples/portfolio/package.json
+++ b/examples/portfolio/package.json
@@ -10,10 +10,10 @@
},
"devDependencies": {
"@astrojs/preact": "^0.0.2",
- "astro": "^0.25.4",
- "sass": "^1.49.9"
+ "astro": "^0.26.0",
+ "sass": "^1.49.11"
},
"dependencies": {
- "preact": "^10.6.6"
+ "preact": "^10.7.0"
}
}
diff --git a/examples/portfolio/src/components/Nav/index.jsx b/examples/portfolio/src/components/Nav/index.jsx
index d74961d6d..b7cd28f36 100644
--- a/examples/portfolio/src/components/Nav/index.jsx
+++ b/examples/portfolio/src/components/Nav/index.jsx
@@ -24,7 +24,13 @@ function Nav() {
</svg>
</a>
<a className={Styles.social} href="https://dev.to/me">
- <svg className={Styles.socialicon} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 40" style="enable-background:new 0 0 50 40" xmlSpace="preserve">
+ <svg
+ className={Styles.socialicon}
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 50 40"
+ style="enable-background:new 0 0 50 40"
+ xmlSpace="preserve"
+ >
<path d="M15.7 15.5c-.4-.3-.7-.4-1.1-.4h-1.7v10.1h1.7c.4 0 .8-.1 1.1-.4.4-.3.6-.7.6-1.3v-6.7c0-.6-.2-1-.6-1.3z" />
<path d="M47 0H3C1.3 0 0 1.3 0 3v34c0 1.7 1.3 3 3 3h44c1.7 0 3-1.3 3-3V3c0-1.7-1.3-3-3-3zM19.1 23.5c0 1.3-.4 2.4-1.3 3.2-.8.9-1.9 1.3-3.3 1.3h-4.4V12.3h4.5c1.3 0 2.4.4 3.2 1.3.8.8 1.3 1.9 1.3 3.2v6.7zm9.1-8.4h-5.1v3.6h3.1v2.8h-3.1v3.7h5.1V28h-5.9c-.6 0-1-.2-1.4-.6-.4-.4-.6-.8-.6-1.4V14.2c0-.6.2-1 .6-1.4.4-.4.8-.6 1.4-.6h5.9v2.9zM37.5 26c-.6 1.3-1.3 2-2.2 2-.9 0-1.7-.7-2.2-2l-3.7-13.8h3.1L35.3 23l2.8-10.8h3.1L37.5 26z" />
</svg>
diff --git a/examples/ssr/package.json b/examples/ssr/package.json
index 370e79972..1688374f6 100644
--- a/examples/ssr/package.json
+++ b/examples/ssr/package.json
@@ -9,15 +9,15 @@
"server": "node server/server.mjs"
},
"devDependencies": {
- "@astrojs/svelte": "^0.0.2",
"@astrojs/node": "^0.0.2",
- "astro": "^0.25.4",
- "concurrently": "^7.0.0",
+ "@astrojs/svelte": "^0.0.2",
+ "astro": "^0.26.0",
+ "concurrently": "^7.1.0",
"lightcookie": "^1.0.25",
"unocss": "^0.15.6",
"vite-imagetools": "^4.0.3"
},
"dependencies": {
- "svelte": "^3.46.4"
+ "svelte": "^3.46.6"
}
}
diff --git a/examples/ssr/src/api.ts b/examples/ssr/src/api.ts
index 82c82a190..939130506 100644
--- a/examples/ssr/src/api.ts
+++ b/examples/ssr/src/api.ts
@@ -21,7 +21,11 @@ function getOrigin(request: Request): string {
return new URL(request.url).origin.replace('localhost', '127.0.0.1');
}
-async function get<T>(incomingReq: Request, endpoint: string, cb: (response: Response) => Promise<T>): Promise<T> {
+async function get<T>(
+ incomingReq: Request,
+ endpoint: string,
+ cb: (response: Response) => Promise<T>
+): Promise<T> {
const response = await fetch(`${getOrigin(incomingReq)}${endpoint}`, {
credentials: 'same-origin',
});
diff --git a/examples/starter/package.json b/examples/starter/package.json
index 65ea2b04d..b6e3884b3 100644
--- a/examples/starter/package.json
+++ b/examples/starter/package.json
@@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/starter/src/styles/global.css b/examples/starter/src/styles/global.css
index a9f830eda..8ef8122cb 100644
--- a/examples/starter/src/styles/global.css
+++ b/examples/starter/src/styles/global.css
@@ -4,7 +4,8 @@
}
:root {
- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
+ font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
+ Apple Color Emoji, Segoe UI Emoji;
font-size: 1rem;
--user-font-scale: 1rem - 16px;
font-size: clamp(0.875rem, 0.4626rem + 1.0309vw + var(--user-font-scale), 1.125rem);
diff --git a/examples/starter/src/styles/home.css b/examples/starter/src/styles/home.css
index b3cbd02d0..147f95776 100644
--- a/examples/starter/src/styles/home.css
+++ b/examples/starter/src/styles/home.css
@@ -1,6 +1,7 @@
:root {
- --font-mono: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
- 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
+ --font-mono: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter',
+ 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco,
+ 'Courier New', Courier, monospace;
--color-light: #f3f4f6;
}
diff --git a/examples/subpath/astro.config.mjs b/examples/subpath/astro.config.mjs
index bb680d762..02b050efc 100644
--- a/examples/subpath/astro.config.mjs
+++ b/examples/subpath/astro.config.mjs
@@ -4,7 +4,5 @@ import react from '@astrojs/react';
// https://astro.build/config
export default defineConfig({
integrations: [react()],
- buildOptions: {
- site: 'http://example.com/blog',
- },
+ site: 'http://example.com/blog',
});
diff --git a/examples/subpath/package.json b/examples/subpath/package.json
index ea792f73a..b46528388 100644
--- a/examples/subpath/package.json
+++ b/examples/subpath/package.json
@@ -9,9 +9,9 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/react": "^0.0.2",
- "astro": "^0.25.4",
- "sass": "^1.49.9"
+ "@astrojs/react": "^0.1.0",
+ "astro": "^0.26.0",
+ "sass": "^1.49.11"
},
"dependencies": {
"react": "^18.0.0",
diff --git a/examples/with-markdown-plugins/astro.config.mjs b/examples/with-markdown-plugins/astro.config.mjs
index 0e112712a..4872caac7 100644
--- a/examples/with-markdown-plugins/astro.config.mjs
+++ b/examples/with-markdown-plugins/astro.config.mjs
@@ -1,17 +1,16 @@
import { defineConfig } from 'astro/config';
-import astroRemark from '@astrojs/markdown-remark';
import addClasses from './add-classes.mjs';
// https://astro.build/config
export default defineConfig({
// Enable Custom Markdown options, plugins, etc.
- markdownOptions: {
- render: [
- astroRemark,
- {
- remarkPlugins: ['remark-code-titles'],
- rehypePlugins: [['rehype-autolink-headings', { behavior: 'prepend' }], ['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'],
- },
+ markdown: {
+ remarkPlugins: ['remark-code-titles'],
+ rehypePlugins: [
+ ['rehype-autolink-headings', { behavior: 'prepend' }],
+ ['rehype-toc', { headings: ['h2', 'h3'] }],
+ [addClasses, { 'h1,h2,h3': 'title' }],
+ 'rehype-slug',
],
},
});
diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json
index 7c02a8014..159b7cc4a 100644
--- a/examples/with-markdown-plugins/package.json
+++ b/examples/with-markdown-plugins/package.json
@@ -9,8 +9,8 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/markdown-remark": "^0.7.0",
- "astro": "^0.25.4",
+ "@astrojs/markdown-remark": "^0.8.0",
+ "astro": "^0.26.0",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.0.1",
diff --git a/examples/with-markdown-shiki/astro.config.mjs b/examples/with-markdown-shiki/astro.config.mjs
index 7a0b4f0f2..a091e103c 100644
--- a/examples/with-markdown-shiki/astro.config.mjs
+++ b/examples/with-markdown-shiki/astro.config.mjs
@@ -1,20 +1,14 @@
import { defineConfig } from 'astro/config';
-import astroRemark from '@astrojs/markdown-remark';
// https://astro.build/config
export default defineConfig({
// Enable Custom Markdown options, plugins, etc.
- markdownOptions: {
- render: [
- astroRemark,
- {
- syntaxHighlight: 'shiki',
- shikiConfig: {
- theme: 'dracula',
- // Learn more about this configuration here:
- // https://docs.astro.build/en/guides/markdown-content/#syntax-highlighting
- },
- },
- ],
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: {
+ theme: 'dracula',
+ // Learn more about this configuration here:
+ // https://docs.astro.build/en/guides/markdown-content/#syntax-highlighting
+ },
},
});
diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json
index 33de85830..e8151440e 100644
--- a/examples/with-markdown-shiki/package.json
+++ b/examples/with-markdown-shiki/package.json
@@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/markdown-remark": "^0.7.0",
- "astro": "^0.25.4"
+ "@astrojs/markdown-remark": "^0.8.0",
+ "astro": "^0.26.0"
}
}
diff --git a/examples/with-markdown/package.json b/examples/with-markdown/package.json
index 7f96d9ffa..1dd993979 100644
--- a/examples/with-markdown/package.json
+++ b/examples/with-markdown/package.json
@@ -9,18 +9,18 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/markdown-remark": "^0.7.0",
+ "@astrojs/markdown-remark": "^0.8.0",
"@astrojs/preact": "^0.0.2",
- "@astrojs/react": "^0.0.2",
+ "@astrojs/react": "^0.1.0",
"@astrojs/svelte": "^0.0.2",
"@astrojs/vue": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
},
"dependencies": {
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
- "svelte": "^3.46.4",
+ "svelte": "^3.46.6",
"vue": "^3.2.31"
}
}
diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json
index 55a60cadb..242828fbb 100644
--- a/examples/with-nanostores/package.json
+++ b/examples/with-nanostores/package.json
@@ -13,7 +13,7 @@
"@nanostores/react": "^0.1.5",
"@nanostores/vue": "^0.4.1",
"nanostores": "^0.5.12",
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"solid-nanostores": "0.0.6",
@@ -21,10 +21,10 @@
},
"devDependencies": {
"@astrojs/preact": "^0.0.2",
- "@astrojs/react": "^0.0.2",
+ "@astrojs/react": "^0.1.0",
"@astrojs/solid-js": "^0.0.3",
"@astrojs/svelte": "^0.0.2",
"@astrojs/vue": "^0.0.2",
- "astro": "^0.25.4"
+ "astro": "^0.26.0"
}
}
diff --git a/examples/with-nanostores/src/styles/global.css b/examples/with-nanostores/src/styles/global.css
index a9f830eda..8ef8122cb 100644
--- a/examples/with-nanostores/src/styles/global.css
+++ b/examples/with-nanostores/src/styles/global.css
@@ -4,7 +4,8 @@
}
:root {
- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
+ font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
+ Apple Color Emoji, Segoe UI Emoji;
font-size: 1rem;
--user-font-scale: 1rem - 16px;
font-size: clamp(0.875rem, 0.4626rem + 1.0309vw + var(--user-font-scale), 1.125rem);
diff --git a/examples/with-nanostores/src/styles/home.css b/examples/with-nanostores/src/styles/home.css
index 5770429d1..c2f50cb19 100644
--- a/examples/with-nanostores/src/styles/home.css
+++ b/examples/with-nanostores/src/styles/home.css
@@ -1,6 +1,7 @@
:root {
- --font-mono: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
- 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
+ --font-mono: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter',
+ 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco,
+ 'Courier New', Courier, monospace;
--color-light: #f3f4f6;
}
diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json
index 04cfa9258..d15a3a81a 100644
--- a/examples/with-tailwindcss/package.json
+++ b/examples/with-tailwindcss/package.json
@@ -9,8 +9,8 @@
"preview": "astro preview"
},
"devDependencies": {
- "@astrojs/tailwind": "^0.0.2",
- "astro": "^0.25.4",
+ "@astrojs/tailwind": "^0.1.0",
+ "astro": "^0.26.0",
"autoprefixer": "^10.4.4",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.12",
diff --git a/examples/with-tailwindcss/src/components/Button.astro b/examples/with-tailwindcss/src/components/Button.astro
index 11c605a2f..7d11c37ea 100644
--- a/examples/with-tailwindcss/src/components/Button.astro
+++ b/examples/with-tailwindcss/src/components/Button.astro
@@ -5,7 +5,8 @@
<button class="py-2 px-4 bg-purple-500 text-white font-semibold rounded-lg shadow-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-opacity-75">
<slot />
</button>
-<script hoist>
+
+<script>
import confetti from 'canvas-confetti';
document.body.querySelector('button').addEventListener("click", () => confetti());
-</script> \ No newline at end of file
+</script>
diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json
index 4ac168012..12a8512fd 100644
--- a/examples/with-vite-plugin-pwa/package.json
+++ b/examples/with-vite-plugin-pwa/package.json
@@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
- "astro": "^0.25.4",
+ "astro": "^0.26.0",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.2"
}
diff --git a/package.json b/package.json
index ef2da5a23..9883dfd85 100644
--- a/package.json
+++ b/package.json
@@ -66,7 +66,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"execa": "^6.1.0",
- "prettier": "^2.6.1",
+ "prettier": "^2.6.2",
"pretty-bytes": "^6.0.0",
"tiny-glob": "^0.2.9",
"turbo": "^1.1.10",
diff --git a/packages/astro-prism/internal.mjs b/packages/astro-prism/internal.mjs
index 0a118ba1b..22a5f9d48 100644
--- a/packages/astro-prism/internal.mjs
+++ b/packages/astro-prism/internal.mjs
@@ -8,7 +8,9 @@ export function addAstro(Prism) {
scriptLang = 'typescript';
} else {
scriptLang = 'javascript';
- console.warn('Prism TypeScript language not loaded, Astro scripts will be treated as JavaScript.');
+ console.warn(
+ 'Prism TypeScript language not loaded, Astro scripts will be treated as JavaScript.'
+ );
}
let script = Prism.util.clone(Prism.languages[scriptLang]);
@@ -38,10 +40,14 @@ export function addAstro(Prism) {
spread = re(spread).source;
Prism.languages.astro = Prism.languages.extend('markup', script);
- Prism.languages.astro.tag.pattern = re(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source);
+ Prism.languages.astro.tag.pattern = re(
+ /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/
+ .source
+ );
Prism.languages.astro.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
- Prism.languages.astro.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s'">]+)/i;
+ Prism.languages.astro.tag.inside['attr-value'].pattern =
+ /=(?!\{)(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s'">]+)/i;
Prism.languages.astro.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
Prism.languages.astro.tag.inside['comment'] = script['comment'];
@@ -109,7 +115,11 @@ export function addAstro(Prism) {
if (token.content[0].content[0].content === '</') {
// Closing tag
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
+ if (
+ openedTags.length > 0 &&
+ openedTags[openedTags.length - 1].tagName ===
+ stringifyToken(token.content[0].content[1])
+ ) {
// Pop matching opening tag
openedTags.pop();
}
@@ -127,7 +137,12 @@ export function addAstro(Prism) {
} else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
// Here we might have entered a Astro context inside a tag
openedTags[openedTags.length - 1].openedBraces++;
- } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
+ } else if (
+ openedTags.length > 0 &&
+ openedTags[openedTags.length - 1].openedBraces > 0 &&
+ token.type === 'punctuation' &&
+ token.content === '}'
+ ) {
// Here we might have left a Astro context inside a tag
openedTags[openedTags.length - 1].openedBraces--;
} else {
@@ -141,7 +156,10 @@ export function addAstro(Prism) {
let plainText = stringifyToken(token);
// And merge text with adjacent text
- if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
+ if (
+ i < tokens.length - 1 &&
+ (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')
+ ) {
plainText += stringifyToken(tokens[i + 1]);
tokens.splice(i + 1, 1);
}
diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md
index 7b86e33b4..57e34b2bc 100644
--- a/packages/astro/CHANGELOG.md
+++ b/packages/astro/CHANGELOG.md
@@ -1,5 +1,51 @@
# astro
+## 0.26.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Implement RFC [#0017](https://github.com/withastro/rfcs/blob/main/proposals/0017-markdown-content-redesign.md)
+
+ - New Markdown API
+ - New `Astro.glob()` API
+ - **BREAKING CHANGE:** Removed `Astro.fetchContent()` (replaced by `Astro.glob()`)
+
+ ```diff
+ // v0.25
+ - let allPosts = Astro.fetchContent('./posts/*.md');
+ // v0.26+
+ + let allPosts = await Astro.glob('./posts/*.md');
+ ```
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Implement [RFC0016](https://github.com/withastro/rfcs/blob/main/proposals/0016-style-script-defaults.md) which changes the default behavior of `script`, introduces `is:inline`, and changes `<style global>` to `<style is:global>`
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Implements the Astro.request RFC
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
+### Patch Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Allow components to return a Response
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - `--experimental-ssr` now is only required when using a 3rd-party adapter
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Improve `Astro.slots` API to support passing arguments to function-based slots.
+
+ This allows for more ergonomic utility components that accept a callback function as a child.
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Fixes non-GET API routes in dev with Node 14
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update CLI error format and style
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update `@astrojs/compiler`, fixing some bugs related to RegExp usage in frontmatter
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Add a Deno adapter for SSR
+
+* [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Fix for copying public when using SSR and not client JS
+
+* Updated dependencies [[`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee)]:
+ - @astrojs/markdown-remark@0.8.0
+
## 0.25.4
### Patch Changes
diff --git a/packages/astro/astro.js b/packages/astro/astro.js
index 0f458bb6d..69ea565f7 100755
--- a/packages/astro/astro.js
+++ b/packages/astro/astro.js
@@ -9,7 +9,8 @@
const CI_INSTRUCTIONS = {
NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
- GITHUB_ACTIONS: 'https://docs.github.com/en/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version',
+ GITHUB_ACTIONS:
+ 'https://docs.github.com/en/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version',
VERCEL: 'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
};
@@ -17,7 +18,10 @@ const CI_INSTRUCTIONS = {
async function main() {
// Check for ESM support.
// Load the "supports-esm" package in an way that works in both ESM & CJS.
- let supportsESM = typeof require !== 'undefined' ? require('supports-esm') : (await import('supports-esm')).default;
+ let supportsESM =
+ typeof require !== 'undefined'
+ ? require('supports-esm')
+ : (await import('supports-esm')).default;
// Check for CJS->ESM named export support.
// "path-to-regexp" is a real-world package that we depend on, that only
@@ -79,7 +83,9 @@ Please upgrade Node.js to a supported version: "${engines}"\n`);
break;
}
}
- console.log(`${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`);
+ console.log(
+ `${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`
+ );
console.log(`Documentation: https://docs.astro.build/guides/deploy`);
if (CI_INSTRUCTIONS[platform]) {
console.log(`${ci.name} Documentation: ${CI_INSTRUCTIONS[platform]}`);
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 8ca558d6b..649081130 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -1,6 +1,6 @@
{
"name": "astro",
- "version": "0.25.4",
+ "version": "0.26.0",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
@@ -73,9 +73,9 @@
"test:match": "mocha --timeout 20000 -g"
},
"dependencies": {
- "@astrojs/compiler": "^0.13.1",
- "@astrojs/language-server": "^0.13.2",
- "@astrojs/markdown-remark": "^0.7.0",
+ "@astrojs/compiler": "^0.14.1",
+ "@astrojs/language-server": "^0.13.3",
+ "@astrojs/markdown-remark": "^0.8.0",
"@astrojs/prism": "0.4.1",
"@astrojs/webapi": "^0.11.0",
"@babel/core": "^7.17.8",
@@ -130,7 +130,7 @@
"strip-ansi": "^7.0.1",
"supports-esm": "^1.0.0",
"tsconfig-resolver": "^3.0.1",
- "vite": "^2.8.6",
+ "vite": "^2.9.1",
"yargs-parser": "^21.0.1",
"zod": "^3.14.3"
},
@@ -159,7 +159,7 @@
"chai": "^4.3.6",
"cheerio": "^1.0.0-rc.10",
"mocha": "^9.2.2",
- "sass": "^1.49.9"
+ "sass": "^1.49.11"
},
"engines": {
"node": "^14.15.0 || >=16.0.0",
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts
index 0f1e48e13..854e7e377 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/@types/astro.ts
@@ -2,6 +2,7 @@ import type { AddressInfo } from 'net';
import type * as babel from '@babel/core';
import type * as vite from 'vite';
import { z } from 'zod';
+import type { ShikiConfig, Plugin } from '@astrojs/markdown-remark';
import type { AstroConfigSchema } from '../core/config';
import type { AstroComponentFactory, Metadata } from '../runtime/server';
import type { ViteConfigWithSSR } from '../core/create-vite';
@@ -24,18 +25,13 @@ export interface AstroComponentMetadata {
/** The flags supported by the Astro CLI */
export interface CLIFlags {
- projectRoot?: string;
+ root?: string;
site?: string;
- sitemap?: boolean;
host?: string | boolean;
- hostname?: string;
port?: number;
config?: string;
- /** @deprecated */
- experimentalStaticBuild?: boolean;
experimentalSsr?: boolean;
experimentalIntegrations?: boolean;
- legacyBuild?: boolean;
drafts?: boolean;
}
@@ -60,7 +56,10 @@ export interface AstroGlobal extends AstroGlobalPartial {
/** get information about this page */
request: Request;
/** see if slots are used */
- slots: Record<string, true | undefined> & { has(slotName: string): boolean; render(slotName: string, args?: any[]): Promise<string> };
+ slots: Record<string, true | undefined> & {
+ has(slotName: string): boolean;
+ render(slotName: string, args?: any[]): Promise<string>;
+ };
}
export interface AstroGlobalPartial {
@@ -76,6 +75,32 @@ export interface AstroGlobalPartial {
site: URL;
}
+type ServerConfig = {
+ /**
+ * @name server.host
+ * @type {string | boolean}
+ * @default `false`
+ * @version 0.24.0
+ * @description
+ * Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs).
+ * - `false` - do not expose on a network IP address
+ * - `true` - listen on all addresses, including LAN and public addresses
+ * - `[custom-address]` - expose on a network IP address at `[custom-address]`
+ */
+ host?: string | boolean;
+
+ /**
+ * @name server.port
+ * @type {number}
+ * @default `3000`
+ * @description
+ * Set which port the dev server should listen on.
+ *
+ * If the given port is already in use, Astro will automatically try the next available port.
+ */
+ port?: number;
+};
+
/**
* Astro User Config
* Docs: https://docs.astro.build/reference/configuration-reference/
@@ -89,50 +114,50 @@ export interface AstroUserConfig {
/**
* @docs
- * @name projectRoot
- * @cli --project-root
+ * @name root
+ * @cli --root
* @type {string}
* @default `"."` (current working directory)
* @summary Set the project root. The project root is the directory where your Astro project (and all `src`, `public` and `package.json` files) live.
* @description You should only provide this option if you run the `astro` CLI commands in a directory other than the project root directory. Usually, this option is provided via the CLI instead of the `astro.config.js` file, since Astro needs to know your project root before it can locate your config file.
*
- * If you provide a relative path (ex: `--project-root: './my-project'`) Astro will resolve it against your current working directory.
+ * If you provide a relative path (ex: `--root: './my-project'`) Astro will resolve it against your current working directory.
*
* #### Examples
*
* ```js
* {
- * projectRoot: './my-project-directory'
+ * root: './my-project-directory'
* }
* ```
* ```bash
- * $ astro build --project-root ./my-project-directory
+ * $ astro build --root ./my-project-directory
* ```
*/
- projectRoot?: string;
+ root?: string;
/**
* @docs
- * @name dist
+ * @name srcDir
* @type {string}
- * @default `"./dist"`
- * @description Set the directory that `astro build` writes your final build to.
+ * @default `"./src"`
+ * @description Set the directory that Astro will read your site from.
*
* The value can be either an absolute file system path or a path relative to the project root.
*
* ```js
* {
- * dist: './my-custom-build-directory'
+ * srcDir: './www'
* }
* ```
*/
- dist?: string;
+ srcDir?: string;
/**
* @docs
- * @name public
+ * @name publicDir
* @type {string}
- * @default `"./public"`
+ * @default `"./publicDir"`
* @description
* Set the directory for your static assets. Files in this directory are served at `/` during dev and copied to your build directory during build. These files are always served or copied as-is, without transform or bundling.
*
@@ -140,162 +165,95 @@ export interface AstroUserConfig {
*
* ```js
* {
- * public: './my-custom-public-directory'
+ * publicDir: './my-custom-publicDir-directory'
* }
* ```
*/
- public?: string;
+ publicDir?: string;
/**
* @docs
- * @name integrations
- * @type {AstroIntegration[]}
- * @default `[]`
- * @description
- * Add Integrations to your project to extend Astro.
- *
- * Integrations are your one-stop shop to add new frameworks (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
- *
- * Setting this configuration will disable Astro's default integration, so it is recommended to provide a renderer for every framework that you use:
+ * @name outDir
+ * @type {string}
+ * @default `"./outDir"`
+ * @description Set the directory that `astro build` writes your final build to.
*
- * Note: Integrations are currently under active development, and only first-party integrations are supported. In the future, 3rd-party integrations will be allowed.
+ * The value can be either an absolute file system path or a path relative to the project root.
*
* ```js
- * import react from '@astrojs/react';
- * import vue from '@astrojs/vue';
* {
- * // Example: Use Astro with Vue + React, and no other frameworks.
- * integrations: [react(), vue()]
+ * outDir: './my-custom-build-directory'
* }
* ```
*/
- integrations?: Array<AstroIntegration | AstroIntegration[]>;
+ outDir?: string;
/**
- * @name adapter
- * @type {AstroIntegration}
- * @default `undefined`
+ * @docs
+ * @name site
+ * @type {string}
* @description
- * Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment.
+ * Your final, deployed URL. Astro uses this full URL to generate your sitemap and canonical URLs in your final build. It is strongly recommended that you set this configuration to get the most out of Astro.
+ *
+ * ```js
+ * {
+ * site: 'https://www.my-site.dev'
+ * }
+ * ```
*/
- adapter?: AstroIntegration;
-
- /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
- renderers?: string[];
+ site?: string;
/**
* @docs
- * @name markdownOptions
- * @type {{render: MarkdownRenderOptions}}
- * @see [Markdown guide](/en/guides/markdown-content/)
+ * @name base
+ * @type {string}
* @description
- * Configure how markdown files (`.md`) are rendered.
+ * The base path you're deploying to. Astro will match this pathname during development so that your development experience matches your build environment as closely as possible. In the example below, `astro dev` will start your server at `/docs`.
*
* ```js
- * import { defineConfig } from "astro/config";
- * import astroRemark from "@astrojs/markdown-remark";
- * import customRehypePlugin from "/path/to/rehypePlugin.mjs";
+ * {
+ * base: '/docs'
+ * }
+ * ```
+ */
+ base?: string;
+
+ /**
+ * @docs
+ * @name trailingSlash
+ * @type {('always' | 'never' | 'ignore')}
+ * @default `'always'`
+ * @see buildOptions.pageUrlFormat
+ * @description
+ *
+ * Set the route matching behavior of the dev server. Choose from the following options:
+ * - `'always'` - Only match URLs that include a trailing slash (ex: "/foo/")
+ * - `'never'` - Never match URLs that include a trailing slash (ex: "/foo")
+ * - `'ignore'` - Match URLs regardless of whether a trailing "/" exists
+ *
+ * Use this configuration option if your production host has strict handling of how trailing slashes work or do not work.
*
- * export default defineConfig({
- * // Enable Custom Markdown options, plugins, etc.
- * markdownOptions: {
- * render: [
- * // The Remark parser to parse Markdown content
- * astroRemark,
- * {
- * // Add a Remark plugin to your project.
- * remarkPlugins: ["remark-code-titles"],
+ * You can also set this if you prefer to be more strict yourself, so that URLs with or without trailing slashes won't work during development.
*
- * // Add a Rehype plugin to your project.
- * rehypePlugins: [
- * "rehype-slug",
- * [customRehypePlugin, { configKey: "value" }],
- * ["rehype-autolink-headings", { behavior: "prepend" }],
- * ],
- * },
- * ],
- * },
- * });
+ * ```js
+ * {
+ * // Example: Require a trailing slash during development
+ * trailingSlash: 'always'
+ * }
* ```
*/
- markdownOptions?: {
- render?: MarkdownRenderOptions;
- };
+ trailingSlash?: 'always' | 'never' | 'ignore';
/**
* @docs
* @kind heading
* @name Build Options
*/
- buildOptions?: {
- /**
- * @docs
- * @name buildOptions.site
- * @type {string}
- * @description
- * Your final, deployed URL. Astro uses this full URL to generate your sitemap and canonical URLs in your final build. It is strongly recommended that you set this configuration to get the most out of Astro.
- *
- * Astro will match the site pathname during development so that your development experience matches your build environment as closely as possible. In the example below, `astro dev` will start your server at `http://localhost:3000/docs`.
- *
- * ```js
- * {
- * buildOptions: {
- * // Example: Tell Astro the final URL of your deployed website.
- * site: 'https://www.my-site.dev/docs'
- * }
- * }
- * ```
- */
- site?: string;
-
+ build?: {
/**
* @docs
- * @name buildOptions.sitemap
- * @type {boolean}
- * @default `true`
- * @description
- * Generate a sitemap for your build. Set to false to disable.
- *
- * Astro will automatically generate a sitemap including all generated pages on your site. If you need more control over your sitemap, consider generating it yourself using a [Non-HTML Page](/en/core-concepts/astro-pages/#non-html-pages).
- *
- * ```js
- * {
- * buildOptions: {
- * // Example: Disable automatic sitemap generation
- * sitemap: false
- * }
- * }
- * ```
- */
- sitemap?: boolean;
-
- /**
- * @docs
- * @name buildOptions.sitemapFilter
- * @typeraw {(page: string) => boolean}
- * @see buildOptions.sitemap
- * @description
- * By default, all pages are included in your generated sitemap.
- * You can filter included pages by URL using `buildOptions.sitemapFilter`.
- *
- * The `page` function parameter is the full URL of your rendered page, including your `buildOptions.site` domain.
- * Return `true` to include a page in your sitemap, and `false` to remove it.
- *
- * ```js
- * {
- * buildOptions: {
- * sitemap: true
- * sitemapFilter: (page) => page !== 'http://example.com/secret-page')
- * }
- * }
- * ```
- */
- sitemapFilter?: (page: string) => boolean;
-
- /**
- * @docs
- * @name buildOptions.pageUrlFormat
- * @type {('file' | 'directory')}
+ * @name build.format
+ * @typeraw {('file' | 'directory')}
* @default `'directory'`
* @description
* Control the output file format of each page.
@@ -304,18 +262,75 @@ export interface AstroUserConfig {
*
* ```js
* {
- * buildOptions: {
+ * build: {
* // Example: Generate `page.html` instead of `page/index.html` during build.
- * pageUrlFormat: 'file'
+ * format: 'file'
* }
* }
* ```
*/
- pageUrlFormat?: 'file' | 'directory';
+ format?: 'file' | 'directory';
+ };
+ /**
+ * @docs
+ * @kind heading
+ * @name Server Options
+ * @description
+ *
+ * Customize the Astro dev server, used by both `astro dev` and `astro serve`.
+ *
+ * ```js
+ * {
+ * server: {port: 1234, host: true}
+ * }
+ * ```
+ *
+ * To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option.
+ *
+ * ```js
+ * {
+ * // Example: Use the function syntax to customize based on command
+ * server: (command) => ({port: command === 'dev' ? 3000 : 4000})
+ * }
+ * ```
+ */
+
+ /**
+ * @docs
+ * @name server.host
+ * @type {string | boolean}
+ * @default `false`
+ * @version 0.24.0
+ * @description
+ * Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs).
+ * - `false` - do not expose on a network IP address
+ * - `true` - listen on all addresses, including LAN and public addresses
+ * - `[custom-address]` - expose on a network IP address at `[custom-address]`
+ */
+
+ /**
+ * @docs
+ * @name server.port
+ * @type {number}
+ * @default `3000`
+ * @description
+ * Set which port the dev server should listen on.
+ *
+ * If the given port is already in use, Astro will automatically try the next available port.
+ */
+
+ server?: ServerConfig | ((options: { command: 'dev' | 'preview' }) => ServerConfig);
+
+ /**
+ * @docs
+ * @kind heading
+ * @name Markdown Options
+ */
+ markdown?: {
/**
* @docs
- * @name buildOptions.drafts
+ * @name markdown.drafts
* @type {boolean}
* @default `false`
* @description
@@ -325,117 +340,120 @@ export interface AstroUserConfig {
*
* ```js
* {
- * buildOptions: {
+ * markdown: {
* // Example: Include all drafts in your final build
- * drafts: true,
+ * drafts: true,
* }
* }
* ```
*/
drafts?: boolean;
- /**
- * Enables "legacy build mode" for compatibility with older Astro versions.
- * Default: false
- */
- legacyBuild?: boolean;
- /**
- * @deprecated
- * Experimental: Enables "static build mode" for faster builds.
- * Default: true
- */
- experimentalStaticBuild?: boolean;
- /**
- * Enable SSR support for 3rd-party adapters.
- * Not required when using a built-in adapter.
- * Default: false
- */
- experimentalSsr?: boolean;
- };
- /**
- * @docs
- * @kind heading
- * @name Dev Options
- */
- devOptions?: {
/**
* @docs
- * @name devOptions.host
- * @type {string | boolean}
- * @default `false`
- * @version 0.24.0
+ * @name markdown.shikiConfig
+ * @type {ShikiConfig}
* @description
- * Set which network IP addresses the dev server should listen on (i.e. non-localhost IPs).
- * - `false` - do not expose on a network IP address
- * - `true` - listen on all addresses, including LAN and public addresses
- * - `[custom-address]` - expose on a network IP address at `[custom-address]`
+ * Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
*/
- host?: string | boolean;
+ shikiConfig?: ShikiConfig;
/**
* @docs
- * @name devOptions.hostname
- * @type {string}
- * @default `'localhost'`
- * @deprecated Use `host` instead
+ * @name markdown.syntaxHighlight
+ * @type {'shiki' | 'prism' | false}
+ * @default `shiki`
* @description
- * > **This option is deprecated.** Consider using `host` instead.
+ * Which syntax highlighter to use, if any.
+ * - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter
+ * - `prism` - use the [Prism](https://prismjs.com/) highlighter
+ * - `false` - do not apply syntax highlighting.
*
- * Set which IP addresses the dev server should listen on. Set this to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
+ * ```js
+ * {
+ * markdown: {
+ * // Example: Switch to use prism for syntax highlighting in Markdown
+ * syntaxHighlight: 'prism',
+ * }
+ * }
+ * ```
*/
- hostname?: string;
+ syntaxHighlight?: 'shiki' | 'prism' | false;
/**
* @docs
- * @name devOptions.port
- * @type {number}
- * @default `3000`
+ * @name markdown.remarkPlugins
+ * @type {Plugin[]}
* @description
- * Set which port the dev server should listen on.
+ * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
+ *
+ * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
*
- * If the given port is already in use, Astro will automatically try the next available port.
+ * ```js
+ * {
+ * markdown: {
+ * // Example: The default set of remark plugins used by Astro
+ * remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]],
+ * },
+ * };
+ * ```
*/
- port?: number;
-
+ remarkPlugins?: Plugin[];
/**
* @docs
- * @name devOptions.trailingSlash
- * @type {('always' | 'never' | 'ignore')}
- * @default `'always'`
- * @see buildOptions.pageUrlFormat
+ * @name markdown.rehypePlugins
+ * @type {Plugin[]}
* @description
+ * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
*
- * Set the route matching behavior of the dev server. Choose from the following options:
- * - 'always' - Only match URLs that include a trailing slash (ex: "/foo/")
- * - 'never' - Never match URLs that include a trailing slash (ex: "/foo")
- * - 'ignore' - Match URLs regardless of whether a trailing "/" exists
- *
- * Use this configuration option if your production host has strict handling of how trailing slashes work or do not work.
- *
- * You can also set this if you prefer to be more strict yourself, so that URLs with or without trailing slashes won't work during development.
+ * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
*
* ```js
* {
- * devOptions: {
- * // Example: Require a trailing slash during development
- * trailingSlash: 'always'
- * }
- * }
+ * markdown: {
+ * // Example: The default set of rehype plugins used by Astro
+ * rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'],
+ * },
+ * };
* ```
*/
- trailingSlash?: 'always' | 'never' | 'ignore';
+ rehypePlugins?: Plugin[];
};
/**
- * Enable experimental support for 3rd-party integrations.
- * Default: false
+ * @name adapter
+ * @type {AstroIntegration}
+ * @default `undefined`
+ * @description
+ * Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment.
*/
- experimentalIntegrations?: boolean;
+ adapter?: AstroIntegration;
/**
* @docs
- * @name vite
- * @type {vite.UserConfig}
+ * @kind heading
+ * @name Integrations
+ * @description
+ *
+ * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
+ *
+ * Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations.
+ *
+ * ```js
+ * import react from '@astrojs/react';
+ * import tailwind from '@astrojs/tailwind';
+ * {
+ * // Example: Add React + Tailwind support to Astro
+ * integrations: [react(), tailwind()]
+ * }
+ * ```
+ */
+ integrations?: Array<AstroIntegration | AstroIntegration[]>;
+
+ /**
+ * @docs
+ * @kind heading
+ * @name Vite
* @description
*
* Pass additional configuration options to Vite. Useful when Astro doesn't support some advanced configuration that you may need.
@@ -447,9 +465,9 @@ export interface AstroUserConfig {
* ```js
* {
* vite: {
- * ssr: {
- * // Example: Force a broken package to skip SSR processing, if needed
- * external: ['broken-npm-package'],
+ * ssr: {
+ * // Example: Force a broken package to skip SSR processing, if needed
+ * external: ['broken-npm-package'],
* }
* }
* }
@@ -459,12 +477,51 @@ export interface AstroUserConfig {
* {
* vite: {
* // Example: Add custom vite plugins directly to your Astro project
- * plugins: [myPlugin()],
+ * plugins: [myPlugin()],
* }
* }
* ```
*/
vite?: vite.UserConfig & { ssr?: vite.SSROptions };
+
+ experimental?: {
+ /**
+ * Enable experimental support for 3rd-party integrations.
+ * Default: false
+ */
+ integrations?: boolean;
+
+ /**
+ * Enable a build for SSR support.
+ * Default: false
+ */
+ ssr?: boolean;
+ };
+
+ // Legacy options to be removed
+
+ /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
+ renderers?: never;
+ /** @deprecated `projectRoot` has been renamed to `root` */
+ projectRoot?: never;
+ /** @deprecated `src` has been renamed to `srcDir` */
+ src?: never;
+ /** @deprecated `pages` has been removed. It is no longer configurable. */
+ pages?: never;
+ /** @deprecated `public` has been renamed to `publicDir` */
+ public?: never;
+ /** @deprecated `dist` has been renamed to `outDir` */
+ dist?: never;
+ /** @deprecated `styleOptions` has been renamed to `style` */
+ styleOptions?: never;
+ /** @deprecated `markdownOptions` has been renamed to `markdown` */
+ markdownOptions?: never;
+ /** @deprecated `buildOptions` has been renamed to `build` */
+ buildOptions?: never;
+ /** @deprecated `devOptions` has been renamed to `server` */
+ devOptions?: never;
+ /** @deprecated `experimentalIntegrations` has been renamed to `experimental: { integrations: true }` */
+ experimentalIntegrations?: never;
}
// NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that
@@ -506,7 +563,12 @@ export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
};
}
-export type AsyncRendererComponentFn<U> = (Component: any, props: any, children: string | undefined, metadata?: AstroComponentMetadata) => Promise<U>;
+export type AsyncRendererComponentFn<U> = (
+ Component: any,
+ props: any,
+ children: string | undefined,
+ metadata?: AstroComponentMetadata
+) => Promise<U>;
/** Generic interface for a component (Astro, Svelte, React, etc.) */
export interface ComponentInstance {
@@ -524,7 +586,9 @@ export interface MarkdownInstance<T extends Record<string, any>> {
getHeaders(): Promise<{ depth: number; slug: string; text: string }[]>;
}
-export type GetHydrateCallback = () => Promise<(element: Element, innerHTML: string | null) => void>;
+export type GetHydrateCallback = () => Promise<
+ (element: Element, innerHTML: string | null) => void
+>;
/**
* getStaticPaths() options
@@ -552,14 +616,20 @@ export interface JSXTransformConfig {
plugins?: babel.PluginItem[];
}
-export type JSXTransformFn = (options: { mode: string; ssr: boolean }) => Promise<JSXTransformConfig>;
+export type JSXTransformFn = (options: {
+ mode: string;
+ ssr: boolean;
+}) => Promise<JSXTransformConfig>;
export interface ManifestData {
routes: RouteData[];
}
export type MarkdownRenderOptions = [string | MarkdownParser, Record<string, any>];
-export type MarkdownParser = (contents: string, options?: Record<string, any>) => MarkdownParserResponse | PromiseLike<MarkdownParserResponse>;
+export type MarkdownParser = (
+ contents: string,
+ options?: Record<string, any>
+) => MarkdownParserResponse | PromiseLike<MarkdownParserResponse>;
export interface MarkdownParserResponse {
frontmatter: {
@@ -677,13 +747,23 @@ export interface AstroIntegration {
// more generalized. Consider the SSR use-case as well.
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
}) => void;
- 'astro:config:done'?: (options: { config: AstroConfig; setAdapter: (adapter: AstroAdapter) => void }) => void | Promise<void>;
+ 'astro:config:done'?: (options: {
+ config: AstroConfig;
+ setAdapter: (adapter: AstroAdapter) => void;
+ }) => void | Promise<void>;
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
'astro:server:done'?: () => void | Promise<void>;
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
- 'astro:build:setup'?: (options: { vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void;
- 'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
+ 'astro:build:setup'?: (options: {
+ vite: ViteConfigWithSSR;
+ target: 'client' | 'server';
+ }) => void;
+ 'astro:build:done'?: (options: {
+ pages: { pathname: string }[];
+ dir: URL;
+ routes: RouteData[];
+ }) => void | Promise<void>;
};
}
@@ -767,7 +847,11 @@ export interface SSRResult {
styles: Set<SSRElement>;
scripts: Set<SSRElement>;
links: Set<SSRElement>;
- createAstro(Astro: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null): AstroGlobal;
+ createAstro(
+ Astro: AstroGlobalPartial,
+ props: Record<string, any>,
+ slots: Record<string, any> | null
+ ): AstroGlobal;
resolve: (s: string) => Promise<string>;
_metadata: SSRMetadata;
}
diff --git a/packages/astro/src/cli/check.ts b/packages/astro/src/cli/check.ts
index ffdc246df..bda394014 100644
--- a/packages/astro/src/cli/check.ts
+++ b/packages/astro/src/cli/check.ts
@@ -8,7 +8,11 @@ import * as path from 'path';
import { pathToFileURL } from 'url';
import * as fs from 'fs';
-async function openAllDocuments(workspaceUri: URL, filePathsToIgnore: string[], checker: AstroCheck) {
+async function openAllDocuments(
+ workspaceUri: URL,
+ filePathsToIgnore: string[],
+ checker: AstroCheck
+) {
const files = await glob('**/*.astro', {
cwd: workspaceUri.pathname,
ignore: ['node_modules/**'].concat(filePathsToIgnore.map((ignore) => `${ignore}/**`)),
@@ -64,7 +68,7 @@ function generateString(str: string, len: number) {
export async function run() {}
export async function check(astroConfig: AstroConfig) {
- const root = astroConfig.projectRoot;
+ const root = astroConfig.root;
let checker = new AstroCheck(root.toString());
await openAllDocuments(root, [], checker);
@@ -79,7 +83,11 @@ export async function check(astroConfig: AstroConfig) {
diag.diagnostics.forEach((d) => {
switch (d.severity) {
case DiagnosticSeverity.Error: {
- console.error(`${bold(cyan(path.relative(root.pathname, diag.filePath)))}:${bold(yellow(d.range.start.line))}:${bold(yellow(d.range.start.character))} - ${d.message}`);
+ console.error(
+ `${bold(cyan(path.relative(root.pathname, diag.filePath)))}:${bold(
+ yellow(d.range.start.line)
+ )}:${bold(yellow(d.range.start.character))} - ${d.message}`
+ );
let startOffset = offsetAt({ line: d.range.start.line, character: 0 }, diag.text);
let endOffset = offsetAt({ line: d.range.start.line + 1, character: 0 }, diag.text);
let str = diag.text.substring(startOffset, endOffset - 1);
diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts
index c68a97a74..50ef47531 100644
--- a/packages/astro/src/cli/index.ts
+++ b/packages/astro/src/cli/index.ts
@@ -36,8 +36,7 @@ function printAstroHelp() {
flags: [
['--host [optional IP]', 'Expose server on network'],
['--config <path>', 'Specify the path to the Astro config file.'],
- ['--project-root <path>', 'Specify the path to the project root folder.'],
- ['--no-sitemap', 'Disable sitemap generation (build only).'],
+ ['--root <path>', 'Specify the path to the project root folder.'],
['--legacy-build', 'Use the build strategy prior to 0.24.0'],
['--experimental-ssr', 'Enable SSR compilation fot 3rd-party adapters.'],
['--drafts', 'Include markdown draft pages in the build.'],
@@ -74,7 +73,7 @@ function resolveCommand(flags: Arguments): CLICommand {
export async function cli(args: string[]) {
const flags = yargs(args);
const cmd = resolveCommand(flags);
- const projectRoot = flags.projectRoot;
+ const root = flags.root;
switch (cmd) {
case 'help':
@@ -101,7 +100,7 @@ export async function cli(args: string[]) {
try {
// Note: ideally, `loadConfig` would return the config AND its filePath
// For now, `add` has to resolve the config again internally
- config = await loadConfig({ cwd: projectRoot, flags });
+ config = await loadConfig({ cwd: root, flags, cmd });
} catch (err) {
return throwAndExit(err);
}
@@ -110,7 +109,7 @@ export async function cli(args: string[]) {
case 'add': {
try {
const packages = flags._.slice(3) as string[];
- return await add(packages, { cwd: projectRoot, flags, logging });
+ return await add(packages, { cwd: root, flags, logging });
} catch (err) {
return throwAndExit(err);
}
diff --git a/packages/astro/src/core/add/babel.ts b/packages/astro/src/core/add/babel.ts
index 8ec31cd46..0c302803d 100644
--- a/packages/astro/src/core/add/babel.ts
+++ b/packages/astro/src/core/add/babel.ts
@@ -14,4 +14,5 @@ export async function generate(ast: t.File) {
return code;
}
-export const parse = (code: string) => parser.parse(code, { sourceType: 'unambiguous', plugins: ['typescript'] });
+export const parse = (code: string) =>
+ parser.parse(code, { sourceType: 'unambiguous', plugins: ['typescript'] });
diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts
index c181d6aae..5de4cf2c2 100644
--- a/packages/astro/src/core/add/index.ts
+++ b/packages/astro/src/core/add/index.ts
@@ -50,7 +50,9 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
configURL = await resolveConfigURL({ cwd, flags });
if (configURL?.pathname.endsWith('package.json')) {
- throw new Error(`Unable to use astro add with package.json#astro configuration! Try migrating to \`astro.config.mjs\` and try again.`);
+ throw new Error(
+ `Unable to use astro add with package.json#astro configuration! Try migrating to \`astro.config.mjs\` and try again.`
+ );
}
applyPolyfill();
@@ -102,7 +104,13 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
debug('add', 'Parsed astro config');
const defineConfig = t.identifier('defineConfig');
- ensureImport(ast, t.importDeclaration([t.importSpecifier(defineConfig, defineConfig)], t.stringLiteral('astro/config')));
+ ensureImport(
+ ast,
+ t.importDeclaration(
+ [t.importSpecifier(defineConfig, defineConfig)],
+ t.stringLiteral('astro/config')
+ )
+ );
wrapDefaultExport(ast, defineConfig);
debug('add', 'Astro config ensured `defineConfig`');
@@ -136,9 +144,13 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
case UpdateResult.none: {
const pkgURL = new URL('./package.json', configURL);
if (existsSync(fileURLToPath(pkgURL))) {
- const { dependencies = {}, devDependencies = {} } = await fs.readFile(fileURLToPath(pkgURL)).then((res) => JSON.parse(res.toString()));
+ const { dependencies = {}, devDependencies = {} } = await fs
+ .readFile(fileURLToPath(pkgURL))
+ .then((res) => JSON.parse(res.toString()));
const deps = Object.keys(Object.assign(dependencies, devDependencies));
- const missingDeps = integrations.filter((integration) => !deps.includes(integration.packageName));
+ const missingDeps = integrations.filter(
+ (integration) => !deps.includes(integration.packageName)
+ );
if (missingDeps.length === 0) {
info(logging, null, msg.success(`Configuration up-to-date.`));
return;
@@ -156,7 +168,11 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
case UpdateResult.updated: {
const len = integrations.length;
if (integrations.find((integration) => integration.id === 'tailwind')) {
- const possibleConfigFiles = ['./tailwind.config.cjs', './tailwind.config.mjs', './tailwind.config.js'].map((p) => fileURLToPath(new URL(p, configURL)));
+ const possibleConfigFiles = [
+ './tailwind.config.cjs',
+ './tailwind.config.mjs',
+ './tailwind.config.js',
+ ].map((p) => fileURLToPath(new URL(p, configURL)));
let alreadyConfigured = false;
for (const possibleConfigPath of possibleConfigFiles) {
if (existsSync(possibleConfigPath)) {
@@ -165,9 +181,19 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
}
}
if (!alreadyConfigured) {
- info(logging, null, `\n ${magenta(`Astro will generate a minimal ${bold('./tailwind.config.cjs')} file.`)}\n`);
+ info(
+ logging,
+ null,
+ `\n ${magenta(
+ `Astro will generate a minimal ${bold('./tailwind.config.cjs')} file.`
+ )}\n`
+ );
if (await askToContinue({ flags })) {
- await fs.writeFile(fileURLToPath(new URL('./tailwind.config.cjs', configURL)), CONSTS.TAILWIND_CONFIG_STUB, { encoding: 'utf-8' });
+ await fs.writeFile(
+ fileURLToPath(new URL('./tailwind.config.cjs', configURL)),
+ CONSTS.TAILWIND_CONFIG_STUB,
+ { encoding: 'utf-8' }
+ );
debug('add', `Generated default ./tailwind.config.cjs file`);
}
} else {
@@ -175,11 +201,24 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO
}
}
const list = integrations.map((integration) => ` - ${integration.packageName}`).join('\n');
- info(logging, null, msg.success(`Added the following integration${len === 1 ? '' : 's'} to your project:\n${list}`));
+ info(
+ logging,
+ null,
+ msg.success(
+ `Added the following integration${len === 1 ? '' : 's'} to your project:\n${list}`
+ )
+ );
return;
}
case UpdateResult.cancelled: {
- info(logging, null, msg.cancelled(`Dependencies ${bold('NOT')} installed.`, `Be sure to install them manually before continuing!`));
+ info(
+ logging,
+ null,
+ msg.cancelled(
+ `Dependencies ${bold('NOT')} installed.`,
+ `Be sure to install them manually before continuing!`
+ )
+ );
return;
}
case UpdateResult.failure: {
@@ -193,7 +232,8 @@ async function parseAstroConfig(configURL: URL): Promise<t.File> {
const result = parse(source);
if (!result) throw new Error('Unknown error parsing astro config');
- if (result.errors.length > 0) throw new Error('Error parsing astro config: ' + JSON.stringify(result.errors));
+ if (result.errors.length > 0)
+ throw new Error('Error parsing astro config: ' + JSON.stringify(result.errors));
return result;
}
@@ -217,7 +257,13 @@ Documentation: https://docs.astro.build/en/guides/integrations-guide/`;
async function addIntegration(ast: t.File, integration: IntegrationInfo) {
const integrationId = t.identifier(toIdent(integration.id));
- ensureImport(ast, t.importDeclaration([t.importDefaultSpecifier(integrationId)], t.stringLiteral(integration.packageName)));
+ ensureImport(
+ ast,
+ t.importDeclaration(
+ [t.importDefaultSpecifier(integrationId)],
+ t.stringLiteral(integration.packageName)
+ )
+ );
visit(ast, {
// eslint-disable-next-line @typescript-eslint/no-shadow
@@ -241,14 +287,20 @@ async function addIntegration(ast: t.File, integration: IntegrationInfo) {
const integrationCall = t.callExpression(integrationId, []);
if (!integrationsProp) {
- configObject.properties.push(t.objectProperty(t.identifier('integrations'), t.arrayExpression([integrationCall])));
+ configObject.properties.push(
+ t.objectProperty(t.identifier('integrations'), t.arrayExpression([integrationCall]))
+ );
return;
}
- if (integrationsProp.value.type !== 'ArrayExpression') throw new Error('Unable to parse integrations');
+ if (integrationsProp.value.type !== 'ArrayExpression')
+ throw new Error('Unable to parse integrations');
const existingIntegrationCall = integrationsProp.value.elements.find(
- (expr) => t.isCallExpression(expr) && t.isIdentifier(expr.callee) && expr.callee.name === integrationId.name
+ (expr) =>
+ t.isCallExpression(expr) &&
+ t.isIdentifier(expr.callee) &&
+ expr.callee.name === integrationId.name
);
if (existingIntegrationCall) return;
@@ -265,7 +317,17 @@ const enum UpdateResult {
failure,
}
-async function updateAstroConfig({ configURL, ast, flags, logging }: { configURL: URL; ast: t.File; flags: yargs.Arguments; logging: LogOptions }): Promise<UpdateResult> {
+async function updateAstroConfig({
+ configURL,
+ ast,
+ flags,
+ logging,
+}: {
+ configURL: URL;
+ ast: t.File;
+ flags: yargs.Arguments;
+ logging: LogOptions;
+}): Promise<UpdateResult> {
const input = await fs.readFile(fileURLToPath(configURL), { encoding: 'utf-8' });
let output = await generate(ast);
const comment = '// https://astro.build/config';
@@ -299,9 +361,18 @@ async function updateAstroConfig({ configURL, ast, flags, logging }: { configURL
diffed = diffed.replace(newContent, coloredOutput);
}
- const message = `\n${boxen(diffed, { margin: 0.5, padding: 0.5, borderStyle: 'round', title: configURL.pathname.split('/').pop() })}\n`;
-
- info(logging, null, `\n ${magenta('Astro will make the following changes to your config file:')}\n${message}`);
+ const message = `\n${boxen(diffed, {
+ margin: 0.5,
+ padding: 0.5,
+ borderStyle: 'round',
+ title: configURL.pathname.split('/').pop(),
+ })}\n`;
+
+ info(
+ logging,
+ null,
+ `\n ${magenta('Astro will make the following changes to your config file:')}\n${message}`
+ );
if (await askToContinue({ flags })) {
await fs.writeFile(fileURLToPath(configURL), output, { encoding: 'utf-8' });
@@ -318,7 +389,13 @@ interface InstallCommand {
flags: string[];
dependencies: string[];
}
-async function getInstallIntegrationsCommand({ integrations, cwd = process.cwd() }: { integrations: IntegrationInfo[]; cwd?: string }): Promise<InstallCommand | null> {
+async function getInstallIntegrationsCommand({
+ integrations,
+ cwd = process.cwd(),
+}: {
+ integrations: IntegrationInfo[];
+ cwd?: string;
+}): Promise<InstallCommand | null> {
const pm = await preferredPM(cwd);
debug('add', `package manager: ${JSON.stringify(pm)}`);
if (!pm) return null;
@@ -359,14 +436,30 @@ async function tryToInstallIntegrations({
info(logging, null);
return UpdateResult.none;
} else {
- const coloredOutput = `${bold(installCommand.pm)} ${installCommand.command} ${installCommand.flags.join(' ')} ${cyan(installCommand.dependencies.join(' '))}`;
- const message = `\n${boxen(coloredOutput, { margin: 0.5, padding: 0.5, borderStyle: 'round' })}\n`;
- info(logging, null, `\n ${magenta('Astro will run the following command:')}\n ${dim('If you skip this step, you can always run it yourself later')}\n${message}`);
+ const coloredOutput = `${bold(installCommand.pm)} ${
+ installCommand.command
+ } ${installCommand.flags.join(' ')} ${cyan(installCommand.dependencies.join(' '))}`;
+ const message = `\n${boxen(coloredOutput, {
+ margin: 0.5,
+ padding: 0.5,
+ borderStyle: 'round',
+ })}\n`;
+ info(
+ logging,
+ null,
+ `\n ${magenta('Astro will run the following command:')}\n ${dim(
+ 'If you skip this step, you can always run it yourself later'
+ )}\n${message}`
+ );
if (await askToContinue({ flags })) {
const spinner = ora('Installing dependencies...').start();
try {
- await execa(installCommand.pm, [installCommand.command, ...installCommand.flags, ...installCommand.dependencies], { cwd });
+ await execa(
+ installCommand.pm,
+ [installCommand.command, ...installCommand.flags, ...installCommand.dependencies],
+ { cwd }
+ );
spinner.succeed();
return UpdateResult.updated;
} catch (err) {
@@ -405,7 +498,9 @@ export async function validateIntegrations(integrations: string[]): Promise<Inte
return res.json();
});
- let dependencies: IntegrationInfo['dependencies'] = [[result['name'], `^${result['version']}`]];
+ let dependencies: IntegrationInfo['dependencies'] = [
+ [result['name'], `^${result['version']}`],
+ ];
if (result['peerDependencies']) {
for (const peer in result['peerDependencies']) {
diff --git a/packages/astro/src/core/add/wrapper.ts b/packages/astro/src/core/add/wrapper.ts
index a8f6b3bc8..c86e87698 100644
--- a/packages/astro/src/core/add/wrapper.ts
+++ b/packages/astro/src/core/add/wrapper.ts
@@ -4,7 +4,12 @@ export function wrapDefaultExport(ast: t.File, functionIdentifier: t.Identifier)
visit(ast, {
ExportDefaultDeclaration(path) {
if (!t.isExpression(path.node.declaration)) return;
- if (t.isCallExpression(path.node.declaration) && t.isIdentifier(path.node.declaration.callee) && path.node.declaration.callee.name === functionIdentifier.name) return;
+ if (
+ t.isCallExpression(path.node.declaration) &&
+ t.isIdentifier(path.node.declaration.callee) &&
+ path.node.declaration.callee.name === functionIdentifier.name
+ )
+ return;
path.node.declaration = t.callExpression(functionIdentifier, [path.node.declaration]);
},
});
diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts
index ee66df9d1..2175b8e9f 100644
--- a/packages/astro/src/core/app/index.ts
+++ b/packages/astro/src/core/app/index.ts
@@ -1,4 +1,9 @@
-import type { ComponentInstance, EndpointHandler, ManifestData, RouteData } from '../../@types/astro';
+import type {
+ ComponentInstance,
+ EndpointHandler,
+ ManifestData,
+ RouteData,
+} from '../../@types/astro';
import type { SSRManifest as Manifest, RouteInfo } from './types';
import type { LogOptions } from '../logger/core.js';
@@ -9,7 +14,10 @@ import { matchRoute } from '../routing/match.js';
import { render } from '../render/core.js';
import { call as callEndpoint } from '../endpoint/index.js';
import { RouteCache } from '../render/route-cache.js';
-import { createLinkStylesheetElementSet, createModuleScriptElementWithSrcSet } from '../render/ssr-element.js';
+import {
+ createLinkStylesheetElementSet,
+ createModuleScriptElementWithSrcSet,
+} from '../render/ssr-element.js';
import { prependForwardSlash } from '../path.js';
import { createRequest } from '../request.js';
@@ -58,7 +66,11 @@ export class App {
}
}
- async #renderPage(request: Request, routeData: RouteData, mod: ComponentInstance): Promise<Response> {
+ async #renderPage(
+ request: Request,
+ routeData: RouteData,
+ mod: ComponentInstance
+ ): Promise<Response> {
const url = new URL(request.url);
const manifest = this.#manifest;
const renderers = manifest.renderers;
@@ -105,7 +117,11 @@ export class App {
});
}
- async #callEndpoint(request: Request, _routeData: RouteData, mod: ComponentInstance): Promise<Response> {
+ async #callEndpoint(
+ request: Request,
+ _routeData: RouteData,
+ mod: ComponentInstance
+ ): Promise<Response> {
const url = new URL(request.url);
const handler = mod as unknown as EndpointHandler;
const result = await callEndpoint(handler, {
diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts
index 0d395c776..27af8b665 100644
--- a/packages/astro/src/core/app/types.ts
+++ b/packages/astro/src/core/app/types.ts
@@ -1,4 +1,10 @@
-import type { RouteData, SerializedRouteData, MarkdownRenderOptions, ComponentInstance, SSRLoadedRenderer } from '../../@types/astro';
+import type {
+ RouteData,
+ SerializedRouteData,
+ MarkdownRenderOptions,
+ ComponentInstance,
+ SSRLoadedRenderer,
+} from '../../@types/astro';
export type ComponentPath = string;
@@ -28,4 +34,7 @@ export type SerializedSSRManifest = Omit<SSRManifest, 'routes'> & {
routes: SerializedRouteInfo[];
};
-export type AdapterCreateExports<T = any> = (manifest: SSRManifest, args?: T) => Record<string, any>;
+export type AdapterCreateExports<T = any> = (
+ manifest: SSRManifest,
+ args?: T
+) => Record<string, any>;
diff --git a/packages/astro/src/core/build/common.ts b/packages/astro/src/core/build/common.ts
index a29aa356c..6b5423857 100644
--- a/packages/astro/src/core/build/common.ts
+++ b/packages/astro/src/core/build/common.ts
@@ -5,10 +5,14 @@ import { appendForwardSlash } from '../../core/path.js';
const STATUS_CODE_PAGES = new Set(['/404', '/500']);
function getOutRoot(astroConfig: AstroConfig): URL {
- return new URL('./', astroConfig.dist);
+ return new URL('./', astroConfig.outDir);
}
-export function getOutFolder(astroConfig: AstroConfig, pathname: string, routeType: RouteType): URL {
+export function getOutFolder(
+ astroConfig: AstroConfig,
+ pathname: string,
+ routeType: RouteType
+): URL {
const outRoot = getOutRoot(astroConfig);
// This is the root folder to write to.
@@ -16,7 +20,7 @@ export function getOutFolder(astroConfig: AstroConfig, pathname: string, routeTy
case 'endpoint':
return new URL('.' + appendForwardSlash(npath.dirname(pathname)), outRoot);
case 'page':
- switch (astroConfig.buildOptions.pageUrlFormat) {
+ switch (astroConfig.build.format) {
case 'directory': {
if (STATUS_CODE_PAGES.has(pathname)) {
return new URL('.' + appendForwardSlash(npath.dirname(pathname)), outRoot);
@@ -30,12 +34,17 @@ export function getOutFolder(astroConfig: AstroConfig, pathname: string, routeTy
}
}
-export function getOutFile(astroConfig: AstroConfig, outFolder: URL, pathname: string, routeType: RouteType): URL {
+export function getOutFile(
+ astroConfig: AstroConfig,
+ outFolder: URL,
+ pathname: string,
+ routeType: RouteType
+): URL {
switch (routeType) {
case 'endpoint':
return new URL(npath.basename(pathname), outFolder);
case 'page':
- switch (astroConfig.buildOptions.pageUrlFormat) {
+ switch (astroConfig.build.format) {
case 'directory': {
if (STATUS_CODE_PAGES.has(pathname)) {
const baseName = npath.basename(pathname);
diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts
index 5d0c70a41..909c0f65a 100644
--- a/packages/astro/src/core/build/generate.ts
+++ b/packages/astro/src/core/build/generate.ts
@@ -1,17 +1,26 @@
+import astroRemark from '@astrojs/markdown-remark';
import fs from 'fs';
-import { bgGreen, bgMagenta, black, cyan, dim, green, magenta } from 'kleur/colors';
+import { bgGreen, black, cyan, dim, green, magenta } from 'kleur/colors';
import npath from 'path';
import type { OutputAsset, OutputChunk, RollupOutput } from 'rollup';
import { fileURLToPath } from 'url';
-import type { AstroConfig, ComponentInstance, EndpointHandler, SSRLoadedRenderer } from '../../@types/astro';
+import type {
+ AstroConfig,
+ ComponentInstance,
+ EndpointHandler,
+ SSRLoadedRenderer,
+} from '../../@types/astro';
import type { BuildInternals } from '../../core/build/internal.js';
import { debug, info } from '../logger/core.js';
-import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
+import { prependForwardSlash } from '../../core/path.js';
import type { RenderOptions } from '../../core/render/core';
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import { call as callEndpoint } from '../endpoint/index.js';
import { render } from '../render/core.js';
-import { createLinkStylesheetElementSet, createModuleScriptElementWithSrcSet } from '../render/ssr-element.js';
+import {
+ createLinkStylesheetElementSet,
+ createModuleScriptElementWithSrcSet,
+} from '../render/ssr-element.js';
import { getOutputFilename, isBuildingToSSR } from '../util.js';
import { getOutFile, getOutFolder } from './common.js';
import { eachPageData, getPageDataByComponent } from './internal.js';
@@ -51,29 +60,40 @@ function* throttle(max: number, inPaths: string[]) {
// Gives back a facadeId that is relative to the root.
// ie, src/pages/index.astro instead of /Users/name..../src/pages/index.astro
export function rootRelativeFacadeId(facadeId: string, astroConfig: AstroConfig): string {
- return facadeId.slice(fileURLToPath(astroConfig.projectRoot).length);
+ return facadeId.slice(fileURLToPath(astroConfig.root).length);
}
// Determines of a Rollup chunk is an entrypoint page.
-export function chunkIsPage(astroConfig: AstroConfig, output: OutputAsset | OutputChunk, internals: BuildInternals) {
+export function chunkIsPage(
+ astroConfig: AstroConfig,
+ output: OutputAsset | OutputChunk,
+ internals: BuildInternals
+) {
if (output.type !== 'chunk') {
return false;
}
const chunk = output as OutputChunk;
if (chunk.facadeModuleId) {
- const facadeToEntryId = prependForwardSlash(rootRelativeFacadeId(chunk.facadeModuleId, astroConfig));
+ const facadeToEntryId = prependForwardSlash(
+ rootRelativeFacadeId(chunk.facadeModuleId, astroConfig)
+ );
return internals.entrySpecifierToBundleMap.has(facadeToEntryId);
}
return false;
}
-export async function generatePages(result: RollupOutput, opts: StaticBuildOptions, internals: BuildInternals, facadeIdToPageDataMap: Map<string, PageBuildData>) {
+export async function generatePages(
+ result: RollupOutput,
+ opts: StaticBuildOptions,
+ internals: BuildInternals,
+ facadeIdToPageDataMap: Map<string, PageBuildData>
+) {
const timer = performance.now();
info(opts.logging, null, `\n${bgGreen(black(' generating static routes '))}`);
const ssr = isBuildingToSSR(opts.astroConfig);
const serverEntry = opts.buildConfig.serverEntry;
- const outFolder = ssr ? opts.buildConfig.server : opts.astroConfig.dist;
+ const outFolder = ssr ? opts.buildConfig.server : opts.astroConfig.outDir;
const ssrEntryURL = new URL('./' + serverEntry + `?time=${Date.now()}`, outFolder);
const ssrEntry = await import(ssrEntryURL.toString());
@@ -100,7 +120,9 @@ async function generatePage(
const pageModule = ssrEntry.pageMap.get(pageData.component);
if (!pageModule) {
- throw new Error(`Unable to find the module for ${pageData.component}. This is unexpected and likely a bug in Astro, please report.`);
+ throw new Error(
+ `Unable to find the module for ${pageData.component}. This is unexpected and likely a bug in Astro, please report.`
+ );
}
const generationOptions: Readonly<GeneratePathOptions> = {
@@ -140,7 +162,11 @@ function addPageName(pathname: string, opts: StaticBuildOptions): void {
opts.pageNames.push(pathname.replace(/\/?$/, '/').replace(/^\//, ''));
}
-async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: GeneratePathOptions) {
+async function generatePath(
+ pathname: string,
+ opts: StaticBuildOptions,
+ gopts: GeneratePathOptions
+) {
const { astroConfig, logging, origin, routeCache } = opts;
const { mod, internals, linkIds, hoistedId, pageData, renderers } = gopts;
@@ -151,7 +177,7 @@ async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: G
debug('build', `Generating: ${pathname}`);
- const site = astroConfig.buildOptions.site;
+ const site = astroConfig.site;
const links = createLinkStylesheetElementSet(linkIds.reverse(), site);
const scripts = createModuleScriptElementWithSrcSet(hoistedId ? [hoistedId] : [], site);
@@ -170,7 +196,7 @@ async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: G
legacyBuild: false,
links,
logging,
- markdownRender: astroConfig.markdownOptions.render,
+ markdownRender: [astroRemark, astroConfig.markdown],
mod,
origin,
pathname,
@@ -196,7 +222,9 @@ async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: G
request: createRequest({ url, headers: new Headers(), logging }),
route: pageData.route,
routeCache,
- site: astroConfig.buildOptions.site,
+ site: astroConfig.site
+ ? new URL(astroConfig.base, astroConfig.site).toString()
+ : astroConfig.site,
ssr: isBuildingToSSR(opts.astroConfig),
};
diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts
index db876176a..ae6d9ff3e 100644
--- a/packages/astro/src/core/build/index.ts
+++ b/packages/astro/src/core/build/index.ts
@@ -7,15 +7,25 @@ import { apply as applyPolyfill } from '../polyfill.js';
import { performance } from 'perf_hooks';
import * as vite from 'vite';
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
-import { debug, info, levels, timerMessage, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
+import {
+ debug,
+ info,
+ levels,
+ timerMessage,
+ warn,
+ warnIfUsingExperimentalSSR,
+} from '../logger/core.js';
import { nodeLogOptions } from '../logger/node.js';
import { createRouteManifest } from '../routing/index.js';
-import { generateSitemap } from '../render/sitemap.js';
import { collectPagesData } from './page-data.js';
-import { build as scanBasedBuild } from './scan-based-build.js';
import { staticBuild } from './static-build.js';
import { RouteCache } from '../render/route-cache.js';
-import { runHookBuildDone, runHookBuildStart, runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js';
+import {
+ runHookBuildDone,
+ runHookBuildStart,
+ runHookConfigDone,
+ runHookConfigSetup,
+} from '../../integrations/index.js';
import { getTimeStat } from './util.js';
import { createSafeError, isBuildingToSSR } from '../util.js';
import { fixViteErrorMessage } from '../errors.js';
@@ -26,7 +36,10 @@ export interface BuildOptions {
}
/** `astro build` */
-export default async function build(config: AstroConfig, options: BuildOptions = { logging: nodeLogOptions }): Promise<void> {
+export default async function build(
+ config: AstroConfig,
+ options: BuildOptions = { logging: nodeLogOptions }
+): Promise<void> {
applyPolyfill();
const builder = new AstroBuilder(config, options);
await builder.run();
@@ -42,17 +55,15 @@ class AstroBuilder {
private timer: Record<string, number>;
constructor(config: AstroConfig, options: BuildOptions) {
- if (!config.buildOptions.site && config.buildOptions.sitemap !== false) {
- warn(options.logging, 'config', `Set "buildOptions.site" to generate correct canonical URLs and sitemap`);
- }
if (options.mode) {
this.mode = options.mode;
}
this.config = config;
- const port = config.devOptions.port; // no need to save this (don’t rely on port in builder)
this.logging = options.logging;
this.routeCache = new RouteCache(this.logging);
- this.origin = config.buildOptions.site ? new URL(config.buildOptions.site).origin : `http://localhost:${port}`;
+ this.origin = config.site
+ ? new URL(config.site).origin
+ : `http://localhost:${config.server.port}`;
this.manifest = createRouteManifest({ config }, this.logging);
this.timer = {};
}
@@ -82,11 +93,17 @@ class AstroBuilder {
}
/** Run the build logic. build() is marked private because usage should go through ".run()" */
- private async build({ viteConfig, viteServer }: { viteConfig: ViteConfigWithSSR; viteServer: vite.ViteDevServer }) {
+ private async build({
+ viteConfig,
+ viteServer,
+ }: {
+ viteConfig: ViteConfigWithSSR;
+ viteServer: vite.ViteDevServer;
+ }) {
const { origin } = this;
const buildConfig: BuildConfig = {
- client: new URL('./client/', this.config.dist),
- server: new URL('./server/', this.config.dist),
+ client: new URL('./client/', this.config.outDir),
+ server: new URL('./server/', this.config.outDir),
serverEntry: 'entry.mjs',
staticMode: undefined,
};
@@ -109,7 +126,7 @@ class AstroBuilder {
if ('frontmatter' in data.preload[1]) {
// TODO: add better type inference to data.preload[1]
const frontmatter = (data.preload[1] as any).frontmatter;
- if (Boolean(frontmatter.draft) && !this.config.buildOptions.drafts) {
+ if (Boolean(frontmatter.draft) && !this.config.markdown.drafts) {
debug('build', timerMessage(`Skipping draft page ${page}`, this.timer.loadStart));
delete allPages[page];
}
@@ -124,33 +141,23 @@ class AstroBuilder {
// Bundle the assets in your final build: This currently takes the HTML output
// of every page (stored in memory) and bundles the assets pointed to on those pages.
this.timer.buildStart = performance.now();
- info(this.logging, 'build', colors.dim(`Completed in ${getTimeStat(this.timer.init, performance.now())}.`));
+ info(
+ this.logging,
+ 'build',
+ colors.dim(`Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
+ );
- // Use the new faster static based build.
- if (!this.config.buildOptions.legacyBuild) {
- await staticBuild({
- allPages,
- astroConfig: this.config,
- logging: this.logging,
- manifest: this.manifest,
- origin: this.origin,
- pageNames,
- routeCache: this.routeCache,
- viteConfig,
- buildConfig,
- });
- } else {
- await scanBasedBuild({
- allPages,
- astroConfig: this.config,
- logging: this.logging,
- origin: this.origin,
- pageNames,
- routeCache: this.routeCache,
- viteConfig,
- viteServer,
- });
- }
+ await staticBuild({
+ allPages,
+ astroConfig: this.config,
+ logging: this.logging,
+ manifest: this.manifest,
+ origin: this.origin,
+ pageNames,
+ routeCache: this.routeCache,
+ viteConfig,
+ buildConfig,
+ });
// Write any additionally generated assets to disk.
this.timer.assetsStart = performance.now();
@@ -163,27 +170,22 @@ class AstroBuilder {
});
debug('build', timerMessage('Additional assets copied', this.timer.assetsStart));
- // Build your final sitemap.
- if (this.config.buildOptions.sitemap && this.config.buildOptions.site) {
- this.timer.sitemapStart = performance.now();
- const sitemapFilter = this.config.buildOptions.sitemapFilter ? (this.config.buildOptions.sitemapFilter as (page: string) => boolean) : undefined;
- const sitemap = generateSitemap(
- pageNames.map((pageName) => new URL(pageName, this.config.buildOptions.site).href),
- sitemapFilter
- );
- const sitemapPath = new URL('./sitemap.xml', this.config.dist);
- await fs.promises.mkdir(new URL('./', sitemapPath), { recursive: true });
- await fs.promises.writeFile(sitemapPath, sitemap, 'utf8');
- debug('build', timerMessage('Sitemap built', this.timer.sitemapStart));
- }
-
// You're done! Time to clean up.
await viteServer.close();
- await runHookBuildDone({ config: this.config, pages: pageNames, routes: Object.values(allPages).map((pd) => pd.route) });
+ await runHookBuildDone({
+ config: this.config,
+ pages: pageNames,
+ routes: Object.values(allPages).map((pd) => pd.route),
+ });
if (this.logging.level && levels[this.logging.level] <= levels['info']) {
const buildMode = isBuildingToSSR(this.config) ? 'ssr' : 'static';
- await this.printStats({ logging: this.logging, timeStart: this.timer.init, pageCount: pageNames.length, buildMode });
+ await this.printStats({
+ logging: this.logging,
+ timeStart: this.timer.init,
+ pageCount: pageNames.length,
+ buildMode,
+ });
}
}
@@ -199,7 +201,17 @@ class AstroBuilder {
}
/** Stats */
- private async printStats({ logging, timeStart, pageCount, buildMode }: { logging: LogOptions; timeStart: number; pageCount: number; buildMode: 'static' | 'ssr' }) {
+ private async printStats({
+ logging,
+ timeStart,
+ pageCount,
+ buildMode,
+ }: {
+ logging: LogOptions;
+ timeStart: number;
+ pageCount: number;
+ buildMode: 'static' | 'ssr';
+ }) {
const buildTime = performance.now() - timeStart;
const total = getTimeStat(timeStart, performance.now());
diff --git a/packages/astro/src/core/build/internal.ts b/packages/astro/src/core/build/internal.ts
index 674a657b6..d74722b1a 100644
--- a/packages/astro/src/core/build/internal.ts
+++ b/packages/astro/src/core/build/internal.ts
@@ -76,13 +76,22 @@ export function createBuildInternals(): BuildInternals {
};
}
-export function trackPageData(internals: BuildInternals, component: string, pageData: PageBuildData, componentModuleId: string, componentURL: URL): void {
+export function trackPageData(
+ internals: BuildInternals,
+ component: string,
+ pageData: PageBuildData,
+ componentModuleId: string,
+ componentURL: URL
+): void {
pageData.moduleSpecifier = componentModuleId;
internals.pagesByComponent.set(component, pageData);
internals.pagesByViteID.set(viteID(componentURL), pageData);
}
-export function* getPageDatasByChunk(internals: BuildInternals, chunk: RenderedChunk): Generator<PageBuildData, void, unknown> {
+export function* getPageDatasByChunk(
+ internals: BuildInternals,
+ chunk: RenderedChunk
+): Generator<PageBuildData, void, unknown> {
const pagesByViteID = internals.pagesByViteID;
for (const [modulePath] of Object.entries(chunk.modules)) {
if (pagesByViteID.has(modulePath)) {
@@ -91,14 +100,20 @@ export function* getPageDatasByChunk(internals: BuildInternals, chunk: RenderedC
}
}
-export function getPageDataByComponent(internals: BuildInternals, component: string): PageBuildData | undefined {
+export function getPageDataByComponent(
+ internals: BuildInternals,
+ component: string
+): PageBuildData | undefined {
if (internals.pagesByComponent.has(component)) {
return internals.pagesByComponent.get(component);
}
return undefined;
}
-export function getPageDataByViteID(internals: BuildInternals, viteid: ViteID): PageBuildData | undefined {
+export function getPageDataByViteID(
+ internals: BuildInternals,
+ viteid: ViteID
+): PageBuildData | undefined {
if (internals.pagesByViteID.has(viteid)) {
return internals.pagesByViteID.get(viteid);
}
diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts
index c84e29588..18823c462 100644
--- a/packages/astro/src/core/build/page-data.ts
+++ b/packages/astro/src/core/build/page-data.ts
@@ -28,7 +28,9 @@ export interface CollectPagesDataResult {
}
// Examines the routes and returns a collection of information about each page.
-export async function collectPagesData(opts: CollectPagesDataOptions): Promise<CollectPagesDataResult> {
+export async function collectPagesData(
+ opts: CollectPagesDataOptions
+): Promise<CollectPagesDataResult> {
const { astroConfig, logging, manifest, origin, routeCache, viteServer } = opts;
const assets: Record<string, string> = {};
@@ -68,14 +70,17 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
scripts: new Set(),
preload: await ssrPreload({
astroConfig,
- filePath: new URL(`./${route.component}`, astroConfig.projectRoot),
+ filePath: new URL(`./${route.component}`, astroConfig.root),
viteServer,
})
.then((routes) => {
clearInterval(routeCollectionLogTimeout);
if (buildMode === 'static') {
const html = `${route.pathname}`.replace(/\/?$/, '/index.html');
- debug('build', `├── ${colors.bold(colors.green('✔'))} ${route.component} → ${colors.yellow(html)}`);
+ debug(
+ 'build',
+ `├── ${colors.bold(colors.green('✔'))} ${route.component} → ${colors.yellow(html)}`
+ );
} else {
debug('build', `├── ${colors.bold(colors.green('✔'))} ${route.component}`);
}
@@ -93,29 +98,36 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
const result = await getStaticPathsForRoute(opts, route)
.then((_result) => {
const label = _result.staticPaths.length === 1 ? 'page' : 'pages';
- debug('build', `├── ${colors.bold(colors.green('✔'))} ${route.component} → ${colors.magenta(`[${_result.staticPaths.length} ${label}]`)}`);
+ debug(
+ 'build',
+ `├── ${colors.bold(colors.green('✔'))} ${route.component} → ${colors.magenta(
+ `[${_result.staticPaths.length} ${label}]`
+ )}`
+ );
return _result;
})
.catch((err) => {
debug('build', `├── ${colors.bold(colors.red('✗'))} ${route.component}`);
throw err;
});
- const rssFn = generateRssFunction(astroConfig.buildOptions.site, route);
+ const rssFn = generateRssFunction(astroConfig.site, route);
for (const rssCallArg of result.rss) {
const rssResult = rssFn(rssCallArg);
if (rssResult.xml) {
const { url, content } = rssResult.xml;
if (content) {
- const rssFile = new URL(url.replace(/^\/?/, './'), astroConfig.dist);
+ const rssFile = new URL(url.replace(/^\/?/, './'), astroConfig.outDir);
if (assets[fileURLToPath(rssFile)]) {
- throw new Error(`[getStaticPaths] RSS feed ${url} already exists.\nUse \`rss(data, {url: '...'})\` to choose a unique, custom URL. (${route.component})`);
+ throw new Error(
+ `[getStaticPaths] RSS feed ${url} already exists.\nUse \`rss(data, {url: '...'})\` to choose a unique, custom URL. (${route.component})`
+ );
}
assets[fileURLToPath(rssFile)] = content;
}
}
if (rssResult.xsl?.content) {
const { url, content } = rssResult.xsl;
- const stylesheetFile = new URL(url.replace(/^\/?/, './'), astroConfig.dist);
+ const stylesheetFile = new URL(url.replace(/^\/?/, './'), astroConfig.outDir);
if (assets[fileURLToPath(stylesheetFile)]) {
throw new Error(
`[getStaticPaths] RSS feed stylesheet ${url} already exists.\nUse \`rss(data, {stylesheet: '...'})\` to choose a unique, custom URL. (${route.component})`
@@ -124,7 +136,9 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
assets[fileURLToPath(stylesheetFile)] = content;
}
}
- const finalPaths = result.staticPaths.map((staticPath) => staticPath.params && route.generate(staticPath.params)).filter(Boolean);
+ const finalPaths = result.staticPaths
+ .map((staticPath) => staticPath.params && route.generate(staticPath.params))
+ .filter(Boolean);
allPages[route.component] = {
component: route.component,
route,
@@ -135,7 +149,7 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
scripts: new Set(),
preload: await ssrPreload({
astroConfig,
- filePath: new URL(`./${route.component}`, astroConfig.projectRoot),
+ filePath: new URL(`./${route.component}`, astroConfig.root),
viteServer,
}),
};
@@ -146,10 +160,13 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
return { assets, allPages };
}
-async function getStaticPathsForRoute(opts: CollectPagesDataOptions, route: RouteData): Promise<RouteCacheEntry> {
+async function getStaticPathsForRoute(
+ opts: CollectPagesDataOptions,
+ route: RouteData
+): Promise<RouteCacheEntry> {
const { astroConfig, logging, routeCache, ssr, viteServer } = opts;
if (!viteServer) throw new Error(`vite.createServer() not called!`);
- const filePath = new URL(`./${route.component}`, astroConfig.projectRoot);
+ const filePath = new URL(`./${route.component}`, astroConfig.root);
const mod = (await viteServer.ssrLoadModule(fileURLToPath(filePath))) as ComponentInstance;
const result = await callGetStaticPaths({ mod, route, isValidate: false, logging, ssr });
routeCache.set(route, result);
diff --git a/packages/astro/src/core/build/scan-based-build.ts b/packages/astro/src/core/build/scan-based-build.ts
deleted file mode 100644
index a4e9009e9..000000000
--- a/packages/astro/src/core/build/scan-based-build.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import type { ViteDevServer } from 'vite';
-import type { RollupOutput, RollupWatcher } from 'rollup';
-import type { AstroConfig, RouteType } from '../../@types/astro';
-import type { AllPagesData, PageBuildData } from './types';
-import type { LogOptions } from '../logger/core';
-import type { ViteConfigWithSSR } from '../create-vite.js';
-
-import { fileURLToPath } from 'url';
-import * as vite from 'vite';
-import { createBuildInternals } from '../../core/build/internal.js';
-import { rollupPluginAstroScanHTML } from '../../vite-plugin-build-html/index.js';
-import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
-import { RouteCache } from '../render/route-cache.js';
-
-export interface ScanBasedBuildOptions {
- allPages: AllPagesData;
- astroConfig: AstroConfig;
- logging: LogOptions;
- origin: string;
- pageNames: string[];
- routeCache: RouteCache;
- viteConfig: ViteConfigWithSSR;
- viteServer: ViteDevServer;
-}
-
-// Returns a filter predicate to filter AllPagesData entries by RouteType
-function entryIsType(type: RouteType) {
- return function withPage([_, pageData]: [string, PageBuildData]) {
- return pageData.route.type === type;
- };
-}
-
-// Reducer to combine AllPageData entries back into an object keyed by filepath
-function reduceEntries<U>(acc: { [key: string]: U }, [key, value]: [string, U]) {
- acc[key] = value;
- return acc;
-}
-
-// Filters an AllPagesData object to only include routes of a specific RouteType
-function routesOfType(type: RouteType, allPages: AllPagesData) {
- return Object.entries(allPages).filter(entryIsType(type)).reduce(reduceEntries, {});
-}
-
-export async function build(opts: ScanBasedBuildOptions): Promise<RollupOutput | RollupOutput[] | RollupWatcher> {
- const { allPages, astroConfig, logging, origin, pageNames, routeCache, viteConfig, viteServer } = opts;
-
- // Internal maps used to coordinate the HTML and CSS plugins.
- const internals = createBuildInternals();
-
- return await vite.build({
- logLevel: 'warn',
- mode: 'production',
- build: {
- emptyOutDir: true,
- minify: 'esbuild', // significantly faster than "terser" but may produce slightly-bigger bundles
- outDir: fileURLToPath(astroConfig.dist),
- rollupOptions: {
- // The `input` will be populated in the build rollup plugin.
- input: [],
- output: {
- format: 'esm',
- },
- },
- target: 'es2020', // must match an esbuild target
- },
- plugins: [
- rollupPluginAstroScanHTML({
- astroConfig,
- internals,
- logging,
- origin,
- allPages: routesOfType('page', allPages),
- pageNames,
- routeCache,
- viteServer,
- }),
- rollupPluginAstroBuildCSS({
- internals,
- legacy: true,
- }),
- ...(viteConfig.plugins || []),
- ],
- publicDir: viteConfig.publicDir,
- root: viteConfig.root,
- envPrefix: 'PUBLIC_',
- server: viteConfig.server,
- base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
- });
-}
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index afe41a01e..bddf4ceca 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -44,7 +44,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
timer.buildStart = performance.now();
for (const [component, pageData] of Object.entries(allPages)) {
- const astroModuleURL = new URL('./' + component, astroConfig.projectRoot);
+ const astroModuleURL = new URL('./' + component, astroConfig.root);
const astroModuleId = prependForwardSlash(component);
// Track the page data in internals
@@ -64,7 +64,9 @@ export async function staticBuild(opts: StaticBuildOptions) {
// Any hydration directive like astro/client/idle.js
...metadata.hydrationDirectiveSpecifiers(),
// The client path for each renderer
- ...renderers.filter((renderer) => !!renderer.clientEntrypoint).map((renderer) => renderer.clientEntrypoint!),
+ ...renderers
+ .filter((renderer) => !!renderer.clientEntrypoint)
+ .map((renderer) => renderer.clientEntrypoint!),
]);
// Add hoisted scripts
@@ -87,7 +89,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
// Empty out the dist folder, if needed. Vite has a config for doing this
// but because we are running 2 vite builds in parallel, that would cause a race
// condition, so we are doing it ourselves
- emptyDir(astroConfig.dist, new Set('.git'));
+ emptyDir(astroConfig.outDir, new Set('.git'));
timer.clientBuild = performance.now();
// Run client build first, so the assets can be fed into the SSR rendered version.
@@ -112,7 +114,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
const { astroConfig, viteConfig } = opts;
const ssr = isBuildingToSSR(astroConfig);
- const out = ssr ? opts.buildConfig.server : astroConfig.dist;
+ const out = ssr ? opts.buildConfig.server : astroConfig.outDir;
const viteBuildConfig = {
logLevel: 'error',
@@ -149,13 +151,14 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
}),
...(viteConfig.plugins || []),
// SSR needs to be last
- isBuildingToSSR(opts.astroConfig) && vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter!),
+ isBuildingToSSR(opts.astroConfig) &&
+ vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter!),
],
publicDir: ssr ? false : viteConfig.publicDir,
root: viteConfig.root,
envPrefix: 'PUBLIC_',
server: viteConfig.server,
- base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
+ base: astroConfig.site ? new URL(astroConfig.site).pathname : '/',
ssr: viteConfig.ssr,
resolve: viteConfig.resolve,
} as ViteConfigWithSSR;
@@ -166,17 +169,21 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
return await vite.build(viteBuildConfig);
}
-async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
+async function clientBuild(
+ opts: StaticBuildOptions,
+ internals: BuildInternals,
+ input: Set<string>
+) {
const { astroConfig, viteConfig } = opts;
const timer = performance.now();
const ssr = isBuildingToSSR(astroConfig);
- const out = ssr ? opts.buildConfig.client : astroConfig.dist;
+ const out = ssr ? opts.buildConfig.client : astroConfig.outDir;
// Nothing to do if there is no client-side JS.
if (!input.size) {
// If SSR, copy public over
if (ssr) {
- await copyFiles(astroConfig.public, out);
+ await copyFiles(astroConfig.publicDir, out);
}
return null;
@@ -218,7 +225,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
root: viteConfig.root,
envPrefix: 'PUBLIC_',
server: viteConfig.server,
- base: appendForwardSlash(astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/'),
+ base: astroConfig.base,
} as ViteConfigWithSSR;
await runHookBuildSetup({ config: astroConfig, vite: viteBuildConfig, target: 'client' });
@@ -231,11 +238,11 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
async function cleanSsrOutput(opts: StaticBuildOptions) {
// The SSR output is all .mjs files, the client output is not.
const files = await glob('**/*.mjs', {
- cwd: fileURLToPath(opts.astroConfig.dist),
+ cwd: fileURLToPath(opts.astroConfig.outDir),
});
await Promise.all(
files.map(async (filename) => {
- const url = new URL(filename, opts.astroConfig.dist);
+ const url = new URL(filename, opts.astroConfig.outDir);
await fs.promises.rm(url);
})
);
@@ -260,7 +267,9 @@ async function copyFiles(fromFolder: URL, toFolder: URL) {
async function ssrMoveAssets(opts: StaticBuildOptions) {
info(opts.logging, 'build', 'Rearranging server assets...');
- const serverRoot = opts.buildConfig.staticMode ? opts.buildConfig.client : opts.buildConfig.server;
+ const serverRoot = opts.buildConfig.staticMode
+ ? opts.buildConfig.client
+ : opts.buildConfig.server;
const clientRoot = opts.buildConfig.client;
const serverAssets = new URL('./assets/', serverRoot);
const clientAssets = new URL('./assets/', clientRoot);
diff --git a/packages/astro/src/core/build/types.d.ts b/packages/astro/src/core/build/types.d.ts
index 9bdab7582..30ea53901 100644
--- a/packages/astro/src/core/build/types.d.ts
+++ b/packages/astro/src/core/build/types.d.ts
@@ -1,5 +1,12 @@
import type { ComponentPreload } from '../render/dev/index';
-import type { AstroConfig, BuildConfig, ManifestData, RouteData, ComponentInstance, SSRLoadedRenderer } from '../../@types/astro';
+import type {
+ AstroConfig,
+ BuildConfig,
+ ManifestData,
+ RouteData,
+ ComponentInstance,
+ SSRLoadedRenderer,
+} from '../../@types/astro';
import type { ViteConfigWithSSR } from '../../create-vite';
import type { LogOptions } from '../../logger';
import type { RouteCache } from '../../render/route-cache.js';
diff --git a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
index 8f2480a63..a355fb282 100644
--- a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
+++ b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
@@ -8,7 +8,10 @@ function virtualHoistedEntry(id: string) {
return id.endsWith('.astro/hoisted.js') || id.endsWith('.md/hoisted.js');
}
-export function vitePluginHoistedScripts(astroConfig: AstroConfig, internals: BuildInternals): VitePlugin {
+export function vitePluginHoistedScripts(
+ astroConfig: AstroConfig,
+ internals: BuildInternals
+): VitePlugin {
return {
name: '@astro/rollup-plugin-astro-hoisted-scripts',
@@ -35,11 +38,15 @@ export function vitePluginHoistedScripts(astroConfig: AstroConfig, internals: Bu
// Find all page entry points and create a map of the entry point to the hashed hoisted script.
// This is used when we render so that we can add the script to the head.
for (const [id, output] of Object.entries(bundle)) {
- if (output.type === 'chunk' && output.facadeModuleId && virtualHoistedEntry(output.facadeModuleId)) {
+ if (
+ output.type === 'chunk' &&
+ output.facadeModuleId &&
+ virtualHoistedEntry(output.facadeModuleId)
+ ) {
const facadeId = output.facadeModuleId!;
const pathname = facadeId.slice(0, facadeId.length - '/hoisted.js'.length);
- const vid = viteID(new URL('.' + pathname, astroConfig.projectRoot));
+ const vid = viteID(new URL('.' + pathname, astroConfig.root));
const pageInfo = getPageDataByViteID(internals, vid);
if (pageInfo) {
pageInfo.hoistedScript = id;
diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts
index d56543232..93c53b99b 100644
--- a/packages/astro/src/core/build/vite-plugin-ssr.ts
+++ b/packages/astro/src/core/build/vite-plugin-ssr.ts
@@ -1,4 +1,4 @@
-import type { OutputBundle, OutputChunk } from 'rollup';
+import astroRemark from '@astrojs/markdown-remark';
import type { Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from './internal.js';
import type { AstroAdapter } from '../../@types/astro';
@@ -15,7 +15,11 @@ export const virtualModuleId = '@astrojs-ssr-virtual-entry';
const resolvedVirtualModuleId = '\0' + virtualModuleId;
const manifestReplace = '@@ASTRO_MANIFEST_REPLACE@@';
-export function vitePluginSSR(buildOpts: StaticBuildOptions, internals: BuildInternals, adapter: AstroAdapter): VitePlugin {
+export function vitePluginSSR(
+ buildOpts: StaticBuildOptions,
+ internals: BuildInternals,
+ adapter: AstroAdapter
+): VitePlugin {
return {
name: '@astrojs/vite-plugin-astro-ssr',
enforce: 'post',
@@ -92,13 +96,14 @@ function buildManifest(opts: StaticBuildOptions, internals: BuildInternals): Ser
// HACK! Patch this special one.
const entryModules = Object.fromEntries(internals.entrySpecifierToBundleMap.entries());
- entryModules[BEFORE_HYDRATION_SCRIPT_ID] = 'data:text/javascript;charset=utf-8,//[no before-hydration script]';
+ entryModules[BEFORE_HYDRATION_SCRIPT_ID] =
+ 'data:text/javascript;charset=utf-8,//[no before-hydration script]';
const ssrManifest: SerializedSSRManifest = {
routes,
- site: astroConfig.buildOptions.site,
+ site: astroConfig.site,
markdown: {
- render: astroConfig.markdownOptions.render,
+ render: [astroRemark, astroConfig.markdown],
},
pageMap: null as any,
renderers: [],
diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts
index 97b467e9d..547e64fa8 100644
--- a/packages/astro/src/core/config.ts
+++ b/packages/astro/src/core/config.ts
@@ -11,6 +11,7 @@ import load from '@proload/core';
import loadTypeScript from '@proload/plugin-tsm';
import postcssrc from 'postcss-load-config';
import { arraify, isObject } from './util.js';
+import { appendForwardSlash, trimSlashes } from './path.js';
load.use([loadTypeScript]);
@@ -43,40 +44,91 @@ async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<Post
}
}
+export const LEGACY_ASTRO_CONFIG_KEYS = new Set([
+ 'projectRoot',
+ 'src',
+ 'pages',
+ 'public',
+ 'dist',
+ 'styleOptions',
+ 'markdownOptions',
+ 'buildOptions',
+ 'devOptions',
+ 'experimentalIntegrations',
+]);
+
export const AstroConfigSchema = z.object({
- projectRoot: z
+ adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
+ root: z
.string()
.optional()
.default('.')
.transform((val) => new URL(val)),
- src: z
+ srcDir: z
.string()
.optional()
.default('./src')
.transform((val) => new URL(val)),
- pages: z
- .string()
- .optional()
- .default('./src/pages')
- .transform((val) => new URL(val)),
- public: z
+ publicDir: z
.string()
.optional()
.default('./public')
.transform((val) => new URL(val)),
- dist: z
+ outDir: z
.string()
.optional()
.default('./dist')
.transform((val) => new URL(val)),
+ site: z
+ .string()
+ .url()
+ .optional()
+ .transform((val) => (val ? appendForwardSlash(val) : val))
+ .refine((val) => !val || new URL(val).pathname.length <= 1, {
+ message:
+ '"site" must be a valid URL origin (ex: "https://example.com") but cannot contain a URL path (ex: "https://example.com/blog"). Use "base" to configure your deployed URL path',
+ }),
+ base: z
+ .string()
+ .optional()
+ .default('./')
+ .transform((val) => (val ? appendForwardSlash(trimSlashes(val)) : val)),
+ trailingSlash: z
+ .union([z.literal('always'), z.literal('never'), z.literal('ignore')])
+ .optional()
+ .default('ignore'),
+ build: z
+ .object({
+ format: z
+ .union([z.literal('file'), z.literal('directory')])
+ .optional()
+ .default('directory'),
+ })
+ .optional()
+ .default({}),
+ server: z.preprocess(
+ // preprocess
+ // NOTE: Uses the "error" command here because this is overwritten by the
+ // individualized schema parser with the correct command.
+ (val) => (typeof val === 'function' ? val({ command: 'error' }) : val),
+ // validate
+ z
+ .object({
+ host: z.union([z.string(), z.boolean()]).optional().default(false),
+ port: z.number().optional().default(3000),
+ })
+ .optional()
+ .default({})
+ ),
integrations: z.preprocess(
// preprocess
(val) => (Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val),
// validate
- z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default([])
+ z
+ .array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }))
+ .default([])
),
- adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
- styleOptions: z
+ style: z
.object({
postcss: z
.object({
@@ -88,50 +140,41 @@ export const AstroConfigSchema = z.object({
})
.optional()
.default({}),
- markdownOptions: z
+ markdown: z
.object({
- render: z.any().optional().default(['@astrojs/markdown-remark', {}]),
- })
- .strict()
- .optional()
- .default({}),
- buildOptions: z
- .object({
- site: z
- .string()
+ drafts: z.boolean().optional().default(false),
+ mode: z
+ .union([z.literal('md'), z.literal('mdx')])
.optional()
- .transform((val) => (val ? addTrailingSlash(val) : val)),
- sitemapFilter: z.function().optional(),
- sitemap: z.boolean().optional().default(true),
- pageUrlFormat: z
- .union([z.literal('file'), z.literal('directory')])
+ .default('md'),
+ syntaxHighlight: z
+ .union([z.literal('shiki'), z.literal('prism'), z.literal(false)])
.optional()
- .default('directory'),
- legacyBuild: z.boolean().optional().default(false),
- experimentalStaticBuild: z.boolean().optional().default(true),
- experimentalSsr: z.boolean().optional().default(false),
- drafts: z.boolean().optional().default(false),
+ .default('shiki'),
+ // TODO: add better type checking
+ shikiConfig: z.any().optional().default({}),
+ remarkPlugins: z.array(z.any()).optional().default([]),
+ rehypePlugins: z.array(z.any()).optional().default([]),
})
+ .passthrough()
.optional()
.default({}),
- devOptions: z
+ vite: z.any().optional().default({}),
+ experimental: z
.object({
- host: z.union([z.string(), z.boolean()]).optional().default(false),
- hostname: z.string().optional().default('localhost'),
- port: z.number().optional().default(3000),
- trailingSlash: z
- .union([z.literal('always'), z.literal('never'), z.literal('ignore')])
- .optional()
- .default('ignore'),
+ ssr: z.boolean().optional().default(false),
+ integrations: z.boolean().optional().default(false),
})
.optional()
.default({}),
- experimentalIntegrations: z.boolean().optional().default(false),
- vite: z.any().optional().default({}), // TODO: we don’t need validation, but can we get better type inference?
});
/** Turn raw config values into normalized values */
-export async function validateConfig(userConfig: any, root: string): Promise<AstroConfig> {
+export async function validateConfig(
+ userConfig: any,
+ root: string,
+ cmd: string
+): Promise<AstroConfig> {
const fileProtocolRoot = pathToFileURL(root + path.sep);
// Manual deprecation checks
/* eslint-disable no-console */
@@ -139,8 +182,12 @@ export async function validateConfig(userConfig: any, root: string): Promise<Ast
console.error('Astro "renderers" are now "integrations"!');
console.error('Update your configuration and install new dependencies:');
try {
- const rendererKeywords = userConfig.renderers.map((r: string) => r.replace('@astrojs/renderer-', ''));
- const rendererImports = rendererKeywords.map((r: string) => ` import ${r} from '@astrojs/${r === 'solid' ? 'solid-js' : r}';`).join('\n');
+ const rendererKeywords = userConfig.renderers.map((r: string) =>
+ r.replace('@astrojs/renderer-', '')
+ );
+ const rendererImports = rendererKeywords
+ .map((r: string) => ` import ${r} from '@astrojs/${r === 'solid' ? 'solid-js' : r}';`)
+ .join('\n');
const rendererIntegrations = rendererKeywords.map((r: string) => ` ${r}(),`).join('\n');
console.error('');
console.error(colors.dim(' // astro.config.js'));
@@ -162,32 +209,54 @@ export async function validateConfig(userConfig: any, root: string): Promise<Ast
}
process.exit(1);
}
+
+ let oldConfig = false;
+ for (const key of Object.keys(userConfig)) {
+ if (LEGACY_ASTRO_CONFIG_KEYS.has(key)) {
+ oldConfig = true;
+ break;
+ }
+ }
+ if (oldConfig) {
+ throw new Error(
+ `Legacy configuration detected. Please update your configuration to the new format!\nSee https://astro.build/config for more information.`
+ );
+ }
/* eslint-enable no-console */
// We need to extend the global schema to add transforms that are relative to root.
// This is type checked against the global schema to make sure we still match.
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
- projectRoot: z
+ root: z
.string()
.default('.')
- .transform((val) => new URL(addTrailingSlash(val), fileProtocolRoot)),
- src: z
+ .transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
+ srcDir: z
.string()
.default('./src')
- .transform((val) => new URL(addTrailingSlash(val), fileProtocolRoot)),
- pages: z
- .string()
- .default('./src/pages')
- .transform((val) => new URL(addTrailingSlash(val), fileProtocolRoot)),
- public: z
+ .transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
+ publicDir: z
.string()
.default('./public')
- .transform((val) => new URL(addTrailingSlash(val), fileProtocolRoot)),
- dist: z
+ .transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
+ outDir: z
.string()
.default('./dist')
- .transform((val) => new URL(addTrailingSlash(val), fileProtocolRoot)),
- styleOptions: z
+ .transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
+ server: z.preprocess(
+ // preprocess
+ (val) =>
+ typeof val === 'function' ? val({ command: cmd === 'dev' ? 'dev' : 'preview' }) : val,
+ // validate
+ z
+ .object({
+ host: z.union([z.string(), z.boolean()]).optional().default(false),
+ port: z.number().optional().default(3000),
+ })
+ .optional()
+ .default({})
+ ),
+ style: z
.object({
postcss: z.preprocess(
(val) => resolvePostcssConfig(val, fileProtocolRoot),
@@ -209,7 +278,10 @@ export async function validateConfig(userConfig: any, root: string): Promise<Ast
_ctx: { scripts: [], renderers: [], adapter: undefined },
};
// Final-Pass Validation (perform checks that require the full config object)
- if (!result.experimentalIntegrations && !result.integrations.every((int) => int.name.startsWith('@astrojs/'))) {
+ if (
+ !result.experimental?.integrations &&
+ !result.integrations.every((int) => int.name.startsWith('@astrojs/'))
+ ) {
throw new Error(
[
`Astro integrations are still experimental.`,
@@ -225,51 +297,51 @@ export async function validateConfig(userConfig: any, root: string): Promise<Ast
return result;
}
-/** Adds '/' to end of string but doesn’t double-up */
-function addTrailingSlash(str: string): string {
- return str.replace(/\/*$/, '/');
-}
-
/** Convert the generic "yargs" flag object into our own, custom TypeScript object. */
function resolveFlags(flags: Partial<Flags>): CLIFlags {
- if (flags.experimentalStaticBuild) {
- // eslint-disable-next-line no-console
- console.warn(`Passing --experimental-static-build is no longer necessary and is now the default. The flag will be removed in a future version of Astro.`);
- }
return {
- projectRoot: typeof flags.projectRoot === 'string' ? flags.projectRoot : undefined,
+ root: typeof flags.root === 'string' ? flags.root : undefined,
site: typeof flags.site === 'string' ? flags.site : undefined,
- sitemap: typeof flags.sitemap === 'boolean' ? flags.sitemap : undefined,
port: typeof flags.port === 'number' ? flags.port : undefined,
config: typeof flags.config === 'string' ? flags.config : undefined,
- hostname: typeof flags.hostname === 'string' ? flags.hostname : undefined,
- host: typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
- legacyBuild: typeof flags.legacyBuild === 'boolean' ? flags.legacyBuild : false,
+ host:
+ typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
experimentalSsr: typeof flags.experimentalSsr === 'boolean' ? flags.experimentalSsr : false,
- experimentalIntegrations: typeof flags.experimentalIntegrations === 'boolean' ? flags.experimentalIntegrations : false,
+ experimentalIntegrations:
+ typeof flags.experimentalIntegrations === 'boolean' ? flags.experimentalIntegrations : false,
drafts: typeof flags.drafts === 'boolean' ? flags.drafts : false,
};
}
/** Merge CLI flags & user config object (CLI flags take priority) */
-function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags) {
- astroConfig.buildOptions = astroConfig.buildOptions || {};
- astroConfig.devOptions = astroConfig.devOptions || {};
- if (typeof flags.sitemap === 'boolean') astroConfig.buildOptions.sitemap = flags.sitemap;
- if (typeof flags.site === 'string') astroConfig.buildOptions.site = flags.site;
- if (typeof flags.port === 'number') astroConfig.devOptions.port = flags.port;
- if (typeof flags.host === 'string' || typeof flags.host === 'boolean') astroConfig.devOptions.host = flags.host;
- if (typeof flags.hostname === 'string') astroConfig.devOptions.hostname = flags.hostname;
- if (typeof flags.legacyBuild === 'boolean') astroConfig.buildOptions.legacyBuild = flags.legacyBuild;
- if (typeof flags.experimentalSsr === 'boolean') astroConfig.buildOptions.experimentalSsr = flags.experimentalSsr;
- if (typeof flags.experimentalIntegrations === 'boolean') astroConfig.experimentalIntegrations = flags.experimentalIntegrations;
- if (typeof flags.drafts === 'boolean') astroConfig.buildOptions.drafts = flags.drafts;
+function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags, cmd: string) {
+ astroConfig.server = astroConfig.server || {};
+ astroConfig.experimental = astroConfig.experimental || {};
+ astroConfig.markdown = astroConfig.markdown || {};
+ if (typeof flags.site === 'string') astroConfig.site = flags.site;
+ if (typeof flags.experimentalSsr === 'boolean')
+ astroConfig.experimental.ssr = flags.experimentalSsr;
+ if (typeof flags.experimentalIntegrations === 'boolean')
+ astroConfig.experimental.integrations = flags.experimentalIntegrations;
+ if (typeof flags.drafts === 'boolean') astroConfig.markdown.drafts = flags.drafts;
+ if (typeof flags.port === 'number') {
+ // @ts-expect-error astroConfig.server may be a function, but TS doesn't like attaching properties to a function.
+ // TODO: Come back here and refactor to remove this expected error.
+ astroConfig.server.port = flags.port;
+ }
+ if (typeof flags.host === 'string' || typeof flags.host === 'boolean') {
+ // @ts-expect-error astroConfig.server may be a function, but TS doesn't like attaching properties to a function.
+ // TODO: Come back here and refactor to remove this expected error.
+ astroConfig.server.host = flags.host;
+ }
return astroConfig;
}
interface LoadConfigOptions {
cwd?: string;
flags?: Flags;
+ cmd: string;
+ validate?: boolean;
}
/**
@@ -277,7 +349,9 @@ interface LoadConfigOptions {
* Note: currently the same as loadConfig but only returns the `filePath`
* instead of the resolved config
*/
-export async function resolveConfigURL(configOptions: LoadConfigOptions): Promise<URL | undefined> {
+export async function resolveConfigURL(
+ configOptions: Pick<LoadConfigOptions, 'cwd' | 'flags'>
+): Promise<URL | undefined> {
const root = configOptions.cwd ? path.resolve(configOptions.cwd) : process.cwd();
const flags = resolveFlags(configOptions.flags || {});
let userConfigPath: string | undefined;
@@ -311,18 +385,27 @@ export async function loadConfig(configOptions: LoadConfigOptions): Promise<Astr
if (config) {
userConfig = config.value;
}
- return resolveConfig(userConfig, root, flags);
+ return resolveConfig(userConfig, root, flags, configOptions.cmd);
}
/** Attempt to resolve an Astro configuration object. Normalize, validate, and return. */
-export async function resolveConfig(userConfig: AstroUserConfig, root: string, flags: CLIFlags = {}): Promise<AstroConfig> {
- const mergedConfig = mergeCLIFlags(userConfig, flags);
- const validatedConfig = await validateConfig(mergedConfig, root);
+export async function resolveConfig(
+ userConfig: AstroUserConfig,
+ root: string,
+ flags: CLIFlags = {},
+ cmd: string
+): Promise<AstroConfig> {
+ const mergedConfig = mergeCLIFlags(userConfig, flags, cmd);
+ const validatedConfig = await validateConfig(mergedConfig, root, cmd);
return validatedConfig;
}
-function mergeConfigRecursively(defaults: Record<string, any>, overrides: Record<string, any>, rootPath: string) {
+function mergeConfigRecursively(
+ defaults: Record<string, any>,
+ overrides: Record<string, any>,
+ rootPath: string
+) {
const merged: Record<string, any> = { ...defaults };
for (const key in overrides) {
const value = overrides[key];
@@ -357,6 +440,10 @@ function mergeConfigRecursively(defaults: Record<string, any>, overrides: Record
return merged;
}
-export function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot = true): Record<string, any> {
+export function mergeConfig(
+ defaults: Record<string, any>,
+ overrides: Record<string, any>,
+ isRoot = true
+): Record<string, any> {
return mergeConfigRecursively(defaults, overrides, isRoot ? '' : '.');
}
diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts
index 8564290e2..982421043 100644
--- a/packages/astro/src/core/create-vite.ts
+++ b/packages/astro/src/core/create-vite.ts
@@ -43,12 +43,15 @@ interface CreateViteOptions {
}
/** Return a common starting point for all Vite actions */
-export async function createVite(commandConfig: ViteConfigWithSSR, { astroConfig, logging, mode }: CreateViteOptions): Promise<ViteConfigWithSSR> {
+export async function createVite(
+ commandConfig: ViteConfigWithSSR,
+ { astroConfig, logging, mode }: CreateViteOptions
+): Promise<ViteConfigWithSSR> {
// Scan for any third-party Astro packages. Vite needs these to be passed to `ssr.noExternal`.
const astroPackages = await getAstroPackages(astroConfig);
// Start with the Vite configuration that Astro core needs
const commonConfig: ViteConfigWithSSR = {
- cacheDir: fileURLToPath(new URL('./node_modules/.vite/', astroConfig.projectRoot)), // using local caches allows Astro to be used in monorepos, etc.
+ cacheDir: fileURLToPath(new URL('./node_modules/.vite/', astroConfig.root)), // using local caches allows Astro to be used in monorepos, etc.
clearScreen: false, // we want to control the output, not Vite
logLevel: 'warn', // log warnings and errors only
optimizeDeps: {
@@ -67,19 +70,22 @@ export async function createVite(commandConfig: ViteConfigWithSSR, { astroConfig
astroPostprocessVitePlugin({ config: astroConfig }),
astroIntegrationsContainerPlugin({ config: astroConfig }),
],
- publicDir: fileURLToPath(astroConfig.public),
- root: fileURLToPath(astroConfig.projectRoot),
+ publicDir: fileURLToPath(astroConfig.publicDir),
+ root: fileURLToPath(astroConfig.root),
envPrefix: 'PUBLIC_',
server: {
force: true, // force dependency rebuild (TODO: enabled only while next is unstable; eventually only call in "production" mode?)
- hmr: process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'production' ? false : undefined, // disable HMR for test
+ hmr:
+ process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'production'
+ ? false
+ : undefined, // disable HMR for test
// handle Vite URLs
proxy: {
// add proxies here
},
},
css: {
- postcss: astroConfig.styleOptions.postcss || {},
+ postcss: astroConfig.style.postcss || {},
},
resolve: {
alias: {
@@ -109,8 +115,8 @@ export async function createVite(commandConfig: ViteConfigWithSSR, { astroConfig
// Scans `projectRoot` for third-party Astro packages that could export an `.astro` file
// `.astro` files need to be built by Vite, so these should use `noExternal`
-async function getAstroPackages({ projectRoot }: AstroConfig): Promise<string[]> {
- const pkgUrl = new URL('./package.json', projectRoot);
+async function getAstroPackages({ root }: AstroConfig): Promise<string[]> {
+ const pkgUrl = new URL('./package.json', root);
const pkgPath = fileURLToPath(pkgUrl);
if (!fs.existsSync(pkgPath)) return [];
@@ -123,11 +129,15 @@ async function getAstroPackages({ projectRoot }: AstroConfig): Promise<string[]>
if (isCommonNotAstro(dep)) return false;
// Attempt: package is named `astro-something`. ✅ Likely a community package
if (/^astro\-/.test(dep)) return true;
- const depPkgUrl = new URL(`./node_modules/${dep}/package.json`, projectRoot);
+ const depPkgUrl = new URL(`./node_modules/${dep}/package.json`, root);
const depPkgPath = fileURLToPath(depPkgUrl);
if (!fs.existsSync(depPkgPath)) return false;
- const { dependencies = {}, peerDependencies = {}, keywords = [] } = JSON.parse(fs.readFileSync(depPkgPath, 'utf-8'));
+ const {
+ dependencies = {},
+ peerDependencies = {},
+ keywords = [],
+ } = JSON.parse(fs.readFileSync(depPkgPath, 'utf-8'));
// Attempt: package relies on `astro`. ✅ Definitely an Astro package
if (peerDependencies.astro || dependencies.astro) return true;
// Attempt: package is tagged with `astro` or `astro-component`. ✅ Likely a community package
@@ -181,7 +191,10 @@ function isCommonNotAstro(dep: string): boolean {
return (
COMMON_DEPENDENCIES_NOT_ASTRO.includes(dep) ||
COMMON_PREFIXES_NOT_ASTRO.some(
- (prefix) => (prefix.startsWith('@') ? dep.startsWith(prefix) : dep.substring(dep.lastIndexOf('/') + 1).startsWith(prefix)) // check prefix omitting @scope/
+ (prefix) =>
+ prefix.startsWith('@')
+ ? dep.startsWith(prefix)
+ : dep.substring(dep.lastIndexOf('/') + 1).startsWith(prefix) // check prefix omitting @scope/
)
);
}
diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts
index dcb4a333b..a1e7e528c 100644
--- a/packages/astro/src/core/dev/index.ts
+++ b/packages/astro/src/core/dev/index.ts
@@ -2,13 +2,18 @@ import type { AddressInfo } from 'net';
import { performance } from 'perf_hooks';
import * as vite from 'vite';
import type { AstroConfig } from '../../@types/astro';
-import { runHookConfigDone, runHookConfigSetup, runHookServerDone, runHookServerSetup, runHookServerStart } from '../../integrations/index.js';
+import {
+ runHookConfigDone,
+ runHookConfigSetup,
+ runHookServerDone,
+ runHookServerSetup,
+ runHookServerStart,
+} from '../../integrations/index.js';
import { createVite } from '../create-vite.js';
import { info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
import { nodeLogOptions } from '../logger/node.js';
import * as msg from '../messages.js';
import { apply as applyPolyfill } from '../polyfill.js';
-import { getResolvedHostForVite } from '../util.js';
export interface DevOptions {
logging: LogOptions;
@@ -20,15 +25,18 @@ export interface DevServer {
}
/** `astro dev` */
-export default async function dev(config: AstroConfig, options: DevOptions = { logging: nodeLogOptions }): Promise<DevServer> {
+export default async function dev(
+ config: AstroConfig,
+ options: DevOptions = { logging: nodeLogOptions }
+): Promise<DevServer> {
const devStart = performance.now();
applyPolyfill();
config = await runHookConfigSetup({ config, command: 'dev' });
+ const { host, port } = config.server;
const viteConfig = await createVite(
{
mode: 'development',
- // TODO: remove call once --hostname is baselined
- server: { host: getResolvedHostForVite(config) },
+ server: { host },
},
{ astroConfig: config, logging: options.logging, mode: 'dev' }
);
@@ -36,11 +44,21 @@ export default async function dev(config: AstroConfig, options: DevOptions = { l
warnIfUsingExperimentalSSR(options.logging, config);
const viteServer = await vite.createServer(viteConfig);
runHookServerSetup({ config, server: viteServer });
- await viteServer.listen(config.devOptions.port);
+ await viteServer.listen(port);
const devServerAddressInfo = viteServer.httpServer!.address() as AddressInfo;
- const site = config.buildOptions.site ? new URL(config.buildOptions.site) : undefined;
- info(options.logging, null, msg.devStart({ startupTime: performance.now() - devStart, config, devServerAddressInfo, site, https: !!viteConfig.server?.https }));
+ const site = config.site ? new URL(config.base, config.site) : undefined;
+ info(
+ options.logging,
+ null,
+ msg.devStart({
+ startupTime: performance.now() - devStart,
+ config,
+ devServerAddressInfo,
+ site,
+ https: !!viteConfig.server?.https,
+ })
+ );
const currentVersion = process.env.PACKAGE_VERSION ?? '0.0.0';
if (currentVersion.includes('-')) {
diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts
index 8f59faad6..de51be2c4 100644
--- a/packages/astro/src/core/endpoint/index.ts
+++ b/packages/astro/src/core/endpoint/index.ts
@@ -3,7 +3,10 @@ import type { RenderOptions } from '../render/core';
import { renderEndpoint } from '../../runtime/server/index.js';
import { getParamsAndProps, GetParamsAndPropsError } from '../render/core.js';
-export type EndpointOptions = Pick<RenderOptions, 'logging' | 'origin' | 'request' | 'route' | 'routeCache' | 'pathname' | 'route' | 'site' | 'ssr'>;
+export type EndpointOptions = Pick<
+ RenderOptions,
+ 'logging' | 'origin' | 'request' | 'route' | 'routeCache' | 'pathname' | 'route' | 'site' | 'ssr'
+>;
type EndpointCallResult =
| {
@@ -15,11 +18,16 @@ type EndpointCallResult =
response: Response;
};
-export async function call(mod: EndpointHandler, opts: EndpointOptions): Promise<EndpointCallResult> {
+export async function call(
+ mod: EndpointHandler,
+ opts: EndpointOptions
+): Promise<EndpointCallResult> {
const paramsAndPropsResp = await getParamsAndProps({ ...opts, mod: mod as any });
if (paramsAndPropsResp === GetParamsAndPropsError.NoMatchingStaticPath) {
- throw new Error(`[getStaticPath] route pattern matched, but no matching static path found. (${opts.pathname})`);
+ throw new Error(
+ `[getStaticPath] route pattern matched, but no matching static path found. (${opts.pathname})`
+ );
}
const [params] = paramsAndPropsResp;
diff --git a/packages/astro/src/core/logger/core.ts b/packages/astro/src/core/logger/core.ts
index 0ac93e59b..834305856 100644
--- a/packages/astro/src/core/logger/core.ts
+++ b/packages/astro/src/core/logger/core.ts
@@ -47,7 +47,12 @@ export const levels: Record<LoggerLevel, number> = {
};
/** Full logging API */
-export function log(opts: LogOptions, level: LoggerLevel, type: string | null, ...args: Array<any>) {
+export function log(
+ opts: LogOptions,
+ level: LoggerLevel,
+ type: string | null,
+ ...args: Array<any>
+) {
const logLevel = opts.level;
const dest = opts.dest;
const event: LogMessage = {
@@ -120,7 +125,8 @@ if (typeof process !== 'undefined') {
/** Print out a timer message for debug() */
export function timerMessage(message: string, startTime: number = Date.now()) {
let timeDiff = Date.now() - startTime;
- let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
+ let timeDisplay =
+ timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
return `${message} ${dim(timeDisplay)}`;
}
diff --git a/packages/astro/src/core/logger/node.ts b/packages/astro/src/core/logger/node.ts
index f83483859..bd6fecf28 100644
--- a/packages/astro/src/core/logger/node.ts
+++ b/packages/astro/src/core/logger/node.ts
@@ -127,5 +127,8 @@ export const logger = {
export function enableVerboseLogging() {
//debugPackage.enable('*,-babel');
debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"');
- debug('cli', 'Tip: Set the DEBUG env variable directly for more control. Example: "DEBUG=astro:*,vite:* astro build".');
+ debug(
+ 'cli',
+ 'Tip: Set the DEBUG env variable directly for more control. Example: "DEBUG=astro:*,vite:* astro build".'
+ );
}
diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts
index 888e6fcf4..fdec71396 100644
--- a/packages/astro/src/core/messages.ts
+++ b/packages/astro/src/core/messages.ts
@@ -2,24 +2,47 @@
* Dev server messages (organized here to prevent clutter)
*/
-import { bold, dim, red, green, underline, yellow, bgYellow, cyan, bgGreen, black, bgRed, bgWhite } from 'kleur/colors';
+import {
+ bold,
+ dim,
+ red,
+ green,
+ underline,
+ yellow,
+ bgYellow,
+ cyan,
+ bgGreen,
+ black,
+ bgRed,
+ bgWhite,
+} from 'kleur/colors';
import os from 'os';
import type { AddressInfo } from 'net';
import type { AstroConfig } from '../@types/astro';
import { collectErrorMetadata, cleanErrorStack } from './errors.js';
import { ZodError } from 'zod';
-import { emoji, getLocalAddress, getResolvedHostForVite, padMultilineString } from './util.js';
+import { emoji, getLocalAddress, padMultilineString } from './util.js';
const PREFIX_PADDING = 6;
/** Display */
-export function req({ url, statusCode, reqTime }: { url: string; statusCode: number; reqTime?: number }): string {
+export function req({
+ url,
+ statusCode,
+ reqTime,
+}: {
+ url: string;
+ statusCode: number;
+ reqTime?: number;
+}): string {
let color = dim;
if (statusCode >= 500) color = red;
else if (statusCode >= 400) color = yellow;
else if (statusCode >= 300) color = dim;
else if (statusCode >= 200) color = green;
- return `${bold(color(`${statusCode}`.padStart(PREFIX_PADDING)))} ${url.padStart(40)} ${reqTime ? dim(Math.round(reqTime) + 'ms') : ''}`.trim();
+ return `${bold(color(`${statusCode}`.padStart(PREFIX_PADDING)))} ${url.padStart(40)} ${
+ reqTime ? dim(Math.round(reqTime) + 'ms') : ''
+ }`.trim();
}
export function reload({ file }: { file: string }): string {
@@ -51,19 +74,25 @@ export function devStart({
const networkPrefix = `${dim('┃')} Network `;
const { address: networkAddress, port } = devServerAddressInfo;
- const localAddress = getLocalAddress(networkAddress, config);
- const networkLogging = getNetworkLogging(config);
- const toDisplayUrl = (hostname: string) => `${https ? 'https' : 'http'}://${hostname}:${port}${rootPath}`;
+ const localAddress = getLocalAddress(networkAddress, config.server.host);
+ const networkLogging = getNetworkLogging(config.server.host);
+ const toDisplayUrl = (hostname: string) =>
+ `${https ? 'https' : 'http'}://${hostname}:${port}${rootPath}`;
let addresses = [];
if (networkLogging === 'none') {
addresses = [`${localPrefix}${bold(cyan(toDisplayUrl(localAddress)))}`];
} else if (networkLogging === 'host-to-expose') {
- addresses = [`${localPrefix}${bold(cyan(toDisplayUrl(localAddress)))}`, `${networkPrefix}${dim('use --host to expose')}`];
+ addresses = [
+ `${localPrefix}${bold(cyan(toDisplayUrl(localAddress)))}`,
+ `${networkPrefix}${dim('use --host to expose')}`,
+ ];
} else {
addresses = Object.values(os.networkInterfaces())
.flatMap((networkInterface) => networkInterface ?? [])
- .filter((networkInterface) => networkInterface?.address && networkInterface?.family === 'IPv4')
+ .filter(
+ (networkInterface) => networkInterface?.address && networkInterface?.family === 'IPv4'
+ )
.map(({ address }) => {
if (address.includes('127.0.0.1')) {
const displayAddress = address.replace('127.0.0.1', localAddress);
@@ -76,7 +105,14 @@ export function devStart({
.sort((msg) => (msg.startsWith(localPrefix) ? -1 : 1));
}
- const messages = [`${emoji('🚀 ', '')}${bgGreen(black(` astro `))} ${green(`v${version}`)} ${dim(`started in ${Math.round(startupTime)}ms`)}`, '', ...addresses, ''];
+ const messages = [
+ `${emoji('🚀 ', '')}${bgGreen(black(` astro `))} ${green(`v${version}`)} ${dim(
+ `started in ${Math.round(startupTime)}ms`
+ )}`,
+ '',
+ ...addresses,
+ '',
+ ];
return messages.map((msg) => ` ${msg}`).join('\n');
}
@@ -125,10 +161,7 @@ export function portInUse({ port }: { port: number }): string {
const LOCAL_IP_HOSTS = new Set(['localhost', '127.0.0.1']);
-export function getNetworkLogging(config: AstroConfig): 'none' | 'host-to-expose' | 'visible' {
- // TODO: remove once --hostname is baselined
- const host = getResolvedHostForVite(config);
-
+export function getNetworkLogging(host: string | boolean): 'none' | 'host-to-expose' | 'visible' {
if (host === false) {
return 'host-to-expose';
} else if (typeof host === 'string' && LOCAL_IP_HOSTS.has(host)) {
@@ -139,8 +172,12 @@ export function getNetworkLogging(config: AstroConfig): 'none' | 'host-to-expose
}
export function formatConfigErrorMessage(err: ZodError) {
- const errorList = err.issues.map((issue) => ` ! ${bold(issue.path.join('.'))} ${red(issue.message + '.')}`);
- return `${red('[config]')} Astro found issue(s) with your configuration:\n${errorList.join('\n')}`;
+ const errorList = err.issues.map(
+ (issue) => ` ! ${bold(issue.path.join('.'))} ${red(issue.message + '.')}`
+ );
+ return `${red('[config]')} Astro found issue(s) with your configuration:\n${errorList.join(
+ '\n'
+ )}`;
}
export function formatErrorMessage(_err: Error, args: string[] = []): string {
@@ -199,7 +236,12 @@ export function printHelp({
let message = [];
if (headline) {
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${process.env.PACKAGE_VERSION ?? ''}`)} ${headline}`);
+ message.push(
+ linebreak(),
+ ` ${bgGreen(black(` ${commandName} `))} ${green(
+ `v${process.env.PACKAGE_VERSION ?? ''}`
+ )} ${headline}`
+ );
}
if (usage) {
@@ -207,7 +249,11 @@ export function printHelp({
}
if (commands) {
- message.push(linebreak(), title('Commands'), table(commands, { padding: 28, prefix: ' astro ' }));
+ message.push(
+ linebreak(),
+ title('Commands'),
+ table(commands, { padding: 28, prefix: ' astro ' })
+ );
}
if (flags) {
diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts
index 48d077800..1d68bd0f1 100644
--- a/packages/astro/src/core/preview/index.ts
+++ b/packages/astro/src/core/preview/index.ts
@@ -24,13 +24,16 @@ export interface PreviewServer {
const HAS_FILE_EXTENSION_REGEXP = /^.*\.[^\\]+$/;
/** The primary dev action */
-export default async function preview(config: AstroConfig, { logging }: PreviewOptions): Promise<PreviewServer> {
+export default async function preview(
+ config: AstroConfig,
+ { logging }: PreviewOptions
+): Promise<PreviewServer> {
const startServerTime = performance.now();
const defaultOrigin = 'http://localhost';
- const trailingSlash = config.devOptions.trailingSlash;
+ const trailingSlash = config.trailingSlash;
/** Base request URL. */
- let baseURL = new URL(config.buildOptions.site || '/', defaultOrigin);
- const staticFileServer = sirv(fileURLToPath(config.dist), {
+ let baseURL = new URL(config.base, new URL(config.site || '/', defaultOrigin));
+ const staticFileServer = sirv(fileURLToPath(config.outDir), {
dev: true,
etag: true,
maxAge: 0,
@@ -59,10 +62,13 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
switch (true) {
case hasTrailingSlash && trailingSlash == 'never' && !isRoot:
- sendError('Not Found (devOptions.trailingSlash is set to "never")');
+ sendError('Not Found (trailingSlash is set to "never")');
return;
- case !hasTrailingSlash && trailingSlash == 'always' && !isRoot && !HAS_FILE_EXTENSION_REGEXP.test(pathname):
- sendError('Not Found (devOptions.trailingSlash is set to "always")');
+ case !hasTrailingSlash &&
+ trailingSlash == 'always' &&
+ !isRoot &&
+ !HAS_FILE_EXTENSION_REGEXP.test(pathname):
+ sendError('Not Found (trailingSlash is set to "always")');
return;
default: {
// HACK: rewrite req.url so that sirv finds the file
@@ -73,8 +79,8 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
}
});
- let { port } = config.devOptions;
- const host = getResolvedHostForHttpServer(config);
+ let { port } = config.server;
+ const host = getResolvedHostForHttpServer(config.server.host);
let httpServer: http.Server;
@@ -87,7 +93,17 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
httpServer = server.listen(port, host, async () => {
if (!showedListenMsg) {
const devServerAddressInfo = server.address() as AddressInfo;
- info(logging, null, msg.devStart({ startupTime: performance.now() - timerStart, config, devServerAddressInfo, https: false, site: baseURL }));
+ info(
+ logging,
+ null,
+ msg.devStart({
+ startupTime: performance.now() - timerStart,
+ config,
+ devServerAddressInfo,
+ https: false,
+ site: baseURL,
+ })
+ );
}
showedListenMsg = true;
resolve();
diff --git a/packages/astro/src/core/preview/util.ts b/packages/astro/src/core/preview/util.ts
index 90c42ec32..87c1bfdf8 100644
--- a/packages/astro/src/core/preview/util.ts
+++ b/packages/astro/src/core/preview/util.ts
@@ -1,17 +1,13 @@
import type { AstroConfig } from '../../@types/astro';
-export function getResolvedHostForHttpServer(config: AstroConfig) {
- const { host, hostname } = config.devOptions;
-
- if (host === false && hostname === 'localhost') {
+export function getResolvedHostForHttpServer(host: string | boolean) {
+ if (host === false) {
// Use a secure default
return '127.0.0.1';
} else if (host === true) {
// If passed --host in the CLI without arguments
return undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)
- } else if (typeof host === 'string') {
- return host;
} else {
- return hostname;
+ return host;
}
}
diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts
index 383128ad0..1be4cb0c2 100644
--- a/packages/astro/src/core/render/core.ts
+++ b/packages/astro/src/core/render/core.ts
@@ -1,4 +1,13 @@
-import type { ComponentInstance, EndpointHandler, MarkdownRenderOptions, Params, Props, SSRLoadedRenderer, RouteData, SSRElement } from '../../@types/astro';
+import type {
+ ComponentInstance,
+ EndpointHandler,
+ MarkdownRenderOptions,
+ Params,
+ Props,
+ SSRLoadedRenderer,
+ RouteData,
+ SSRElement,
+} from '../../@types/astro';
import type { LogOptions } from '../logger/core.js';
import { renderHead, renderPage } from '../../runtime/server/index.js';
@@ -19,7 +28,9 @@ export const enum GetParamsAndPropsError {
NoMatchingStaticPath,
}
-export async function getParamsAndProps(opts: GetParamsAndPropsOptions): Promise<[Params, Props] | GetParamsAndPropsError> {
+export async function getParamsAndProps(
+ opts: GetParamsAndPropsOptions
+): Promise<[Params, Props] | GetParamsAndPropsError> {
const { logging, mod, route, routeCache, pathname, ssr } = opts;
// Handle dynamic routes
let params: Params = {};
@@ -73,8 +84,26 @@ export interface RenderOptions {
request: Request;
}
-export async function render(opts: RenderOptions): Promise<{ type: 'html'; html: string } | { type: 'response'; response: Response }> {
- const { legacyBuild, links, logging, origin, markdownRender, mod, pathname, scripts, renderers, request, resolve, route, routeCache, site, ssr } = opts;
+export async function render(
+ opts: RenderOptions
+): Promise<{ type: 'html'; html: string } | { type: 'response'; response: Response }> {
+ const {
+ legacyBuild,
+ links,
+ logging,
+ origin,
+ markdownRender,
+ mod,
+ pathname,
+ scripts,
+ renderers,
+ request,
+ resolve,
+ route,
+ routeCache,
+ site,
+ ssr,
+ } = opts;
const paramsAndPropsRes = await getParamsAndProps({
logging,
@@ -86,14 +115,18 @@ export async function render(opts: RenderOptions): Promise<{ type: 'html'; html:
});
if (paramsAndPropsRes === GetParamsAndPropsError.NoMatchingStaticPath) {
- throw new Error(`[getStaticPath] route pattern matched, but no matching static path found. (${pathname})`);
+ throw new Error(
+ `[getStaticPath] route pattern matched, but no matching static path found. (${pathname})`
+ );
}
const [params, pageProps] = paramsAndPropsRes;
// Validate the page component before rendering the page
const Component = await mod.default;
- if (!Component) throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
- if (!Component.isAstroComponentFactory) throw new Error(`Unable to SSR non-Astro component (${route?.component})`);
+ if (!Component)
+ throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
+ if (!Component.isAstroComponentFactory)
+ throw new Error(`Unable to SSR non-Astro component (${route?.component})`);
const result = createResult({
legacyBuild,
@@ -126,7 +159,7 @@ export async function render(opts: RenderOptions): Promise<{ type: 'html'; html:
html = html.replace('<!--astro:head:injected-->', '');
// inject <!doctype html> if missing (TODO: is a more robust check needed for comments, etc.?)
- if (!legacyBuild && !/<!doctype html/i.test(html)) {
+ if (!/<!doctype html/i.test(html)) {
html = '<!DOCTYPE html>\n' + html;
}
diff --git a/packages/astro/src/core/render/dev/html.ts b/packages/astro/src/core/render/dev/html.ts
index d7596fb6d..243eeb295 100644
--- a/packages/astro/src/core/render/dev/html.ts
+++ b/packages/astro/src/core/render/dev/html.ts
@@ -98,7 +98,10 @@ function serializeTag({ tag, attrs, children }: vite.HtmlTagDescriptor, indent =
if (unaryTags.has(tag)) {
return `<${tag}${serializeAttrs(attrs)}>`;
} else {
- return `<${tag}${serializeAttrs(attrs)}>${serializeTags(children, incrementIndent(indent))}</${tag}>`;
+ return `<${tag}${serializeAttrs(attrs)}>${serializeTags(
+ children,
+ incrementIndent(indent)
+ )}</${tag}>`;
}
}
diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts
index b81ef6863..39e3ad552 100644
--- a/packages/astro/src/core/render/dev/index.ts
+++ b/packages/astro/src/core/render/dev/index.ts
@@ -1,6 +1,15 @@
+import astroRemark from '@astrojs/markdown-remark';
import { fileURLToPath } from 'url';
import type * as vite from 'vite';
-import type { AstroConfig, AstroRenderer, ComponentInstance, RouteData, RuntimeMode, SSRElement, SSRLoadedRenderer } from '../../../@types/astro';
+import type {
+ AstroConfig,
+ AstroRenderer,
+ ComponentInstance,
+ RouteData,
+ RuntimeMode,
+ SSRElement,
+ SSRLoadedRenderer,
+} from '../../../@types/astro';
import { LogOptions } from '../../logger/core.js';
import { render as coreRender } from '../core.js';
import { prependForwardSlash } from '../../../core/path.js';
@@ -20,7 +29,7 @@ export interface SSROptions {
logging: LogOptions;
/** "development" or "production" */
mode: RuntimeMode;
- /** production website, needed for some RSS & Sitemap functions */
+ /** production website, needed for some RSS functions */
origin: string;
/** the web request (needed for dynamic routes) */
pathname: string;
@@ -36,24 +45,38 @@ export interface SSROptions {
export type ComponentPreload = [SSRLoadedRenderer[], ComponentInstance];
-export type RenderResponse = { type: 'html'; html: string } | { type: 'response'; response: Response };
+export type RenderResponse =
+ | { type: 'html'; html: string }
+ | { type: 'response'; response: Response };
const svelteStylesRE = /svelte\?svelte&type=style/;
-async function loadRenderer(viteServer: vite.ViteDevServer, renderer: AstroRenderer): Promise<SSRLoadedRenderer> {
+async function loadRenderer(
+ viteServer: vite.ViteDevServer,
+ renderer: AstroRenderer
+): Promise<SSRLoadedRenderer> {
// Vite modules can be out-of-date when using an un-resolved url
// We also encountered inconsistencies when using the resolveUrl and resolveId helpers
// We've found that pulling the ID directly from the urlToModuleMap is the most stable!
- const id = viteServer.moduleGraph.urlToModuleMap.get(renderer.serverEntrypoint)?.id ?? renderer.serverEntrypoint;
+ const id =
+ viteServer.moduleGraph.urlToModuleMap.get(renderer.serverEntrypoint)?.id ??
+ renderer.serverEntrypoint;
const mod = (await viteServer.ssrLoadModule(id)) as { default: SSRLoadedRenderer['ssr'] };
return { ...renderer, ssr: mod.default };
}
-export async function loadRenderers(viteServer: vite.ViteDevServer, astroConfig: AstroConfig): Promise<SSRLoadedRenderer[]> {
+export async function loadRenderers(
+ viteServer: vite.ViteDevServer,
+ astroConfig: AstroConfig
+): Promise<SSRLoadedRenderer[]> {
return Promise.all(astroConfig._ctx.renderers.map((r) => loadRenderer(viteServer, r)));
}
-export async function preload({ astroConfig, filePath, viteServer }: Pick<SSROptions, 'astroConfig' | 'filePath' | 'viteServer'>): Promise<ComponentPreload> {
+export async function preload({
+ astroConfig,
+ filePath,
+ viteServer,
+}: Pick<SSROptions, 'astroConfig' | 'filePath' | 'viteServer'>): Promise<ComponentPreload> {
// Important: This needs to happen first, in case a renderer provides polyfills.
const renderers = await loadRenderers(viteServer, astroConfig);
// Load the module from the Vite SSR Runtime.
@@ -63,21 +86,44 @@ export async function preload({ astroConfig, filePath, viteServer }: Pick<SSROpt
}
/** use Vite to SSR */
-export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInstance, ssrOpts: SSROptions): Promise<RenderResponse> {
- const { astroConfig, filePath, logging, mode, origin, pathname, request, route, routeCache, viteServer } = ssrOpts;
- const legacy = astroConfig.buildOptions.legacyBuild;
+export async function render(
+ renderers: SSRLoadedRenderer[],
+ mod: ComponentInstance,
+ ssrOpts: SSROptions
+): Promise<RenderResponse> {
+ const {
+ astroConfig,
+ filePath,
+ logging,
+ mode,
+ origin,
+ pathname,
+ request,
+ route,
+ routeCache,
+ viteServer,
+ } = ssrOpts;
+ // TODO: clean up "legacy" flag passed through helper functions
+ const isLegacyBuild = false;
// Add hoisted script tags
- const scripts = createModuleScriptElementWithSrcSet(!legacy && mod.hasOwnProperty('$$metadata') ? Array.from(mod.$$metadata.hoistedScriptPaths()) : []);
+ const scripts = createModuleScriptElementWithSrcSet(
+ !isLegacyBuild && mod.hasOwnProperty('$$metadata')
+ ? Array.from(mod.$$metadata.hoistedScriptPaths())
+ : []
+ );
// Inject HMR scripts
- if (mod.hasOwnProperty('$$metadata') && mode === 'development' && !legacy) {
+ if (mod.hasOwnProperty('$$metadata') && mode === 'development' && !isLegacyBuild) {
scripts.add({
props: { type: 'module', src: '/@vite/client' },
children: '',
});
scripts.add({
- props: { type: 'module', src: new URL('../../../runtime/client/hmr.js', import.meta.url).pathname },
+ props: {
+ type: 'module',
+ src: new URL('../../../runtime/client/hmr.js', import.meta.url).pathname,
+ },
children: '',
});
}
@@ -93,7 +139,7 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
// Pass framework CSS in as link tags to be appended to the page.
let links = new Set<SSRElement>();
- if (!legacy) {
+ if (!isLegacyBuild) {
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
if (mode === 'development' && svelteStylesRE.test(href)) {
scripts.add({
@@ -114,10 +160,11 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
}
let content = await coreRender({
- legacyBuild: astroConfig.buildOptions.legacyBuild,
+ // TODO: Remove this flag once legacyBuild support is removed
+ legacyBuild: isLegacyBuild,
links,
logging,
- markdownRender: astroConfig.markdownOptions.render,
+ markdownRender: [astroRemark, astroConfig.markdown],
mod,
origin,
pathname,
@@ -126,28 +173,21 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
// TODO: Can we pass the hydration code more directly through Vite, so that we
// don't need to copy-paste and maintain Vite's import resolution here?
async resolve(s: string) {
- // The legacy build needs these to remain unresolved so that vite HTML
- // Can do the resolution. Without this condition the build output will be
- // broken in the legacy build. This can be removed once the legacy build is removed.
- if (!astroConfig.buildOptions.legacyBuild) {
- const [resolvedUrl, resolvedPath] = await viteServer.moduleGraph.resolveUrl(s);
- if (resolvedPath.includes('node_modules/.vite')) {
- return resolvedPath.replace(/.*?node_modules\/\.vite/, '/node_modules/.vite');
- }
- // NOTE: This matches the same logic that Vite uses to add the `/@id/` prefix.
- if (!resolvedUrl.startsWith('.') && !resolvedUrl.startsWith('/')) {
- return '/@id' + prependForwardSlash(resolvedUrl);
- }
- return '/@fs' + prependForwardSlash(resolvedPath);
- } else {
- return s;
+ const [resolvedUrl, resolvedPath] = await viteServer.moduleGraph.resolveUrl(s);
+ if (resolvedPath.includes('node_modules/.vite')) {
+ return resolvedPath.replace(/.*?node_modules\/\.vite/, '/node_modules/.vite');
+ }
+ // NOTE: This matches the same logic that Vite uses to add the `/@id/` prefix.
+ if (!resolvedUrl.startsWith('.') && !resolvedUrl.startsWith('/')) {
+ return '/@id' + prependForwardSlash(resolvedUrl);
}
+ return '/@fs' + prependForwardSlash(resolvedPath);
},
renderers,
request,
route,
routeCache,
- site: astroConfig.buildOptions.site,
+ site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : undefined,
ssr: isBuildingToSSR(astroConfig),
});
@@ -159,7 +199,7 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
const tags: vite.HtmlTagDescriptor[] = [];
// dev only: inject Astro HMR client
- if (mode === 'development' && legacy) {
+ if (mode === 'development' && isLegacyBuild) {
tags.push({
tag: 'script',
attrs: { type: 'module' },
@@ -171,7 +211,7 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
}
// inject CSS
- if (legacy) {
+ if (isLegacyBuild) {
[...getStylesForURL(filePath, viteServer)].forEach((href) => {
if (mode === 'development' && svelteStylesRE.test(href)) {
tags.push({
@@ -196,12 +236,6 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
// add injected tags
let html = injectTags(content.html, tags);
- // run transformIndexHtml() in dev to run Vite dev transformations
- if (mode === 'development' && astroConfig.buildOptions.legacyBuild) {
- const relativeURL = filePath.href.replace(astroConfig.projectRoot.href, '/');
- html = await viteServer.transformIndexHtml(relativeURL, html, pathname);
- }
-
// inject <!doctype html> if missing (TODO: is a more robust check needed for comments, etc.?)
if (!/<!doctype html/i.test(html)) {
html = '<!DOCTYPE html>\n' + content;
@@ -213,7 +247,10 @@ export async function render(renderers: SSRLoadedRenderer[], mod: ComponentInsta
};
}
-export async function ssr(preloadedComponent: ComponentPreload, ssrOpts: SSROptions): Promise<RenderResponse> {
+export async function ssr(
+ preloadedComponent: ComponentPreload,
+ ssrOpts: SSROptions
+): Promise<RenderResponse> {
const [renderers, mod] = preloadedComponent;
return await render(renderers, mod, ssrOpts); // NOTE: without "await", errors won’t get caught below
}
diff --git a/packages/astro/src/core/render/paginate.ts b/packages/astro/src/core/render/paginate.ts
index 96d8a435a..f9da47a26 100644
--- a/packages/astro/src/core/render/paginate.ts
+++ b/packages/astro/src/core/render/paginate.ts
@@ -1,7 +1,17 @@
-import { GetStaticPathsResult, Page, PaginateFunction, Params, Props, RouteData } from '../../@types/astro';
+import {
+ GetStaticPathsResult,
+ Page,
+ PaginateFunction,
+ Params,
+ Props,
+ RouteData,
+} from '../../@types/astro';
export function generatePaginateFunction(routeMatch: RouteData): PaginateFunction {
- return function paginateUtility(data: any[], args: { pageSize?: number; params?: Params; props?: Props } = {}) {
+ return function paginateUtility(
+ data: any[],
+ args: { pageSize?: number; params?: Params; props?: Props } = {}
+ ) {
let { pageSize: _pageSize, params: _params, props: _props } = args;
const pageSize = _pageSize || 10;
const paramName = 'page';
@@ -41,8 +51,20 @@ export function generatePaginateFunction(routeMatch: RouteData): PaginateFunctio
lastPage: lastPage,
url: {
current: routeMatch.generate({ ...params }),
- next: pageNum === lastPage ? undefined : routeMatch.generate({ ...params, page: String(pageNum + 1) }),
- prev: pageNum === 1 ? undefined : routeMatch.generate({ ...params, page: !includesFirstPageNumber && pageNum - 1 === 1 ? undefined : String(pageNum - 1) }),
+ next:
+ pageNum === lastPage
+ ? undefined
+ : routeMatch.generate({ ...params, page: String(pageNum + 1) }),
+ prev:
+ pageNum === 1
+ ? undefined
+ : routeMatch.generate({
+ ...params,
+ page:
+ !includesFirstPageNumber && pageNum - 1 === 1
+ ? undefined
+ : String(pageNum - 1),
+ }),
},
} as Page,
},
diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts
index 7c9a9c30f..241807a1f 100644
--- a/packages/astro/src/core/render/result.ts
+++ b/packages/astro/src/core/render/result.ts
@@ -1,5 +1,14 @@
import { bold } from 'kleur/colors';
-import type { AstroGlobal, AstroGlobalPartial, MarkdownParser, MarkdownRenderOptions, Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
+import type {
+ AstroGlobal,
+ AstroGlobalPartial,
+ MarkdownParser,
+ MarkdownRenderOptions,
+ Params,
+ SSRElement,
+ SSRLoadedRenderer,
+ SSRResult,
+} from '../../@types/astro';
import { renderSlot } from '../../runtime/server/index.js';
import { LogOptions, warn } from '../logger/core.js';
import { createCanonicalURL, isCSSRequest } from './util.js';
@@ -45,7 +54,9 @@ class Slots {
if (slots) {
for (const key of Object.keys(slots)) {
if ((this as any)[key] !== undefined) {
- throw new Error(`Unable to create a slot named "${key}". "${key}" is a reserved slot name!\nPlease update the name of this slot.`);
+ throw new Error(
+ `Unable to create a slot named "${key}". "${key}" is a reserved slot name!\nPlease update the name of this slot.`
+ );
}
Object.defineProperty(this, key, {
get() {
@@ -75,10 +86,14 @@ class Slots {
const expression = getFunctionExpression(component);
if (expression) {
const slot = expression(...args);
- return await renderSlot(this.#result, slot).then((res) => (res != null ? String(res) : res));
+ return await renderSlot(this.#result, slot).then((res) =>
+ res != null ? String(res) : res
+ );
}
}
- const content = await renderSlot(this.#result, this.#slots[name]).then((res) => (res != null ? String(res) : res));
+ const content = await renderSlot(this.#result, this.#slots[name]).then((res) =>
+ res != null ? String(res) : res
+ );
if (cacheable) this.#cache.set(name, content);
return content;
}
@@ -98,7 +113,11 @@ export function createResult(args: CreateResultArgs): SSRResult {
scripts: args.scripts ?? new Set<SSRElement>(),
links: args.links ?? new Set<SSRElement>(),
/** This function returns the `Astro` faux-global */
- createAstro(astroGlobal: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null) {
+ createAstro(
+ astroGlobal: AstroGlobalPartial,
+ props: Record<string, any>,
+ slots: Record<string, any> | null
+ ) {
const astroSlots = new Slots(result, slots);
const Astro = {
@@ -122,10 +141,9 @@ export function createResult(args: CreateResultArgs): SSRResult {
let extra = `This can be replaced with a dynamic import like so: await import("${path}")`;
if (isCSSRequest(path)) {
extra = `It looks like you are resolving styles. If you are adding a link tag, replace with this:
-
-<style global>
-@import "${path}";
-</style>
+---
+import "${path}";
+---
`;
} else if (isScriptRequest(path)) {
extra = `It looks like you are resolving scripts. If you are adding a script tag, replace with this:
@@ -134,7 +152,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
or consider make it a module like so:
-<script type="module" hoist>
+<script>
import MyModule from "${path}";
</script>
`;
@@ -143,7 +161,9 @@ or consider make it a module like so:
warn(
args.logging,
`deprecation`,
- `${bold('Astro.resolve()')} is deprecated. We see that you are trying to resolve ${path}.
+ `${bold(
+ 'Astro.resolve()'
+ )} is deprecated. We see that you are trying to resolve ${path}.
${extra}`
);
// Intentionally return an empty string so that it is not relied upon.
@@ -159,6 +179,7 @@ ${extra}`
// Ensure this API is not exposed to users
enumerable: false,
writable: false,
+ // TODO: remove 1. markdown parser logic 2. update MarkdownRenderOptions to take a function only
// <Markdown> also needs the same `astroConfig.markdownOptions.render` as `.md` pages
value: async function (content: string, opts: any) {
let [mdRender, renderOpts] = markdownRender;
diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts
index 1b60bd0db..f9ef8209d 100644
--- a/packages/astro/src/core/render/route-cache.ts
+++ b/packages/astro/src/core/render/route-cache.ts
@@ -1,8 +1,19 @@
-import type { ComponentInstance, GetStaticPathsItem, GetStaticPathsResult, GetStaticPathsResultKeyed, Params, RouteData, RSS } from '../../@types/astro';
+import type {
+ ComponentInstance,
+ GetStaticPathsItem,
+ GetStaticPathsResult,
+ GetStaticPathsResultKeyed,
+ Params,
+ RouteData,
+ RSS,
+} from '../../@types/astro';
import { LogOptions, warn, debug } from '../logger/core.js';
import { generatePaginateFunction } from './paginate.js';
-import { validateGetStaticPathsModule, validateGetStaticPathsResult } from '../routing/validation.js';
+import {
+ validateGetStaticPathsModule,
+ validateGetStaticPathsResult,
+} from '../routing/validation.js';
type RSSFn = (...args: any[]) => any;
@@ -19,7 +30,13 @@ interface CallGetStaticPathsOptions {
ssr: boolean;
}
-export async function callGetStaticPaths({ isValidate, logging, mod, route, ssr }: CallGetStaticPathsOptions): Promise<RouteCacheEntry> {
+export async function callGetStaticPaths({
+ isValidate,
+ logging,
+ mod,
+ route,
+ ssr,
+}: CallGetStaticPathsOptions): Promise<RouteCacheEntry> {
validateGetStaticPathsModule(mod, { ssr });
const resultInProgress = {
rss: [] as RSS[],
@@ -80,7 +97,11 @@ export class RouteCache {
// Warn here so that an unexpected double-call of getStaticPaths()
// isn't invisible and developer can track down the issue.
if (this.cache[route.component]) {
- warn(this.logging, 'routeCache', `Internal Warning: route cache overwritten. (${route.component})`);
+ warn(
+ this.logging,
+ 'routeCache',
+ `Internal Warning: route cache overwritten. (${route.component})`
+ );
}
this.cache[route.component] = entry;
}
@@ -98,5 +119,7 @@ export function findPathItemByKey(staticPaths: GetStaticPathsResultKeyed, params
}
debug('findPathItemByKey', `Unexpected cache miss looking for ${paramsKey}`);
- matchedStaticPath = staticPaths.find(({ params: _params }) => JSON.stringify(_params) === paramsKey);
+ matchedStaticPath = staticPaths.find(
+ ({ params: _params }) => JSON.stringify(_params) === paramsKey
+ );
}
diff --git a/packages/astro/src/core/render/rss.ts b/packages/astro/src/core/render/rss.ts
index e02a6155e..38a10604f 100644
--- a/packages/astro/src/core/render/rss.ts
+++ b/packages/astro/src/core/render/rss.ts
@@ -9,8 +9,10 @@ export function validateRSS(args: GenerateRSSArgs): void {
const { rssData, srcFile } = args;
if (!rssData.title) throw new Error(`[${srcFile}] rss.title required`);
if (!rssData.description) throw new Error(`[${srcFile}] rss.description required`);
- if ((rssData as any).item) throw new Error(`[${srcFile}] \`item: Function\` should be \`items: Item[]\``);
- if (!Array.isArray(rssData.items)) throw new Error(`[${srcFile}] rss.items should be an array of items`);
+ if ((rssData as any).item)
+ throw new Error(`[${srcFile}] \`item: Function\` should be \`items: Item[]\``);
+ if (!Array.isArray(rssData.items))
+ throw new Error(`[${srcFile}] rss.items should be an array of items`);
}
type GenerateRSSArgs = { site: string; rssData: RSS; srcFile: string };
@@ -19,7 +21,10 @@ type GenerateRSSArgs = { site: string; rssData: RSS; srcFile: string };
export function generateRSS(args: GenerateRSSArgs): string {
validateRSS(args);
const { srcFile, rssData, site } = args;
- if ((rssData as any).item) throw new Error(`[${srcFile}] rss() \`item()\` function was deprecated, and is now \`items: object[]\`.`);
+ if ((rssData as any).item)
+ throw new Error(
+ `[${srcFile}] rss() \`item()\` function was deprecated, and is now \`items: object[]\`.`
+ );
let xml = `<?xml version="1.0" encoding="UTF-8"?>`;
if (typeof rssData.stylesheet === 'string') {
@@ -45,12 +50,27 @@ export function generateRSS(args: GenerateRSSArgs): string {
for (const result of rssData.items) {
xml += `<item>`;
// validate
- if (typeof result !== 'object') throw new Error(`[${srcFile}] rss.items expected an object. got: "${JSON.stringify(result)}"`);
- if (!result.title) throw new Error(`[${srcFile}] rss.items required "title" property is missing. got: "${JSON.stringify(result)}"`);
- if (!result.link) throw new Error(`[${srcFile}] rss.items required "link" property is missing. got: "${JSON.stringify(result)}"`);
+ if (typeof result !== 'object')
+ throw new Error(
+ `[${srcFile}] rss.items expected an object. got: "${JSON.stringify(result)}"`
+ );
+ if (!result.title)
+ throw new Error(
+ `[${srcFile}] rss.items required "title" property is missing. got: "${JSON.stringify(
+ result
+ )}"`
+ );
+ if (!result.link)
+ throw new Error(
+ `[${srcFile}] rss.items required "link" property is missing. got: "${JSON.stringify(
+ result
+ )}"`
+ );
xml += `<title><![CDATA[${result.title}]]></title>`;
// If the item's link is already a valid URL, don't mess with it.
- const itemLink = isValidURL(result.link) ? result.link : createCanonicalURL(result.link, site).href;
+ const itemLink = isValidURL(result.link)
+ ? result.link
+ : createCanonicalURL(result.link, site).href;
xml += `<link>${itemLink}</link>`;
xml += `<guid>${itemLink}</guid>`;
if (result.description) xml += `<description><![CDATA[${result.description}]]></description>`;
@@ -87,7 +107,9 @@ export function generateRSSStylesheet() {
export function generateRssFunction(site: string | undefined, route: RouteData): RSSFunction {
return function rssUtility(args: RSS): RSSResult {
if (!site) {
- throw new Error(`[${route.component}] rss() tried to generate RSS but "buildOptions.site" missing in astro.config.mjs`);
+ throw new Error(
+ `[${route.component}] rss() tried to generate RSS but "site" missing in astro.config.mjs`
+ );
}
let result: RSSResult = {} as any;
const { dest, ...rssData } = args;
diff --git a/packages/astro/src/core/render/sitemap.ts b/packages/astro/src/core/render/sitemap.ts
deleted file mode 100644
index b7191e23e..000000000
--- a/packages/astro/src/core/render/sitemap.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-const STATUS_CODE_PAGE_REGEXP = /\/[0-9]{3}\/?$/;
-
-/** Construct sitemap.xml given a set of URLs */
-export function generateSitemap(pages: string[], filter?: (page: string) => boolean): string {
- // TODO: find way to respect <link rel="canonical"> URLs here
-
- // copy just in case original copy is needed
- // make sure that 404 page is excluded
- // also works for other error pages
- let urls = [...pages].filter((url) => !STATUS_CODE_PAGE_REGEXP.test(url));
-
- if (filter) {
- urls = urls.filter((url) => filter(url));
- }
-
- urls.sort((a, b) => a.localeCompare(b, 'en', { numeric: true })); // sort alphabetically so sitemap is same each time
- let sitemap = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`;
- for (const url of urls) {
- sitemap += `<url><loc>${url}</loc></url>`;
- }
- sitemap += `</urlset>\n`;
- return sitemap;
-}
diff --git a/packages/astro/src/core/render/ssr-element.ts b/packages/astro/src/core/render/ssr-element.ts
index 88c387db1..628294f44 100644
--- a/packages/astro/src/core/render/ssr-element.ts
+++ b/packages/astro/src/core/render/ssr-element.ts
@@ -35,6 +35,9 @@ export function createModuleScriptElementWithSrc(src: string, site?: string): SS
};
}
-export function createModuleScriptElementWithSrcSet(srces: string[], site?: string): Set<SSRElement> {
+export function createModuleScriptElementWithSrcSet(
+ srces: string[],
+ site?: string
+): Set<SSRElement> {
return new Set<SSRElement>(srces.map((src) => createModuleScriptElementWithSrc(src, site)));
}
diff --git a/packages/astro/src/core/render/util.ts b/packages/astro/src/core/render/util.ts
index 9acf2d9d3..6ef412a9c 100644
--- a/packages/astro/src/core/render/util.ts
+++ b/packages/astro/src/core/render/util.ts
@@ -19,7 +19,16 @@ export function isValidURL(url: string): boolean {
}
// https://vitejs.dev/guide/features.html#css-pre-processors
-export const STYLE_EXTENSIONS = new Set(['.css', '.pcss', '.postcss', '.scss', '.sass', '.styl', '.stylus', '.less']);
+export const STYLE_EXTENSIONS = new Set([
+ '.css',
+ '.pcss',
+ '.postcss',
+ '.scss',
+ '.sass',
+ '.styl',
+ '.stylus',
+ '.less',
+]);
const cssRe = new RegExp(
`\\.(${Array.from(STYLE_EXTENSIONS)
diff --git a/packages/astro/src/core/request.ts b/packages/astro/src/core/request.ts
index 8b5c40748..abccbf995 100644
--- a/packages/astro/src/core/request.ts
+++ b/packages/astro/src/core/request.ts
@@ -13,8 +13,17 @@ export interface CreateRequestOptions {
logging: LogOptions;
}
-export function createRequest({ url, headers, method = 'GET', body = undefined, logging }: CreateRequestOptions): Request {
- let headersObj = headers instanceof Headers ? headers : new Headers(Object.entries(headers as Record<string, any>));
+export function createRequest({
+ url,
+ headers,
+ method = 'GET',
+ body = undefined,
+ logging,
+}: CreateRequestOptions): Request {
+ let headersObj =
+ headers instanceof Headers
+ ? headers
+ : new Headers(Object.entries(headers as Record<string, any>));
const request = new Request(url.toString(), {
method: method,
@@ -25,7 +34,11 @@ export function createRequest({ url, headers, method = 'GET', body = undefined,
Object.defineProperties(request, {
canonicalURL: {
get() {
- warn(logging, 'deprecation', `Astro.request.canonicalURL has been moved to Astro.canonicalURL`);
+ warn(
+ logging,
+ 'deprecation',
+ `Astro.request.canonicalURL has been moved to Astro.canonicalURL`
+ );
return undefined;
},
},
diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts
index 6c7cb4829..ec1d6a578 100644
--- a/packages/astro/src/core/routing/manifest/create.ts
+++ b/packages/astro/src/core/routing/manifest/create.ts
@@ -7,6 +7,7 @@ import { compile } from 'path-to-regexp';
import slash from 'slash';
import { fileURLToPath } from 'url';
import { warn } from '../../logger/core.js';
+import { resolvePages } from '../../util.js';
interface Part {
content: string;
@@ -55,7 +56,7 @@ function getParts(part: string, file: string) {
return result;
}
-function getPattern(segments: Part[][], addTrailingSlash: AstroConfig['devOptions']['trailingSlash']) {
+function getPattern(segments: Part[][], addTrailingSlash: AstroConfig['trailingSlash']) {
const pathname = segments
.map((segment) => {
return segment[0].spread
@@ -78,11 +79,12 @@ function getPattern(segments: Part[][], addTrailingSlash: AstroConfig['devOption
})
.join('');
- const trailing = addTrailingSlash && segments.length ? getTrailingSlashPattern(addTrailingSlash) : '$';
+ const trailing =
+ addTrailingSlash && segments.length ? getTrailingSlashPattern(addTrailingSlash) : '$';
return new RegExp(`^${pathname || '\\/'}${trailing}`);
}
-function getTrailingSlashPattern(addTrailingSlash: AstroConfig['devOptions']['trailingSlash']): string {
+function getTrailingSlashPattern(addTrailingSlash: AstroConfig['trailingSlash']): string {
if (addTrailingSlash === 'always') {
return '\\/$';
}
@@ -92,7 +94,7 @@ function getTrailingSlashPattern(addTrailingSlash: AstroConfig['devOptions']['tr
return '\\/?$';
}
-function getGenerator(segments: Part[][], addTrailingSlash: AstroConfig['devOptions']['trailingSlash']) {
+function getGenerator(segments: Part[][], addTrailingSlash: AstroConfig['trailingSlash']) {
const template = segments
.map((segment) => {
return segment[0].spread
@@ -154,7 +156,10 @@ function comparator(a: Item, b: Item) {
}
if (!aSubPart.dynamic && aSubPart.content !== bSubPart.content) {
- return bSubPart.content.length - aSubPart.content.length || (aSubPart.content < bSubPart.content ? -1 : 1);
+ return (
+ bSubPart.content.length - aSubPart.content.length ||
+ (aSubPart.content < bSubPart.content ? -1 : 1)
+ );
}
}
@@ -167,7 +172,10 @@ function comparator(a: Item, b: Item) {
}
/** Create manifest of all static routes */
-export function createRouteManifest({ config, cwd }: { config: AstroConfig; cwd?: string }, logging: LogOptions): ManifestData {
+export function createRouteManifest(
+ { config, cwd }: { config: AstroConfig; cwd?: string },
+ logging: LogOptions
+): ManifestData {
const components: string[] = [];
const routes: RouteData[] = [];
const validPageExtensions: Set<string> = new Set(['.astro', '.md']);
@@ -177,7 +185,7 @@ export function createRouteManifest({ config, cwd }: { config: AstroConfig; cwd?
let items: Item[] = [];
fs.readdirSync(dir).forEach((basename) => {
const resolved = path.join(dir, basename);
- const file = slash(path.relative(cwd || fileURLToPath(config.projectRoot), resolved));
+ const file = slash(path.relative(cwd || fileURLToPath(config.root), resolved));
const isDir = fs.statSync(resolved).isDirectory();
const ext = path.extname(basename);
@@ -195,7 +203,9 @@ export function createRouteManifest({ config, cwd }: { config: AstroConfig; cwd?
}
const segment = isDir ? basename : name;
if (/^\$/.test(segment)) {
- throw new Error(`Invalid route ${file} — Astro's Collections API has been replaced by dynamic route params.`);
+ throw new Error(
+ `Invalid route ${file} — Astro's Collections API has been replaced by dynamic route params.`
+ );
}
if (/\]\[/.test(segment)) {
throw new Error(`Invalid route ${file} — parameters must be separated`);
@@ -265,10 +275,12 @@ export function createRouteManifest({ config, cwd }: { config: AstroConfig; cwd?
} else {
components.push(item.file);
const component = item.file;
- const trailingSlash = item.isPage ? config.devOptions.trailingSlash : 'never';
+ const trailingSlash = item.isPage ? config.trailingSlash : 'never';
const pattern = getPattern(segments, trailingSlash);
const generate = getGenerator(segments, trailingSlash);
- const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join('/')}` : null;
+ const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic)
+ ? `/${segments.map((segment) => segment[0].content).join('/')}`
+ : null;
routes.push({
type: item.isPage ? 'page' : 'endpoint',
@@ -282,10 +294,12 @@ export function createRouteManifest({ config, cwd }: { config: AstroConfig; cwd?
});
}
- if (fs.existsSync(config.pages)) {
- walk(fileURLToPath(config.pages), [], []);
+ const pages = resolvePages(config);
+
+ if (fs.existsSync(pages)) {
+ walk(fileURLToPath(pages), [], []);
} else {
- const pagesDirRootRelative = config.pages.href.slice(config.projectRoot.href.length);
+ const pagesDirRootRelative = pages.href.slice(config.root.href.length);
warn(logging, 'astro', `Missing pages directory: ${pagesDirRootRelative}`);
}
diff --git a/packages/astro/src/core/routing/manifest/serialization.ts b/packages/astro/src/core/routing/manifest/serialization.ts
index 8e3a42204..e167eb374 100644
--- a/packages/astro/src/core/routing/manifest/serialization.ts
+++ b/packages/astro/src/core/routing/manifest/serialization.ts
@@ -1,6 +1,12 @@
import type { RouteData, SerializedRouteData } from '../../../@types/astro';
-function createRouteData(pattern: RegExp, params: string[], component: string, pathname: string | undefined, type: 'page' | 'endpoint'): RouteData {
+function createRouteData(
+ pattern: RegExp,
+ params: string[],
+ component: string,
+ pathname: string | undefined,
+ type: 'page' | 'endpoint'
+): RouteData {
return {
type,
pattern,
diff --git a/packages/astro/src/core/routing/validation.ts b/packages/astro/src/core/routing/validation.ts
index 80f50e19e..a82ba58a3 100644
--- a/packages/astro/src/core/routing/validation.ts
+++ b/packages/astro/src/core/routing/validation.ts
@@ -12,26 +12,48 @@ export function validateGetStaticPathsModule(mod: ComponentInstance, { ssr }: Va
throw new Error(`[createCollection] deprecated. Please use getStaticPaths() instead.`);
}
if (!mod.getStaticPaths && !ssr) {
- throw new Error(`[getStaticPaths] getStaticPaths() function is required. Make sure that you \`export\` the function from your component.`);
+ throw new Error(
+ `[getStaticPaths] getStaticPaths() function is required. Make sure that you \`export\` the function from your component.`
+ );
}
}
/** Throw error for malformed getStaticPaths() response */
export function validateGetStaticPathsResult(result: GetStaticPathsResult, logging: LogOptions) {
if (!Array.isArray(result)) {
- throw new Error(`[getStaticPaths] invalid return value. Expected an array of path objects, but got \`${JSON.stringify(result)}\`.`);
+ throw new Error(
+ `[getStaticPaths] invalid return value. Expected an array of path objects, but got \`${JSON.stringify(
+ result
+ )}\`.`
+ );
}
result.forEach((pathObject) => {
if (!pathObject.params) {
- warn(logging, 'getStaticPaths', `invalid path object. Expected an object with key \`params\`, but got \`${JSON.stringify(pathObject)}\`. Skipped.`);
+ warn(
+ logging,
+ 'getStaticPaths',
+ `invalid path object. Expected an object with key \`params\`, but got \`${JSON.stringify(
+ pathObject
+ )}\`. Skipped.`
+ );
return;
}
for (const [key, val] of Object.entries(pathObject.params)) {
if (!(typeof val === 'undefined' || typeof val === 'string')) {
- warn(logging, 'getStaticPaths', `invalid path param: ${key}. A string value was expected, but got \`${JSON.stringify(val)}\`.`);
+ warn(
+ logging,
+ 'getStaticPaths',
+ `invalid path param: ${key}. A string value was expected, but got \`${JSON.stringify(
+ val
+ )}\`.`
+ );
}
if (val === '') {
- warn(logging, 'getStaticPaths', `invalid path param: ${key}. \`undefined\` expected for an optional param, but got empty string.`);
+ warn(
+ logging,
+ 'getStaticPaths',
+ `invalid path param: ${key}. \`undefined\` expected for an optional param, but got empty string.`
+ );
}
}
});
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts
index 2ec2a1744..703e01ec9 100644
--- a/packages/astro/src/core/util.ts
+++ b/packages/astro/src/core/util.ts
@@ -34,14 +34,16 @@ export function getOutputFilename(astroConfig: AstroConfig, name: string) {
if (name === '/' || name === '') {
return path.posix.join(name, 'index.html');
}
- if (astroConfig.buildOptions.pageUrlFormat === 'directory' && !STATUS_CODE_REGEXP.test(name)) {
+ if (astroConfig.build.format === 'directory' && !STATUS_CODE_REGEXP.test(name)) {
return path.posix.join(name, 'index.html');
}
return `${removeEndingForwardSlash(name || 'index')}.html`;
}
/** is a specifier an npm package? */
-export function parseNpmName(spec: string): { scope?: string; name: string; subpath?: string } | undefined {
+export function parseNpmName(
+ spec: string
+): { scope?: string; name: string; subpath?: string } | undefined {
// not an npm package
if (!spec || spec[0] === '.' || spec[0] === '/') return undefined;
@@ -66,7 +68,9 @@ export function parseNpmName(spec: string): { scope?: string; name: string; subp
/** Coalesce any throw variable to an Error instance. */
export function createSafeError(err: any): Error {
- return err instanceof Error || (err && err.name && err.message) ? err : new Error(JSON.stringify(err));
+ return err instanceof Error || (err && err.name && err.message)
+ ? err
+ : new Error(JSON.stringify(err));
}
/** generate code frame from esbuild error */
@@ -90,14 +94,17 @@ export function codeFrame(src: string, loc: ErrorPayload['err']['loc']): string
const isFocusedLine = lineNo === loc.line - 1;
output += isFocusedLine ? '> ' : ' ';
output += `${lineNo + 1} | ${lines[lineNo]}\n`;
- if (isFocusedLine) output += `${[...new Array(gutterWidth)].join(' ')} | ${[...new Array(loc.column)].join(' ')}^\n`;
+ if (isFocusedLine)
+ output += `${[...new Array(gutterWidth)].join(' ')} | ${[...new Array(loc.column)].join(
+ ' '
+ )}^\n`;
}
return output;
}
export function resolveDependency(dep: string, astroConfig: AstroConfig) {
const resolved = resolve.sync(dep, {
- basedir: fileURLToPath(astroConfig.projectRoot),
+ basedir: fileURLToPath(astroConfig.root),
});
// For Windows compat, we need a fully resolved `file://` URL string
return pathToFileURL(resolved).toString();
@@ -138,12 +145,16 @@ export function emptyDir(_dir: URL, skip?: Set<string>): void {
}
}
+export function resolvePages(config: AstroConfig) {
+ return new URL('./pages', config.srcDir);
+}
+
export function isBuildingToSSR(config: AstroConfig): boolean {
const adapter = config._ctx.adapter;
if (!adapter) return false;
if (typeof adapter.serverEntrypoint === 'string') {
- if (!adapter.name.startsWith('@astrojs/') && !config.buildOptions.experimentalSsr) {
+ if (!adapter.name.startsWith('@astrojs/') && !config.experimental.ssr) {
throw new Error(
[
`Server-side rendering (SSR) is still experimental.`,
@@ -166,17 +177,7 @@ export function emoji(char: string, fallback: string) {
return process.platform !== 'win32' ? char : fallback;
}
-// TODO: remove once --hostname is baselined
-export function getResolvedHostForVite(config: AstroConfig) {
- if (config.devOptions.host === false && config.devOptions.hostname !== 'localhost') {
- return config.devOptions.hostname;
- } else {
- return config.devOptions.host;
- }
-}
-
-export function getLocalAddress(serverAddress: string, config: AstroConfig): string {
- const host = getResolvedHostForVite(config);
+export function getLocalAddress(serverAddress: string, host: string | boolean): string {
if (typeof host === 'boolean' || host === 'localhost') {
return 'localhost';
} else {
diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts
index 93176a6bf..9e96b1a5a 100644
--- a/packages/astro/src/integrations/index.ts
+++ b/packages/astro/src/integrations/index.ts
@@ -5,7 +5,13 @@ import { mergeConfig } from '../core/config.js';
import ssgAdapter from '../adapter-ssg/index.js';
import type { ViteConfigWithSSR } from '../core/create-vite.js';
-export async function runHookConfigSetup({ config: _config, command }: { config: AstroConfig; command: 'dev' | 'build' }): Promise<AstroConfig> {
+export async function runHookConfigSetup({
+ config: _config,
+ command,
+}: {
+ config: AstroConfig;
+ command: 'dev' | 'build';
+}): Promise<AstroConfig> {
if (_config.adapter) {
_config.integrations.push(_config.adapter);
}
@@ -38,7 +44,9 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
config,
setAdapter(adapter) {
if (config._ctx.adapter && config._ctx.adapter.name !== adapter.name) {
- throw new Error(`Adapter already set to ${config._ctx.adapter.name}. You can only have one adapter.`);
+ throw new Error(
+ `Adapter already set to ${config._ctx.adapter.name}. You can only have one adapter.`
+ );
}
config._ctx.adapter = adapter;
},
@@ -60,7 +68,13 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
}
}
-export async function runHookServerSetup({ config, server }: { config: AstroConfig; server: ViteDevServer }) {
+export async function runHookServerSetup({
+ config,
+ server,
+}: {
+ config: AstroConfig;
+ server: ViteDevServer;
+}) {
for (const integration of config.integrations) {
if (integration.hooks['astro:server:setup']) {
await integration.hooks['astro:server:setup']({ server });
@@ -68,7 +82,13 @@ export async function runHookServerSetup({ config, server }: { config: AstroConf
}
}
-export async function runHookServerStart({ config, address }: { config: AstroConfig; address: AddressInfo }) {
+export async function runHookServerStart({
+ config,
+ address,
+}: {
+ config: AstroConfig;
+ address: AddressInfo;
+}) {
for (const integration of config.integrations) {
if (integration.hooks['astro:server:start']) {
await integration.hooks['astro:server:start']({ address });
@@ -84,7 +104,13 @@ export async function runHookServerDone({ config }: { config: AstroConfig }) {
}
}
-export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig; buildConfig: BuildConfig }) {
+export async function runHookBuildStart({
+ config,
+ buildConfig,
+}: {
+ config: AstroConfig;
+ buildConfig: BuildConfig;
+}) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:start']) {
await integration.hooks['astro:build:start']({ buildConfig });
@@ -92,7 +118,15 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro
}
}
-export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig; vite: ViteConfigWithSSR; target: 'server' | 'client' }) {
+export async function runHookBuildSetup({
+ config,
+ vite,
+ target,
+}: {
+ config: AstroConfig;
+ vite: ViteConfigWithSSR;
+ target: 'server' | 'client';
+}) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:setup']) {
await integration.hooks['astro:build:setup']({ vite, target });
@@ -100,10 +134,22 @@ export async function runHookBuildSetup({ config, vite, target }: { config: Astr
}
}
-export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
+export async function runHookBuildDone({
+ config,
+ pages,
+ routes,
+}: {
+ config: AstroConfig;
+ pages: string[];
+ routes: RouteData[];
+}) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:done']) {
- await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
+ await integration.hooks['astro:build:done']({
+ pages: pages.map((p) => ({ pathname: p })),
+ dir: config.outDir,
+ routes,
+ });
}
}
}
diff --git a/packages/astro/src/runtime/client/idle.ts b/packages/astro/src/runtime/client/idle.ts
index 4d7d52245..627d896db 100644
--- a/packages/astro/src/runtime/client/idle.ts
+++ b/packages/astro/src/runtime/client/idle.ts
@@ -4,7 +4,11 @@ import type { GetHydrateCallback, HydrateOptions } from '../../@types/astro';
* Hydrate this component as soon as the main thread is free
* (or after a short delay, if `requestIdleCallback`) isn't supported
*/
-export default async function onIdle(astroId: string, options: HydrateOptions, getHydrateCallback: GetHydrateCallback) {
+export default async function onIdle(
+ astroId: string,
+ options: HydrateOptions,
+ getHydrateCallback: GetHydrateCallback
+) {
const cb = async () => {
const roots = document.querySelectorAll(`astro-root[uid="${astroId}"]`);
if (roots.length === 0) {
diff --git a/packages/astro/src/runtime/client/load.ts b/packages/astro/src/runtime/client/load.ts
index a9a6fcf6b..cf4cd83af 100644
--- a/packages/astro/src/runtime/client/load.ts
+++ b/packages/astro/src/runtime/client/load.ts
@@ -3,7 +3,11 @@ import type { GetHydrateCallback, HydrateOptions } from '../../@types/astro';
/**
* Hydrate this component immediately
*/
-export default async function onLoad(astroId: string, options: HydrateOptions, getHydrateCallback: GetHydrateCallback) {
+export default async function onLoad(
+ astroId: string,
+ options: HydrateOptions,
+ getHydrateCallback: GetHydrateCallback
+) {
const roots = document.querySelectorAll(`astro-root[uid="${astroId}"]`);
if (roots.length === 0) {
throw new Error(`Unable to find the root for the component ${options.name}`);
diff --git a/packages/astro/src/runtime/client/media.ts b/packages/astro/src/runtime/client/media.ts
index 56d67d95f..32e883908 100644
--- a/packages/astro/src/runtime/client/media.ts
+++ b/packages/astro/src/runtime/client/media.ts
@@ -3,7 +3,11 @@ import type { GetHydrateCallback, HydrateOptions } from '../../@types/astro';
/**
* Hydrate this component when a matching media query is found
*/
-export default async function onMedia(astroId: string, options: HydrateOptions, getHydrateCallback: GetHydrateCallback) {
+export default async function onMedia(
+ astroId: string,
+ options: HydrateOptions,
+ getHydrateCallback: GetHydrateCallback
+) {
const roots = document.querySelectorAll(`astro-root[uid="${astroId}"]`);
if (roots.length === 0) {
throw new Error(`Unable to find the root for the component ${options.name}`);
diff --git a/packages/astro/src/runtime/client/only.ts b/packages/astro/src/runtime/client/only.ts
index 472a6badd..6400d44b8 100644
--- a/packages/astro/src/runtime/client/only.ts
+++ b/packages/astro/src/runtime/client/only.ts
@@ -3,7 +3,11 @@ import type { GetHydrateCallback, HydrateOptions } from '../../@types/astro';
/**
* Hydrate this component immediately
*/
-export default async function onLoad(astroId: string, options: HydrateOptions, getHydrateCallback: GetHydrateCallback) {
+export default async function onLoad(
+ astroId: string,
+ options: HydrateOptions,
+ getHydrateCallback: GetHydrateCallback
+) {
const roots = document.querySelectorAll(`astro-root[uid="${astroId}"]`);
if (roots.length === 0) {
throw new Error(`Unable to find the root for the component ${options.name}`);
diff --git a/packages/astro/src/runtime/client/visible.ts b/packages/astro/src/runtime/client/visible.ts
index 1e6f7ea3c..e0c1fdc73 100644
--- a/packages/astro/src/runtime/client/visible.ts
+++ b/packages/astro/src/runtime/client/visible.ts
@@ -5,7 +5,11 @@ import type { GetHydrateCallback, HydrateOptions } from '../../@types/astro';
* We target the children because `astro-root` is set to `display: contents`
* which doesn't work with IntersectionObserver
*/
-export default async function onVisible(astroId: string, options: HydrateOptions, getHydrateCallback: GetHydrateCallback) {
+export default async function onVisible(
+ astroId: string,
+ options: HydrateOptions,
+ getHydrateCallback: GetHydrateCallback
+) {
const roots = document.querySelectorAll(`astro-root[uid="${astroId}"]`);
if (roots.length === 0) {
throw new Error(`Unable to find the root for the component ${options.name}`);
diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts
index c963e42c8..e7267fe16 100644
--- a/packages/astro/src/runtime/server/hydration.ts
+++ b/packages/astro/src/runtime/server/hydration.ts
@@ -58,12 +58,21 @@ export function extractDirectives(inputProps: Record<string | number, any>): Ext
// throw an error if an invalid hydration directive was provided
if (HydrationDirectives.indexOf(extracted.hydration.directive) < 0) {
- throw new Error(`Error: invalid hydration directive "${key}". Supported hydration methods: ${HydrationDirectives.map((d) => `"client:${d}"`).join(', ')}`);
+ throw new Error(
+ `Error: invalid hydration directive "${key}". Supported hydration methods: ${HydrationDirectives.map(
+ (d) => `"client:${d}"`
+ ).join(', ')}`
+ );
}
// throw an error if the query wasn't provided for client:media
- if (extracted.hydration.directive === 'media' && typeof extracted.hydration.value !== 'string') {
- throw new Error('Error: Media query must be provided for "client:media", similar to client:media="(max-width: 600px)"');
+ if (
+ extracted.hydration.directive === 'media' &&
+ typeof extracted.hydration.value !== 'string'
+ ) {
+ throw new Error(
+ 'Error: Media query must be provided for "client:media", similar to client:media="(max-width: 600px)"'
+ );
}
break;
@@ -88,20 +97,27 @@ interface HydrateScriptOptions {
}
/** For hydrated components, generate a <script type="module"> to load the component */
-export async function generateHydrateScript(scriptOptions: HydrateScriptOptions, metadata: Required<AstroComponentMetadata>): Promise<SSRElement> {
+export async function generateHydrateScript(
+ scriptOptions: HydrateScriptOptions,
+ metadata: Required<AstroComponentMetadata>
+): Promise<SSRElement> {
const { renderer, result, astroId, props } = scriptOptions;
const { hydrate, componentUrl, componentExport } = metadata;
if (!componentExport) {
- throw new Error(`Unable to resolve a componentExport for "${metadata.displayName}"! Please open an issue.`);
+ throw new Error(
+ `Unable to resolve a componentExport for "${metadata.displayName}"! Please open an issue.`
+ );
}
let hydrationSource = ``;
hydrationSource += renderer.clientEntrypoint
- ? `const [{ ${componentExport.value}: Component }, { default: hydrate }] = await Promise.all([import("${await result.resolve(componentUrl)}"), import("${await result.resolve(
- renderer.clientEntrypoint
- )}")]);
+ ? `const [{ ${
+ componentExport.value
+ }: Component }, { default: hydrate }] = await Promise.all([import("${await result.resolve(
+ componentUrl
+ )}"), import("${await result.resolve(renderer.clientEntrypoint)}")]);
return (el, children) => hydrate(el)(Component, ${serializeProps(props)}, children);
`
: `await import("${await result.resolve(componentUrl)}");
@@ -113,7 +129,9 @@ export async function generateHydrateScript(scriptOptions: HydrateScriptOptions,
props: { type: 'module', 'data-astro-component-hydration': true },
children: `import setup from '${await result.resolve(hydrationSpecifier(hydrate))}';
${`import '${await result.resolve('astro:scripts/before-hydration.js')}';`}
-setup("${astroId}", {name:"${metadata.displayName}",${metadata.hydrateArgs ? `value: ${JSON.stringify(metadata.hydrateArgs)}` : ''}}, async () => {
+setup("${astroId}", {name:"${metadata.displayName}",${
+ metadata.hydrateArgs ? `value: ${JSON.stringify(metadata.hydrateArgs)}` : ''
+ }}, async () => {
${hydrationSource}
});
`,
diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts
index 7cf56c35f..61ad2d0e7 100644
--- a/packages/astro/src/runtime/server/index.ts
+++ b/packages/astro/src/runtime/server/index.ts
@@ -1,5 +1,13 @@
import shorthash from 'shorthash';
-import type { AstroComponentMetadata, AstroGlobalPartial, EndpointHandler, Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
+import type {
+ AstroComponentMetadata,
+ AstroGlobalPartial,
+ EndpointHandler,
+ Params,
+ SSRElement,
+ SSRLoadedRenderer,
+ SSRResult,
+} from '../../@types/astro';
import { escapeHTML, HTMLString, markHTMLString } from './escape.js';
import { extractDirectives, generateHydrateScript, serializeProps } from './hydration.js';
import { serializeListValue } from './util.js';
@@ -8,7 +16,8 @@ export { markHTMLString, markHTMLString as unescapeHTML } from './escape.js';
export type { Metadata } from './metadata';
export { createMetadata } from './metadata.js';
-const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
+const voidElementNames =
+ /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
const htmlBooleanAttributes =
/^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
@@ -40,7 +49,10 @@ async function _render(child: any): Promise<any> {
}
// Add a comment explaining why each of these are needed.
// Maybe create clearly named function for what this is doing.
- else if (child instanceof AstroComponent || Object.prototype.toString.call(child) === '[object AstroComponent]') {
+ else if (
+ child instanceof AstroComponent ||
+ Object.prototype.toString.call(child) === '[object AstroComponent]'
+ ) {
return markHTMLString(await renderAstroComponent(child));
} else {
return child;
@@ -76,7 +88,9 @@ export class AstroComponent {
}
function isAstroComponent(obj: any): obj is AstroComponent {
- return typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object AstroComponent]';
+ return (
+ typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object AstroComponent]'
+ );
}
export async function render(htmlParts: TemplateStringsArray, ...expressions: any[]) {
@@ -128,7 +142,13 @@ function formatList(values: string[]): string {
return `${values.slice(0, -1).join(', ')} or ${values[values.length - 1]}`;
}
-export async function renderComponent(result: SSRResult, displayName: string, Component: unknown, _props: Record<string | number, any>, slots: any = {}) {
+export async function renderComponent(
+ result: SSRResult,
+ displayName: string,
+ Component: unknown,
+ _props: Record<string | number, any>,
+ slots: any = {}
+) {
Component = await Component;
const children = await renderSlot(result, slots?.default);
@@ -145,7 +165,9 @@ export async function renderComponent(result: SSRResult, displayName: string, Co
}
if (Component === null && !_props['client:only']) {
- throw new Error(`Unable to render ${displayName} because it is ${Component}!\nDid you forget to import the component or is it possible there is a typo?`);
+ throw new Error(
+ `Unable to render ${displayName} because it is ${Component}!\nDid you forget to import the component or is it possible there is a typo?`
+ );
}
const { renderers } = result._metadata;
@@ -162,7 +184,12 @@ export async function renderComponent(result: SSRResult, displayName: string, Co
}
const probableRendererNames = guessRenderers(metadata.componentUrl);
- if (Array.isArray(renderers) && renderers.length === 0 && typeof Component !== 'string' && !componentIsHTMLElement(Component)) {
+ if (
+ Array.isArray(renderers) &&
+ renderers.length === 0 &&
+ typeof Component !== 'string' &&
+ !componentIsHTMLElement(Component)
+ ) {
const message = `Unable to render ${metadata.displayName}!
There are no \`integrations\` set in your \`astro.config.mjs\` file.
@@ -189,7 +216,9 @@ Did you mean to add ${formatList(probableRendererNames.map((r) => '`' + r + '`')
// Attempt: use explicitly passed renderer name
if (metadata.hydrateArgs) {
const rendererName = metadata.hydrateArgs;
- renderer = renderers.filter(({ name }) => name === `@astrojs/${rendererName}` || name === rendererName)[0];
+ renderer = renderers.filter(
+ ({ name }) => name === `@astrojs/${rendererName}` || name === rendererName
+ )[0];
}
// Attempt: user only has a single renderer, default to that
if (!renderer && renderers.length === 1) {
@@ -198,7 +227,9 @@ Did you mean to add ${formatList(probableRendererNames.map((r) => '`' + r + '`')
// Attempt: can we guess the renderer from the export extension?
if (!renderer) {
const extname = metadata.componentUrl?.split('.').pop();
- renderer = renderers.filter(({ name }) => name === `@astrojs/${extname}` || name === extname)[0];
+ renderer = renderers.filter(
+ ({ name }) => name === `@astrojs/${extname}` || name === extname
+ )[0];
}
}
@@ -209,7 +240,9 @@ Did you mean to add ${formatList(probableRendererNames.map((r) => '`' + r + '`')
throw new Error(`Unable to render ${metadata.displayName}!
Using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.
-Did you mean to pass <${metadata.displayName} client:only="${probableRendererNames.map((r) => r.replace('@astrojs/', '')).join('|')}" />
+Did you mean to pass <${metadata.displayName} client:only="${probableRendererNames
+ .map((r) => r.replace('@astrojs/', ''))
+ .join('|')}" />
`);
} else if (typeof Component !== 'string') {
const matchingRenderers = renderers.filter((r) => probableRendererNames.includes(r.name));
@@ -217,7 +250,9 @@ Did you mean to pass <${metadata.displayName} client:only="${probableRendererNam
if (matchingRenderers.length === 0) {
throw new Error(`Unable to render ${metadata.displayName}!
-There ${plural ? 'are' : 'is'} ${renderers.length} renderer${plural ? 's' : ''} configured in your \`astro.config.mjs\` file,
+There ${plural ? 'are' : 'is'} ${renderers.length} renderer${
+ plural ? 's' : ''
+ } configured in your \`astro.config.mjs\` file,
but ${plural ? 'none were' : 'it was not'} able to server-side render ${metadata.displayName}.
Did you mean to enable ${formatList(probableRendererNames.map((r) => '`' + r + '`'))}?`);
@@ -253,7 +288,9 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
if (!html && typeof Component === 'string') {
html = await renderAstroComponent(
await render`<${Component}${spreadAttributes(props)}${markHTMLString(
- (children == null || children == '') && voidElementNames.test(Component) ? `/>` : `>${children}</${Component}>`
+ (children == null || children == '') && voidElementNames.test(Component)
+ ? `/>`
+ : `>${children}</${Component}>`
)}`
);
}
@@ -263,16 +300,29 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
}
// Include componentExport name, componentUrl, and props in hash to dedupe identical islands
- const astroId = shorthash.unique(`<!--${metadata.componentExport!.value}:${metadata.componentUrl}-->\n${html}\n${serializeProps(props)}`);
+ const astroId = shorthash.unique(
+ `<!--${metadata.componentExport!.value}:${metadata.componentUrl}-->\n${html}\n${serializeProps(
+ props
+ )}`
+ );
// Rather than appending this inline in the page, puts this into the `result.scripts` set that will be appended to the head.
// INVESTIGATE: This will likely be a problem in streaming because the `<head>` will be gone at this point.
- result.scripts.add(await generateHydrateScript({ renderer: renderer!, result, astroId, props }, metadata as Required<AstroComponentMetadata>));
+ result.scripts.add(
+ await generateHydrateScript(
+ { renderer: renderer!, result, astroId, props },
+ metadata as Required<AstroComponentMetadata>
+ )
+ );
// Render a template if no fragment is provided.
const needsAstroTemplate = children && !/<\/?astro-fragment\>/.test(html);
const template = needsAstroTemplate ? `<template data-astro-template>${children}</template>` : '';
- return markHTMLString(`<astro-root uid="${astroId}"${needsAstroTemplate ? ' tmpl' : ''}>${html ?? ''}${template}</astro-root>`);
+ return markHTMLString(
+ `<astro-root uid="${astroId}"${needsAstroTemplate ? ' tmpl' : ''}>${
+ html ?? ''
+ }${template}</astro-root>`
+ );
}
/** Create the Astro.fetchContent() runtime function. */
@@ -299,7 +349,11 @@ function createAstroGlobFn() {
// This is used to create the top-level Astro global; the one that you can use
// Inside of getStaticPaths.
-export function createAstro(filePathname: string, _site: string, projectRootStr: string): AstroGlobalPartial {
+export function createAstro(
+ filePathname: string,
+ _site: string,
+ projectRootStr: string
+): AstroGlobalPartial {
const site = new URL(_site);
const url = new URL(filePathname, site);
const projectRoot = new URL(projectRootStr);
@@ -320,7 +374,8 @@ export function createAstro(filePathname: string, _site: string, projectRootStr:
};
}
-const toAttributeString = (value: any, shouldEscape = true) => (shouldEscape ? String(value).replace(/&/g, '&#38;').replace(/"/g, '&#34;') : value);
+const toAttributeString = (value: any, shouldEscape = true) =>
+ shouldEscape ? String(value).replace(/&/g, '&#38;').replace(/"/g, '&#34;') : value;
const STATIC_DIRECTIVES = new Set(['set:html', 'set:text']);
@@ -392,7 +447,9 @@ export async function renderEndpoint(mod: EndpointHandler, request: Request, par
const handler = mod[chosenMethod];
if (!handler || typeof handler !== 'function') {
- throw new Error(`Endpoint handler not found! Expected an exported function for "${chosenMethod}"`);
+ throw new Error(
+ `Endpoint handler not found! Expected an exported function for "${chosenMethod}"`
+ );
}
return await handler.call(mod, params, request);
@@ -409,7 +466,12 @@ async function replaceHeadInjection(result: SSRResult, html: string): Promise<st
}
// Calls a component and renders it into a string of HTML
-export async function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string> {
+export async function renderToString(
+ result: SSRResult,
+ componentFactory: AstroComponentFactory,
+ props: any,
+ children: any
+): Promise<string> {
const Component = await componentFactory(result, props, children);
if (!isAstroComponent(Component)) {
const response: Response = Component;
@@ -458,7 +520,9 @@ export async function renderPage(
const uniqueElements = (item: any, index: number, all: any[]) => {
const props = JSON.stringify(item.props);
const children = item.children;
- return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
+ return (
+ index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children)
+ );
};
// Renders a page to completion by first calling the factory callback, waiting for its result, and then appending
@@ -467,6 +531,7 @@ export async function renderHead(result: SSRResult): Promise<string> {
const styles = Array.from(result.styles)
.filter(uniqueElements)
.map((style) => {
+ // TODO: clean up legacyBuild from metadata
const styleChildren = !result._metadata.legacyBuild ? '' : style.children;
return renderElement('style', {
children: styleChildren,
@@ -486,12 +551,19 @@ export async function renderHead(result: SSRResult): Promise<string> {
});
});
if (needsHydrationStyles) {
- styles.push(renderElement('style', { props: { 'astro-style': true }, children: 'astro-root, astro-fragment { display: contents; }' }));
+ styles.push(
+ renderElement('style', {
+ props: { 'astro-style': true },
+ children: 'astro-root, astro-fragment { display: contents; }',
+ })
+ );
}
const links = Array.from(result.links)
.filter(uniqueElements)
.map((link) => renderElement('link', link, false));
- return markHTMLString(links.join('\n') + styles.join('\n') + scripts.join('\n') + '\n' + '<!--astro:head:injected-->');
+ return markHTMLString(
+ links.join('\n') + styles.join('\n') + scripts.join('\n') + '\n' + '<!--astro:head:injected-->'
+ );
}
export async function renderAstroComponent(component: InstanceType<typeof AstroComponent>) {
@@ -510,7 +582,12 @@ function componentIsHTMLElement(Component: unknown) {
return typeof HTMLElement !== 'undefined' && HTMLElement.isPrototypeOf(Component as object);
}
-export async function renderHTMLElement(result: SSRResult, constructor: typeof HTMLElement, props: any, slots: any) {
+export async function renderHTMLElement(
+ result: SSRResult,
+ constructor: typeof HTMLElement,
+ props: any,
+ slots: any
+) {
const name = getHTMLElementName(constructor);
let attrHTML = '';
@@ -519,11 +596,15 @@ export async function renderHTMLElement(result: SSRResult, constructor: typeof H
attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
}
- return markHTMLString(`<${name}${attrHTML}>${await renderSlot(result, slots?.default)}</${name}>`);
+ return markHTMLString(
+ `<${name}${attrHTML}>${await renderSlot(result, slots?.default)}</${name}>`
+ );
}
function getHTMLElementName(constructor: typeof HTMLElement) {
- const definedName = (customElements as CustomElementRegistry & { getName(_constructor: typeof HTMLElement): string }).getName(constructor);
+ const definedName = (
+ customElements as CustomElementRegistry & { getName(_constructor: typeof HTMLElement): string }
+ ).getName(constructor);
if (definedName) return definedName;
const assignedName = constructor.name
@@ -534,17 +615,22 @@ function getHTMLElementName(constructor: typeof HTMLElement) {
return assignedName;
}
-function renderElement(name: string, { props: _props, children = '' }: SSRElement, shouldEscape = true) {
- // Do not print `hoist`, `lang`, `global`
+function renderElement(
+ name: string,
+ { props: _props, children = '' }: SSRElement,
+ shouldEscape = true
+) {
+ // Do not print `hoist`, `lang`, `is:global`
const { lang: _, 'data-astro-id': astroId, 'define:vars': defineVars, ...props } = _props;
if (defineVars) {
if (name === 'style') {
- if (props.global) {
+ if (props['is:global']) {
children = defineStyleVars(`:root`, defineVars) + '\n' + children;
} else {
children = defineStyleVars(`.astro-${astroId}`, defineVars) + '\n' + children;
}
- delete props.global;
+ delete props['is:global'];
+ delete props['is:scoped'];
}
if (name === 'script') {
delete props.hoist;
diff --git a/packages/astro/src/template/4xx.ts b/packages/astro/src/template/4xx.ts
index 7f90b6e16..e498d7e30 100644
--- a/packages/astro/src/template/4xx.ts
+++ b/packages/astro/src/template/4xx.ts
@@ -15,7 +15,13 @@ interface ErrorTemplateOptions {
}
/** Display all errors */
-export default function template({ title, pathname, statusCode = 404, tabTitle, body }: ErrorTemplateOptions): string {
+export default function template({
+ title,
+ pathname,
+ statusCode = 404,
+ tabTitle,
+ body,
+}: ErrorTemplateOptions): string {
return `<!doctype html>
<html lang="en">
<head>
@@ -46,7 +52,9 @@ export default function template({ title, pathname, statusCode = 404, tabTitle,
<body>
<main class="center">
<svg class="astro" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M163.008 18.929c1.944 2.413 2.935 5.67 4.917 12.181l43.309 142.27a180.277 180.277 0 00-51.778-17.53l-28.198-95.29a3.67 3.67 0 00-7.042.01l-27.857 95.232a180.225 180.225 0 00-52.01 17.557l43.52-142.281c1.99-6.502 2.983-9.752 4.927-12.16a15.999 15.999 0 016.484-4.798c2.872-1.154 6.271-1.154 13.07-1.154h31.085c6.807 0 10.211 0 13.086 1.157a16.004 16.004 0 016.487 4.806z" fill="white"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M168.19 180.151c-7.139 6.105-21.39 10.268-37.804 10.268-20.147 0-37.033-6.272-41.513-14.707-1.602 4.835-1.961 10.367-1.961 13.902 0 0-1.056 17.355 11.015 29.426 0-6.268 5.081-11.349 11.349-11.349 10.743 0 10.731 9.373 10.721 16.977v.679c0 11.542 7.054 21.436 17.086 25.606a23.27 23.27 0 01-2.339-10.2c0-11.008 6.463-15.107 13.974-19.87 5.976-3.79 12.616-8.001 17.192-16.449a31.024 31.024 0 003.743-14.82c0-3.299-.513-6.479-1.463-9.463z" fill="#ff5d01"></path></svg>
- <h1>${statusCode ? `<span class="statusCode">${statusCode}: </span> ` : ''}<span class="statusMessage">${title}</span></h1>
+ <h1>${
+ statusCode ? `<span class="statusCode">${statusCode}: </span> ` : ''
+ }<span class="statusMessage">${title}</span></h1>
${
body ||
`
@@ -64,7 +72,7 @@ export function subpathNotUsedTemplate(base: string, pathname: string) {
statusCode: 404,
title: 'Not found',
tabTitle: '404: Not Found',
- body: `<p>In your <code>buildOptions.site</code> you have your base path set to <a href="${base}">${base}</a>. Do you want to go there instead?</p>
+ body: `<p>In your <code>site</code> you have your base path set to <a href="${base}">${base}</a>. Do you want to go there instead?</p>
<p>Come to our <a href="https://astro.build/chat">Discord</a> if you need help.</p>`,
});
}
diff --git a/packages/astro/src/template/5xx.ts b/packages/astro/src/template/5xx.ts
index ee1f17fa6..a40c3e47d 100644
--- a/packages/astro/src/template/5xx.ts
+++ b/packages/astro/src/template/5xx.ts
@@ -17,7 +17,14 @@ interface ErrorTemplateOptions {
}
/** Display all errors */
-export default function template({ title, url, message, stack, statusCode, tabTitle }: ErrorTemplateOptions): string {
+export default function template({
+ title,
+ url,
+ message,
+ stack,
+ statusCode,
+ tabTitle,
+}: ErrorTemplateOptions): string {
let error = url ? message.replace(url, '') : message;
return `<!doctype html>
<html lang="en">
@@ -60,7 +67,9 @@ export default function template({ title, url, message, stack, statusCode, tabTi
<main class="wrapper">
<header>
<svg class="astro" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M163.008 18.929c1.944 2.413 2.935 5.67 4.917 12.181l43.309 142.27a180.277 180.277 0 00-51.778-17.53l-28.198-95.29a3.67 3.67 0 00-7.042.01l-27.857 95.232a180.225 180.225 0 00-52.01 17.557l43.52-142.281c1.99-6.502 2.983-9.752 4.927-12.16a15.999 15.999 0 016.484-4.798c2.872-1.154 6.271-1.154 13.07-1.154h31.085c6.807 0 10.211 0 13.086 1.157a16.004 16.004 0 016.487 4.806z" fill="white"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M168.19 180.151c-7.139 6.105-21.39 10.268-37.804 10.268-20.147 0-37.033-6.272-41.513-14.707-1.602 4.835-1.961 10.367-1.961 13.902 0 0-1.056 17.355 11.015 29.426 0-6.268 5.081-11.349 11.349-11.349 10.743 0 10.731 9.373 10.721 16.977v.679c0 11.542 7.054 21.436 17.086 25.606a23.27 23.27 0 01-2.339-10.2c0-11.008 6.463-15.107 13.974-19.87 5.976-3.79 12.616-8.001 17.192-16.449a31.024 31.024 0 003.743-14.82c0-3.299-.513-6.479-1.463-9.463z" fill="#ff5d01"></path></svg>
- <h1>${statusCode ? `<span class="statusCode">${statusCode}: </span> ` : ''}<span class="statusMessage">${title}</span></h1>
+ <h1>${
+ statusCode ? `<span class="statusCode">${statusCode}: </span> ` : ''
+ }<span class="statusMessage">${title}</span></h1>
</header>
<pre>${encode(error)}</pre>
${url ? `<a target="_blank" href="${url}">${url}</a>` : ''}
diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts
index 58bd7566d..3e53e5044 100644
--- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts
+++ b/packages/astro/src/vite-plugin-astro-postprocess/index.ts
@@ -1,5 +1,9 @@
import { parse as babelParser } from '@babel/parser';
-import type { ArrowFunctionExpressionKind, CallExpressionKind, StringLiteralKind } from 'ast-types/gen/kinds';
+import type {
+ ArrowFunctionExpressionKind,
+ CallExpressionKind,
+ StringLiteralKind,
+} from 'ast-types/gen/kinds';
import type { NodePath } from 'ast-types/lib/node-path';
import { parse, print, types, visit } from 'recast';
import type { Plugin } from 'vite';
@@ -58,7 +62,11 @@ export default function astro({ config }: AstroPluginOptions): Plugin {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
- object: { type: 'MetaProperty', meta: { type: 'Identifier', name: 'import' }, property: { type: 'Identifier', name: 'meta' } },
+ object: {
+ type: 'MetaProperty',
+ meta: { type: 'Identifier', name: 'import' },
+ property: { type: 'Identifier', name: 'meta' },
+ },
property: { type: 'Identifier', name: 'glob' },
computed: false,
},
diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts
index 5d85555af..dba3b861b 100644
--- a/packages/astro/src/vite-plugin-astro-server/index.ts
+++ b/packages/astro/src/vite-plugin-astro-server/index.ts
@@ -6,7 +6,7 @@ import { debug, info, warn, error, LogOptions } from '../core/logger/core.js';
import { getParamsAndProps, GetParamsAndPropsError } from '../core/render/core.js';
import { createRouteManifest, matchRoute } from '../core/routing/index.js';
import stripAnsi from 'strip-ansi';
-import { createSafeError, isBuildingToSSR } from '../core/util.js';
+import { createSafeError, resolvePages, isBuildingToSSR } from '../core/util.js';
import { ssr, preload } from '../core/render/dev/index.js';
import { call as callEndpoint } from '../core/endpoint/dev/index.js';
import * as msg from '../core/messages.js';
@@ -22,7 +22,11 @@ interface AstroPluginOptions {
logging: LogOptions;
}
-const BAD_VITE_MIDDLEWARE = ['viteIndexHtmlMiddleware', 'vite404Middleware', 'viteSpaFallbackMiddleware'];
+const BAD_VITE_MIDDLEWARE = [
+ 'viteIndexHtmlMiddleware',
+ 'vite404Middleware',
+ 'viteSpaFallbackMiddleware',
+];
function removeViteHttpMiddleware(server: vite.Connect.Server) {
for (let i = server.stack.length - 1; i > 0; i--) {
// @ts-expect-error using internals until https://github.com/vitejs/vite/pull/4640 is merged
@@ -62,7 +66,11 @@ async function writeWebResponse(res: http.ServerResponse, webResponse: Response)
res.end();
}
-async function writeSSRResult(result: RenderResponse, res: http.ServerResponse, statusCode: 200 | 404) {
+async function writeSSRResult(
+ result: RenderResponse,
+ res: http.ServerResponse,
+ statusCode: 200 | 404
+) {
if (result.type === 'response') {
const { response } = result;
await writeWebResponse(res, response);
@@ -73,20 +81,36 @@ async function writeSSRResult(result: RenderResponse, res: http.ServerResponse,
writeHtmlResponse(res, statusCode, html);
}
-async function handle404Response(origin: string, config: AstroConfig, req: http.IncomingMessage, res: http.ServerResponse) {
- const site = config.buildOptions.site ? new URL(config.buildOptions.site) : undefined;
+async function handle404Response(
+ origin: string,
+ config: AstroConfig,
+ req: http.IncomingMessage,
+ res: http.ServerResponse
+) {
+ const site = config.site ? new URL(config.base, config.site) : undefined;
const devRoot = site ? site.pathname : '/';
const pathname = decodeURI(new URL(origin + req.url).pathname);
let html = '';
if (pathname === '/' && !pathname.startsWith(devRoot)) {
html = subpathNotUsedTemplate(devRoot, pathname);
} else {
- html = notFoundTemplate({ statusCode: 404, title: 'Not found', tabTitle: '404: Not Found', pathname });
+ html = notFoundTemplate({
+ statusCode: 404,
+ title: 'Not found',
+ tabTitle: '404: Not Found',
+ pathname,
+ });
}
writeHtmlResponse(res, 404, html);
}
-async function handle500Response(viteServer: vite.ViteDevServer, origin: string, req: http.IncomingMessage, res: http.ServerResponse, err: any) {
+async function handle500Response(
+ viteServer: vite.ViteDevServer,
+ origin: string,
+ req: http.IncomingMessage,
+ res: http.ServerResponse,
+ err: any
+) {
const pathname = decodeURI(new URL(origin + req.url).pathname);
const html = serverErrorTemplate({
statusCode: 500,
@@ -101,7 +125,7 @@ async function handle500Response(viteServer: vite.ViteDevServer, origin: string,
}
function getCustom404Route(config: AstroConfig, manifest: ManifestData) {
- const relPages = config.pages.href.replace(config.projectRoot.href, '');
+ const relPages = resolvePages(config).href.replace(config.root.href, '');
return manifest.routes.find((r) => r.component === relPages + '404.astro');
}
@@ -120,7 +144,7 @@ async function handleRequest(
res: http.ServerResponse
) {
const reqStart = performance.now();
- const site = config.buildOptions.site ? new URL(config.buildOptions.site) : undefined;
+ const site = config.site ? new URL(config.base, config.site) : undefined;
const devRoot = site ? site.pathname : '/';
const origin = `${viteServer.config.server.https ? 'https' : 'http'}://${req.headers.host}`;
const buildingToSSR = isBuildingToSSR(config);
@@ -174,7 +198,7 @@ async function handleRequest(
}
}
- const filePath = new URL(`./${route.component}`, config.projectRoot);
+ const filePath = new URL(`./${route.component}`, config.root);
const preloadedComponent = await preload({ astroConfig: config, filePath, viteServer });
const [, mod] = preloadedComponent;
// attempt to get static paths
@@ -188,12 +212,20 @@ async function handleRequest(
ssr: isBuildingToSSR(config),
});
if (paramsAndPropsRes === GetParamsAndPropsError.NoMatchingStaticPath) {
- warn(logging, 'getStaticPaths', `Route pattern matched, but no matching static path found. (${pathname})`);
+ warn(
+ logging,
+ 'getStaticPaths',
+ `Route pattern matched, but no matching static path found. (${pathname})`
+ );
log404(logging, pathname);
const routeCustom404 = getCustom404Route(config, manifest);
if (routeCustom404) {
- const filePathCustom404 = new URL(`./${routeCustom404.component}`, config.projectRoot);
- const preloadedCompCustom404 = await preload({ astroConfig: config, filePath: filePathCustom404, viteServer });
+ const filePathCustom404 = new URL(`./${routeCustom404.component}`, config.root);
+ const preloadedCompCustom404 = await preload({
+ astroConfig: config,
+ filePath: filePathCustom404,
+ viteServer,
+ });
const result = await ssr(preloadedCompCustom404, {
astroConfig: config,
filePath: filePathCustom404,
diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts
index 48bada5f4..afa4cd637 100644
--- a/packages/astro/src/vite-plugin-astro/compile.ts
+++ b/packages/astro/src/vite-plugin-astro/compile.ts
@@ -34,10 +34,16 @@ function safelyReplaceImportPlaceholder(code: string) {
const configCache = new WeakMap<AstroConfig, CompilationCache>();
-async function compile(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts: { ssr: boolean }): Promise<CompileResult> {
+async function compile(
+ config: AstroConfig,
+ filename: string,
+ source: string,
+ viteTransform: TransformHook,
+ opts: { ssr: boolean }
+): Promise<CompileResult> {
const filenameURL = new URL(`file://${filename}`);
const normalizedID = fileURLToPath(filenameURL);
- const pathname = filenameURL.pathname.substr(config.projectRoot.pathname.length - 1);
+ const pathname = filenameURL.pathname.substr(config.root.pathname.length - 1);
let rawCSSDeps = new Set<string>();
let cssTransformError: Error | undefined;
@@ -47,20 +53,23 @@ async function compile(config: AstroConfig, filename: string, source: string, vi
// result passed to esbuild, but also available in the catch handler.
const transformResult = await transform(source, {
pathname,
- projectRoot: config.projectRoot.toString(),
- site: config.buildOptions.site,
+ projectRoot: config.root.toString(),
+ site: config.site ? new URL(config.base, config.site).toString() : undefined,
sourcefile: filename,
sourcemap: 'both',
- internalURL: `/@fs${prependForwardSlash(viteID(new URL('../runtime/server/index.js', import.meta.url)))}`,
- experimentalStaticExtraction: !config.buildOptions.legacyBuild,
- // TODO add experimental flag here
+ internalURL: `/@fs${prependForwardSlash(
+ viteID(new URL('../runtime/server/index.js', import.meta.url))
+ )}`,
+ // TODO: baseline flag
+ experimentalStaticExtraction: true,
preprocessStyle: async (value: string, attrs: Record<string, string>) => {
const lang = `.${attrs?.lang || 'css'}`.toLowerCase();
try {
// In the static build, grab any @import as CSS dependencies for HMR.
- if (!config.buildOptions.legacyBuild) {
- value.replace(/(?:@import)\s(?:url\()?\s?["\'](.*?)["\']\s?\)?(?:[^;]*);?/gi, (match, spec) => {
+ value.replace(
+ /(?:@import)\s(?:url\()?\s?["\'](.*?)["\']\s?\)?(?:[^;]*);?/gi,
+ (match, spec) => {
rawCSSDeps.add(spec);
// If the language is CSS: prevent `@import` inlining to prevent scoping of imports.
// Otherwise: Sass, etc. need to see imports for variables, so leave in for their compiler to handle.
@@ -69,8 +78,8 @@ async function compile(config: AstroConfig, filename: string, source: string, vi
} else {
return match;
}
- });
- }
+ }
+ );
const result = await transformWithVite({
value,
@@ -122,7 +131,13 @@ export function invalidateCompilation(config: AstroConfig, filename: string) {
}
}
-export async function cachedCompilation(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts: { ssr: boolean }): Promise<CompileResult> {
+export async function cachedCompilation(
+ config: AstroConfig,
+ filename: string,
+ source: string,
+ viteTransform: TransformHook,
+ opts: { ssr: boolean }
+): Promise<CompileResult> {
let cache: CompilationCache;
if (!configCache.has(config)) {
cache = new Map();
diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts
index b70efa2a8..433b15901 100644
--- a/packages/astro/src/vite-plugin-astro/hmr.ts
+++ b/packages/astro/src/vite-plugin-astro/hmr.ts
@@ -13,7 +13,10 @@ interface TrackCSSDependenciesOptions {
deps: Set<string>;
}
-export async function trackCSSDependencies(this: RollupPluginContext, opts: TrackCSSDependenciesOptions): Promise<void> {
+export async function trackCSSDependencies(
+ this: RollupPluginContext,
+ opts: TrackCSSDependenciesOptions
+): Promise<void> {
const { viteDevServer, filename, deps, id } = opts;
// Dev, register CSS dependencies for HMR.
if (viteDevServer) {
@@ -80,10 +83,10 @@ export async function handleHotUpdate(ctx: HmrContext, config: AstroConfig, logg
}
const mod = ctx.modules.find((m) => m.file === ctx.file);
- const file = ctx.file.replace(config.projectRoot.pathname, '/');
// Note: this intentionally ONLY applies to Astro components
// HMR is handled for other file types by their respective plugins
+ const file = ctx.file.replace(config.root.pathname, '/');
if (ctx.file.endsWith('.astro')) {
ctx.server.ws.send({ type: 'custom', event: 'astro:update', data: { file } });
}
diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts
index aded8f425..d82bd2f33 100644
--- a/packages/astro/src/vite-plugin-astro/index.ts
+++ b/packages/astro/src/vite-plugin-astro/index.ts
@@ -14,6 +14,7 @@ import ancestor from 'common-ancestor-path';
import { trackCSSDependencies, handleHotUpdate } from './hmr.js';
import { isRelativePath, startsWithForwardSlash } from '../core/path.js';
import { PAGE_SCRIPT_ID, PAGE_SSR_SCRIPT_ID } from '../vite-plugin-scripts/index.js';
+import { resolvePages } from '../core/util.js';
const FRONTMATTER_PARSE_REGEXP = /^\-\-\-(.*)^\-\-\-/ms;
interface AstroPluginOptions {
@@ -26,14 +27,14 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
function normalizeFilename(filename: string) {
if (filename.startsWith('/@fs')) {
filename = filename.slice('/@fs'.length);
- } else if (filename.startsWith('/') && !ancestor(filename, config.projectRoot.pathname)) {
- filename = new URL('.' + filename, config.projectRoot).pathname;
+ } else if (filename.startsWith('/') && !ancestor(filename, config.root.pathname)) {
+ filename = new URL('.' + filename, config.root).pathname;
}
return filename;
}
function relativeToRoot(pathname: string) {
const arg = startsWithForwardSlash(pathname) ? '.' + pathname : pathname;
- const url = new URL(arg, config.projectRoot);
+ const url = new URL(arg, config.root);
return slash(fileURLToPath(url)) + url.search;
}
@@ -42,7 +43,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
let viteDevServer: vite.ViteDevServer | null = null;
// Variables for determing if an id starts with /src...
- const srcRootWeb = config.src.pathname.slice(config.projectRoot.pathname.length - 1);
+ const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1);
const isBrowserPath = (path: string) => path.startsWith(srcRootWeb);
return {
@@ -94,9 +95,9 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
const filename = normalizeFilename(parsedId.filename);
const fileUrl = new URL(`file://${filename}`);
let source = await fs.promises.readFile(fileUrl, 'utf-8');
- const isPage = fileUrl.pathname.startsWith(config.pages.pathname);
+ const isPage = fileUrl.pathname.startsWith(resolvePages(config).pathname);
if (isPage && config._ctx.scripts.some((s) => s.stage === 'page')) {
- source += `\n<script hoist src="${PAGE_SCRIPT_ID}" />`;
+ source += `\n<script src="${PAGE_SCRIPT_ID}" />`;
}
if (query.astro) {
if (query.type === 'style') {
@@ -104,10 +105,17 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
throw new Error(`Requests for Astro CSS must include an index.`);
}
- const transformResult = await cachedCompilation(config, filename, source, viteTransform, { ssr: Boolean(opts?.ssr) });
+ const transformResult = await cachedCompilation(config, filename, source, viteTransform, {
+ ssr: Boolean(opts?.ssr),
+ });
// Track any CSS dependencies so that HMR is triggered when they change.
- await trackCSSDependencies.call(this, { viteDevServer, id, filename, deps: transformResult.rawCSSDeps });
+ await trackCSSDependencies.call(this, {
+ viteDevServer,
+ id,
+ filename,
+ deps: transformResult.rawCSSDeps,
+ });
const csses = transformResult.css;
const code = csses[query.index];
@@ -119,7 +127,9 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
throw new Error(`Requests for hoisted scripts must include an index`);
}
- const transformResult = await cachedCompilation(config, filename, source, viteTransform, { ssr: Boolean(opts?.ssr) });
+ const transformResult = await cachedCompilation(config, filename, source, viteTransform, {
+ ssr: Boolean(opts?.ssr),
+ });
const scripts = transformResult.scripts;
const hoistedScript = scripts[query.index];
@@ -127,14 +137,29 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
throw new Error(`No hoisted script at index ${query.index}`);
}
+ if (hoistedScript.type === 'external') {
+ const src = hoistedScript.src!;
+ if (src.startsWith('/') && !isBrowserPath(src)) {
+ const publicDir = config.publicDir.pathname.replace(/\/$/, '').split('/').pop() + '/';
+ throw new Error(
+ `\n\n<script src="${src}"> references an asset in the "${publicDir}" directory. Please add the "is:inline" directive to keep this asset from being bundled.\n\nFile: ${filename}`
+ );
+ }
+ }
+
return {
- code: hoistedScript.type === 'inline' ? hoistedScript.code! : `import "${hoistedScript.src!}";`,
+ code:
+ hoistedScript.type === 'inline'
+ ? hoistedScript.code!
+ : `import "${hoistedScript.src!}";`,
};
}
}
try {
- const transformResult = await cachedCompilation(config, filename, source, viteTransform, { ssr: Boolean(opts?.ssr) });
+ const transformResult = await cachedCompilation(config, filename, source, viteTransform, {
+ ssr: Boolean(opts?.ssr),
+ });
// Compile all TypeScript to JavaScript.
// Also, catches invalid JS/TS in the compiled output before returning.
@@ -143,7 +168,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
sourcemap: 'external',
sourcefile: id,
// Pass relevant Vite options, if needed:
- define: config.vite.define,
+ define: config.vite?.define,
});
let SUFFIX = '';
@@ -171,12 +196,19 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
const scannedFrontmatter = FRONTMATTER_PARSE_REGEXP.exec(source);
if (scannedFrontmatter) {
try {
- await esbuild.transform(scannedFrontmatter[1], { loader: 'ts', sourcemap: false, sourcefile: id });
+ await esbuild.transform(scannedFrontmatter[1], {
+ loader: 'ts',
+ sourcemap: false,
+ sourcefile: id,
+ });
} catch (frontmatterErr: any) {
// Improve the error by replacing the phrase "unexpected end of file"
// with "unexpected end of frontmatter" in the esbuild error message.
if (frontmatterErr && frontmatterErr.message) {
- frontmatterErr.message = frontmatterErr.message.replace('end of file', 'end of frontmatter');
+ frontmatterErr.message = frontmatterErr.message.replace(
+ 'end of file',
+ 'end of frontmatter'
+ );
}
throw frontmatterErr;
}
@@ -191,7 +223,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
\`@astrojs/compiler\` encountered an unrecoverable error when compiling the following file.
- **${id.replace(fileURLToPath(config.projectRoot), '')}**
+ **${id.replace(fileURLToPath(config.root), '')}**
\`\`\`astro
${source}
\`\`\`
diff --git a/packages/astro/src/vite-plugin-astro/styles.ts b/packages/astro/src/vite-plugin-astro/styles.ts
index 85467506e..d9fb5eaf8 100644
--- a/packages/astro/src/vite-plugin-astro/styles.ts
+++ b/packages/astro/src/vite-plugin-astro/styles.ts
@@ -2,7 +2,11 @@ import type * as vite from 'vite';
import { STYLE_EXTENSIONS } from '../core/render/util.js';
-export type TransformHook = (code: string, id: string, ssr?: boolean) => Promise<vite.TransformResult>;
+export type TransformHook = (
+ code: string,
+ id: string,
+ ssr?: boolean
+) => Promise<vite.TransformResult>;
/** Load vite:css’ transform() hook */
export function getViteTransform(viteConfig: vite.ResolvedConfig): TransformHook {
@@ -21,7 +25,13 @@ interface TransformWithViteOptions {
}
/** Transform style using Vite hook */
-export async function transformWithVite({ value, lang, transformHook, id, ssr }: TransformWithViteOptions): Promise<vite.TransformResult | null> {
+export async function transformWithVite({
+ value,
+ lang,
+ transformHook,
+ id,
+ ssr,
+}: TransformWithViteOptions): Promise<vite.TransformResult | null> {
if (!STYLE_EXTENSIONS.has(lang)) {
return null; // only preprocess langs supported by Vite
}
diff --git a/packages/astro/src/vite-plugin-build-css/index.ts b/packages/astro/src/vite-plugin-build-css/index.ts
index 11eb6b096..686dc3e52 100644
--- a/packages/astro/src/vite-plugin-build-css/index.ts
+++ b/packages/astro/src/vite-plugin-build-css/index.ts
@@ -5,7 +5,11 @@ import * as path from 'path';
import esbuild from 'esbuild';
import { Plugin as VitePlugin } from 'vite';
import { isCSSRequest } from '../core/render/util.js';
-import { getPageDatasByChunk, getPageDataByViteID, hasPageDataByViteID } from '../core/build/internal.js';
+import {
+ getPageDatasByChunk,
+ getPageDataByViteID,
+ hasPageDataByViteID,
+} from '../core/build/internal.js';
const PLUGIN_NAME = '@astrojs/rollup-plugin-build-css';
@@ -52,7 +56,11 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
const { internals, legacy } = options;
const styleSourceMap = new Map<string, string>();
- function* walkStyles(ctx: PluginContext, id: string, seen = new Set<string>()): Generator<[string, string], void, unknown> {
+ function* walkStyles(
+ ctx: PluginContext,
+ id: string,
+ seen = new Set<string>()
+ ): Generator<[string, string], void, unknown> {
seen.add(id);
if (styleSourceMap.has(id)) {
yield [id, styleSourceMap.get(id)!];
@@ -203,12 +211,19 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
// Delete CSS chunks so JS is not produced for them.
async generateBundle(opts, bundle) {
const hasPureCSSChunks = internals.pureCSSChunks.size;
- const pureChunkFilenames = new Set([...internals.pureCSSChunks].map((chunk) => chunk.fileName));
+ const pureChunkFilenames = new Set(
+ [...internals.pureCSSChunks].map((chunk) => chunk.fileName)
+ );
const emptyChunkFiles = [...pureChunkFilenames]
.map((file) => path.basename(file))
.join('|')
.replace(/\./g, '\\.');
- const emptyChunkRE = new RegExp(opts.format === 'es' ? `\\bimport\\s*"[^"]*(?:${emptyChunkFiles})";\n?` : `\\brequire\\(\\s*"[^"]*(?:${emptyChunkFiles})"\\);\n?`, 'g');
+ const emptyChunkRE = new RegExp(
+ opts.format === 'es'
+ ? `\\bimport\\s*"[^"]*(?:${emptyChunkFiles})";\n?`
+ : `\\brequire\\(\\s*"[^"]*(?:${emptyChunkFiles})"\\);\n?`,
+ 'g'
+ );
// Crawl the module graph to find CSS chunks to create
if (!legacy) {
diff --git a/packages/astro/src/vite-plugin-build-html/extract-assets.ts b/packages/astro/src/vite-plugin-build-html/extract-assets.ts
index 5d9638630..ffc0446a3 100644
--- a/packages/astro/src/vite-plugin-build-html/extract-assets.ts
+++ b/packages/astro/src/vite-plugin-build-html/extract-assets.ts
@@ -12,7 +12,9 @@ function getSrcSetUrls(srcset: string) {
return [];
}
const srcsetParts = srcset.includes(',') ? srcset.split(',') : [srcset];
- const urls = srcsetParts.map((url) => url.trim()).map((url) => (url.includes(' ') ? url.split(' ')[0] : url));
+ const urls = srcsetParts
+ .map((url) => url.trim())
+ .map((url) => (url.includes(' ') ? url.split(' ')[0] : url));
return urls;
}
@@ -116,9 +118,20 @@ export function isHashedAsset(node: Element) {
}
}
-export function resolveAssetFilePath(browserPath: string, htmlDir: string, projectRootDir: string, absolutePathPrefix?: string) {
- const _browserPath = absolutePathPrefix && browserPath[0] === '/' ? '/' + npath.posix.relative(absolutePathPrefix, browserPath) : browserPath;
- return npath.join(_browserPath.startsWith('/') ? projectRootDir : htmlDir, _browserPath.split('/').join(npath.sep));
+export function resolveAssetFilePath(
+ browserPath: string,
+ htmlDir: string,
+ projectRootDir: string,
+ absolutePathPrefix?: string
+) {
+ const _browserPath =
+ absolutePathPrefix && browserPath[0] === '/'
+ ? '/' + npath.posix.relative(absolutePathPrefix, browserPath)
+ : browserPath;
+ return npath.join(
+ _browserPath.startsWith('/') ? projectRootDir : htmlDir,
+ _browserPath.split('/').join(npath.sep)
+ );
}
export function getSourceAttribute(node: Element) {
diff --git a/packages/astro/src/vite-plugin-build-html/index.ts b/packages/astro/src/vite-plugin-build-html/index.ts
index a3af1f97e..9221028f2 100644
--- a/packages/astro/src/vite-plugin-build-html/index.ts
+++ b/packages/astro/src/vite-plugin-build-html/index.ts
@@ -1,4 +1,12 @@
-import { createElement, createScript, getAttribute, hasAttribute, insertBefore, remove, setAttribute } from '@web/parse5-utils';
+import {
+ createElement,
+ createScript,
+ getAttribute,
+ hasAttribute,
+ insertBefore,
+ remove,
+ setAttribute,
+} from '@web/parse5-utils';
import { promises as fs } from 'fs';
import parse5 from 'parse5';
import * as npath from 'path';
@@ -15,8 +23,21 @@ import { RouteCache } from '../core/render/route-cache.js';
import { getOutputFilename } from '../core/util.js';
import { getAstroPageStyleId, getAstroStyleId } from '../vite-plugin-build-css/index.js';
import { addRollupInput } from './add-rollup-input.js';
-import { findAssets, findExternalScripts, findInlineScripts, findInlineStyles, getAttributes, getTextContent } from './extract-assets.js';
-import { hasSrcSet, isBuildableImage, isBuildableLink, isHoistedScript, isInSrcDirectory } from './util.js';
+import {
+ findAssets,
+ findExternalScripts,
+ findInlineScripts,
+ findInlineStyles,
+ getAttributes,
+ getTextContent,
+} from './extract-assets.js';
+import {
+ hasSrcSet,
+ isBuildableImage,
+ isBuildableLink,
+ isHoistedScript,
+ isInSrcDirectory,
+} from './util.js';
import { createRequest } from '../core/request.js';
// This package isn't real ESM, so have to coerce it
@@ -45,12 +66,13 @@ function relativePath(from: string, to: string): string {
}
export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
- const { astroConfig, internals, logging, origin, allPages, routeCache, viteServer, pageNames } = options;
+ const { astroConfig, internals, logging, origin, allPages, routeCache, viteServer, pageNames } =
+ options;
// The filepath root of the src folder
- const srcRoot = astroConfig.src.pathname;
+ const srcRoot = astroConfig.srcDir.pathname;
// The web path of the src folter
- const srcRootWeb = srcRoot.substr(astroConfig.projectRoot.pathname.length - 1);
+ const srcRootWeb = srcRoot.substr(astroConfig.root.pathname.length - 1);
// A map of pages to rendered HTML
const renderedPageMap = new Map<string, string>();
@@ -86,7 +108,7 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
const id = ASTRO_PAGE_PREFIX + pathname;
const response = await ssrRender(renderers, mod, {
astroConfig,
- filePath: new URL(`./${component}`, astroConfig.projectRoot),
+ filePath: new URL(`./${component}`, astroConfig.root),
logging,
request: createRequest({
url: new URL(origin + pathname),
@@ -162,7 +184,7 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
if (src?.startsWith(srcRoot) && !astroAssetMap.has(src)) {
astroAssetMap.set(src, fs.readFile(new URL(`file://${src}`)));
} else if (src?.startsWith(srcRootWeb) && !astroAssetMap.has(src)) {
- const resolved = new URL('.' + src, astroConfig.projectRoot);
+ const resolved = new URL('.' + src, astroConfig.root);
astroAssetMap.set(src, fs.readFile(resolved));
}
}
@@ -173,7 +195,7 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
if (url.startsWith(srcRoot) && !astroAssetMap.has(url)) {
astroAssetMap.set(url, fs.readFile(new URL(`file://${url}`)));
} else if (url.startsWith(srcRootWeb) && !astroAssetMap.has(url)) {
- const resolved = new URL('.' + url, astroConfig.projectRoot);
+ const resolved = new URL('.' + url, astroConfig.root);
astroAssetMap.set(url, fs.readFile(resolved));
}
}
@@ -322,7 +344,12 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
// Keep track of links added so we don't do so twice.
const linkChunksAdded = new Set<string>();
- const appendStyleChunksBefore = (ref: parse5.Element, pathname: string, referenceIds: string[] | undefined, attrs: Record<string, any> = {}) => {
+ const appendStyleChunksBefore = (
+ ref: parse5.Element,
+ pathname: string,
+ referenceIds: string[] | undefined,
+ attrs: Record<string, any> = {}
+ ) => {
let added = false;
if (referenceIds) {
const lastNode = ref;
@@ -403,7 +430,7 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
let src = getAttribute(script, 'src');
// If this is projectRoot relative, get the fullpath to match the facadeId.
if (src?.startsWith(srcRootWeb)) {
- src = new URL('.' + src, astroConfig.projectRoot).pathname;
+ src = new URL('.' + src, astroConfig.root).pathname;
}
// On windows the facadeId doesn't start with / but does not Unix :/
if (src && (facadeIdMap.has(src) || facadeIdMap.has(src.substr(1)))) {
@@ -433,7 +460,12 @@ export function rollupPluginAstroScanHTML(options: PluginOptions): VitePlugin {
if (!pageCSSAdded) {
const attrs = getAttributes(node);
delete attrs['data-astro-injected'];
- pageCSSAdded = appendStyleChunksBefore(node, pathname, cssChunkMap.get(styleId), attrs);
+ pageCSSAdded = appendStyleChunksBefore(
+ node,
+ pathname,
+ cssChunkMap.get(styleId),
+ attrs
+ );
}
remove(node);
break;
diff --git a/packages/astro/src/vite-plugin-build-html/util.ts b/packages/astro/src/vite-plugin-build-html/util.ts
index f42db5e72..8380b55fd 100644
--- a/packages/astro/src/vite-plugin-build-html/util.ts
+++ b/packages/astro/src/vite-plugin-build-html/util.ts
@@ -12,7 +12,12 @@ function startsWithSrcRoot(pathname: string, srcRoot: string, srcRootWeb: string
); // Windows fix: some paths are missing leading "/"
}
-export function isInSrcDirectory(node: parse5.Element, attr: string, srcRoot: string, srcRootWeb: string): boolean {
+export function isInSrcDirectory(
+ node: parse5.Element,
+ attr: string,
+ srcRoot: string,
+ srcRootWeb: string
+): boolean {
const value = getAttribute(node, attr);
return value ? startsWithSrcRoot(value, srcRoot, srcRootWeb) : false;
}
@@ -21,7 +26,11 @@ export function isAstroInjectedLink(node: parse5.Element): boolean {
return isStylesheetLink(node) && getAttribute(node, 'data-astro-injected') === '';
}
-export function isBuildableLink(node: parse5.Element, srcRoot: string, srcRootWeb: string): boolean {
+export function isBuildableLink(
+ node: parse5.Element,
+ srcRoot: string,
+ srcRootWeb: string
+): boolean {
if (isAstroInjectedLink(node)) {
return true;
}
@@ -34,7 +43,11 @@ export function isBuildableLink(node: parse5.Element, srcRoot: string, srcRootWe
return startsWithSrcRoot(href, srcRoot, srcRootWeb);
}
-export function isBuildableImage(node: parse5.Element, srcRoot: string, srcRootWeb: string): boolean {
+export function isBuildableImage(
+ node: parse5.Element,
+ srcRoot: string,
+ srcRootWeb: string
+): boolean {
if (getTagName(node) === 'img') {
const src = getAttribute(node, 'src');
return src ? startsWithSrcRoot(src, srcRoot, srcRootWeb) : false;
diff --git a/packages/astro/src/vite-plugin-config-alias/index.ts b/packages/astro/src/vite-plugin-config-alias/index.ts
index 022165a03..d07dcb631 100644
--- a/packages/astro/src/vite-plugin-config-alias/index.ts
+++ b/packages/astro/src/vite-plugin-config-alias/index.ts
@@ -14,7 +14,10 @@ export declare interface Alias {
const normalize = (pathname: string) => String(pathname).split(path.sep).join(path.posix.sep);
/** Returns the results of a config file if it exists, otherwise null. */
-const getExistingConfig = (searchName: string, cwd: string | undefined): tsr.TsConfigResultSuccess | null => {
+const getExistingConfig = (
+ searchName: string,
+ cwd: string | undefined
+): tsr.TsConfigResultSuccess | null => {
const config = tsr.tsconfigResolverSync({ cwd, searchName });
return config.exists ? config : null;
@@ -35,24 +38,37 @@ const getConfigAlias = (cwd: string | undefined): Alias[] | null => {
if (!compilerOptions.baseUrl) return null;
// resolve the base url from the configuration file directory
- const baseUrl = path.posix.resolve(path.posix.dirname(normalize(config.path).replace(/^\/?/, '/')), normalize(compilerOptions.baseUrl));
+ const baseUrl = path.posix.resolve(
+ path.posix.dirname(normalize(config.path).replace(/^\/?/, '/')),
+ normalize(compilerOptions.baseUrl)
+ );
/** List of compiled alias expressions. */
const aliases: Alias[] = [];
// compile any alias expressions and push them to the list
- for (let [alias, values] of Object.entries(Object(compilerOptions.paths) as { [key: string]: string[] })) {
+ for (let [alias, values] of Object.entries(
+ Object(compilerOptions.paths) as { [key: string]: string[] }
+ )) {
values = [].concat(values as never);
/** Regular Expression used to match a given path. */
- const find = new RegExp(`^${[...alias].map((segment) => (segment === '*' ? '(.+)' : segment.replace(/[\\^$*+?.()|[\]{}]/, '\\$&'))).join('')}$`);
+ const find = new RegExp(
+ `^${[...alias]
+ .map((segment) =>
+ segment === '*' ? '(.+)' : segment.replace(/[\\^$*+?.()|[\]{}]/, '\\$&')
+ )
+ .join('')}$`
+ );
/** Internal index used to calculate the matching id in a replacement. */
let matchId = 0;
for (let value of values) {
/** String used to replace a matched path. */
- const replacement = [...path.posix.resolve(baseUrl, value)].map((segment) => (segment === '*' ? `$${++matchId}` : segment === '$' ? '$$' : segment)).join('');
+ const replacement = [...path.posix.resolve(baseUrl, value)]
+ .map((segment) => (segment === '*' ? `$${++matchId}` : segment === '$' ? '$$' : segment))
+ .join('');
aliases.push({ find, replacement });
}
@@ -70,9 +86,12 @@ const getConfigAlias = (cwd: string | undefined): Alias[] | null => {
};
/** Returns a Vite plugin used to alias pathes from tsconfig.json and jsconfig.json. */
-export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL; [key: string]: unknown }): vite.PluginOption {
+export default function configAliasVitePlugin(astroConfig: {
+ root?: URL;
+ [key: string]: unknown;
+}): vite.PluginOption {
/** Aliases from the tsconfig.json or jsconfig.json configuration. */
- const configAlias = getConfigAlias(astroConfig.projectRoot && url.fileURLToPath(astroConfig.projectRoot));
+ const configAlias = getConfigAlias(astroConfig.root && url.fileURLToPath(astroConfig.root));
// if no config alias was found, bypass this plugin
if (!configAlias) return {} as vite.PluginOption;
@@ -94,7 +113,10 @@ export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL;
const aliasedSourceId = sourceId.replace(alias.find, alias.replacement);
/** Resolved ID conditionally handled by any other resolver. (this also gives priority to all other resolvers) */
- const resolvedAliasedId = await this.resolve(aliasedSourceId, importer, { skipSelf: true, ...options });
+ const resolvedAliasedId = await this.resolve(aliasedSourceId, importer, {
+ skipSelf: true,
+ ...options,
+ });
// if the existing resolvers find the file, return that resolution
if (resolvedAliasedId) return resolvedAliasedId;
diff --git a/packages/astro/src/vite-plugin-env/index.ts b/packages/astro/src/vite-plugin-env/index.ts
index e602a675e..7a716019e 100644
--- a/packages/astro/src/vite-plugin-env/index.ts
+++ b/packages/astro/src/vite-plugin-env/index.ts
@@ -12,9 +12,15 @@ interface EnvPluginOptions {
function getPrivateEnv(viteConfig: vite.ResolvedConfig, astroConfig: AstroConfig) {
let envPrefixes: string[] = ['PUBLIC_'];
if (viteConfig.envPrefix) {
- envPrefixes = Array.isArray(viteConfig.envPrefix) ? viteConfig.envPrefix : [viteConfig.envPrefix];
+ envPrefixes = Array.isArray(viteConfig.envPrefix)
+ ? viteConfig.envPrefix
+ : [viteConfig.envPrefix];
}
- const fullEnv = loadEnv(viteConfig.mode, viteConfig.envDir ?? fileURLToPath(astroConfig.projectRoot), '');
+ const fullEnv = loadEnv(
+ viteConfig.mode,
+ viteConfig.envDir ?? fileURLToPath(astroConfig.root),
+ ''
+ );
const privateKeys = Object.keys(fullEnv).filter((key) => {
// don't expose any variables also on `process.env`
// note: this filters out `CLI_ARGS=1` passed to node!
@@ -44,7 +50,9 @@ function getReferencedPrivateKeys(source: string, privateEnv: Record<string, any
return references;
}
-export default function envVitePlugin({ config: astroConfig }: EnvPluginOptions): vite.PluginOption {
+export default function envVitePlugin({
+ config: astroConfig,
+}: EnvPluginOptions): vite.PluginOption {
let privateEnv: Record<string, any> | null;
let config: vite.ResolvedConfig;
let replacements: Record<string, string>;
@@ -69,7 +77,10 @@ export default function envVitePlugin({ config: astroConfig }: EnvPluginOptions)
if (typeof privateEnv === 'undefined') {
privateEnv = getPrivateEnv(config, astroConfig);
if (privateEnv) {
- const entries = Object.entries(privateEnv).map(([key, value]) => [`import.meta.env.${key}`, value]);
+ const entries = Object.entries(privateEnv).map(([key, value]) => [
+ `import.meta.env.${key}`,
+ value,
+ ]);
replacements = Object.fromEntries(entries);
// These additional replacements are needed to match Vite
replacements = Object.assign(replacements, {
diff --git a/packages/astro/src/vite-plugin-integrations-container/index.ts b/packages/astro/src/vite-plugin-integrations-container/index.ts
index 8defa16b5..da14e43f9 100644
--- a/packages/astro/src/vite-plugin-integrations-container/index.ts
+++ b/packages/astro/src/vite-plugin-integrations-container/index.ts
@@ -3,7 +3,11 @@ import { AstroConfig } from '../@types/astro.js';
import { runHookServerSetup } from '../integrations/index.js';
/** Connect Astro integrations into Vite, as needed. */
-export default function astroIntegrationsContainerPlugin({ config }: { config: AstroConfig }): VitePlugin {
+export default function astroIntegrationsContainerPlugin({
+ config,
+}: {
+ config: AstroConfig;
+}): VitePlugin {
return {
name: 'astro:integration-container',
configureServer(server) {
diff --git a/packages/astro/src/vite-plugin-jsx/index.ts b/packages/astro/src/vite-plugin-jsx/index.ts
index b04152a9a..dee04c0b1 100644
--- a/packages/astro/src/vite-plugin-jsx/index.ts
+++ b/packages/astro/src/vite-plugin-jsx/index.ts
@@ -30,7 +30,9 @@ function getEsbuildLoader(fileExt: string): string {
function collectJSXRenderers(renderers: AstroRenderer[]): Map<string, AstroRenderer> {
const renderersWithJSXSupport = renderers.filter((r) => r.jsxImportSource);
- return new Map(renderersWithJSXSupport.map((r) => [r.jsxImportSource, r] as [string, AstroRenderer]));
+ return new Map(
+ renderersWithJSXSupport.map((r) => [r.jsxImportSource, r] as [string, AstroRenderer])
+ );
}
interface TransformJSXOptions {
@@ -41,7 +43,13 @@ interface TransformJSXOptions {
ssr: boolean;
}
-async function transformJSX({ code, mode, id, ssr, renderer }: TransformJSXOptions): Promise<TransformResult> {
+async function transformJSX({
+ code,
+ mode,
+ id,
+ ssr,
+ renderer,
+}: TransformJSXOptions): Promise<TransformResult> {
const { jsxTransformOptions } = renderer;
const options = await jsxTransformOptions!({ mode, ssr });
const plugins = [...(options.plugins || [])];
@@ -117,7 +125,13 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
sourcefile: id,
sourcemap: 'inline',
});
- return transformJSX({ code: jsxCode, id, renderer: [...jsxRenderers.values()][0], mode, ssr });
+ return transformJSX({
+ code: jsxCode,
+ id,
+ renderer: [...jsxRenderers.values()][0],
+ mode,
+ ssr,
+ });
}
// Attempt: Multiple JSX renderers
@@ -165,7 +179,13 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
const jsxRenderer = jsxRenderers.get(importSource);
// if renderer not installed for this JSX source, throw error
if (!jsxRenderer) {
- error(logging, 'renderer', `${colors.yellow(id)} No renderer installed for ${importSource}. Try adding \`@astrojs/${importSource}\` to your project.`);
+ error(
+ logging,
+ 'renderer',
+ `${colors.yellow(
+ id
+ )} No renderer installed for ${importSource}. Try adding \`@astrojs/${importSource}\` to your project.`
+ );
return null;
}
// downlevel any non-standard syntax, but preserve JSX
@@ -175,7 +195,13 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
sourcefile: id,
sourcemap: 'inline',
});
- return await transformJSX({ code: jsxCode, id, renderer: jsxRenderers.get(importSource) as AstroRenderer, mode, ssr });
+ return await transformJSX({
+ code: jsxCode,
+ id,
+ renderer: jsxRenderers.get(importSource) as AstroRenderer,
+ mode,
+ ssr,
+ });
}
// if we still can’t tell, throw error
@@ -185,7 +211,9 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
'renderer',
`${colors.yellow(id)}
Unable to resolve a renderer that handles this file! With more than one renderer enabled, you should include an import or use a pragma comment.
-Add ${colors.cyan(IMPORT_STATEMENTS[defaultRenderer] || `import '${defaultRenderer}';`)} or ${colors.cyan(`/* jsxImportSource: ${defaultRenderer} */`)} to this file.
+Add ${colors.cyan(
+ IMPORT_STATEMENTS[defaultRenderer] || `import '${defaultRenderer}';`
+ )} or ${colors.cyan(`/* jsxImportSource: ${defaultRenderer} */`)} to this file.
`
);
return null;
diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts
index a250da2af..615894fca 100644
--- a/packages/astro/src/vite-plugin-markdown/index.ts
+++ b/packages/astro/src/vite-plugin-markdown/index.ts
@@ -1,3 +1,4 @@
+import astroRemark from '@astrojs/markdown-remark';
import { transform } from '@astrojs/compiler';
import ancestor from 'common-ancestor-path';
import esbuild from 'esbuild';
@@ -8,6 +9,8 @@ import type { Plugin } from 'vite';
import type { AstroConfig } from '../@types/astro';
import { PAGE_SSR_SCRIPT_ID } from '../vite-plugin-scripts/index.js';
import { virtualModuleId as pagesVirtualModuleId } from '../core/build/vite-plugin-pages.js';
+import { appendForwardSlash } from '../core/path.js';
+import { resolvePages } from '../core/util.js';
interface AstroPluginOptions {
config: AstroConfig;
@@ -23,8 +26,8 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
function normalizeFilename(filename: string) {
if (filename.startsWith('/@fs')) {
filename = filename.slice('/@fs'.length);
- } else if (filename.startsWith('/') && !ancestor(filename, config.projectRoot.pathname)) {
- filename = new URL('.' + filename, config.projectRoot).pathname;
+ } else if (filename.startsWith('/') && !ancestor(filename, config.root.pathname)) {
+ filename = new URL('.' + filename, config.root).pathname;
}
return filename;
}
@@ -32,7 +35,7 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
// Weird Vite behavior: Vite seems to use a fake "index.html" importer when you
// have `enforce: pre`. This can probably be removed once the vite issue is fixed.
// see: https://github.com/vitejs/vite/issues/5981
- const fakeRootImporter = fileURLToPath(new URL('index.html', config.projectRoot));
+ const fakeRootImporter = fileURLToPath(new URL('index.html', config.root));
function isRootImport(importer: string | undefined) {
if (!importer) {
return true;
@@ -79,9 +82,13 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
// Return the file's JS representation, including all Markdown
// frontmatter and a deferred `import() of the compiled markdown content.
if (id.startsWith(VIRTUAL_MODULE_ID)) {
- const sitePathname = config.buildOptions.site ? new URL(config.buildOptions.site).pathname : '/';
+ const sitePathname = config.site
+ ? appendForwardSlash(new URL(config.base, config.site).pathname)
+ : '/';
const fileId = id.substring(VIRTUAL_MODULE_ID.length);
- const fileUrl = fileId.includes('/pages/') ? fileId.replace(/^.*\/pages\//, sitePathname).replace(/(\/index)?\.md$/, '') : undefined;
+ const fileUrl = fileId.includes('/pages/')
+ ? fileId.replace(/^.*\/pages\//, sitePathname).replace(/(\/index)?\.md$/, '')
+ : undefined;
const source = await fs.promises.readFile(fileId, 'utf8');
const { data: frontmatter } = matter(source);
return {
@@ -111,19 +118,12 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
// This returns the compiled markdown -> astro component that renders to HTML.
if (id.endsWith('.md')) {
const source = await fs.promises.readFile(id, 'utf8');
- let render = config.markdownOptions.render;
- let renderOpts = {};
- if (Array.isArray(render)) {
- renderOpts = render[1];
- render = render[0];
- }
- if (typeof render === 'string') {
- ({ default: render } = await import(render));
- }
+ const render = astroRemark;
+ const renderOpts = config.markdown;
const filename = normalizeFilename(id);
const fileUrl = new URL(`file://${filename}`);
- const isPage = fileUrl.pathname.startsWith(config.pages.pathname);
+ const isPage = fileUrl.pathname.startsWith(resolvePages(config).pathname);
const hasInjectedScript = isPage && config._ctx.scripts.some((s) => s.stage === 'page-ssr');
// Extract special frontmatter keys
@@ -151,9 +151,9 @@ ${setup}`.trim();
// Transform from `.astro` to valid `.ts`
let { code: tsResult } = await transform(astroResult, {
- pathname: fileUrl.pathname.substr(config.projectRoot.pathname.length - 1),
- projectRoot: config.projectRoot.toString(),
- site: config.buildOptions.site,
+ pathname: fileUrl.pathname.substr(config.root.pathname.length - 1),
+ projectRoot: config.root.toString(),
+ site: config.site ? new URL(config.base, config.site).toString() : undefined,
sourcefile: id,
sourcemap: 'inline',
internalURL: `/@fs${new URL('../runtime/server/index.js', import.meta.url).pathname}`,
@@ -164,7 +164,11 @@ export const frontmatter = ${JSON.stringify(content)};
${tsResult}`;
// Compile from `.ts` to `.js`
- const { code } = await esbuild.transform(tsResult, { loader: 'ts', sourcemap: false, sourcefile: id });
+ const { code } = await esbuild.transform(tsResult, {
+ loader: 'ts',
+ sourcemap: false,
+ sourcefile: id,
+ });
return {
code,
map: null,
diff --git a/packages/astro/src/vite-plugin-scripts/index.ts b/packages/astro/src/vite-plugin-scripts/index.ts
index 0d1601bba..20f4fdafe 100644
--- a/packages/astro/src/vite-plugin-scripts/index.ts
+++ b/packages/astro/src/vite-plugin-scripts/index.ts
@@ -5,7 +5,9 @@ import { AstroConfig, InjectedScriptStage } from '../@types/astro.js';
// inject these as ESM imports into actual code, where they would not
// resolve correctly.
const SCRIPT_ID_PREFIX = `astro:scripts/`;
-export const BEFORE_HYDRATION_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${'before-hydration' as InjectedScriptStage}.js`;
+export const BEFORE_HYDRATION_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${
+ 'before-hydration' as InjectedScriptStage
+}.js`;
export const PAGE_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${'page' as InjectedScriptStage}.js`;
export const PAGE_SSR_SCRIPT_ID = `${SCRIPT_ID_PREFIX}${'page-ssr' as InjectedScriptStage}.js`;
@@ -45,7 +47,9 @@ export default function astroScriptsPlugin({ config }: { config: AstroConfig }):
// for the frontend AND some hydrated components exist in
// the final build. We can detect this by looking for a
// `astro/client/*` input, which signifies both conditions are met.
- const hasHydratedComponents = Array.isArray(options.input) && options.input.some((input) => input.startsWith('astro/client'));
+ const hasHydratedComponents =
+ Array.isArray(options.input) &&
+ options.input.some((input) => input.startsWith('astro/client'));
const hasHydrationScripts = config._ctx.scripts.some((s) => s.stage === 'before-hydration');
if (hasHydratedComponents && hasHydrationScripts) {
this.emitFile({
diff --git a/packages/astro/test/0-css.test.js b/packages/astro/test/0-css.test.js
index 6d86bf886..9d08c1aa9 100644
--- a/packages/astro/test/0-css.test.js
+++ b/packages/astro/test/0-css.test.js
@@ -12,7 +12,7 @@ let fixture;
describe('CSS', function () {
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/0-css/' });
+ fixture = await loadFixture({ root: './fixtures/0-css/' });
});
// test HTML and CSS contents for accuracy
@@ -214,37 +214,49 @@ describe('CSS', function () {
it('<style>', async () => {
const el = $('#svelte-css');
const classes = el.attr('class').split(' ');
- const scopedClass = classes.find((name) => name !== 'svelte-css' && /^svelte-[A-Za-z0-9-]+/.test(name));
+ const scopedClass = classes.find(
+ (name) => name !== 'svelte-css' && /^svelte-[A-Za-z0-9-]+/.test(name)
+ );
// 1. check HTML
expect(el.attr('class')).to.include('svelte-css');
// 2. check CSS
- expect(bundledCSS).to.match(new RegExp(`.svelte-css.${scopedClass}[^{]*{font-family:Comic Sans MS`));
+ expect(bundledCSS).to.match(
+ new RegExp(`.svelte-css.${scopedClass}[^{]*{font-family:Comic Sans MS`)
+ );
});
it('<style lang="sass">', async () => {
const el = $('#svelte-sass');
const classes = el.attr('class').split(' ');
- const scopedClass = classes.find((name) => name !== 'svelte-sass' && /^svelte-[A-Za-z0-9-]+/.test(name));
+ const scopedClass = classes.find(
+ (name) => name !== 'svelte-sass' && /^svelte-[A-Za-z0-9-]+/.test(name)
+ );
// 1. check HTML
expect(el.attr('class')).to.include('svelte-sass');
// 2. check CSS
- expect(bundledCSS).to.match(new RegExp(`.svelte-sass.${scopedClass}[^{]*{font-family:Comic Sans MS`));
+ expect(bundledCSS).to.match(
+ new RegExp(`.svelte-sass.${scopedClass}[^{]*{font-family:Comic Sans MS`)
+ );
});
it('<style lang="scss">', async () => {
const el = $('#svelte-scss');
const classes = el.attr('class').split(' ');
- const scopedClass = classes.find((name) => name !== 'svelte-scss' && /^svelte-[A-Za-z0-9-]+/.test(name));
+ const scopedClass = classes.find(
+ (name) => name !== 'svelte-scss' && /^svelte-[A-Za-z0-9-]+/.test(name)
+ );
// 1. check HTML
expect(el.attr('class')).to.include('svelte-scss');
// 2. check CSS
- expect(bundledCSS).to.match(new RegExp(`.svelte-scss.${scopedClass}[^{]*{font-family:Comic Sans MS`));
+ expect(bundledCSS).to.match(
+ new RegExp(`.svelte-scss.${scopedClass}[^{]*{font-family:Comic Sans MS`)
+ );
});
});
});
@@ -285,7 +297,14 @@ describe('CSS', function () {
});
it('resolves Styles from React', async () => {
- const styles = ['ReactCSS.css', 'ReactModules.module.css', 'ReactModules.module.scss', 'ReactModules.module.sass', 'ReactSass.sass', 'ReactScss.scss'];
+ const styles = [
+ 'ReactCSS.css',
+ 'ReactModules.module.css',
+ 'ReactModules.module.scss',
+ 'ReactModules.module.sass',
+ 'ReactSass.sass',
+ 'ReactScss.scss',
+ ];
for (const style of styles) {
const href = $(`link[href$="${style}"]`).attr('href');
expect((await fixture.fetch(href)).status, style).to.equal(200);
@@ -293,7 +312,11 @@ describe('CSS', function () {
});
it('resolves CSS from Svelte', async () => {
- const scripts = ['SvelteCSS.svelte?svelte&type=style&lang.css', 'SvelteSass.svelte?svelte&type=style&lang.css', 'SvelteScss.svelte?svelte&type=style&lang.css'];
+ const scripts = [
+ 'SvelteCSS.svelte?svelte&type=style&lang.css',
+ 'SvelteSass.svelte?svelte&type=style&lang.css',
+ 'SvelteScss.svelte?svelte&type=style&lang.css',
+ ];
for (const script of scripts) {
const src = $(`script[src$="${script}"]`).attr('src');
expect((await fixture.fetch(src)).status, script).to.equal(200);
diff --git a/packages/astro/test/astro-assets.test.js b/packages/astro/test/astro-assets.test.js
index 84f361672..a003f70c9 100644
--- a/packages/astro/test/astro-assets.test.js
+++ b/packages/astro/test/astro-assets.test.js
@@ -12,7 +12,7 @@ describe('Assets', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-assets/',
+ root: './fixtures/astro-assets/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.test.js
index 1f2dc1544..ad52782bb 100644
--- a/packages/astro/test/astro-attrs.test.js
+++ b/packages/astro/test/astro-attrs.test.js
@@ -6,7 +6,7 @@ describe('Attributes', async () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-attrs/' });
+ fixture = await loadFixture({ root: './fixtures/astro-attrs/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-basic.test.js b/packages/astro/test/astro-basic.test.js
index 4b76b7d40..e6d59af49 100644
--- a/packages/astro/test/astro-basic.test.js
+++ b/packages/astro/test/astro-basic.test.js
@@ -8,7 +8,7 @@ describe('Astro basics', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-basic/',
+ root: './fixtures/astro-basic/',
});
await fixture.build();
previewServer = await fixture.preview();
@@ -104,7 +104,9 @@ describe('Astro basics', () => {
expect($('body > :nth-child(3)').prop('outerHTML')).to.equal('<input type="text">');
// <Input type="select"><option>option</option></Input>
- expect($('body > :nth-child(4)').prop('outerHTML')).to.equal('<select><option>option</option></select>');
+ expect($('body > :nth-child(4)').prop('outerHTML')).to.equal(
+ '<select><option>option</option></select>'
+ );
// <Input type="textarea">textarea</Input>
expect($('body > :nth-child(5)').prop('outerHTML')).to.equal('<textarea>textarea</textarea>');
diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.test.js
index d3f985f63..3d6ff54c0 100644
--- a/packages/astro/test/astro-children.test.js
+++ b/packages/astro/test/astro-children.test.js
@@ -6,7 +6,7 @@ describe('Component children', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-children/' });
+ fixture = await loadFixture({ root: './fixtures/astro-children/' });
await fixture.build();
});
@@ -75,8 +75,14 @@ describe('Component children', () => {
expect($('#ssr-only').children()).to.have.lengthOf(0);
// test 2: If client, and no children are rendered, a template is.
- expect($('#client').parent().children()).to.have.lengthOf(2, 'rendered the client component and a template');
- expect($('#client').parent().find('template[data-astro-template]')).to.have.lengthOf(1, 'Found 1 template');
+ expect($('#client').parent().children()).to.have.lengthOf(
+ 2,
+ 'rendered the client component and a template'
+ );
+ expect($('#client').parent().find('template[data-astro-template]')).to.have.lengthOf(
+ 1,
+ 'Found 1 template'
+ );
// test 3: If client, and children are rendered, no template is.
expect($('#client-render').parent().children()).to.have.lengthOf(1);
diff --git a/packages/astro/test/astro-class-list.test.js b/packages/astro/test/astro-class-list.test.js
index 9516c3002..24a6ff81e 100644
--- a/packages/astro/test/astro-class-list.test.js
+++ b/packages/astro/test/astro-class-list.test.js
@@ -6,7 +6,7 @@ describe('Class List', async () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-class-list/' });
+ fixture = await loadFixture({ root: './fixtures/astro-class-list/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-client-only.test.js b/packages/astro/test/astro-client-only.test.js
index 211a7df2a..812b7229b 100644
--- a/packages/astro/test/astro-client-only.test.js
+++ b/packages/astro/test/astro-client-only.test.js
@@ -7,7 +7,7 @@ describe('Client only components', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-client-only/',
+ root: './fixtures/astro-client-only/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-component-code.test.js b/packages/astro/test/astro-component-code.test.js
index 6c143eb18..783fa734d 100644
--- a/packages/astro/test/astro-component-code.test.js
+++ b/packages/astro/test/astro-component-code.test.js
@@ -6,7 +6,7 @@ describe('<Code>', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-component-code/' });
+ fixture = await loadFixture({ root: './fixtures/astro-component-code/' });
await fixture.build();
});
@@ -14,7 +14,10 @@ describe('<Code>', () => {
let html = await fixture.readFile('/no-lang/index.html');
const $ = cheerio.load(html);
expect($('pre')).to.have.lengthOf(1);
- expect($('pre').attr('style')).to.equal('background-color: #0d1117; overflow-x: auto;', 'applies default and overflow');
+ expect($('pre').attr('style')).to.equal(
+ 'background-color: #0d1117; overflow-x: auto;',
+ 'applies default and overflow'
+ );
expect($('pre > code')).to.have.lengthOf(1);
// test: contains some generated spans
@@ -36,7 +39,10 @@ describe('<Code>', () => {
const $ = cheerio.load(html);
expect($('pre')).to.have.lengthOf(1);
expect($('pre').attr('class')).to.equal('astro-code');
- expect($('pre').attr('style')).to.equal('background-color: #2e3440ff; overflow-x: auto;', 'applies custom theme');
+ expect($('pre').attr('style')).to.equal(
+ 'background-color: #2e3440ff; overflow-x: auto;',
+ 'applies custom theme'
+ );
});
it('<Code wrap>', async () => {
@@ -45,7 +51,9 @@ describe('<Code>', () => {
const $ = cheerio.load(html);
expect($('pre')).to.have.lengthOf(1);
// test: applies wrap overflow
- expect($('pre').attr('style')).to.equal('background-color: #0d1117; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;');
+ expect($('pre').attr('style')).to.equal(
+ 'background-color: #0d1117; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;'
+ );
}
{
let html = await fixture.readFile('/wrap-false/index.html');
diff --git a/packages/astro/test/astro-css-bundling-import.test.js b/packages/astro/test/astro-css-bundling-import.test.js
index 4722a7e33..62e996dbd 100644
--- a/packages/astro/test/astro-css-bundling-import.test.js
+++ b/packages/astro/test/astro-css-bundling-import.test.js
@@ -7,7 +7,7 @@ describe('CSS Bundling (ESM import)', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-css-bundling-import/',
+ root: './fixtures/astro-css-bundling-import/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js
index 105b35bc9..ea589816e 100644
--- a/packages/astro/test/astro-css-bundling.test.js
+++ b/packages/astro/test/astro-css-bundling.test.js
@@ -9,14 +9,21 @@ const EXPECTED_CSS = {
'/one/index.html': ['/assets/'],
'/two/index.html': ['/assets/'],
};
-const UNEXPECTED_CSS = ['/src/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css'];
+const UNEXPECTED_CSS = [
+ '/src/components/nav.css',
+ '../css/typography.css',
+ '../css/colors.css',
+ '../css/page-index.css',
+ '../css/page-one.css',
+ '../css/page-two.css',
+];
describe('CSS Bundling', function () {
let fixture;
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-css-bundling/',
+ root: './fixtures/astro-css-bundling/',
});
await fixture.build({ mode: 'production' });
});
diff --git a/packages/astro/test/astro-directives.test.js b/packages/astro/test/astro-directives.test.js
index 536ba3441..e2223e637 100644
--- a/packages/astro/test/astro-directives.test.js
+++ b/packages/astro/test/astro-directives.test.js
@@ -6,7 +6,7 @@ describe('Directives', async () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-directives/' });
+ fixture = await loadFixture({ root: './fixtures/astro-directives/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-doctype.test.js b/packages/astro/test/astro-doctype.test.js
index b1661db1a..cb9a0c63c 100644
--- a/packages/astro/test/astro-doctype.test.js
+++ b/packages/astro/test/astro-doctype.test.js
@@ -6,7 +6,7 @@ describe('Doctype', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-doctype/' });
+ fixture = await loadFixture({ root: './fixtures/astro-doctype/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js
index bc3d10b78..d133fba29 100644
--- a/packages/astro/test/astro-dynamic.test.js
+++ b/packages/astro/test/astro-dynamic.test.js
@@ -7,7 +7,7 @@ describe('Dynamic components', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-dynamic/',
+ root: './fixtures/astro-dynamic/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-envs.test.js b/packages/astro/test/astro-envs.test.js
index 5cf3dc84a..f44b007c8 100644
--- a/packages/astro/test/astro-envs.test.js
+++ b/packages/astro/test/astro-envs.test.js
@@ -6,7 +6,7 @@ describe('Environment Variables', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-envs/',
+ root: './fixtures/astro-envs/',
});
await fixture.build();
diff --git a/packages/astro/test/astro-expr.test.js b/packages/astro/test/astro-expr.test.js
index 679cac1cf..0a514e48f 100644
--- a/packages/astro/test/astro-expr.test.js
+++ b/packages/astro/test/astro-expr.test.js
@@ -7,7 +7,7 @@ describe('Expressions', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-expr/',
+ root: './fixtures/astro-expr/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-external-files.test.js b/packages/astro/test/astro-external-files.test.js
index fba051c65..397f31785 100644
--- a/packages/astro/test/astro-external-files.test.js
+++ b/packages/astro/test/astro-external-files.test.js
@@ -6,7 +6,7 @@ import { loadFixture } from './test-utils.js';
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-external-files/' });
+ fixture = await loadFixture({ root: './fixtures/astro-external-files/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-fallback.test.js b/packages/astro/test/astro-fallback.test.js
index f098bd177..9e9752c8a 100644
--- a/packages/astro/test/astro-fallback.test.js
+++ b/packages/astro/test/astro-fallback.test.js
@@ -7,7 +7,7 @@ describe('Dynamic component fallback', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-fallback',
+ root: './fixtures/astro-fallback',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-get-static-paths.test.js b/packages/astro/test/astro-get-static-paths.test.js
index cecfebe70..3de3b58c9 100644
--- a/packages/astro/test/astro-get-static-paths.test.js
+++ b/packages/astro/test/astro-get-static-paths.test.js
@@ -4,11 +4,9 @@ import { loadFixture } from './test-utils.js';
describe('getStaticPaths - build calls', () => {
before(async () => {
const fixture = await loadFixture({
- projectRoot: './fixtures/astro-get-static-paths/',
- buildOptions: {
- site: 'https://mysite.dev/blog/',
- sitemap: false,
- },
+ root: './fixtures/astro-get-static-paths/',
+ site: 'https://mysite.dev/',
+ base: '/blog',
});
await fixture.build();
});
@@ -23,7 +21,7 @@ describe('getStaticPaths - 404 behavior', () => {
let devServer;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-get-static-paths/' });
+ fixture = await loadFixture({ root: './fixtures/astro-get-static-paths/' });
devServer = await fixture.startDevServer();
});
diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js
index 8330be821..01c92f584 100644
--- a/packages/astro/test/astro-global.test.js
+++ b/packages/astro/test/astro-global.test.js
@@ -7,11 +7,7 @@ describe('Astro.*', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-global/',
- buildOptions: {
- site: 'https://mysite.dev/blog/',
- sitemap: false,
- },
+ root: './fixtures/astro-global/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-markdown-drafts.test.js b/packages/astro/test/astro-markdown-drafts.test.js
index beee3fd7f..2c6e60be8 100644
--- a/packages/astro/test/astro-markdown-drafts.test.js
+++ b/packages/astro/test/astro-markdown-drafts.test.js
@@ -7,12 +7,7 @@ describe('Astro Markdown with draft posts disabled', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-markdown-drafts/',
- buildOptions: {
- // drafts is false by default but added here for clarity
- drafts: false,
- sitemap: false,
- },
+ root: './fixtures/astro-markdown-drafts/',
});
await fixture.build();
});
@@ -30,10 +25,9 @@ describe('Astro Markdown with draft posts enabled', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-markdown-drafts/',
- buildOptions: {
+ root: './fixtures/astro-markdown-drafts/',
+ markdown: {
drafts: true,
- sitemap: false,
},
});
await fixture.build();
diff --git a/packages/astro/test/astro-markdown-plugins.test.js b/packages/astro/test/astro-markdown-plugins.test.js
index 01c6c01b2..35a3f829d 100644
--- a/packages/astro/test/astro-markdown-plugins.test.js
+++ b/packages/astro/test/astro-markdown-plugins.test.js
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
-import markdownRemark from '@astrojs/markdown-remark';
import addClasses from './fixtures/astro-markdown-plugins/add-classes.mjs';
describe('Astro Markdown plugins', () => {
@@ -9,18 +8,17 @@ describe('Astro Markdown plugins', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-markdown-plugins/',
- markdownOptions: {
- render: [
- markdownRemark,
- {
- remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]],
- rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'],
- },
+ root: './fixtures/astro-markdown-plugins/',
+ markdown: {
+ remarkPlugins: [
+ 'remark-code-titles',
+ ['rehype-autolink-headings', { behavior: 'prepend' }],
+ ],
+ rehypePlugins: [
+ ['rehype-toc', { headings: ['h2', 'h3'] }],
+ [addClasses, { 'h1,h2,h3': 'title' }],
+ 'rehype-slug',
],
- },
- buildOptions: {
- sitemap: false,
},
});
await fixture.build();
diff --git a/packages/astro/test/astro-markdown-shiki.test.js b/packages/astro/test/astro-markdown-shiki.test.js
index f98b5413b..e4b945a0d 100644
--- a/packages/astro/test/astro-markdown-shiki.test.js
+++ b/packages/astro/test/astro-markdown-shiki.test.js
@@ -7,7 +7,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/normal/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/normal/' });
await fixture.build();
});
@@ -43,7 +43,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/themes-integrated/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/themes-integrated/' });
await fixture.build();
});
@@ -70,7 +70,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/themes-custom/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/themes-custom/' });
await fixture.build();
});
@@ -98,7 +98,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/langs/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/langs/' });
await fixture.build();
});
@@ -126,11 +126,12 @@ describe('Astro Markdown Shiki', () => {
describe('Wrap', () => {
describe('wrap = true', () => {
- const style = 'background-color: #0d1117; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;';
+ const style =
+ 'background-color: #0d1117; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;';
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/wrap-true/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-true/' });
await fixture.build();
});
@@ -157,7 +158,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/wrap-false/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-false/' });
await fixture.build();
});
@@ -183,7 +184,7 @@ describe('Astro Markdown Shiki', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-markdown-shiki/wrap-null/' });
+ fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-null/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js
index fdcd2bde2..10e403659 100644
--- a/packages/astro/test/astro-markdown.test.js
+++ b/packages/astro/test/astro-markdown.test.js
@@ -7,7 +7,7 @@ describe('Astro Markdown', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-markdown/',
+ root: './fixtures/astro-markdown/',
});
await fixture.build();
});
diff --git a/packages/astro/test/astro-pageDirectoryUrl.test.js b/packages/astro/test/astro-pageDirectoryUrl.test.js
index 7fec5bb35..978db056a 100644
--- a/packages/astro/test/astro-pageDirectoryUrl.test.js
+++ b/packages/astro/test/astro-pageDirectoryUrl.test.js
@@ -1,14 +1,14 @@
import { expect } from 'chai';
import { loadFixture } from './test-utils.js';
-describe('pageUrlFormat', () => {
+describe('build format', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-page-directory-url',
- buildOptions: {
- pageUrlFormat: 'file',
+ root: './fixtures/astro-page-directory-url',
+ build: {
+ format: 'file',
},
});
await fixture.build();
diff --git a/packages/astro/test/astro-pages.test.js b/packages/astro/test/astro-pages.test.js
index 6cb0f8dfd..3a1a504ad 100644
--- a/packages/astro/test/astro-pages.test.js
+++ b/packages/astro/test/astro-pages.test.js
@@ -6,7 +6,7 @@ describe('Pages', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-pages/' });
+ fixture = await loadFixture({ root: './fixtures/astro-pages/' });
await fixture.build();
});
diff --git a/packages/astro/test/astro-pagination.test.js b/packages/astro/test/astro-pagination.test.js
index 923342cd7..80c460f94 100644
--- a/packages/astro/test/astro-pagination.test.js
+++ b/packages/astro/test/astro-pagination.test.js
@@ -7,23 +7,29 @@ describe('Pagination', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-pagination/',
- buildOptions: {
- site: 'https://mysite.dev/blog/',
- sitemap: false,
- },
+ root: './fixtures/astro-pagination/',
+ site: 'https://mysite.dev/',
+ base: '/blog',
});
await fixture.build();
});
it('optional root page', async () => {
- for (const file of ['/posts/optional-root-page/index.html', '/posts/optional-root-page/2/index.html', '/posts/optional-root-page/3/index.html']) {
+ for (const file of [
+ '/posts/optional-root-page/index.html',
+ '/posts/optional-root-page/2/index.html',
+ '/posts/optional-root-page/3/index.html',
+ ]) {
expect(await fixture.readFile(file)).to.be.ok;
}
});
it('named root page', async () => {
- for (const file of ['/posts/named-root-page/1/index.html', '/posts/named-root-page/2/index.html', '/posts/named-root-page/3/index.html']) {
+ for (const file of [
+ '/posts/named-root-page/1/index.html',
+ '/posts/named-root-page/2/index.html',
+ '/posts/named-root-page/3/index.html',
+ ]) {
expect(await fixture.readFile(file)).to.be.ok;
}
});
diff --git a/packages/astro/test/astro-partial-html.test.js b/packages/astro/test/astro-partial-html.test.js
index f2d1852dd..bc50df41b 100644
--- a/packages/astro/test/astro-partial-html.test.js
+++ b/packages/astro/test/astro-partial-html.test.js
@@ -8,7 +8,7 @@ describe('Partial HTML', async () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-partial-html/',
+ root: './fixtures/astro-partial-html/',
});
devServer = await fixture.startDevServer();
});
diff --git a/packages/astro/test/astro-public.test.js b/packages/astro/test/astro-public.test.js
index 56b407df5..9f4094e1c 100644
--- a/packages/astro/test/astro-public.test.js
+++ b/packages/astro/test/astro-public.test.js
@@ -5,14 +5,14 @@ describe('Public', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-public/' });
+ fixture = await loadFixture({ root: './fixtures/astro-public/' });
await fixture.build();
});
it('css and js files do not get bundled', async () => {
let indexHtml = await fixture.readFile('/index.html');
expect(indexHtml).to.include('<script src="/example.js"></script>');
- expect(indexHtml).to.include('<link href="/example.css" ref="stylesheet">');
+ expect(indexHtml).to.include('<link href="/example.css" rel="stylesheet">');
expect(indexHtml).to.include('<img src="/images/twitter.png">');
});
});
diff --git a/packages/astro/test/astro-response.test.js b/packages/astro/test/astro-response.test.js
index 719d14d30..195247eba 100644
--- a/packages/astro/test/astro-response.test.js
+++ b/packages/astro/test/astro-response.test.js
@@ -10,7 +10,7 @@ describe('Returning responses', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-response/',
+ root: './fixtures/astro-response/',
});
devServer = await fixture.startDevServer();
diff --git a/packages/astro/test/astro-scripts.test.js b/packages/astro/test/astro-scripts.test.js
index d11b7c264..ad60511ed 100644
--- a/packages/astro/test/astro-scripts.test.js
+++ b/packages/astro/test/astro-scripts.test.js
@@ -8,7 +8,7 @@ describe('Scripts (hoisted and not)', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/astro-scripts/',
+ root: './fixtures/astro-scripts/',
vite: {
build: {
assetsInlineLimit: 0,
diff --git a/packages/astro/test/astro-sitemap-rss.test.js b/packages/astro/test/astro-sitemap-rss.test.js
deleted file mode 100644
index 38b788efb..000000000
--- a/packages/astro/test/astro-sitemap-rss.test.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import { expect } from 'chai';
-import { loadFixture } from './test-utils.js';
-
-describe('Sitemaps', () => {
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({
- projectRoot: './fixtures/astro-sitemap-rss/',
- buildOptions: {
- site: 'https://astro.build/',
- sitemap: true,
- },
- });
- await fixture.build();
- });
-
- describe('RSS Generation', () => {
- it('generates RSS correctly', async () => {
- const rss = await fixture.readFile('/custom/feed.xml');
- expect(rss).to.equal(
- `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://astro.build/</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://astro.build/episode/rap-snitch-knishes/</link><guid>https://astro.build/episode/rap-snitch-knishes/</guid><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://astro.build/episode/fazers/</link><guid>https://astro.build/episode/fazers/</guid><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Thu, 03 Jul 2003 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://astro.build/episode/rhymes-like-dimes/</link><guid>https://astro.build/episode/rhymes-like-dimes/</guid><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s.
-]]></description><pubDate>Tue, 19 Oct 1999 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>`
- );
- });
- it('generates RSS with pregenerated URLs correctly', async () => {
- const rss = await fixture.readFile('/custom/feed-pregenerated-urls.xml');
- expect(rss).to.equal(
- `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://astro.build/</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://example.com/episode/rap-snitch-knishes/</link><guid>https://example.com/episode/rap-snitch-knishes/</guid><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://example.com/episode/fazers/</link><guid>https://example.com/episode/fazers/</guid><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Thu, 03 Jul 2003 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://example.com/episode/rhymes-like-dimes/</link><guid>https://example.com/episode/rhymes-like-dimes/</guid><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s.
-]]></description><pubDate>Tue, 19 Oct 1999 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>`
- );
- });
- });
-
- describe('Sitemap Generation', () => {
- it('Generates Sitemap correctly', async () => {
- let sitemap = await fixture.readFile('/sitemap.xml');
- expect(sitemap).to.equal(
- `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://astro.build/episode/fazers/</loc></url><url><loc>https://astro.build/episode/rap-snitch-knishes/</loc></url><url><loc>https://astro.build/episode/rhymes-like-dimes/</loc></url><url><loc>https://astro.build/episodes/</loc></url></urlset>\n`
- );
- });
- });
-});
-
-describe('Sitemaps served from subdirectory', () => {
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({
- projectRoot: './fixtures/astro-sitemap-rss/',
- buildOptions: {
- site: 'https://astro.build/base-directory/',
- sitemap: true,
- },
- });
- await fixture.build();
- });
-
- describe('Sitemap Generation', () => {
- it('Generates Sitemap correctly', async () => {
- let sitemap = await fixture.readFile('/sitemap.xml');
- expect(sitemap).to.equal(
- `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://astro.build/base-directory/episode/fazers/</loc></url><url><loc>https://astro.build/base-directory/episode/rap-snitch-knishes/</loc></url><url><loc>https://astro.build/base-directory/episode/rhymes-like-dimes/</loc></url><url><loc>https://astro.build/base-directory/episodes/</loc></url></urlset>\n`
- );
- });
- });
-});
diff --git a/packages/astro/test/astro-slots.test.js b/packages/astro/test/astro-slots.test.js
index dd4883708..d890f2f31 100644
--- a/packages/astro/test/astro-slots.test.js
+++ b/packages/astro/test/astro-slots.test.js
@@ -6,7 +6,7 @@ describe('Slots', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/astro-slots/' });
+ fixture = await loadFixture({ root: './fixtures/astro-slots/' });
await fixture.build();
});
diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js
index c23fca34f..369c12103 100644
--- a/packages/astro/test/cli.test.js
+++ b/packages/astro/test/cli.test.js
@@ -7,7 +7,7 @@ import { isIPv4 } from 'net';
describe('astro cli', () => {
const cliServerLogSetupWithFixture = (flags, cmd) => {
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
- return cliServerLogSetup(['--project-root', fileURLToPath(projectRootURL), ...flags], cmd);
+ return cliServerLogSetup(['--root', fileURLToPath(projectRootURL), ...flags], cmd);
};
it('astro', async () => {
@@ -27,7 +27,7 @@ describe('astro cli', () => {
it('astro build', async () => {
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
- const proc = await cli('build', '--project-root', fileURLToPath(projectRootURL));
+ const proc = await cli('build', '--root', fileURLToPath(projectRootURL));
expect(proc.stdout).to.include('Complete');
});
@@ -36,7 +36,7 @@ describe('astro cli', () => {
const pkgVersion = await fs.readFile(pkgURL, 'utf8').then((data) => JSON.parse(data).version);
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
- const proc = cli('dev', '--project-root', fileURLToPath(projectRootURL));
+ const proc = cli('dev', '--root', fileURLToPath(projectRootURL));
const { messages } = await parseCliDevStart(proc);
expect(messages[0]).to.contain('astro');
@@ -45,10 +45,13 @@ describe('astro cli', () => {
});
['dev', 'preview'].forEach((cmd) => {
- const networkLogFlags = [['--host'], ['--host', '0.0.0.0'], ['--hostname', '0.0.0.0']];
+ const networkLogFlags = [['--host'], ['--host', '0.0.0.0']];
networkLogFlags.forEach(([flag, flagValue]) => {
it(`astro ${cmd} ${flag} ${flagValue ?? ''} - network log`, async () => {
- const { local, network } = await cliServerLogSetupWithFixture(flagValue ? [flag, flagValue] : [flag], cmd);
+ const { local, network } = await cliServerLogSetupWithFixture(
+ flagValue ? [flag, flagValue] : [flag],
+ cmd
+ );
expect(local).to.not.be.undefined;
expect(network).to.not.be.undefined;
@@ -56,18 +59,27 @@ describe('astro cli', () => {
const localURL = new URL(local);
const networkURL = new URL(network);
- expect(localURL.hostname).to.be.equal(flagValue ?? 'localhost', `Expected local URL to be on localhost`);
+ expect(localURL.hostname).to.be.equal(
+ flagValue ?? 'localhost',
+ `Expected local URL to be on localhost`
+ );
// Note: our tests run in parallel so this could be 3000+!
- expect(Number.parseInt(localURL.port)).to.be.greaterThanOrEqual(3000, `Expected Port to be >= 3000`);
- expect(networkURL.port).to.be.equal(localURL.port, `Expected local and network ports to be equal`);
- expect(isIPv4(networkURL.hostname)).to.be.equal(true, `Expected network URL to respect --host flag`);
+ expect(Number.parseInt(localURL.port)).to.be.greaterThanOrEqual(
+ 3000,
+ `Expected Port to be >= 3000`
+ );
+ expect(networkURL.port).to.be.equal(
+ localURL.port,
+ `Expected local and network ports to be equal`
+ );
+ expect(isIPv4(networkURL.hostname)).to.be.equal(
+ true,
+ `Expected network URL to respect --host flag`
+ );
});
});
- const hostToExposeFlags = [
- ['', ''],
- ['--hostname', 'localhost'],
- ];
+ const hostToExposeFlags = [['', '']];
hostToExposeFlags.forEach(([flag, flagValue]) => {
it(`astro ${cmd} ${flag} ${flagValue} - host to expose`, async () => {
const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd);
@@ -84,7 +96,6 @@ describe('astro cli', () => {
const noNetworkLogFlags = [
['--host', 'localhost'],
['--host', '127.0.0.1'],
- ['--hostname', '127.0.0.1'],
];
noNetworkLogFlags.forEach(([flag, flagValue]) => {
it(`astro ${cmd} ${flag} ${flagValue} - no network log`, async () => {
diff --git a/packages/astro/test/config-validate.test.js b/packages/astro/test/config-validate.test.js
index c543a013c..e90eea69c 100644
--- a/packages/astro/test/config-validate.test.js
+++ b/packages/astro/test/config-validate.test.js
@@ -10,45 +10,40 @@ describe('Config Validation', () => {
});
it('Zod errors are returned when invalid config is used', async () => {
- const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
+ const configError = await validateConfig({ site: 42 }, process.cwd()).catch((err) => err);
expect(configError instanceof z.ZodError).to.equal(true);
});
- it('errors when an older markdownOptions format is used', async () => {
- const configError = await validateConfig({ markdownOptions: { rehypePlugins: ['rehype-autolink-headings'] } }, process.cwd()).catch((err) => err);
- expect(configError instanceof z.ZodError).to.equal(true);
- expect(configError.issues[0].message).to.equal("Unrecognized key(s) in object: 'rehypePlugins'");
- });
-
it('A validation error can be formatted correctly', async () => {
- const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
+ const configError = await validateConfig({ site: 42 }, process.cwd()).catch((err) => err);
expect(configError instanceof z.ZodError).to.equal(true);
const formattedError = stripAnsi(formatConfigErrorMessage(configError));
expect(formattedError).to.equal(
`[config] Astro found issue(s) with your configuration:
- ! buildOptions.sitemap Expected boolean, received number.`
+ ! site Expected string, received number.`
);
});
it('Multiple validation errors can be formatted correctly', async () => {
const veryBadConfig = {
integrations: [42],
- buildOptions: { pageUrlFormat: 'invalid' },
- pages: {},
+ build: { format: 'invalid' },
};
const configError = await validateConfig(veryBadConfig, process.cwd()).catch((err) => err);
expect(configError instanceof z.ZodError).to.equal(true);
const formattedError = stripAnsi(formatConfigErrorMessage(configError));
expect(formattedError).to.equal(
`[config] Astro found issue(s) with your configuration:
- ! pages Expected string, received object.
! integrations.0 Expected object, received number.
- ! buildOptions.pageUrlFormat Invalid input.`
+ ! build.format Invalid input.`
);
});
it('ignores falsey "integration" values', async () => {
- const result = await validateConfig({ integrations: [0, false, null, undefined] }, process.cwd());
+ const result = await validateConfig(
+ { integrations: [0, false, null, undefined] },
+ process.cwd()
+ );
expect(result.integrations).to.deep.equal([]);
});
it('normalizes "integration" values', async () => {
@@ -56,7 +51,10 @@ describe('Config Validation', () => {
expect(result.integrations).to.deep.equal([{ name: '@astrojs/a', hooks: {} }]);
});
it('flattens array "integration" values', async () => {
- const result = await validateConfig({ integrations: [{ name: '@astrojs/a' }, [{ name: '@astrojs/b' }, { name: '@astrojs/c' }]] }, process.cwd());
+ const result = await validateConfig(
+ { integrations: [{ name: '@astrojs/a' }, [{ name: '@astrojs/b' }, { name: '@astrojs/c' }]] },
+ process.cwd()
+ );
expect(result.integrations).to.deep.equal([
{ name: '@astrojs/a', hooks: {} },
{ name: '@astrojs/b', hooks: {} },
@@ -64,11 +62,17 @@ describe('Config Validation', () => {
]);
});
it('blocks third-party "integration" values', async () => {
- const configError = await validateConfig({ integrations: [{ name: '@my-plugin/a' }] }, process.cwd()).catch((err) => err);
+ const configError = await validateConfig(
+ { integrations: [{ name: '@my-plugin/a' }] },
+ process.cwd()
+ ).catch((err) => err);
expect(configError).to.be.instanceOf(Error);
expect(configError.message).to.include('Astro integrations are still experimental.');
});
it('allows third-party "integration" values with the --experimental-integrations flag', async () => {
- await validateConfig({ integrations: [{ name: '@my-plugin/a' }], experimentalIntegrations: true }, process.cwd()).catch((err) => err);
+ await validateConfig(
+ { integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true } },
+ process.cwd()
+ ).catch((err) => err);
});
});
diff --git a/packages/astro/test/config.test.js b/packages/astro/test/config.test.js
index 80a2668e6..1f255097c 100644
--- a/packages/astro/test/config.test.js
+++ b/packages/astro/test/config.test.js
@@ -1,62 +1,47 @@
import { expect } from 'chai';
-import { cli, loadFixture, cliServerLogSetup } from './test-utils.js';
+import { loadFixture, cliServerLogSetup } from './test-utils.js';
import { fileURLToPath } from 'url';
import { isIPv4 } from 'net';
describe('config', () => {
- let hostnameFixture;
let hostFixture;
let portFixture;
before(async () => {
- [hostnameFixture, hostFixture, portFixture] = await Promise.all([
+ [hostFixture, portFixture] = await Promise.all([
loadFixture({
- projectRoot: './fixtures/config-host/',
- devOptions: {
- hostname: '0.0.0.0',
- },
- }),
- loadFixture({
- projectRoot: './fixtures/config-host/',
- devOptions: {
+ root: './fixtures/config-host/',
+ server: {
host: true,
},
}),
loadFixture({
- projectRoot: './fixtures/config-host/',
- devOptions: {
+ root: './fixtures/config-host/',
+ server: {
port: 5006,
},
}),
]);
});
- // TODO: remove test once --hostname is baselined
- describe('hostname', () => {
- it('can be specified in astro.config.mjs', async () => {
- expect(hostnameFixture.config.devOptions.hostname).to.equal('0.0.0.0');
- });
-
- it('can be specified via --hostname flag', async () => {
- const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
- const { network } = await cliServerLogSetup(['--project-root', fileURLToPath(projectRootURL), '--hostname', '0.0.0.0']);
-
- const networkURL = new URL(network);
- expect(isIPv4(networkURL.hostname)).to.be.equal(true, `Expected network URL to respect --hostname flag`);
- });
- });
-
describe('host', () => {
it('can be specified in astro.config.mjs', async () => {
- expect(hostFixture.config.devOptions.host).to.equal(true);
+ expect(hostFixture.config.server.host).to.equal(true);
});
it('can be specified via --host flag', async () => {
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
- const { network } = await cliServerLogSetup(['--project-root', fileURLToPath(projectRootURL), '--host']);
+ const { network } = await cliServerLogSetup([
+ '--root',
+ fileURLToPath(projectRootURL),
+ '--host',
+ ]);
const networkURL = new URL(network);
- expect(isIPv4(networkURL.hostname)).to.be.equal(true, `Expected network URL to respect --hostname flag`);
+ expect(isIPv4(networkURL.hostname)).to.be.equal(
+ true,
+ `Expected network URL to respect --host flag`
+ );
});
});
@@ -64,16 +49,24 @@ describe('config', () => {
it('can be passed via --config', async () => {
const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url);
const configFileURL = new URL('./fixtures/config-path/config/my-config.mjs', import.meta.url);
- const { network } = await cliServerLogSetup(['--project-root', fileURLToPath(projectRootURL), '--config', configFileURL.pathname]);
+ const { network } = await cliServerLogSetup([
+ '--root',
+ fileURLToPath(projectRootURL),
+ '--config',
+ configFileURL.pathname,
+ ]);
const networkURL = new URL(network);
- expect(isIPv4(networkURL.hostname)).to.be.equal(true, `Expected network URL to respect --hostname flag`);
+ expect(isIPv4(networkURL.hostname)).to.be.equal(
+ true,
+ `Expected network URL to respect --host flag`
+ );
});
});
describe('port', () => {
it('can be specified in astro.config.mjs', async () => {
- expect(portFixture.config.devOptions.port).to.deep.equal(5006);
+ expect(portFixture.config.server.port).to.deep.equal(5006);
});
});
});
diff --git a/packages/astro/test/custom-elements.test.js b/packages/astro/test/custom-elements.test.js
index 4224cbc83..a34efca14 100644
--- a/packages/astro/test/custom-elements.test.js
+++ b/packages/astro/test/custom-elements.test.js
@@ -11,7 +11,7 @@ describe.skip('Custom Elements', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/custom-elements/',
+ root: './fixtures/custom-elements/',
intergrations: ['@test/custom-element-renderer'],
});
await fixture.build();
diff --git a/packages/astro/test/debug-component.test.js b/packages/astro/test/debug-component.test.js
index 1eae70d1d..ef5e0ad34 100644
--- a/packages/astro/test/debug-component.test.js
+++ b/packages/astro/test/debug-component.test.js
@@ -14,7 +14,7 @@ describe('<Debug />', () => {
let devServer;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/debug-component/' });
+ fixture = await loadFixture({ root: './fixtures/debug-component/' });
devServer = await fixture.startDevServer();
});
diff --git a/packages/astro/test/dev-routing.test.js b/packages/astro/test/dev-routing.test.js
index d411f5de9..7ec6348c4 100644
--- a/packages/astro/test/dev-routing.test.js
+++ b/packages/astro/test/dev-routing.test.js
@@ -10,7 +10,7 @@ describe('Development Routing', () => {
let devServer;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/without-site-config/' });
+ fixture = await loadFixture({ root: './fixtures/without-site-config/' });
devServer = await fixture.startDevServer();
});
@@ -52,11 +52,9 @@ describe('Development Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: './dist-4007',
- buildOptions: {
- site: 'http://example.com/',
- },
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ outDir: './dist-4007',
+ site: 'http://example.com/',
});
devServer = await fixture.startDevServer();
});
@@ -94,11 +92,10 @@ describe('Development Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: './dist-4008',
- buildOptions: {
- site: 'http://example.com/blog/',
- },
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ outDir: './dist-4008',
+ site: 'http://example.com',
+ base: '/blog',
});
devServer = await fixture.startDevServer();
});
@@ -146,8 +143,9 @@ describe('Development Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: './dist-4009',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: './dist-4009',
});
devServer = await fixture.startDevServer();
});
@@ -195,10 +193,8 @@ describe('Development Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-endpoint-routes/',
- buildOptions: {
- site: 'http://example.com/',
- },
+ root: './fixtures/with-endpoint-routes/',
+ site: 'http://example.com/',
});
devServer = await fixture.startDevServer();
});
diff --git a/packages/astro/test/errors.test.js b/packages/astro/test/errors.test.js
index 7caec0642..85baee002 100644
--- a/packages/astro/test/errors.test.js
+++ b/packages/astro/test/errors.test.js
@@ -9,7 +9,7 @@ describe('Error display', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/errors',
+ root: './fixtures/errors',
});
});
diff --git a/packages/astro/test/fetch.test.js b/packages/astro/test/fetch.test.js
index ba76ce6a6..c548aa3f1 100644
--- a/packages/astro/test/fetch.test.js
+++ b/packages/astro/test/fetch.test.js
@@ -6,7 +6,7 @@ describe('Global Fetch', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/fetch/' });
+ fixture = await loadFixture({ root: './fixtures/fetch/' });
await fixture.build();
});
@@ -18,7 +18,10 @@ describe('Global Fetch', () => {
it('Is available in Astro components', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('#astro-component').text()).to.equal('function', 'Fetch supported in .astro components');
+ expect($('#astro-component').text()).to.equal(
+ 'function',
+ 'Fetch supported in .astro components'
+ );
});
it('Is available in non-Astro components', async () => {
const html = await fixture.readFile('/index.html');
@@ -31,6 +34,9 @@ describe('Global Fetch', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('#already-imported').text()).to.equal('function', 'Existing fetch imports respected');
- expect($('#custom-declaration').text()).to.equal('number', 'Custom fetch declarations respected');
+ expect($('#custom-declaration').text()).to.equal(
+ 'number',
+ 'Custom fetch declarations respected'
+ );
});
});
diff --git a/packages/astro/test/fixtures/astro-css-bundling/src/components/Nav.astro b/packages/astro/test/fixtures/astro-css-bundling/src/components/Nav.astro
index 159ef6719..37a2cecf1 100644
--- a/packages/astro/test/fixtures/astro-css-bundling/src/components/Nav.astro
+++ b/packages/astro/test/fixtures/astro-css-bundling/src/components/Nav.astro
@@ -19,7 +19,7 @@
}
</style>
-<style global>
+<style is:global>
html {
--primary: aquamarine;
}
diff --git a/packages/astro/test/fixtures/astro-global/astro.config.mjs b/packages/astro/test/fixtures/astro-global/astro.config.mjs
new file mode 100644
index 000000000..d87985387
--- /dev/null
+++ b/packages/astro/test/fixtures/astro-global/astro.config.mjs
@@ -0,0 +1,4 @@
+export default {
+ site: 'https://mysite.dev/',
+ base: '/blog'
+}
diff --git a/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro b/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro
index 1a21cf475..ee34156db 100644
--- a/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro
+++ b/packages/astro/test/fixtures/astro-global/src/pages/posts/[page].astro
@@ -4,7 +4,7 @@ export async function getStaticPaths({paginate}) {
return paginate(data, {pageSize: 1});
}
const { page } = Astro.props;
-const { params, canonicalURL} = Astro;
+const { params, canonicalURL } = Astro;
---
<html>
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/langs/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/langs/astro.config.mjs
index 97198ae94..130596b0c 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/langs/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/langs/astro.config.mjs
@@ -3,25 +3,17 @@ const riGrammar = JSON.parse(
);
export default {
- markdownOptions: {
- render: [
- "@astrojs/markdown-remark",
- {
- syntaxHighlight: 'shiki',
- shikiConfig: {
- langs: [
- {
- id: 'rinfo',
- scopeName: 'source.rinfo',
- grammar: riGrammar,
- aliases: ['ri'],
- },
- ],
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: {
+ langs: [
+ {
+ id: 'rinfo',
+ scopeName: 'source.rinfo',
+ grammar: riGrammar,
+ aliases: ['ri'],
},
- },
- ],
- },
- buildOptions: {
- sitemap: false,
+ ],
+ },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/normal/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/normal/astro.config.mjs
index 8d5aa6f81..acd4c5abc 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/normal/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/normal/astro.config.mjs
@@ -1,8 +1,5 @@
export default {
- markdownOptions: {
- render: ['@astrojs/markdown-remark', { syntaxHighlight: 'shiki' }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/themes-custom/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/themes-custom/astro.config.mjs
index 8f5289d0e..fa208789e 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/themes-custom/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/themes-custom/astro.config.mjs
@@ -3,10 +3,8 @@ const serendipity = JSON.parse(
);
export default {
- markdownOptions: {
- render: ["@astrojs/markdown-remark", { syntaxHighlight: 'shiki', shikiConfig: { theme: serendipity } }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: { theme: serendipity },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/themes-integrated/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/themes-integrated/astro.config.mjs
index 26ce0d008..7ddfeeb16 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/themes-integrated/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/themes-integrated/astro.config.mjs
@@ -1,8 +1,6 @@
export default {
- markdownOptions: {
- render: ["@astrojs/markdown-remark", { syntaxHighlight: 'shiki', shikiConfig: { theme: 'github-light' } }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: { theme: 'github-light' },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-false/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-false/astro.config.mjs
index 2317e36f7..e95742529 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-false/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-false/astro.config.mjs
@@ -1,8 +1,6 @@
export default {
- markdownOptions: {
- render: ['@astrojs/markdown-remark', { syntaxHighlight: 'shiki', shikiConfig: { wrap: false } }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: { wrap: false },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-null/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-null/astro.config.mjs
index 12a27dbbe..b1fa06335 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-null/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-null/astro.config.mjs
@@ -1,8 +1,6 @@
export default {
- markdownOptions: {
- render: ['@astrojs/markdown-remark', { syntaxHighlight: 'shiki', shikiConfig: { wrap: null } }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: { wrap: null },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-true/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-true/astro.config.mjs
index f1cae49a9..0e95f569b 100644
--- a/packages/astro/test/fixtures/astro-markdown-shiki/wrap-true/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown-shiki/wrap-true/astro.config.mjs
@@ -1,8 +1,6 @@
export default {
- markdownOptions: {
- render: ['@astrojs/markdown-remark', { syntaxHighlight: 'shiki', shikiConfig: { wrap: true } }],
- },
- buildOptions: {
- sitemap: false,
+ markdown: {
+ syntaxHighlight: 'shiki',
+ shikiConfig: { wrap: true },
},
}
diff --git a/packages/astro/test/fixtures/astro-markdown/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown/astro.config.mjs
index 680c77bdb..08916b1fe 100644
--- a/packages/astro/test/fixtures/astro-markdown/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-markdown/astro.config.mjs
@@ -4,7 +4,4 @@ import preact from '@astrojs/preact';
// https://astro.build/config
export default defineConfig({
integrations: [preact()],
- buildOptions: {
- sitemap: false,
- },
});
diff --git a/packages/astro/test/fixtures/astro-public/src/pages/index.astro b/packages/astro/test/fixtures/astro-public/src/pages/index.astro
index 1bb4b37e7..7c81f4aba 100644
--- a/packages/astro/test/fixtures/astro-public/src/pages/index.astro
+++ b/packages/astro/test/fixtures/astro-public/src/pages/index.astro
@@ -1,10 +1,10 @@
<html lang="en">
<head>
<title>This Site</title>
- <link href="/example.css" ref="stylesheet"/>
- <script src="/example.js"></script>
+ <link href="/example.css" rel="stylesheet"/>
+ <script is:inline src="/example.js"></script>
</head>
<body>
<img src="/images/twitter.png" />
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro b/packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro
index 3dac7f270..dfe895d6c 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro
@@ -1,3 +1,3 @@
-<script hoist type="module">
+<script>
console.log('some content here.');
-</script> \ No newline at end of file
+</script>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistClassic.astro b/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistClassic.astro
index d3bbdf473..7b2c5d3d2 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistClassic.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistClassic.astro
@@ -1,4 +1,4 @@
---
import url from "../scripts/no_hoist_nonmodule.js?url"
---
-<script src={url}></script>
+<script is:inline src={url}></script>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistModule.astro b/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistModule.astro
index f9dbcfa53..a25da8ea2 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistModule.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/components/NoHoistModule.astro
@@ -1,4 +1,4 @@
---
import url from '../scripts/no_hoist_module.js?url';
---
-<script type="module" src={url}></script>
+<script is:inline type="module" src={url}></script>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/components/Widget.astro b/packages/astro/test/fixtures/astro-scripts/src/components/Widget.astro
index 9c8378e3c..f976eb796 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/components/Widget.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/components/Widget.astro
@@ -1 +1 @@
-<script hoist type="module" src="../scripts/something.js"></script>
+<script src="../scripts/something.js"></script>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/components/Widget2.astro b/packages/astro/test/fixtures/astro-scripts/src/components/Widget2.astro
index 5f2ce4da3..638352524 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/components/Widget2.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/components/Widget2.astro
@@ -1 +1 @@
-<script hoist type="module" src="../scripts/another_external.js"></script>
+<script src="../scripts/another_external.js"></script>
diff --git a/packages/astro/test/fixtures/astro-scripts/src/pages/external.astro b/packages/astro/test/fixtures/astro-scripts/src/pages/external.astro
index 2fbdc02b3..e5b7fda80 100644
--- a/packages/astro/test/fixtures/astro-scripts/src/pages/external.astro
+++ b/packages/astro/test/fixtures/astro-scripts/src/pages/external.astro
@@ -16,4 +16,4 @@ import Widget2 from '../components/Widget2.astro';
<Widget />
<Widget2 />
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/packages/astro/test/fixtures/config-path/config/my-config.mjs b/packages/astro/test/fixtures/config-path/config/my-config.mjs
index c9d45e6c8..eb66c74ca 100644
--- a/packages/astro/test/fixtures/config-path/config/my-config.mjs
+++ b/packages/astro/test/fixtures/config-path/config/my-config.mjs
@@ -1,5 +1,5 @@
export default {
- devOptions: {
+ server: {
host: true,
port: 8080,
},
diff --git a/packages/astro/test/fixtures/markdown/astro.config.mjs b/packages/astro/test/fixtures/markdown/astro.config.mjs
index b4ba9c918..08916b1fe 100644
--- a/packages/astro/test/fixtures/markdown/astro.config.mjs
+++ b/packages/astro/test/fixtures/markdown/astro.config.mjs
@@ -3,8 +3,5 @@ import preact from '@astrojs/preact';
// https://astro.build/config
export default defineConfig({
- buildOptions: {
- sitemap: false,
- },
integrations: [preact()],
-}); \ No newline at end of file
+});
diff --git a/packages/astro/test/fixtures/remote-css/src/components/CommonHead.astro b/packages/astro/test/fixtures/remote-css/src/components/CommonHead.astro
index 06520fef3..1ac907169 100644
--- a/packages/astro/test/fixtures/remote-css/src/components/CommonHead.astro
+++ b/packages/astro/test/fixtures/remote-css/src/components/CommonHead.astro
@@ -1,5 +1,5 @@
- <style global>
+ <style is:global>
/* Testing remote imports */
@import "https://unpkg.com/open-props";
@import "https://unpkg.com/open-props/normalize.min.css";
- </style> \ No newline at end of file
+ </style>
diff --git a/packages/astro/test/fixtures/sass/package.json b/packages/astro/test/fixtures/sass/package.json
index 482f5e3f6..2250f7f54 100644
--- a/packages/astro/test/fixtures/sass/package.json
+++ b/packages/astro/test/fixtures/sass/package.json
@@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"astro": "workspace:*",
- "sass": "^1.49.9"
+ "sass": "^1.49.11"
}
}
diff --git a/packages/astro/test/fixtures/static build/astro.config.mjs b/packages/astro/test/fixtures/static build/astro.config.mjs
index 32807d063..cc4fa3ae9 100644
--- a/packages/astro/test/fixtures/static build/astro.config.mjs
+++ b/packages/astro/test/fixtures/static build/astro.config.mjs
@@ -4,10 +4,9 @@ import preact from '@astrojs/preact';
// https://astro.build/config
export default defineConfig({
integrations: [preact()],
- buildOptions: {
- site: 'http://example.com/subpath/',
- },
+ site: 'http://example.com',
+ base: '/subpath',
ssr: {
noExternal: ['@test/static-build-pkg'],
},
-}); \ No newline at end of file
+});
diff --git a/packages/astro/test/fixtures/static-build-page-url-format/astro.config.mjs b/packages/astro/test/fixtures/static-build-page-url-format/astro.config.mjs
index 7c6e98cc0..55525c455 100644
--- a/packages/astro/test/fixtures/static-build-page-url-format/astro.config.mjs
+++ b/packages/astro/test/fixtures/static-build-page-url-format/astro.config.mjs
@@ -2,8 +2,9 @@ import { defineConfig } from 'astro/config';
// https://astro.build/config
export default defineConfig({
- buildOptions: {
- site: 'http://example.com/subpath/',
- pageUrlFormat: 'file',
+ site: 'http://example.com/',
+ base: '/subpath',
+ build: {
+ format: 'file',
},
-}); \ No newline at end of file
+});
diff --git a/packages/astro/test/fixtures/with-subpath-no-trailing-slash/astro.config.mjs b/packages/astro/test/fixtures/with-subpath-no-trailing-slash/astro.config.mjs
index 3ce56e992..227d24574 100644
--- a/packages/astro/test/fixtures/with-subpath-no-trailing-slash/astro.config.mjs
+++ b/packages/astro/test/fixtures/with-subpath-no-trailing-slash/astro.config.mjs
@@ -1,6 +1,4 @@
export default {
- buildOptions: {
- site: 'http://example.com/blog'
- }
+ site: 'http://example.com',
}
diff --git a/packages/astro/test/legacy-build.test.js b/packages/astro/test/legacy-build.test.js
deleted file mode 100644
index 20b8dcf9c..000000000
--- a/packages/astro/test/legacy-build.test.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import { expect } from 'chai';
-import cheerio from 'cheerio';
-import { loadFixture } from './test-utils.js';
-
-describe('Legacy Build', () => {
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({
- projectRoot: './fixtures/legacy-build/',
- });
- await fixture.build({ buildOptions: { legacyBuild: true } });
- });
-
- describe('build', () => {
- it('is successful', async () => {
- const html = await fixture.readFile(`/index.html`);
- const $ = cheerio.load(html);
- expect($('title').text()).to.equal('Demo app');
- });
- });
-});
diff --git a/packages/astro/test/lit-element.test.js b/packages/astro/test/lit-element.test.js
index 65f1a01fb..6b8690fff 100644
--- a/packages/astro/test/lit-element.test.js
+++ b/packages/astro/test/lit-element.test.js
@@ -16,7 +16,7 @@ describe('LitElement test', function () {
return;
}
fixture = await loadFixture({
- projectRoot: './fixtures/lit-element/',
+ root: './fixtures/lit-element/',
});
await fixture.build();
});
@@ -36,7 +36,9 @@ describe('LitElement test', function () {
expect($('my-element').html()).to.include(`<div>Testing...</div>`);
// test 3: string reactive property set
- expect(stripExpressionMarkers($('my-element').html())).to.include(`<div id="str">initialized</div>`);
+ expect(stripExpressionMarkers($('my-element').html())).to.include(
+ `<div id="str">initialized</div>`
+ );
// test 4: boolean reactive property correctly set
// <my-element bool="false"> Lit will equate to true because it uses
@@ -45,7 +47,9 @@ describe('LitElement test', function () {
// test 5: object reactive property set
// by default objects will be stringifed to [object Object]
- expect(stripExpressionMarkers($('my-element').html())).to.include(`<div id="data">data: 1</div>`);
+ expect(stripExpressionMarkers($('my-element').html())).to.include(
+ `<div id="data">data: 1</div>`
+ );
// test 6: reactive properties are not rendered as attributes
expect($('my-element').attr('obj')).to.equal(undefined);
diff --git a/packages/astro/test/markdown.test.js b/packages/astro/test/markdown.test.js
index 5d4fdefda..b8263ce76 100644
--- a/packages/astro/test/markdown.test.js
+++ b/packages/astro/test/markdown.test.js
@@ -7,7 +7,7 @@ describe('Markdown tests', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/markdown/',
+ root: './fixtures/markdown/',
});
await fixture.build();
});
diff --git a/packages/astro/test/page-level-styles.test.js b/packages/astro/test/page-level-styles.test.js
index 6b3fb5dac..3fdce62b9 100644
--- a/packages/astro/test/page-level-styles.test.js
+++ b/packages/astro/test/page-level-styles.test.js
@@ -8,7 +8,7 @@ describe('Page-level styles', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/page-level-styles/',
+ root: './fixtures/page-level-styles/',
});
await fixture.build();
});
diff --git a/packages/astro/test/postcss.test.js b/packages/astro/test/postcss.test.js
index c60cf772f..53c4f7665 100644
--- a/packages/astro/test/postcss.test.js
+++ b/packages/astro/test/postcss.test.js
@@ -10,7 +10,7 @@ describe('PostCSS', () => {
let bundledCSS;
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/postcss',
+ root: './fixtures/postcss',
});
await fixture.build();
diff --git a/packages/astro/test/preact-component.test.js b/packages/astro/test/preact-component.test.js
index e6e018068..868f15270 100644
--- a/packages/astro/test/preact-component.test.js
+++ b/packages/astro/test/preact-component.test.js
@@ -7,7 +7,7 @@ describe('Preact component', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/preact-component/',
+ root: './fixtures/preact-component/',
});
await fixture.build();
});
diff --git a/packages/astro/test/preview-routing.test.js b/packages/astro/test/preview-routing.test.js
index 005eeef57..591618126 100644
--- a/packages/astro/test/preview-routing.test.js
+++ b/packages/astro/test/preview-routing.test.js
@@ -2,7 +2,7 @@ import { expect } from 'chai';
import { loadFixture } from './test-utils.js';
describe('Preview Routing', () => {
- describe('pageUrlFormat: directory', () => {
+ describe('build format: directory', () => {
describe('Subpath without trailing slash and trailingSlash: never', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
@@ -11,13 +11,14 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4000/', import.meta.url),
- buildOptions: {
- pageUrlFormat: 'directory',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4000/', import.meta.url),
+ build: {
+ format: 'directory',
},
- devOptions: {
- trailingSlash: 'never',
+ trailingSlash: 'never',
+ server: {
port: 4000,
},
});
@@ -69,11 +70,11 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4001/', import.meta.url),
- buildOptions: {},
- devOptions: {
- trailingSlash: 'always',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4001/', import.meta.url),
+ trailingSlash: 'always',
+ server: {
port: 4001,
},
});
@@ -129,11 +130,11 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4002/', import.meta.url),
- buildOptions: {},
- devOptions: {
- trailingSlash: 'ignore',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4002/', import.meta.url),
+ trailingSlash: 'ignore',
+ server: {
port: 4002,
},
});
@@ -182,7 +183,7 @@ describe('Preview Routing', () => {
});
});
- describe('pageUrlFormat: file', () => {
+ describe('build format: file', () => {
describe('Subpath without trailing slash and trailingSlash: never', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
@@ -191,13 +192,14 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4003/', import.meta.url),
- buildOptions: {
- pageUrlFormat: 'file',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4003/', import.meta.url),
+ build: {
+ format: 'file',
},
- devOptions: {
- trailingSlash: 'never',
+ trailingSlash: 'never',
+ server: {
port: 4003,
},
});
@@ -249,13 +251,14 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4004/', import.meta.url),
- buildOptions: {
- pageUrlFormat: 'file',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4004/', import.meta.url),
+ build: {
+ format: 'file',
},
- devOptions: {
- trailingSlash: 'always',
+ trailingSlash: 'always',
+ server: {
port: 4004,
},
});
@@ -311,13 +314,14 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4005/', import.meta.url),
- buildOptions: {
- pageUrlFormat: 'file',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4005/', import.meta.url),
+ build: {
+ format: 'file',
},
- devOptions: {
- trailingSlash: 'ignore',
+ trailingSlash: 'ignore',
+ server: {
port: 4005,
},
});
@@ -373,13 +377,14 @@ describe('Preview Routing', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/with-subpath-no-trailing-slash/',
- dist: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4006/', import.meta.url),
- buildOptions: {
- pageUrlFormat: 'file',
+ root: './fixtures/with-subpath-no-trailing-slash/',
+ base: '/blog',
+ outDir: new URL('./fixtures/with-subpath-no-trailing-slash/dist-4006/', import.meta.url),
+ build: {
+ format: 'file',
},
- devOptions: {
- trailingSlash: 'ignore',
+ trailingSlash: 'ignore',
+ server: {
port: 4006,
},
});
diff --git a/packages/astro/test/react-component.test.js b/packages/astro/test/react-component.test.js
index b1080dc9f..bb67f3df2 100644
--- a/packages/astro/test/react-component.test.js
+++ b/packages/astro/test/react-component.test.js
@@ -7,7 +7,7 @@ let fixture;
describe('React Components', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/react-component/',
+ root: './fixtures/react-component/',
});
});
diff --git a/packages/astro/test/remote-css.test.js b/packages/astro/test/remote-css.test.js
index a6f5cdd55..e7cb54090 100644
--- a/packages/astro/test/remote-css.test.js
+++ b/packages/astro/test/remote-css.test.js
@@ -7,7 +7,7 @@ describe('Remote CSS', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/remote-css/',
+ root: './fixtures/remote-css/',
});
await fixture.build();
});
diff --git a/packages/astro/test/route-manifest.test.js b/packages/astro/test/route-manifest.test.js
index 2432b0327..0b4052256 100644
--- a/packages/astro/test/route-manifest.test.js
+++ b/packages/astro/test/route-manifest.test.js
@@ -1,242 +1,241 @@
-import { expect } from 'chai';
-import { fileURLToPath } from 'url';
-import { createRouteManifest } from '../dist/core/routing/index.js';
-
-const cwd = new URL('./fixtures/route-manifest/', import.meta.url);
-
-const create = (dir, trailingSlash) => {
- return createRouteManifest({
- config: {
- projectRoot: cwd,
- pages: new URL(dir, cwd),
- devOptions: {
- trailingSlash,
- },
- },
- cwd: fileURLToPath(cwd),
- });
-};
-function cleanRoutes(routes) {
- return routes.map((r) => {
- delete r.generate;
- return r;
- });
-}
-
-describe('route manifest', () => {
- it('creates routes with trailingSlashes = always', () => {
- const { routes } = create('basic', 'always');
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/$/,
- params: [],
- component: 'basic/index.astro',
- pathname: '/',
- },
-
- {
- type: 'page',
- pattern: /^\/about\/$/,
- params: [],
- component: 'basic/about.astro',
- pathname: '/about',
- },
-
- {
- type: 'page',
- pattern: /^\/blog\/$/,
- params: [],
- component: 'basic/blog/index.astro',
- pathname: '/blog',
- },
-
- {
- type: 'page',
- pattern: /^\/blog\/([^/]+?)\/$/,
- params: ['slug'],
- component: 'basic/blog/[slug].astro',
- pathname: undefined,
- },
- ]);
- });
-
- it('creates routes with trailingSlashes = never', () => {
- const { routes } = create('basic', 'never');
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/$/,
- params: [],
- component: 'basic/index.astro',
- pathname: '/',
- },
-
- {
- type: 'page',
- pattern: /^\/about$/,
- params: [],
- component: 'basic/about.astro',
- pathname: '/about',
- },
-
- {
- type: 'page',
- pattern: /^\/blog$/,
- params: [],
- component: 'basic/blog/index.astro',
- pathname: '/blog',
- },
-
- {
- type: 'page',
- pattern: /^\/blog\/([^/]+?)$/,
- params: ['slug'],
- component: 'basic/blog/[slug].astro',
- pathname: undefined,
- },
- ]);
- });
-
- it('creates routes with trailingSlashes = ignore', () => {
- const { routes } = create('basic', 'ignore');
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/$/,
- params: [],
- component: 'basic/index.astro',
- pathname: '/',
- },
-
- {
- type: 'page',
- pattern: /^\/about\/?$/,
- params: [],
- component: 'basic/about.astro',
- pathname: '/about',
- },
-
- {
- type: 'page',
- pattern: /^\/blog\/?$/,
- params: [],
- component: 'basic/blog/index.astro',
- pathname: '/blog',
- },
-
- {
- type: 'page',
- pattern: /^\/blog\/([^/]+?)\/?$/,
- params: ['slug'],
- component: 'basic/blog/[slug].astro',
- pathname: undefined,
- },
- ]);
- });
-
- it('encodes invalid characters', () => {
- const { routes } = create('encoding', 'always');
-
- // had to remove ? and " because windows
-
- // const quote = 'encoding/".astro';
- const hash = 'encoding/#.astro';
- // const question_mark = 'encoding/?.astro';
-
- expect(routes.map((p) => p.pattern)).to.deep.equal([
- // /^\/%22$/,
- /^\/%23\/$/,
- // /^\/%3F$/
- ]);
- });
-
- it('ignores files and directories with leading underscores', () => {
- const { routes } = create('hidden-underscore', 'always');
-
- expect(routes.map((r) => r.component).filter(Boolean)).to.deep.equal(['hidden-underscore/index.astro', 'hidden-underscore/e/f/g/h.astro']);
- });
-
- it('ignores files and directories with leading dots except .well-known', () => {
- const { routes } = create('hidden-dot', 'always');
-
- expect(routes.map((r) => r.component).filter(Boolean)).to.deep.equal(['hidden-dot/.well-known/dnt-policy.astro']);
- });
-
- it('fails if dynamic params are not separated', () => {
- expect(() => create('invalid-params', 'always')).to.throw('Invalid route invalid-params/[foo][bar].astro — parameters must be separated');
- });
-
- it('disallows rest parameters inside segments', () => {
- expect(() => create('invalid-rest', 'always')).to.throw('Invalid route invalid-rest/foo-[...rest]-bar.astro — rest parameter must be a standalone segment');
- });
-
- it('ignores things that look like lockfiles', () => {
- const { routes } = create('lockfiles', 'always');
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/foo\/$/,
- params: [],
- component: 'lockfiles/foo.astro',
- pathname: '/foo',
- },
- ]);
- });
-
- it('ignores invalid route extensions', () => {
- const { routes } = create('invalid-extension', 'always');
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/$/,
- params: [],
- component: 'invalid-extension/index.astro',
- pathname: '/',
- },
-
- {
- type: 'page',
- pattern: /^\/about\/$/,
- params: [],
- component: 'invalid-extension/about.astro',
- pathname: '/about',
- },
- ]);
- });
-
- it('allows multiple slugs', () => {
- const { routes } = create('multiple-slugs', 'always');
-
- expect(cleanRoutes(routes)).to.deep.equal([
- {
- type: 'page',
- pattern: /^\/([^/]+?)\.([^/]+?)\/$/,
- component: 'multiple-slugs/[file].[ext].astro',
- params: ['file', 'ext'],
- pathname: undefined,
- },
- ]);
- });
-
- it('sorts routes correctly', () => {
- const { routes } = create('sorting', 'always');
-
- expect(routes.map((p) => p.component)).to.deep.equal([
- 'sorting/index.astro',
- 'sorting/about.astro',
- 'sorting/post/index.astro',
- 'sorting/post/bar.astro',
- 'sorting/post/foo.astro',
- 'sorting/post/f[xx].astro',
- 'sorting/post/f[yy].astro',
- 'sorting/post/[id].astro',
- 'sorting/[wildcard].astro',
- 'sorting/[...rest]/deep/[...deep_rest]/xyz.astro',
- 'sorting/[...rest]/deep/[...deep_rest]/index.astro',
- 'sorting/[...rest]/deep/index.astro',
- 'sorting/[...rest]/abc.astro',
- 'sorting/[...rest]/index.astro',
- ]);
- });
-});
+// TODO: unskip this test
+// import { expect } from 'chai';
+// import { fileURLToPath } from 'url';
+// import { createRouteManifest } from '../dist/core/routing/index.js';
+// import { validateConfig } from '../dist/core/config.js';
+
+// const cwd = new URL('./fixtures/route-manifest/', import.meta.url);
+
+// const create = async (dir, trailingSlash) => {
+// return createRouteManifest({
+// config: await validateConfig({
+// root: cwd.pathname,
+// trailingSlash,
+// }),
+// cwd: fileURLToPath(cwd),
+// });
+// };
+// function cleanRoutes(routes) {
+// return routes.map((r) => {
+// delete r.generate;
+// return r;
+// });
+// }
+
+// describe('route manifest', () => {
+// it('creates routes with trailingSlashes = always', async () => {
+// const { routes } = await create('basic', 'always');
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/$/,
+// params: [],
+// component: 'basic/index.astro',
+// pathname: '/',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/about\/$/,
+// params: [],
+// component: 'basic/about.astro',
+// pathname: '/about',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog\/$/,
+// params: [],
+// component: 'basic/blog/index.astro',
+// pathname: '/blog',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog\/([^/]+?)\/$/,
+// params: ['slug'],
+// component: 'basic/blog/[slug].astro',
+// pathname: undefined,
+// },
+// ]);
+// });
+
+// it('creates routes with trailingSlashes = never', async () => {
+// const { routes } = await create('basic', 'never');
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/$/,
+// params: [],
+// component: 'basic/index.astro',
+// pathname: '/',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/about$/,
+// params: [],
+// component: 'basic/about.astro',
+// pathname: '/about',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog$/,
+// params: [],
+// component: 'basic/blog/index.astro',
+// pathname: '/blog',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog\/([^/]+?)$/,
+// params: ['slug'],
+// component: 'basic/blog/[slug].astro',
+// pathname: undefined,
+// },
+// ]);
+// });
+
+// it('creates routes with trailingSlashes = ignore', async () => {
+// const { routes } = await create('basic', 'ignore');
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/$/,
+// params: [],
+// component: 'basic/index.astro',
+// pathname: '/',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/about\/?$/,
+// params: [],
+// component: 'basic/about.astro',
+// pathname: '/about',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog\/?$/,
+// params: [],
+// component: 'basic/blog/index.astro',
+// pathname: '/blog',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/blog\/([^/]+?)\/?$/,
+// params: ['slug'],
+// component: 'basic/blog/[slug].astro',
+// pathname: undefined,
+// },
+// ]);
+// });
+
+// it('encodes invalid characters', async () => {
+// const { routes } = await create('encoding', 'always');
+
+// // had to remove ? and " because windows
+
+// // const quote = 'encoding/".astro';
+// const hash = 'encoding/#.astro';
+// // const question_mark = 'encoding/?.astro';
+
+// expect(routes.map((p) => p.pattern)).to.deep.equal([
+// // /^\/%22$/,
+// /^\/%23\/$/,
+// // /^\/%3F$/
+// ]);
+// });
+
+// it('ignores files and directories with leading underscores', async () => {
+// const { routes } = await create('hidden-underscore', 'always');
+
+// expect(routes.map((r) => r.component).filter(Boolean)).to.deep.equal(['hidden-underscore/index.astro', 'hidden-underscore/e/f/g/h.astro']);
+// });
+
+// it('ignores files and directories with leading dots except .well-known', async () => {
+// const { routes } = await create('hidden-dot', 'always');
+
+// expect(routes.map((r) => r.component).filter(Boolean)).to.deep.equal(['hidden-dot/.well-known/dnt-policy.astro']);
+// });
+
+// it('fails if dynamic params are not separated', async () => {
+// expect(() => await create('invalid-params', 'always')).to.throw('Invalid route invalid-params/[foo][bar].astro — parameters must be separated');
+// });
+
+// it('disallows rest parameters inside segments', async () => {
+// expect(() => await create('invalid-rest', 'always')).to.throw('Invalid route invalid-rest/foo-[...rest]-bar.astro — rest parameter must be a standalone segment');
+// });
+
+// it('ignores things that look like lockfiles', async () => {
+// const { routes } = await create('lockfiles', 'always');
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/foo\/$/,
+// params: [],
+// component: 'lockfiles/foo.astro',
+// pathname: '/foo',
+// },
+// ]);
+// });
+
+// it('ignores invalid route extensions', async () => {
+// const { routes } = await create('invalid-extension', 'always');
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/$/,
+// params: [],
+// component: 'invalid-extension/index.astro',
+// pathname: '/',
+// },
+
+// {
+// type: 'page',
+// pattern: /^\/about\/$/,
+// params: [],
+// component: 'invalid-extension/about.astro',
+// pathname: '/about',
+// },
+// ]);
+// });
+
+// it('allows multiple slugs', async () => {
+// const { routes } = await create('multiple-slugs', 'always');
+
+// expect(cleanRoutes(routes)).to.deep.equal([
+// {
+// type: 'page',
+// pattern: /^\/([^/]+?)\.([^/]+?)\/$/,
+// component: 'multiple-slugs/[file].[ext].astro',
+// params: ['file', 'ext'],
+// pathname: undefined,
+// },
+// ]);
+// });
+
+// it('sorts routes correctly', async () => {
+// const { routes } = await create('sorting', 'always');
+
+// expect(routes.map((p) => p.component)).to.deep.equal([
+// 'sorting/index.astro',
+// 'sorting/about.astro',
+// 'sorting/post/index.astro',
+// 'sorting/post/bar.astro',
+// 'sorting/post/foo.astro',
+// 'sorting/post/f[xx].astro',
+// 'sorting/post/f[yy].astro',
+// 'sorting/post/[id].astro',
+// 'sorting/[wildcard].astro',
+// 'sorting/[...rest]/deep/[...deep_rest]/xyz.astro',
+// 'sorting/[...rest]/deep/[...deep_rest]/index.astro',
+// 'sorting/[...rest]/deep/index.astro',
+// 'sorting/[...rest]/abc.astro',
+// 'sorting/[...rest]/index.astro',
+// ]);
+// });
+// });
diff --git a/packages/astro/test/sass.test.js b/packages/astro/test/sass.test.js
index e62092e42..4072d5547 100644
--- a/packages/astro/test/sass.test.js
+++ b/packages/astro/test/sass.test.js
@@ -9,7 +9,7 @@ describe('Sass', () => {
let devServer;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/sass/' });
+ fixture = await loadFixture({ root: './fixtures/sass/' });
devServer = await fixture.startDevServer();
});
diff --git a/packages/astro/test/slots-preact.test.js b/packages/astro/test/slots-preact.test.js
index 3419dfda6..380979f04 100644
--- a/packages/astro/test/slots-preact.test.js
+++ b/packages/astro/test/slots-preact.test.js
@@ -6,7 +6,7 @@ describe('Slots: Preact', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/slots-preact/' });
+ fixture = await loadFixture({ root: './fixtures/slots-preact/' });
await fixture.build();
});
diff --git a/packages/astro/test/slots-react.test.js b/packages/astro/test/slots-react.test.js
index 1c721c6e2..3cca8ae05 100644
--- a/packages/astro/test/slots-react.test.js
+++ b/packages/astro/test/slots-react.test.js
@@ -6,7 +6,7 @@ describe('Slots: React', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/slots-react/' });
+ fixture = await loadFixture({ root: './fixtures/slots-react/' });
await fixture.build();
});
diff --git a/packages/astro/test/slots-solid.test.js b/packages/astro/test/slots-solid.test.js
index 2b45dd5d9..cf59ada41 100644
--- a/packages/astro/test/slots-solid.test.js
+++ b/packages/astro/test/slots-solid.test.js
@@ -6,7 +6,7 @@ describe('Slots: Solid', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/slots-solid/' });
+ fixture = await loadFixture({ root: './fixtures/slots-solid/' });
await fixture.build();
});
diff --git a/packages/astro/test/slots-svelte.test.js b/packages/astro/test/slots-svelte.test.js
index 3a267ccb1..3c5b5d7fa 100644
--- a/packages/astro/test/slots-svelte.test.js
+++ b/packages/astro/test/slots-svelte.test.js
@@ -6,7 +6,7 @@ describe('Slots: Svelte', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/slots-svelte/' });
+ fixture = await loadFixture({ root: './fixtures/slots-svelte/' });
await fixture.build();
});
diff --git a/packages/astro/test/slots-vue.test.js b/packages/astro/test/slots-vue.test.js
index c598d346b..9cd8ac6eb 100644
--- a/packages/astro/test/slots-vue.test.js
+++ b/packages/astro/test/slots-vue.test.js
@@ -6,7 +6,7 @@ describe('Slots: Vue', () => {
let fixture;
before(async () => {
- fixture = await loadFixture({ projectRoot: './fixtures/slots-vue/' });
+ fixture = await loadFixture({ root: './fixtures/slots-vue/' });
await fixture.build();
});
diff --git a/packages/astro/test/solid-component.test.js b/packages/astro/test/solid-component.test.js
index 07e01fba0..f870468f2 100644
--- a/packages/astro/test/solid-component.test.js
+++ b/packages/astro/test/solid-component.test.js
@@ -7,7 +7,7 @@ describe('Solid component', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/solid-component/',
+ root: './fixtures/solid-component/',
});
});
diff --git a/packages/astro/test/ssr-adapter-build-config.test.js b/packages/astro/test/ssr-adapter-build-config.test.js
new file mode 100644
index 000000000..427049532
--- /dev/null
+++ b/packages/astro/test/ssr-adapter-build-config.test.js
@@ -0,0 +1,71 @@
+import { expect } from 'chai';
+import { load as cheerioLoad } from 'cheerio';
+import { loadFixture } from './test-utils.js';
+import { viteID } from '../dist/core/util.js';
+
+// Asset bundling
+describe('Integration buildConfig hook', () => {
+ /** @type {import('./test-utils').Fixture} */
+ let fixture;
+
+ before(async () => {
+ let _config;
+ fixture = await loadFixture({
+ root: './fixtures/ssr-request/',
+ experimental: {
+ ssr: true,
+ },
+ adapter: {
+ name: 'my-ssr-adapter',
+ hooks: {
+ 'astro:config:setup': ({ updateConfig }) => {
+ updateConfig({
+ vite: {
+ plugins: [
+ {
+ resolveId(id) {
+ if (id === '@my-ssr') {
+ return id;
+ } else if (id === 'astro/app') {
+ const id = viteID(new URL('../dist/core/app/index.js', import.meta.url));
+ return id;
+ }
+ },
+ load(id) {
+ if (id === '@my-ssr') {
+ return `import { App } from 'astro/app';export function createExports(manifest) { return { manifest, createApp: () => new App(manifest) }; }`;
+ }
+ },
+ },
+ ],
+ },
+ });
+ },
+ 'astro:build:start': ({ buildConfig }) => {
+ buildConfig.server = new URL('./dist/.root/server/', _config.root);
+ buildConfig.client = new URL('./dist/.root/client/', _config.root);
+ },
+ 'astro:config:done': ({ config, setAdapter }) => {
+ _config = config;
+ setAdapter({
+ name: 'my-ssr-adapter',
+ serverEntrypoint: '@my-ssr',
+ exports: ['manifest', 'createApp'],
+ });
+ },
+ },
+ },
+ });
+ await fixture.build();
+ });
+
+ it('Puts client files in the client folder', async () => {
+ let data = await fixture.readFile('/.root/client/cars.json');
+ expect(data).to.not.be.undefined;
+ });
+
+ it('Puts the server entry into the server folder', async () => {
+ let data = await fixture.readFile('/.root/server/entry.mjs');
+ expect(data).to.not.be.undefined;
+ });
+});
diff --git a/packages/astro/test/ssr-api-route.test.js b/packages/astro/test/ssr-api-route.test.js
index 6bf8fcd20..666fd217d 100644
--- a/packages/astro/test/ssr-api-route.test.js
+++ b/packages/astro/test/ssr-api-route.test.js
@@ -9,8 +9,10 @@ describe('API routes in SSR', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/ssr-api-route/',
- buildOptions: { experimentalSsr: true },
+ root: './fixtures/ssr-api-route/',
+ experimental: {
+ ssr: true,
+ },
adapter: testAdapter(),
});
await fixture.build();
@@ -35,7 +37,7 @@ describe('API routes in SSR', () => {
expect(body.length).to.equal(3);
});
- describe('Dev', () => {
+ describe('API Routes - Dev', () => {
let devServer;
before(async () => {
devServer = await fixture.startDevServer();
diff --git a/packages/astro/test/ssr-dynamic.test.js b/packages/astro/test/ssr-dynamic.test.js
index 98d73b98e..01ff3d2be 100644
--- a/packages/astro/test/ssr-dynamic.test.js
+++ b/packages/astro/test/ssr-dynamic.test.js
@@ -10,8 +10,10 @@ describe('Dynamic pages in SSR', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/ssr-dynamic/',
- buildOptions: { experimentalSsr: true },
+ root: './fixtures/ssr-dynamic/',
+ experimental: {
+ ssr: true,
+ },
adapter: testAdapter(),
});
await fixture.build();
diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js
index 04a00a195..0cba2a49e 100644
--- a/packages/astro/test/ssr-request.test.js
+++ b/packages/astro/test/ssr-request.test.js
@@ -10,11 +10,11 @@ describe('Using Astro.request in SSR', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/ssr-request/',
- buildOptions: {
- experimentalSsr: true,
- },
+ root: './fixtures/ssr-request/',
adapter: testAdapter(),
+ experimental: {
+ ssr: true,
+ },
});
await fixture.build();
});
diff --git a/packages/astro/test/static-build-code-component.test.js b/packages/astro/test/static-build-code-component.test.js
index ec5e33945..f6a7d205d 100644
--- a/packages/astro/test/static-build-code-component.test.js
+++ b/packages/astro/test/static-build-code-component.test.js
@@ -7,7 +7,7 @@ describe('Code component inside static build', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/static-build-code-component/',
+ root: './fixtures/static-build-code-component/',
});
await fixture.build();
});
diff --git a/packages/astro/test/static-build-frameworks.test.js b/packages/astro/test/static-build-frameworks.test.js
index 9b6d50028..8bb2e116a 100644
--- a/packages/astro/test/static-build-frameworks.test.js
+++ b/packages/astro/test/static-build-frameworks.test.js
@@ -11,7 +11,7 @@ describe('Static build - frameworks', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/static-build-frameworks/',
+ root: './fixtures/static-build-frameworks/',
});
await fixture.build();
});
diff --git a/packages/astro/test/static-build-page-url-format.test.js b/packages/astro/test/static-build-page-url-format.test.js
index 4a21419cc..941a7e571 100644
--- a/packages/astro/test/static-build-page-url-format.test.js
+++ b/packages/astro/test/static-build-page-url-format.test.js
@@ -6,12 +6,12 @@ function addLeadingSlash(path) {
return path.startsWith('/') ? path : '/' + path;
}
-describe("Static build - pageUrlFormat: 'file'", () => {
+describe("Static build - format: 'file'", () => {
let fixture;
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/static-build-page-url-format/',
+ root: './fixtures/static-build-page-url-format/',
});
await fixture.build();
});
diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js
index 47707ea27..55ce6ca07 100644
--- a/packages/astro/test/static-build.test.js
+++ b/packages/astro/test/static-build.test.js
@@ -11,7 +11,7 @@ describe('Static build', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/static build/',
+ root: './fixtures/static build/',
});
await fixture.build();
});
@@ -72,7 +72,7 @@ describe('Static build', () => {
const $ = cheerioLoad(html);
const links = $('link[rel=stylesheet]');
for (const link of links) {
- const href = $(link).attr('href').slice('/subpath'.length);
+ const href = $(link).attr('href');
const data = await fixture.readFile(addLeadingSlash(href));
if (expected.test(data)) {
return true;
diff --git a/packages/astro/test/status-page.test.js b/packages/astro/test/status-page.test.js
index 5cce71f48..06b2d0ae8 100644
--- a/packages/astro/test/status-page.test.js
+++ b/packages/astro/test/status-page.test.js
@@ -7,7 +7,7 @@ describe('Status Code Pages', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/status-code/',
+ root: './fixtures/status-code/',
});
await fixture.build();
});
diff --git a/packages/astro/test/svelte-component.test.js b/packages/astro/test/svelte-component.test.js
index c088bf9b5..36ba35b51 100644
--- a/packages/astro/test/svelte-component.test.js
+++ b/packages/astro/test/svelte-component.test.js
@@ -7,7 +7,7 @@ describe('Svelte component', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/svelte-component/',
+ root: './fixtures/svelte-component/',
});
});
diff --git a/packages/astro/test/tailwindcss.test.js b/packages/astro/test/tailwindcss.test.js
index 957b3f1a2..762728310 100644
--- a/packages/astro/test/tailwindcss.test.js
+++ b/packages/astro/test/tailwindcss.test.js
@@ -9,7 +9,7 @@ describe('Tailwind', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/tailwindcss/',
+ root: './fixtures/tailwindcss/',
});
});
@@ -38,7 +38,9 @@ describe('Tailwind', () => {
expect(bundledCSS, 'includes responsive classes').to.match(/\.lg\\:py-3{/);
// tailwind escapes brackets, `font-[900]` compiles to `font-\[900\]`
- expect(bundledCSS, 'supports arbitrary value classes').to.match(/\.font-\\\[900\\\]{font-weight:900}/);
+ expect(bundledCSS, 'supports arbitrary value classes').to.match(
+ /\.font-\\\[900\\\]{font-weight:900}/
+ );
});
it('maintains classes in HTML', async () => {
diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js
index 56c18580b..ab04f9604 100644
--- a/packages/astro/test/test-utils.js
+++ b/packages/astro/test/test-utils.js
@@ -36,7 +36,7 @@ polyfill(globalThis, {
/**
* Load Astro fixture
- * @param {AstroConfig} inlineConfig Astro config partial (note: must specify projectRoot)
+ * @param {AstroConfig} inlineConfig Astro config partial (note: must specify `root`)
* @returns {Promise<Fixture>} The fixture. Has the following properties:
* .config - Returns the final config. Will be automatically passed to the methods below:
*
@@ -55,11 +55,12 @@ polyfill(globalThis, {
* .clean() - Async. Removes the project’s dist folder.
*/
export async function loadFixture(inlineConfig) {
- if (!inlineConfig || !inlineConfig.projectRoot) throw new Error("Must provide { projectRoot: './fixtures/...' }");
+ if (!inlineConfig || !inlineConfig.root)
+ throw new Error("Must provide { root: './fixtures/...' }");
// load config
- let cwd = inlineConfig.projectRoot;
- delete inlineConfig.projectRoot;
+ let cwd = inlineConfig.root;
+ delete inlineConfig.root;
if (typeof cwd === 'string') {
try {
cwd = new URL(cwd.replace(/\/?$/, '/'));
@@ -69,7 +70,15 @@ export async function loadFixture(inlineConfig) {
}
// Load the config.
let config = await loadConfig({ cwd: fileURLToPath(cwd) });
- config = merge(config, { ...inlineConfig, projectRoot: cwd });
+ config = merge(config, { ...inlineConfig, root: cwd });
+
+ // Note: the inline config doesn't run through config validation where these normalizations usually occur
+ if (typeof inlineConfig.site === 'string') {
+ config.site = new URL(inlineConfig.site);
+ }
+ if (inlineConfig.base && !inlineConfig.base.endsWith('/')) {
+ config.base = inlineConfig.base + '/';
+ }
/** @type {import('../src/core/logger/core').LogOptions} */
const logging = {
@@ -81,20 +90,22 @@ export async function loadFixture(inlineConfig) {
build: (opts = {}) => build(config, { mode: 'development', logging, ...opts }),
startDevServer: async (opts = {}) => {
const devResult = await dev(config, { logging, ...opts });
- config.devOptions.port = devResult.address.port; // update port
+ config.server.port = devResult.address.port; // update port
return devResult;
},
config,
- fetch: (url, init) => fetch(`http://${'127.0.0.1'}:${config.devOptions.port}${url.replace(/^\/?/, '/')}`, init),
+ fetch: (url, init) =>
+ fetch(`http://${'127.0.0.1'}:${config.server.port}${url.replace(/^\/?/, '/')}`, init),
preview: async (opts = {}) => {
const previewServer = await preview(config, { logging, ...opts });
return previewServer;
},
- readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.dist), 'utf8'),
- readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.dist)),
- clean: () => fs.promises.rm(config.dist, { maxRetries: 10, recursive: true, force: true }),
+ readFile: (filePath) =>
+ fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.outDir), 'utf8'),
+ readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.outDir)),
+ clean: () => fs.promises.rm(config.outDir, { maxRetries: 10, recursive: true, force: true }),
loadTestAdapterApp: async () => {
- const url = new URL('./server/entry.mjs', config.dist);
+ const url = new URL('./server/entry.mjs', config.outDir);
const { createApp } = await import(url);
return createApp();
},
@@ -112,7 +123,11 @@ function merge(a, b) {
const c = {};
for (const k of allKeys) {
const needsObjectMerge =
- typeof a[k] === 'object' && typeof b[k] === 'object' && (Object.keys(a[k]).length || Object.keys(b[k]).length) && !Array.isArray(a[k]) && !Array.isArray(b[k]);
+ typeof a[k] === 'object' &&
+ typeof b[k] === 'object' &&
+ (Object.keys(a[k]).length || Object.keys(b[k]).length) &&
+ !Array.isArray(a[k]) &&
+ !Array.isArray(b[k]);
if (needsObjectMerge) {
c[k] = merge(a[k] || {}, b[k] || {});
continue;
diff --git a/packages/astro/test/vue-component.test.js b/packages/astro/test/vue-component.test.js
index b15f6a759..e26a3cdbe 100644
--- a/packages/astro/test/vue-component.test.js
+++ b/packages/astro/test/vue-component.test.js
@@ -7,7 +7,7 @@ describe('Vue component', () => {
before(async () => {
fixture = await loadFixture({
- projectRoot: './fixtures/vue-component/',
+ root: './fixtures/vue-component/',
});
});
diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts
index f41f2a87c..ec54d250c 100644
--- a/packages/create-astro/src/index.ts
+++ b/packages/create-astro/src/index.ts
@@ -28,14 +28,20 @@ export function mkdirp(dir: string) {
}
}
-const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
+const { version } = JSON.parse(
+ fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')
+);
const POSTPROCESS_FILES = ['package.json', 'astro.config.mjs', 'CHANGELOG.md']; // some files need processing after copying.
export async function main() {
logger.debug('Verbose logging turned on');
console.log(`\n${bold('Welcome to Astro!')} ${gray(`(create-astro v${version})`)}`);
- console.log(`If you encounter a problem, visit ${cyan('https://github.com/withastro/astro/issues')} to search or file a new issue.\n`);
+ console.log(
+ `If you encounter a problem, visit ${cyan(
+ 'https://github.com/withastro/astro/issues'
+ )} to search or file a new issue.\n`
+ );
let spinner = ora({ color: 'green', text: 'Prepare for liftoff.' });
@@ -74,7 +80,9 @@ export async function main() {
const hash = args.commit ? `#${args.commit}` : '';
- const templateTarget = options.template.includes('/') ? options.template : `withastro/astro/examples/${options.template}#latest`;
+ const templateTarget = options.template.includes('/')
+ ? options.template
+ : `withastro/astro/examples/${options.template}#latest`;
const emitter = degit(`${templateTarget}${hash}`, {
cache: false,
@@ -118,13 +126,25 @@ export async function main() {
// Warning for issue #655
if (err.message === 'zlib: unexpected end of file') {
- console.log(yellow("This seems to be a cache related problem. Remove the folder '~/.degit/github/withastro' to fix this error."));
- console.log(yellow('For more information check out this issue: https://github.com/withastro/astro/issues/655'));
+ console.log(
+ yellow(
+ "This seems to be a cache related problem. Remove the folder '~/.degit/github/withastro' to fix this error."
+ )
+ );
+ console.log(
+ yellow(
+ 'For more information check out this issue: https://github.com/withastro/astro/issues/655'
+ )
+ );
}
// Helpful message when encountering the "could not find commit hash for ..." error
if (err.code === 'MISSING_REF') {
- console.log(yellow("This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com)."));
+ console.log(
+ yellow(
+ "This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com)."
+ )
+ );
console.log(
yellow(
"If you do have 'git' installed, please run this command with the --verbose flag and file a new issue with the command output here: https://github.com/withastro/astro/issues"
@@ -178,8 +198,13 @@ export async function main() {
)
).flat(1);
// merge and sort dependencies
- packageJSON.devDependencies = { ...(packageJSON.devDependencies ?? {}), ...Object.fromEntries(integrationEntries) };
- packageJSON.devDependencies = Object.fromEntries(Object.entries(packageJSON.devDependencies).sort((a, b) => a[0].localeCompare(b[0])));
+ packageJSON.devDependencies = {
+ ...(packageJSON.devDependencies ?? {}),
+ ...Object.fromEntries(integrationEntries),
+ };
+ packageJSON.devDependencies = Object.fromEntries(
+ Object.entries(packageJSON.devDependencies).sort((a, b) => a[0].localeCompare(b[0]))
+ );
await fs.promises.writeFile(fileLoc, JSON.stringify(packageJSON, undefined, 2));
break;
}
@@ -196,7 +221,9 @@ export async function main() {
const component = COUNTER_COMPONENTS[integration.id as keyof typeof COUNTER_COMPONENTS];
const componentName = path.basename(component.filename, path.extname(component.filename));
const absFileLoc = path.resolve(cwd, component.filename);
- importStatements.push(`import ${componentName} from '${component.filename.replace(/^src/, '..')}';`);
+ importStatements.push(
+ `import ${componentName} from '${component.filename.replace(/^src/, '..')}';`
+ );
components.push(`<${componentName} client:visible />`);
await fs.promises.writeFile(absFileLoc, component.content);
})
@@ -225,7 +252,11 @@ export async function main() {
}
console.log(` ${i++}: ${bold(cyan('npm install'))} (or pnpm install, yarn, etc)`);
- console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional step)`);
+ console.log(
+ ` ${i++}: ${bold(
+ cyan('git init && git add -A && git commit -m "Initial commit"')
+ )} (optional step)`
+ );
console.log(` ${i++}: ${bold(cyan('npm run dev'))} (or pnpm, yarn, etc)`);
console.log(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`);
diff --git a/packages/create-astro/src/logger.ts b/packages/create-astro/src/logger.ts
index afde6a2af..65f354632 100644
--- a/packages/create-astro/src/logger.ts
+++ b/packages/create-astro/src/logger.ts
@@ -96,7 +96,12 @@ export const levels: Record<LoggerLevel, number> = {
};
/** Full logging API */
-export function log(opts: LogOptions = {}, level: LoggerLevel, type: string | null, ...args: Array<any>) {
+export function log(
+ opts: LogOptions = {},
+ level: LoggerLevel,
+ type: string | null,
+ ...args: Array<any>
+) {
const logLevel = opts.level ?? defaultLogOptions.level;
const dest = opts.dest ?? defaultLogOptions.dest;
const event: LogMessage = {
diff --git a/packages/create-astro/test/create-astro.test.js b/packages/create-astro/test/create-astro.test.js
index 15e1991f1..86a64e1f5 100644
--- a/packages/create-astro/test/create-astro.test.js
+++ b/packages/create-astro/test/create-astro.test.js
@@ -108,11 +108,17 @@ async function testAll() {
await Promise.all(
TEMPLATES.map(async ({ value: template }) => {
// setup: `npm init astro`
- await execa('../../create-astro.mjs', [template, '--template', template, '--commit', GITHUB_SHA, '--force-overwrite'], {
- cwd: FIXTURES_DIR,
- });
+ await execa(
+ '../../create-astro.mjs',
+ [template, '--template', template, '--commit', GITHUB_SHA, '--force-overwrite'],
+ {
+ cwd: FIXTURES_DIR,
+ }
+ );
// setup: `pnpm install` (note: running multiple `pnpm`s in parallel in CI will conflict)
- await execa('pnpm', ['install', '--no-package-lock', '--silent'], { cwd: path.join(FIXTURES_DIR, template) });
+ await execa('pnpm', ['install', '--no-package-lock', '--silent'], {
+ cwd: path.join(FIXTURES_DIR, template),
+ });
})
);
diff --git a/packages/integrations/deno/CHANGELOG.md b/packages/integrations/deno/CHANGELOG.md
index 31593ed2b..0e7aa5fb6 100644
--- a/packages/integrations/deno/CHANGELOG.md
+++ b/packages/integrations/deno/CHANGELOG.md
@@ -1,5 +1,15 @@
# @astrojs/node
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
+### Patch Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Add a Deno adapter for SSR
+
## 0.0.2-next.0
### Patch Changes
diff --git a/packages/integrations/deno/package.json b/packages/integrations/deno/package.json
index 6fd86ab71..db93d8098 100644
--- a/packages/integrations/deno/package.json
+++ b/packages/integrations/deno/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/deno",
"description": "Deploy your site to a Deno server",
- "version": "0.0.2-next.0",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
diff --git a/packages/integrations/deno/test/fixtures/basics/astro.config.mjs b/packages/integrations/deno/test/fixtures/basics/astro.config.mjs
index 38490926b..e56fe2e98 100644
--- a/packages/integrations/deno/test/fixtures/basics/astro.config.mjs
+++ b/packages/integrations/deno/test/fixtures/basics/astro.config.mjs
@@ -3,5 +3,7 @@ import deno from '@astrojs/deno';
export default defineConfig({
adapter: deno(),
- buildOptions: { experimentalSsr: true }
+ experimental: {
+ ssr: true
+ }
})
diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js
index cab3fe4d9..e9cf1aecf 100644
--- a/packages/integrations/lit/client-shim.js
+++ b/packages/integrations/lit/client-shim.js
@@ -1,9 +1,15 @@
async function polyfill() {
- const { hydrateShadowRoots } = await import('@webcomponents/template-shadowroot/template-shadowroot.js');
+ const { hydrateShadowRoots } = await import(
+ '@webcomponents/template-shadowroot/template-shadowroot.js'
+ );
hydrateShadowRoots(document.body);
}
-const polyfillCheckEl = new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', { includeShadowRoots: true }).querySelector('p');
+const polyfillCheckEl = new DOMParser()
+ .parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
+ includeShadowRoots: true,
+ })
+ .querySelector('p');
if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) {
polyfill();
diff --git a/packages/integrations/lit/client-shim.min.js b/packages/integrations/lit/client-shim.min.js
index 0c6a452d8..f9fe14fdd 100644
--- a/packages/integrations/lit/client-shim.min.js
+++ b/packages/integrations/lit/client-shim.min.js
@@ -8,7 +8,8 @@ var b = (t, n) => {
function s() {
if (d === void 0) {
let t = document.createElement('div');
- (t.innerHTML = '<div><template shadowroot="open"></template></div>'), (d = !!t.firstElementChild.shadowRoot);
+ (t.innerHTML = '<div><template shadowroot="open"></template></div>'),
+ (d = !!t.firstElementChild.shadowRoot);
}
return d;
}
@@ -18,7 +19,9 @@ var p,
c,
f,
u = i(() => {
- (p = (t) => t.parentElement === null), (c = (t) => t.tagName === 'TEMPLATE'), (f = (t) => t.nodeType === Node.ELEMENT_NODE);
+ (p = (t) => t.parentElement === null),
+ (c = (t) => t.tagName === 'TEMPLATE'),
+ (f = (t) => t.nodeType === Node.ELEMENT_NODE);
});
var h,
E = i(() => {
@@ -52,7 +55,8 @@ var h,
(e = r), o !== void 0 && o.parentElement.removeChild(o);
break;
}
- let l = (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling;
+ let l =
+ (n = e.parentElement) === null || n === void 0 ? void 0 : n.nextElementSibling;
if (l != null) {
(e = l), o !== void 0 && o.parentElement.removeChild(o);
break;
@@ -75,5 +79,9 @@ async function g() {
let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v));
t(document.body);
}
-var x = new DOMParser().parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', { includeShadowRoots: !0 }).querySelector('p');
+var x = new DOMParser()
+ .parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', {
+ includeShadowRoots: !0,
+ })
+ .querySelector('p');
(!x || !x.shadowRoot) && g();
diff --git a/packages/integrations/lit/src/index.ts b/packages/integrations/lit/src/index.ts
index bf256eb84..f945f1ca3 100644
--- a/packages/integrations/lit/src/index.ts
+++ b/packages/integrations/lit/src/index.ts
@@ -13,7 +13,12 @@ function getViteConfiguration() {
exclude: ['@astrojs/lit/server.js'],
},
ssr: {
- external: ['lit-element/lit-element.js', '@lit-labs/ssr/lib/install-global-dom-shim.js', '@lit-labs/ssr/lib/render-lit-html.js', '@lit-labs/ssr/lib/lit-element-renderer.js'],
+ external: [
+ 'lit-element/lit-element.js',
+ '@lit-labs/ssr/lib/install-global-dom-shim.js',
+ '@lit-labs/ssr/lib/render-lit-html.js',
+ '@lit-labs/ssr/lib/lit-element-renderer.js',
+ ],
},
};
}
@@ -24,7 +29,10 @@ export default function (): AstroIntegration {
hooks: {
'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => {
// Inject the necessary polyfills on every page (inlined for speed).
- injectScript('head-inline', readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' }));
+ injectScript(
+ 'head-inline',
+ readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' })
+ );
// Inject the hydration code, before a component is hydrated.
injectScript('before-hydration', `import '@astrojs/lit/hydration-support.js';`);
// Add the lit renderer so that Astro can understand lit components.
diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md
index 49efea64e..91d885de1 100644
--- a/packages/integrations/netlify/CHANGELOG.md
+++ b/packages/integrations/netlify/CHANGELOG.md
@@ -1,5 +1,11 @@
# @astrojs/netlify
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
## 0.0.2
### Patch Changes
diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json
index 7fbeac138..80b0565ad 100644
--- a/packages/integrations/netlify/package.json
+++ b/packages/integrations/netlify/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/netlify",
"description": "Deploy your site to Netlify",
- "version": "0.0.2",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts
index 5d54f7db6..e7fb72633 100644
--- a/packages/integrations/netlify/src/index.ts
+++ b/packages/integrations/netlify/src/index.ts
@@ -22,19 +22,19 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
hooks: {
'astro:config:setup': ({ config }) => {
if (dist) {
- config.dist = dist;
+ config.outDir = dist;
} else {
- config.dist = new URL('./netlify/', config.projectRoot);
+ config.outDir = new URL('./netlify/', config.root);
}
},
'astro:config:done': ({ config, setAdapter }) => {
- setAdapter(getAdapter(config.buildOptions.site));
+ setAdapter(getAdapter(new URL(config.base, config.site).toString()));
_config = config;
},
'astro:build:start': async ({ buildConfig }) => {
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
- buildConfig.client = _config.dist;
- buildConfig.server = new URL('./functions/', _config.dist);
+ buildConfig.client = _config.outDir;
+ buildConfig.server = new URL('./functions/', _config.outDir);
},
'astro:build:done': async ({ routes, dir }) => {
const _redirectsURL = new URL('./_redirects', dir);
diff --git a/packages/integrations/partytown/CHANGELOG.md b/packages/integrations/partytown/CHANGELOG.md
index 52c5ed511..db57a46ad 100644
--- a/packages/integrations/partytown/CHANGELOG.md
+++ b/packages/integrations/partytown/CHANGELOG.md
@@ -1,5 +1,11 @@
# @astrojs/partytown
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
## 0.0.2
### Patch Changes
diff --git a/packages/integrations/partytown/package.json b/packages/integrations/partytown/package.json
index 3e9a4d79f..7b3186543 100644
--- a/packages/integrations/partytown/package.json
+++ b/packages/integrations/partytown/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/partytown",
"description": "Astro + Partytown integration",
- "version": "0.0.2",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts
index 479f86b07..ebd133e33 100644
--- a/packages/integrations/partytown/src/index.ts
+++ b/packages/integrations/partytown/src/index.ts
@@ -23,10 +23,19 @@ export default function createPlugin(): AstroIntegration {
config = _config;
},
'astro:server:setup': ({ server }) => {
- server.middlewares.use(sirv(partytownLibDirectory, { mount: '/~partytown', dev: true, etag: true, extensions: [] }));
+ server.middlewares.use(
+ sirv(partytownLibDirectory, {
+ mount: '/~partytown',
+ dev: true,
+ etag: true,
+ extensions: [],
+ })
+ );
},
'astro:build:done': async () => {
- await copyLibFiles(fileURLToPath(new URL('~partytown', config.dist)), { debugDir: false });
+ await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), {
+ debugDir: false,
+ });
},
},
};
diff --git a/packages/integrations/partytown/src/sirv.ts b/packages/integrations/partytown/src/sirv.ts
index 860a715bf..aab0c7d96 100644
--- a/packages/integrations/partytown/src/sirv.ts
+++ b/packages/integrations/partytown/src/sirv.ts
@@ -223,7 +223,8 @@ export default function (dir, opts = {}) {
}
}
- let data = lookup(pathname, extns) || (isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns));
+ let data =
+ lookup(pathname, extns) || (isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns));
if (!data) return next ? next() : isNotFound(req, res);
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
diff --git a/packages/integrations/preact/client.js b/packages/integrations/preact/client.js
index 85c18c76c..5ece5ddb2 100644
--- a/packages/integrations/preact/client.js
+++ b/packages/integrations/preact/client.js
@@ -1,4 +1,8 @@
import { h, render } from 'preact';
import StaticHtml from './static-html.js';
-export default (element) => (Component, props, children) => render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children), element);
+export default (element) => (Component, props, children) =>
+ render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
+ element
+ );
diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json
index 74f2f6edc..3c3d89f9f 100644
--- a/packages/integrations/preact/package.json
+++ b/packages/integrations/preact/package.json
@@ -36,7 +36,7 @@
"devDependencies": {
"astro": "workspace:*",
"astro-scripts": "workspace:*",
- "preact": "^10.6.6"
+ "preact": "^10.7.0"
},
"peerDependencies": {
"preact": "^10.6.5"
diff --git a/packages/integrations/preact/server.js b/packages/integrations/preact/server.js
index 25b1a1530..0729f42e9 100644
--- a/packages/integrations/preact/server.js
+++ b/packages/integrations/preact/server.js
@@ -25,7 +25,9 @@ function check(Component, props, children) {
}
function renderToStaticMarkup(Component, props, children) {
- const html = render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children));
+ const html = render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children)
+ );
return { html };
}
diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts
index c96bf1190..0b0896210 100644
--- a/packages/integrations/preact/src/index.ts
+++ b/packages/integrations/preact/src/index.ts
@@ -21,7 +21,12 @@ function getRenderer() {
function getViteConfiguration() {
return {
optimizeDeps: {
- include: ['@astrojs/preact/client.js', 'preact', 'preact/jsx-runtime', 'preact-render-to-string'],
+ include: [
+ '@astrojs/preact/client.js',
+ 'preact',
+ 'preact/jsx-runtime',
+ 'preact-render-to-string',
+ ],
exclude: ['@astrojs/preact/server.js'],
},
ssr: {
diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md
index 3fc5d0350..8a20e5c9d 100644
--- a/packages/integrations/react/CHANGELOG.md
+++ b/packages/integrations/react/CHANGELOG.md
@@ -1,5 +1,11 @@
# @astrojs/react
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Add support for React v18
+
## 0.0.2
### Patch Changes
diff --git a/packages/integrations/react/client-v17.js b/packages/integrations/react/client-v17.js
index a6bc7d3bc..64284a0b0 100644
--- a/packages/integrations/react/client-v17.js
+++ b/packages/integrations/react/client-v17.js
@@ -7,7 +7,9 @@ export default (element) => (Component, props, children) =>
createElement(
Component,
{ ...props, suppressHydrationWarning: true },
- children != null ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) : children
+ children != null
+ ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
+ : children
),
element
);
diff --git a/packages/integrations/react/client.js b/packages/integrations/react/client.js
index 11d63cfcb..7eba8984c 100644
--- a/packages/integrations/react/client.js
+++ b/packages/integrations/react/client.js
@@ -8,6 +8,8 @@ export default (element) => (Component, props, children) =>
createElement(
Component,
{ ...props, suppressHydrationWarning: true },
- children != null ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) : children
+ children != null
+ ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
+ : children
)
);
diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json
index 1184ce8d3..359ad1c30 100644
--- a/packages/integrations/react/package.json
+++ b/packages/integrations/react/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/react",
"description": "Use React components within Astro",
- "version": "0.0.2",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js
index 1c0c41286..b48d7b6f4 100644
--- a/packages/integrations/react/server-v17.js
+++ b/packages/integrations/react/server-v17.js
@@ -5,7 +5,11 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
- return err.message && (err.message.startsWith("Cannot read property '__H'") || err.message.includes("(reading '__H')"));
+ return (
+ err.message &&
+ (err.message.startsWith("Cannot read property '__H'") ||
+ err.message.includes("(reading '__H')"))
+ );
}
function check(Component, props, children) {
diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js
index e102b57fe..6ae49e7bc 100644
--- a/packages/integrations/react/server.js
+++ b/packages/integrations/react/server.js
@@ -5,7 +5,11 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
- return err.message && (err.message.startsWith("Cannot read property '__H'") || err.message.includes("(reading '__H')"));
+ return (
+ err.message &&
+ (err.message.startsWith("Cannot read property '__H'") ||
+ err.message.includes("(reading '__H')"))
+ );
}
function check(Component, props, children) {
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index 25899a025..a283938c3 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -4,8 +4,12 @@ import { version as ReactVersion } from 'react-dom';
function getRenderer() {
return {
name: '@astrojs/react',
- clientEntrypoint: ReactVersion.startsWith('18.') ? '@astrojs/react/client.js' : '@astrojs/react/client-v17.js',
- serverEntrypoint: ReactVersion.startsWith('18.') ? '@astrojs/react/server.js' : '@astrojs/react/server-v17.js',
+ clientEntrypoint: ReactVersion.startsWith('18.')
+ ? '@astrojs/react/client.js'
+ : '@astrojs/react/client-v17.js',
+ serverEntrypoint: ReactVersion.startsWith('18.')
+ ? '@astrojs/react/server.js'
+ : '@astrojs/react/server-v17.js',
jsxImportSource: 'react',
jsxTransformOptions: async () => {
const {
@@ -34,14 +38,28 @@ function getRenderer() {
function getViteConfiguration() {
return {
optimizeDeps: {
- include: [ReactVersion.startsWith('18.') ? '@astrojs/react/client.js' : '@astrojs/react/client-v17.js', 'react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom'],
- exclude: [ReactVersion.startsWith('18.') ? '@astrojs/react/server.js' : '@astrojs/react/server-v17.js'],
+ include: [
+ ReactVersion.startsWith('18.')
+ ? '@astrojs/react/client.js'
+ : '@astrojs/react/client-v17.js',
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ],
+ exclude: [
+ ReactVersion.startsWith('18.')
+ ? '@astrojs/react/server.js'
+ : '@astrojs/react/server-v17.js',
+ ],
},
resolve: {
dedupe: ['react', 'react-dom'],
},
ssr: {
- external: ReactVersion.startsWith('18.') ? ['react-dom/server', 'react-dom/client'] : ['react-dom/server.js', 'react-dom/client.js'],
+ external: ReactVersion.startsWith('18.')
+ ? ['react-dom/server', 'react-dom/client']
+ : ['react-dom/server.js', 'react-dom/client.js'],
},
};
}
diff --git a/packages/integrations/react/static-html.js b/packages/integrations/react/static-html.js
index 47130d786..ecd76ae9b 100644
--- a/packages/integrations/react/static-html.js
+++ b/packages/integrations/react/static-html.js
@@ -9,7 +9,10 @@ import { createElement as h } from 'react';
*/
const StaticHtml = ({ value }) => {
if (!value) return null;
- return h('astro-fragment', { suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: value } });
+ return h('astro-fragment', {
+ suppressHydrationWarning: true,
+ dangerouslySetInnerHTML: { __html: value },
+ });
};
/**
diff --git a/packages/integrations/sitemap/CHANGELOG.md b/packages/integrations/sitemap/CHANGELOG.md
index 0ad92093d..5cab73553 100644
--- a/packages/integrations/sitemap/CHANGELOG.md
+++ b/packages/integrations/sitemap/CHANGELOG.md
@@ -1,5 +1,17 @@
# @astrojs/sitemap
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
+### Patch Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Add new sitemap configuration options:
+ - `filter`: filter pages to include in your sitemap
+ - `canonicalURL`: override your astro.config `site` with a custom base URL
+
## 0.0.2
### Patch Changes
diff --git a/packages/integrations/sitemap/README.md b/packages/integrations/sitemap/README.md
index 02fa02597..9d84cae19 100644
--- a/packages/integrations/sitemap/README.md
+++ b/packages/integrations/sitemap/README.md
@@ -50,7 +50,7 @@ export default {
## Getting started
-`@astrojs/sitemap` requires a deployment / site URL for generation. Add your site's URL under your `astro.config.*` using the `buildOptions.site` property:
+`@astrojs/sitemap` requires a deployment / site URL for generation. Add your site's URL under your `astro.config.*` using the `site` property:
__astro.config.mjs__
@@ -59,9 +59,7 @@ import sitemap from '@astrojs/sitemap';
export default {
// ...
- buildOptions: {
- site: 'https://stargazers.club',
- },
+ site: 'https://stargazers.club',
integrations: [sitemap()],
}
```
@@ -70,5 +68,48 @@ Now, [build your site for production](https://docs.astro.build/en/reference/cli-
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
+## Configuration
+
+### filter
+
+All pages are included in your sitemap by default. By adding a custom `filter`, you can filter included pages by URL.
+
+__astro.config.mjs__
+
+```js
+import sitemap from '@astrojs/sitemap';
+
+export default {
+ site: 'https://stargazers.club',
+ integrations: [
+ sitemap({
+ filter: (page) => page !== 'https://stargazers.club/secret-vip-lounge'
+ }),
+ ],
+}
+```
+
+The `page` function parameter is the full URL of your rendered page, including your `site` domain. Return `true` to include a page in your sitemap, and `false` to remove it.
+
+### canonicalURL
+
+If present, we use the `site` config option as the base for all sitemap URLs. Use `canonicalURL` to override this.
+
+__astro.config.mjs__
+
+```js
+import sitemap from '@astrojs/sitemap';
+
+export default {
+ site: 'https://stargazers.club',
+ integrations: [
+ sitemap({
+ // https://astronaut.party will be used for all sitemap URLs instead
+ canonicalURL: 'https://astronaut.party',
+ }),
+ ],
+}
+```
+
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
[astro-ui-frameworks]: https://docs.astro.build/en/core-concepts/framework-components/#using-framework-components
diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json
index 857322859..26d517b40 100644
--- a/packages/integrations/sitemap/package.json
+++ b/packages/integrations/sitemap/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/sitemap",
"description": "Generate a sitemap for Astro",
- "version": "0.0.2",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts
index 28bc61396..70441cb8e 100644
--- a/packages/integrations/sitemap/src/index.ts
+++ b/packages/integrations/sitemap/src/index.ts
@@ -2,10 +2,32 @@ import fs from 'node:fs';
import type { AstroConfig, AstroIntegration } from 'astro';
const STATUS_CODE_PAGE_REGEXP = /\/[0-9]{3}\/?$/;
+type SitemapOptions =
+ | {
+ /**
+ * All pages are included in your sitemap by default.
+ * With this config option, you can filter included pages by URL.
+ *
+ * The `page` function parameter is the full URL of your rendered page, including your `site` domain.
+ * Return `true` to include a page in your sitemap, and `false` to remove it.
+ *
+ * ```js
+ * filter: (page) => page !== 'http://example.com/secret-page'
+ * ```
+ */
+ filter?(page: string): string;
+
+ /**
+ * If present, we use the `site` config option as the base for all sitemap URLs
+ * Use `canonicalURL` to override this
+ */
+ canonicalURL?: string;
+ }
+ | undefined;
+
/** Construct sitemap.xml given a set of URLs */
function generateSitemap(pages: string[]) {
// TODO: find way to respect <link rel="canonical"> URLs here
- // TODO: find way to exclude pages from sitemap
const urls = [...pages].filter((url) => !STATUS_CODE_PAGE_REGEXP.test(url));
urls.sort((a, b) => a.localeCompare(b, 'en', { numeric: true })); // sort alphabetically so sitemap is same each time
let sitemap = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`;
@@ -16,7 +38,10 @@ function generateSitemap(pages: string[]) {
return sitemap;
}
-export default function createPlugin(): AstroIntegration {
+export default function createPlugin({
+ filter,
+ canonicalURL,
+}: SitemapOptions = {}): AstroIntegration {
let config: AstroConfig;
return {
name: '@astrojs/sitemap',
@@ -25,11 +50,17 @@ export default function createPlugin(): AstroIntegration {
config = _config;
},
'astro:build:done': async ({ pages, dir }) => {
- const finalSiteUrl = config.buildOptions.site;
+ const finalSiteUrl = canonicalURL || config.site;
if (!finalSiteUrl) {
+ console.warn(
+ 'The Sitemap integration requires either the `site` astro.config option or `canonicalURL` integration option. Skipping.'
+ );
return;
}
- const pageUrls = pages.map((p) => new URL(p.pathname, finalSiteUrl).href);
+ let pageUrls = pages.map((p) => new URL(p.pathname, finalSiteUrl).href);
+ if (filter) {
+ pageUrls = pageUrls.filter((page: string) => filter(page));
+ }
const sitemapContent = generateSitemap(pageUrls);
fs.writeFileSync(new URL('sitemap.xml', dir), sitemapContent);
},
diff --git a/packages/integrations/solid/server.js b/packages/integrations/solid/server.js
index d32d60a64..ccee482ea 100644
--- a/packages/integrations/solid/server.js
+++ b/packages/integrations/solid/server.js
@@ -19,7 +19,9 @@ function renderToStaticMarkup(Component, props, children) {
children: children != null ? ssr(`<astro-fragment>${children}</astro-fragment>`) : children,
})
);
- return { html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>` };
+ return {
+ html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>`,
+ };
}
export default {
diff --git a/packages/integrations/svelte/Wrapper.svelte.ssr.js b/packages/integrations/svelte/Wrapper.svelte.ssr.js
index 9bca437b5..e6a4781a7 100644
--- a/packages/integrations/svelte/Wrapper.svelte.ssr.js
+++ b/packages/integrations/svelte/Wrapper.svelte.ssr.js
@@ -8,7 +8,12 @@ const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
children.default = () => `<astro-fragment>${__astro_children}</astro-fragment>`;
}
- return `${validate_component(Component || missing_component, 'svelte:component').$$render($$result, Object.assign(props), {}, children)}`;
+ return `${validate_component(Component || missing_component, 'svelte:component').$$render(
+ $$result,
+ Object.assign(props),
+ {},
+ children
+ )}`;
});
export default App;
diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json
index abe58baac..37c40d484 100644
--- a/packages/integrations/svelte/package.json
+++ b/packages/integrations/svelte/package.json
@@ -38,7 +38,7 @@
"devDependencies": {
"astro": "workspace:*",
"astro-scripts": "workspace:*",
- "svelte": "^3.46.4"
+ "svelte": "^3.46.6"
},
"peerDependencies": {
"svelte": "^3.46.4"
diff --git a/packages/integrations/svelte/server.js b/packages/integrations/svelte/server.js
index c51b2f4b4..3c989cd5a 100644
--- a/packages/integrations/svelte/server.js
+++ b/packages/integrations/svelte/server.js
@@ -5,7 +5,11 @@ function check(Component) {
}
async function renderToStaticMarkup(Component, props, children) {
- const { html } = SvelteWrapper.render({ __astro_component: Component, __astro_children: children, ...props });
+ const { html } = SvelteWrapper.render({
+ __astro_component: Component,
+ __astro_children: children,
+ ...props,
+ });
return { html };
}
diff --git a/packages/integrations/tailwind/CHANGELOG.md b/packages/integrations/tailwind/CHANGELOG.md
index 0d8ce6c98..3f0a1bb4e 100644
--- a/packages/integrations/tailwind/CHANGELOG.md
+++ b/packages/integrations/tailwind/CHANGELOG.md
@@ -1,5 +1,15 @@
# @astrojs/tailwind
+## 0.1.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
+### Patch Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Adds an option to opt-out of the default base styles for the Tailwind integration
+
## 0.0.2
### Patch Changes
diff --git a/packages/integrations/tailwind/README.md b/packages/integrations/tailwind/README.md
index 1cf730f7a..d0ab7d97d 100644
--- a/packages/integrations/tailwind/README.md
+++ b/packages/integrations/tailwind/README.md
@@ -82,6 +82,19 @@ export default {
}
```
+We will include `@tailwind` directives for each of Tailwind's layers to enable Tailwind styles by default. If you need to customize this behavior, with Tailwind's [`@layer` directive](https://tailwindcss.com/docs/functions-and-directives#layer) for example, opt-out via the `config.applyBaseStyles` integration option:
+
+__astro.config.mjs__
+
+```js
+export default {
+ // ...
+ integrations: [tailwind({
+ config: { applyBaseStyles: false },
+ })],
+}
+```
+
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json
index 6ecdbdbf4..0d9fb62a2 100644
--- a/packages/integrations/tailwind/package.json
+++ b/packages/integrations/tailwind/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/tailwind",
"description": "Tailwind + Astro Integrations",
- "version": "0.0.2",
+ "version": "0.1.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@@ -27,13 +27,13 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
- "tailwindcss": "^3.0.23",
- "autoprefixer": "^10.4.4",
"@proload/core": "^0.2.2",
- "postcss": "^8.4.12"
+ "autoprefixer": "^10.4.4",
+ "postcss": "^8.4.12",
+ "tailwindcss": "^3.0.23"
},
"devDependencies": {
- "@types/tailwindcss": "^3.0.9",
+ "@types/tailwindcss": "^3.0.10",
"astro": "workspace:*",
"astro-scripts": "workspace:*"
},
diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts
index bb5a4ade3..3efd8fde8 100644
--- a/packages/integrations/tailwind/src/index.ts
+++ b/packages/integrations/tailwind/src/index.ts
@@ -17,16 +17,16 @@ function getDefaultTailwindConfig(srcUrl: URL): TailwindConfig {
});
}
-async function getUserConfig(projectRoot: URL, configPath?: string) {
- const resolvedProjectRoot = fileURLToPath(projectRoot);
+async function getUserConfig(root: URL, configPath?: string) {
+ const resolvedRoot = fileURLToPath(root);
let userConfigPath: string | undefined;
if (configPath) {
const configPathWithLeadingSlash = /^\.*\//.test(configPath) ? configPath : `./${configPath}`;
- userConfigPath = fileURLToPath(new URL(configPathWithLeadingSlash, projectRoot));
+ userConfigPath = fileURLToPath(new URL(configPathWithLeadingSlash, root));
}
- return await load('tailwind', { mustExist: false, cwd: resolvedProjectRoot, filePath: userConfigPath });
+ return await load('tailwind', { mustExist: false, cwd: resolvedRoot, filePath: userConfigPath });
}
type TailwindOptions =
@@ -43,36 +43,55 @@ type TailwindOptions =
* @default true
*/
applyAstroPreset?: boolean;
+ /**
+ * Apply Tailwind's base styles
+ * Disabling this is useful when further customization of Tailwind styles
+ * and directives is required. See {@link https://tailwindcss.com/docs/functions-and-directives#tailwind Tailwind's docs}
+ * for more details on directives and customization.
+ * @default: true
+ */
+ applyBaseStyles?: boolean;
};
}
| undefined;
export default function tailwindIntegration(options: TailwindOptions): AstroIntegration {
const applyAstroConfigPreset = options?.config?.applyAstroPreset ?? true;
+ const applyBaseStyles = options?.config?.applyBaseStyles ?? true;
const customConfigPath = options?.config?.path;
return {
name: '@astrojs/tailwind',
hooks: {
'astro:config:setup': async ({ config, injectScript }) => {
// Inject the Tailwind postcss plugin
- const userConfig = await getUserConfig(config.projectRoot, customConfigPath);
+ const userConfig = await getUserConfig(config.root, customConfigPath);
if (customConfigPath && !userConfig?.value) {
- throw new Error(`Could not find a Tailwind config at ${JSON.stringify(customConfigPath)}. Does the file exist?`);
+ throw new Error(
+ `Could not find a Tailwind config at ${JSON.stringify(
+ customConfigPath
+ )}. Does the file exist?`
+ );
}
- const tailwindConfig: TailwindConfig = (userConfig?.value as TailwindConfig) ?? getDefaultTailwindConfig(config.src);
+ const tailwindConfig: TailwindConfig =
+ (userConfig?.value as TailwindConfig) ?? getDefaultTailwindConfig(config.srcDir);
if (applyAstroConfigPreset && userConfig?.value) {
// apply Astro config as a preset to user config
// this avoids merging or applying nested spread operators ourselves
- tailwindConfig.presets = [getDefaultTailwindConfig(config.src), ...(tailwindConfig.presets || [])];
+ tailwindConfig.presets = [
+ getDefaultTailwindConfig(config.srcDir),
+ ...(tailwindConfig.presets || []),
+ ];
}
- config.styleOptions.postcss.plugins.push(tailwindPlugin(tailwindConfig));
- config.styleOptions.postcss.plugins.push(autoprefixerPlugin);
+ config.style.postcss.plugins.push(tailwindPlugin(tailwindConfig));
+ config.style.postcss.plugins.push(autoprefixerPlugin);
- // Inject the Tailwind base import
- injectScript('page-ssr', `import '@astrojs/tailwind/base.css';`);
+ if (applyBaseStyles) {
+ // Inject the Tailwind base import
+ injectScript('page-ssr', `import '@astrojs/tailwind/base.css';`);
+ }
},
},
};
diff --git a/packages/integrations/turbolinks/src/index.ts b/packages/integrations/turbolinks/src/index.ts
index 3299736ba..fbf893f68 100644
--- a/packages/integrations/turbolinks/src/index.ts
+++ b/packages/integrations/turbolinks/src/index.ts
@@ -8,7 +8,10 @@ export default function createPlugin(): AstroIntegration {
// This gets injected into the user's page, so we need to re-export Turbolinks
// from our own package so that package managers like pnpm don't get mad and
// can follow the import correctly.
- injectScript('page', `import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`);
+ injectScript(
+ 'page',
+ `import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`
+ );
},
},
};
diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json
index e25e2d744..dfc40d95f 100644
--- a/packages/integrations/vue/package.json
+++ b/packages/integrations/vue/package.json
@@ -31,7 +31,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
- "@vitejs/plugin-vue": "^2.2.4"
+ "@vitejs/plugin-vue": "^2.3.1"
},
"devDependencies": {
"astro": "workspace:*",
diff --git a/packages/markdown/remark/CHANGELOG.md b/packages/markdown/remark/CHANGELOG.md
index 3a35a1b89..1f03397e8 100644
--- a/packages/markdown/remark/CHANGELOG.md
+++ b/packages/markdown/remark/CHANGELOG.md
@@ -1,5 +1,11 @@
# @astrojs/markdown-remark
+## 0.8.0
+
+### Minor Changes
+
+- [`e425f896`](https://github.com/withastro/astro/commit/e425f896b668d98033ad3b998b50c1f28bc7f6ee) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update config options to resepect [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md)
+
## 0.7.0
### Minor Changes
diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json
index cfee47f76..799be8dbf 100644
--- a/packages/markdown/remark/package.json
+++ b/packages/markdown/remark/package.json
@@ -1,6 +1,6 @@
{
"name": "@astrojs/markdown-remark",
- "version": "0.7.0",
+ "version": "0.8.0",
"type": "module",
"author": "withastro",
"license": "MIT",
diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts
index 3ea436795..c15cf502d 100644
--- a/packages/markdown/remark/src/index.ts
+++ b/packages/markdown/remark/src/index.ts
@@ -1,4 +1,4 @@
-import type { AstroMarkdownOptions, MarkdownRenderingOptions } from './types';
+import type { AstroMarkdownOptions, MarkdownRenderingOptions, ShikiConfig, Plugin } from './types';
import createCollectHeaders from './rehype-collect-headers.js';
import scopedStyles from './remark-scoped-styles.js';
@@ -20,10 +20,13 @@ import rehypeStringify from 'rehype-stringify';
import rehypeRaw from 'rehype-raw';
import matter from 'gray-matter';
-export { AstroMarkdownOptions, MarkdownRenderingOptions };
+export { AstroMarkdownOptions, MarkdownRenderingOptions, ShikiConfig, Plugin };
/** Internal utility for rendering a full markdown file and extracting Frontmatter data */
-export async function renderMarkdownWithFrontmatter(contents: string, opts?: MarkdownRenderingOptions | null) {
+export async function renderMarkdownWithFrontmatter(
+ contents: string,
+ opts?: MarkdownRenderingOptions | null
+) {
const { data: frontmatter, content } = matter(contents);
const value = await renderMarkdown(content, opts);
return { ...value, frontmatter };
@@ -73,7 +76,15 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp
parser.use([remarkPrism(scopedClassName)]);
}
- parser.use([[markdownToHtml as any, { allowDangerousHtml: true, passThrough: ['raw', 'mdxTextExpression', 'mdxJsxTextElement', 'mdxJsxFlowElement'] }]]);
+ parser.use([
+ [
+ markdownToHtml as any,
+ {
+ allowDangerousHtml: true,
+ passThrough: ['raw', 'mdxTextExpression', 'mdxJsxTextElement', 'mdxJsxFlowElement'],
+ },
+ ],
+ ]);
loadedRehypePlugins.forEach(([plugin, opts]) => {
parser.use([[plugin, opts]]);
@@ -88,7 +99,10 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp
let result: string;
try {
- const vfile = await parser.use([rehypeCollectHeaders]).use(rehypeStringify, { allowDangerousHtml: true }).process(content);
+ const vfile = await parser
+ .use([rehypeCollectHeaders])
+ .use(rehypeStringify, { allowDangerousHtml: true })
+ .process(content);
result = vfile.toString();
} catch (err) {
console.error(err);
diff --git a/packages/markdown/remark/src/rehype-islands.ts b/packages/markdown/remark/src/rehype-islands.ts
index 868f9096e..bbd584792 100644
--- a/packages/markdown/remark/src/rehype-islands.ts
+++ b/packages/markdown/remark/src/rehype-islands.ts
@@ -2,7 +2,11 @@ import { SKIP, visit as _visit } from 'unist-util-visit';
// This is a workaround.
// It fixes a compatibility issue between different, incompatible ASTs given by plugins to Unist
-const visit = _visit as (node: any, type: string, callback?: (node: any, index: number, parent: any) => any) => any;
+const visit = _visit as (
+ node: any,
+ type: string,
+ callback?: (node: any, index: number, parent: any) => any
+) => any;
// This fixes some confusing bugs coming from somewhere inside of our Markdown pipeline.
// `unist`/`remark`/`rehype` (not sure) often generate malformed HTML inside of <astro-root>
@@ -18,7 +22,11 @@ export default function rehypeIslands(): any {
// Sometimes comments can be trapped as text, which causes them to be escaped
// This casts them back to real HTML comments
if (parent && child.value.indexOf('<!--') > -1 && index != null) {
- parent.children.splice(index, 1, { ...child, type: 'comment', value: child.value.replace('<!--', '').replace('-->', '').trim() });
+ parent.children.splice(index, 1, {
+ ...child,
+ type: 'comment',
+ value: child.value.replace('<!--', '').replace('-->', '').trim(),
+ });
return [SKIP, index];
}
// For some reason `rehype` likes to inject extra linebreaks,
diff --git a/packages/markdown/remark/src/remark-prism.ts b/packages/markdown/remark/src/remark-prism.ts
index 6d3e4e664..544de1540 100644
--- a/packages/markdown/remark/src/remark-prism.ts
+++ b/packages/markdown/remark/src/remark-prism.ts
@@ -56,7 +56,9 @@ function transformer(className: MaybeString) {
if (className) {
classes.push(className);
}
- node.value = `<pre class="${classes.join(' ')}"><code is:raw class="${classLanguage}">${html}</code></pre>`;
+ node.value = `<pre class="${classes.join(
+ ' '
+ )}"><code is:raw class="${classLanguage}">${html}</code></pre>`;
return node;
};
return visit(tree, 'code', visitor);
diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts
index f34fa26ef..314a0e38e 100644
--- a/packages/markdown/remark/src/remark-shiki.ts
+++ b/packages/markdown/remark/src/remark-shiki.ts
@@ -37,7 +37,10 @@ export interface ShikiConfig {
*/
const highlighterCacheAsync = new Map<string, Promise<shiki.Highlighter>>();
-const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: ShikiConfig, scopedClassName?: string | null) => {
+const remarkShiki = async (
+ { langs = [], theme = 'github-dark', wrap = false }: ShikiConfig,
+ scopedClassName?: string | null
+) => {
const cacheID: string = typeof theme === 'string' ? theme : theme.name;
let highlighterAsync = highlighterCacheAsync.get(cacheID);
if (!highlighterAsync) {
@@ -63,15 +66,24 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
// &lt;span class=&quot;line&quot;
// Replace "shiki" class naming with "astro" and add "is:raw".
- html = html.replace('<pre class="shiki"', `<pre is:raw class="astro-code${scopedClassName ? ' ' + scopedClassName : ''}"`);
+ html = html.replace(
+ '<pre class="shiki"',
+ `<pre is:raw class="astro-code${scopedClassName ? ' ' + scopedClassName : ''}"`
+ );
// Replace "shiki" css variable naming with "astro".
- html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
+ html = html.replace(
+ /style="(background-)?color: var\(--shiki-/g,
+ 'style="$1color: var(--astro-code-'
+ );
// Handle code wrapping
// if wrap=null, do nothing.
if (wrap === false) {
html = html.replace(/style="(.*?)"/, 'style="$1; overflow-x: auto;"');
} else if (wrap === true) {
- html = html.replace(/style="(.*?)"/, 'style="$1; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"');
+ html = html.replace(
+ /style="(.*?)"/,
+ 'style="$1; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"'
+ );
}
// Apply scopedClassName to all nested lines
diff --git a/packages/markdown/remark/src/remark-unwrap.ts b/packages/markdown/remark/src/remark-unwrap.ts
index 6da2a496a..3ce7a72c0 100644
--- a/packages/markdown/remark/src/remark-unwrap.ts
+++ b/packages/markdown/remark/src/remark-unwrap.ts
@@ -2,7 +2,11 @@ import { visit as _visit, SKIP } from 'unist-util-visit';
// This is a workaround.
// It fixes a compatibility issue between different, incompatible ASTs given by plugins to Unist
-const visit = _visit as (node: any, type: string, callback?: (node: any, index: number, parent: any) => any) => any;
+const visit = _visit as (
+ node: any,
+ type: string,
+ callback?: (node: any, index: number, parent: any) => any
+) => any;
// Remove the wrapping paragraph for <astro-root> islands
export default function remarkUnwrap() {
@@ -33,6 +37,8 @@ export default function remarkUnwrap() {
};
function containsAstroRootNode(node: any) {
- return node.children.map((child: any) => astroRootNodes.has(child)).reduce((all: boolean, v: boolean) => (all ? all : v), false);
+ return node.children
+ .map((child: any) => astroRootNodes.has(child))
+ .reduce((all: boolean, v: boolean) => (all ? all : v), false);
}
}
diff --git a/packages/markdown/remark/src/types.ts b/packages/markdown/remark/src/types.ts
index eb0eb5d3e..43e8331b4 100644
--- a/packages/markdown/remark/src/types.ts
+++ b/packages/markdown/remark/src/types.ts
@@ -1,5 +1,6 @@
import type * as unified from 'unified';
import type { ShikiConfig } from './remark-shiki';
+export { ShikiConfig };
export type Plugin = string | [string, any] | unified.Plugin | [unified.Plugin, any];
diff --git a/packages/renderers/renderer-lit/client-shim.js b/packages/renderers/renderer-lit/client-shim.js
index cab3fe4d9..e9cf1aecf 100644
--- a/packages/renderers/renderer-lit/client-shim.js
+++ b/packages/renderers/renderer-lit/client-shim.js
@@ -1,9 +1,15 @@
async function polyfill() {
- const { hydrateShadowRoots } = await import('@webcomponents/template-shadowroot/template-shadowroot.js');
+ const { hydrateShadowRoots } = await import(
+ '@webcomponents/template-shadowroot/template-shadowroot.js'
+ );
hydrateShadowRoots(document.body);
}
-const polyfillCheckEl = new DOMParser().parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', { includeShadowRoots: true }).querySelector('p');
+const polyfillCheckEl = new DOMParser()
+ .parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
+ includeShadowRoots: true,
+ })
+ .querySelector('p');
if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) {
polyfill();
diff --git a/packages/renderers/renderer-lit/index.js b/packages/renderers/renderer-lit/index.js
index e6abec137..b051bc3a5 100644
--- a/packages/renderers/renderer-lit/index.js
+++ b/packages/renderers/renderer-lit/index.js
@@ -3,7 +3,9 @@
const NODE_VERSION = parseFloat(process.versions.node);
if (NODE_VERSION < 13.9) {
- throw new Error(`Package @lit-labs/ssr requires Node version v13.9 or higher. Please update Node to use @astrojs/renderer-lit`);
+ throw new Error(
+ `Package @lit-labs/ssr requires Node version v13.9 or higher. Please update Node to use @astrojs/renderer-lit`
+ );
}
export default {
diff --git a/packages/renderers/renderer-preact/client.js b/packages/renderers/renderer-preact/client.js
index 85c18c76c..5ece5ddb2 100644
--- a/packages/renderers/renderer-preact/client.js
+++ b/packages/renderers/renderer-preact/client.js
@@ -1,4 +1,8 @@
import { h, render } from 'preact';
import StaticHtml from './static-html.js';
-export default (element) => (Component, props, children) => render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children), element);
+export default (element) => (Component, props, children) =>
+ render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children),
+ element
+ );
diff --git a/packages/renderers/renderer-preact/compat/index.js b/packages/renderers/renderer-preact/compat/index.js
index 3f993ec2f..a5580f04d 100644
--- a/packages/renderers/renderer-preact/compat/index.js
+++ b/packages/renderers/renderer-preact/compat/index.js
@@ -21,7 +21,12 @@ export default {
dedupe: ['react', 'react-dom'],
},
optimizeDeps: {
- include: ['@astrojs/renderer-preact/client.js', 'preact/compat', 'preact/compat/jsx-runtime', 'preact-render-to-string'],
+ include: [
+ '@astrojs/renderer-preact/client.js',
+ 'preact/compat',
+ 'preact/compat/jsx-runtime',
+ 'preact-render-to-string',
+ ],
},
ssr: {
external: ['preact-render-to-string'],
diff --git a/packages/renderers/renderer-preact/index.js b/packages/renderers/renderer-preact/index.js
index 59e900ebe..fe0a24528 100644
--- a/packages/renderers/renderer-preact/index.js
+++ b/packages/renderers/renderer-preact/index.js
@@ -14,7 +14,12 @@ export default {
viteConfig() {
return {
optimizeDeps: {
- include: ['@astrojs/renderer-preact/client.js', 'preact', 'preact/jsx-runtime', 'preact-render-to-string'],
+ include: [
+ '@astrojs/renderer-preact/client.js',
+ 'preact',
+ 'preact/jsx-runtime',
+ 'preact-render-to-string',
+ ],
exclude: ['@astrojs/renderer-preact/server.js'],
},
ssr: {
diff --git a/packages/renderers/renderer-preact/package.json b/packages/renderers/renderer-preact/package.json
index 2fabb00a7..9174628e8 100644
--- a/packages/renderers/renderer-preact/package.json
+++ b/packages/renderers/renderer-preact/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.17.3",
- "preact": "^10.6.6",
+ "preact": "^10.7.0",
"preact-render-to-string": "^5.1.20"
},
"engines": {
diff --git a/packages/renderers/renderer-preact/server.js b/packages/renderers/renderer-preact/server.js
index 25b1a1530..0729f42e9 100644
--- a/packages/renderers/renderer-preact/server.js
+++ b/packages/renderers/renderer-preact/server.js
@@ -25,7 +25,9 @@ function check(Component, props, children) {
}
function renderToStaticMarkup(Component, props, children) {
- const html = render(h(Component, props, children != null ? h(StaticHtml, { value: children }) : children));
+ const html = render(
+ h(Component, props, children != null ? h(StaticHtml, { value: children }) : children)
+ );
return { html };
}
diff --git a/packages/renderers/renderer-react/client.js b/packages/renderers/renderer-react/client.js
index a6bc7d3bc..64284a0b0 100644
--- a/packages/renderers/renderer-react/client.js
+++ b/packages/renderers/renderer-react/client.js
@@ -7,7 +7,9 @@ export default (element) => (Component, props, children) =>
createElement(
Component,
{ ...props, suppressHydrationWarning: true },
- children != null ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) : children
+ children != null
+ ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true })
+ : children
),
element
);
diff --git a/packages/renderers/renderer-react/index.js b/packages/renderers/renderer-react/index.js
index 6dd5106dc..698f2a13c 100644
--- a/packages/renderers/renderer-react/index.js
+++ b/packages/renderers/renderer-react/index.js
@@ -22,7 +22,13 @@ export default {
viteConfig() {
return {
optimizeDeps: {
- include: ['@astrojs/renderer-react/client.js', 'react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom'],
+ include: [
+ '@astrojs/renderer-react/client.js',
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ],
exclude: ['@astrojs/renderer-react/server.js'],
},
resolve: {
diff --git a/packages/renderers/renderer-react/server.js b/packages/renderers/renderer-react/server.js
index 1c0c41286..b48d7b6f4 100644
--- a/packages/renderers/renderer-react/server.js
+++ b/packages/renderers/renderer-react/server.js
@@ -5,7 +5,11 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
- return err.message && (err.message.startsWith("Cannot read property '__H'") || err.message.includes("(reading '__H')"));
+ return (
+ err.message &&
+ (err.message.startsWith("Cannot read property '__H'") ||
+ err.message.includes("(reading '__H')"))
+ );
}
function check(Component, props, children) {
diff --git a/packages/renderers/renderer-react/static-html.js b/packages/renderers/renderer-react/static-html.js
index 47130d786..ecd76ae9b 100644
--- a/packages/renderers/renderer-react/static-html.js
+++ b/packages/renderers/renderer-react/static-html.js
@@ -9,7 +9,10 @@ import { createElement as h } from 'react';
*/
const StaticHtml = ({ value }) => {
if (!value) return null;
- return h('astro-fragment', { suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: value } });
+ return h('astro-fragment', {
+ suppressHydrationWarning: true,
+ dangerouslySetInnerHTML: { __html: value },
+ });
};
/**
diff --git a/packages/renderers/renderer-solid/index.js b/packages/renderers/renderer-solid/index.js
index b0b9aaab5..42715ffe6 100644
--- a/packages/renderers/renderer-solid/index.js
+++ b/packages/renderers/renderer-solid/index.js
@@ -18,7 +18,13 @@ export default {
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
const replaceDev = options.mode === 'development' || options.command === 'serve';
- const nestedDeps = ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'];
+ const nestedDeps = [
+ 'solid-js',
+ 'solid-js/web',
+ 'solid-js/store',
+ 'solid-js/html',
+ 'solid-js/h',
+ ];
return {
/**
diff --git a/packages/renderers/renderer-solid/server.js b/packages/renderers/renderer-solid/server.js
index d32d60a64..ccee482ea 100644
--- a/packages/renderers/renderer-solid/server.js
+++ b/packages/renderers/renderer-solid/server.js
@@ -19,7 +19,9 @@ function renderToStaticMarkup(Component, props, children) {
children: children != null ? ssr(`<astro-fragment>${children}</astro-fragment>`) : children,
})
);
- return { html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>` };
+ return {
+ html: html + `<script>window._$HY||(_$HY={events:[],completed:new WeakSet,r:{}})</script>`,
+ };
}
export default {
diff --git a/packages/renderers/renderer-svelte/Wrapper.svelte.ssr.js b/packages/renderers/renderer-svelte/Wrapper.svelte.ssr.js
index 9bca437b5..e6a4781a7 100644
--- a/packages/renderers/renderer-svelte/Wrapper.svelte.ssr.js
+++ b/packages/renderers/renderer-svelte/Wrapper.svelte.ssr.js
@@ -8,7 +8,12 @@ const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
children.default = () => `<astro-fragment>${__astro_children}</astro-fragment>`;
}
- return `${validate_component(Component || missing_component, 'svelte:component').$$render($$result, Object.assign(props), {}, children)}`;
+ return `${validate_component(Component || missing_component, 'svelte:component').$$render(
+ $$result,
+ Object.assign(props),
+ {},
+ children
+ )}`;
});
export default App;
diff --git a/packages/renderers/renderer-svelte/package.json b/packages/renderers/renderer-svelte/package.json
index cbb782c53..8da05e9f8 100644
--- a/packages/renderers/renderer-svelte/package.json
+++ b/packages/renderers/renderer-svelte/package.json
@@ -21,9 +21,9 @@
},
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.40",
- "svelte": "^3.46.4",
+ "svelte": "^3.46.6",
"svelte-preprocess": "^4.10.4",
- "vite": "^2.8.6"
+ "vite": "^2.9.1"
},
"engines": {
"node": "^14.15.0 || >=16.0.0"
diff --git a/packages/renderers/renderer-svelte/server.js b/packages/renderers/renderer-svelte/server.js
index c51b2f4b4..3c989cd5a 100644
--- a/packages/renderers/renderer-svelte/server.js
+++ b/packages/renderers/renderer-svelte/server.js
@@ -5,7 +5,11 @@ function check(Component) {
}
async function renderToStaticMarkup(Component, props, children) {
- const { html } = SvelteWrapper.render({ __astro_component: Component, __astro_children: children, ...props });
+ const { html } = SvelteWrapper.render({
+ __astro_component: Component,
+ __astro_children: children,
+ ...props,
+ });
return { html };
}
diff --git a/packages/renderers/renderer-vue/package.json b/packages/renderers/renderer-vue/package.json
index 9cfc5c727..84eb4b522 100644
--- a/packages/renderers/renderer-vue/package.json
+++ b/packages/renderers/renderer-vue/package.json
@@ -20,8 +20,8 @@
"./package.json": "./package.json"
},
"dependencies": {
- "@vitejs/plugin-vue": "^2.2.4",
- "vite": "^2.8.6",
+ "@vitejs/plugin-vue": "^2.3.1",
+ "vite": "^2.9.1",
"vue": "^3.2.31"
},
"engines": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b99a7f117..4bffb8598 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -16,7 +16,7 @@ importers:
eslint-config-prettier: ^8.5.0
eslint-plugin-prettier: ^4.0.0
execa: ^6.1.0
- prettier: ^2.6.1
+ prettier: ^2.6.2
pretty-bytes: ^6.0.0
tiny-glob: ^0.2.9
turbo: ^1.1.10
@@ -33,9 +33,9 @@ importers:
esbuild: 0.14.25
eslint: 8.12.0
eslint-config-prettier: 8.5.0_eslint@8.12.0
- eslint-plugin-prettier: 4.0.0_b253a92c95b42c3296c682f11cccb3bd
+ eslint-plugin-prettier: 4.0.0_f2c91d0f54113167d2bd9214a5ab5a36
execa: 6.1.0
- prettier: 2.6.1
+ prettier: 2.6.2
pretty-bytes: 6.0.0
tiny-glob: 0.2.9
turbo: 1.1.10
@@ -44,10 +44,10 @@ importers:
examples/blog:
specifiers:
'@astrojs/preact': ^0.0.2
- astro: ^0.25.4
- preact: ^10.6.6
+ astro: ^0.26.0
+ preact: ^10.7.0
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
devDependencies:
'@astrojs/preact': link:../../packages/integrations/preact
astro: link:../../packages/astro
@@ -55,26 +55,26 @@ importers:
examples/blog-multiple-authors:
specifiers:
'@astrojs/preact': ^0.0.2
- astro: ^0.25.4
- preact: ^10.6.6
- sass: ^1.49.9
+ astro: ^0.26.0
+ preact: ^10.7.0
+ sass: ^1.49.11
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
devDependencies:
'@astrojs/preact': link:../../packages/integrations/preact
astro: link:../../packages/astro
- sass: 1.49.9
+ sass: 1.49.11
examples/component:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
examples/component/demo:
specifiers:
'@example/my-component': workspace:*
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
'@example/my-component': link:../packages/my-component
astro: link:../../../packages/astro
@@ -86,12 +86,12 @@ importers:
specifiers:
'@algolia/client-search': ^4.13.0
'@astrojs/preact': ^0.0.2
- '@astrojs/react': ^0.0.2
+ '@astrojs/react': ^0.1.0
'@docsearch/css': ^3.0.0
'@docsearch/react': ^3.0.0
'@types/react': ^17.0.43
- astro: ^0.25.4
- preact: ^10.6.6
+ astro: ^0.26.0
+ preact: ^10.7.0
react: ^18.0.0
react-dom: ^18.0.0
dependencies:
@@ -99,7 +99,7 @@ importers:
'@docsearch/css': 3.0.0
'@docsearch/react': 3.0.0_9e0989ed96c3582fc46f3bba1f5ac769
'@types/react': 17.0.43
- preact: 10.6.6
+ preact: 10.7.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
devDependencies:
@@ -109,13 +109,13 @@ importers:
examples/env-vars:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
examples/framework-alpine:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
@@ -123,7 +123,7 @@ importers:
specifiers:
'@astrojs/lit': ^0.0.2
'@webcomponents/template-shadowroot': ^0.1.0
- astro: ^0.25.4
+ astro: ^0.26.0
lit: ^2.2.1
dependencies:
'@webcomponents/template-shadowroot': 0.1.0
@@ -136,27 +136,27 @@ importers:
specifiers:
'@astrojs/lit': ^0.0.2
'@astrojs/preact': ^0.0.2
- '@astrojs/react': ^0.0.2
+ '@astrojs/react': ^0.1.0
'@astrojs/solid-js': ^0.0.3
'@astrojs/svelte': ^0.0.2
'@astrojs/vue': ^0.0.2
'@webcomponents/template-shadowroot': ^0.1.0
- astro: ^0.25.4
+ astro: ^0.26.0
lit: ^2.2.1
- preact: ^10.6.6
+ preact: ^10.7.0
react: ^18.0.0
react-dom: ^18.0.0
solid-js: ^1.3.13
- svelte: ^3.46.4
+ svelte: ^3.46.6
vue: ^3.2.31
dependencies:
'@webcomponents/template-shadowroot': 0.1.0
lit: 2.2.1
- preact: 10.6.6
+ preact: 10.7.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
solid-js: 1.3.13
- svelte: 3.46.4
+ svelte: 3.46.6
vue: 3.2.31
devDependencies:
'@astrojs/lit': link:../../packages/integrations/lit
@@ -170,18 +170,18 @@ importers:
examples/framework-preact:
specifiers:
'@astrojs/preact': ^0.0.2
- astro: ^0.25.4
- preact: ^10.6.6
+ astro: ^0.26.0
+ preact: ^10.7.0
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
devDependencies:
'@astrojs/preact': link:../../packages/integrations/preact
astro: link:../../packages/astro
examples/framework-react:
specifiers:
- '@astrojs/react': ^0.0.2
- astro: ^0.25.4
+ '@astrojs/react': ^0.1.0
+ astro: ^0.26.0
react: ^18.0.0
react-dom: ^18.0.0
dependencies:
@@ -194,7 +194,7 @@ importers:
examples/framework-solid:
specifiers:
'@astrojs/solid-js': ^0.0.3
- astro: ^0.25.4
+ astro: ^0.26.0
solid-js: ^1.3.13
dependencies:
solid-js: 1.3.13
@@ -205,10 +205,10 @@ importers:
examples/framework-svelte:
specifiers:
'@astrojs/svelte': ^0.0.2
- astro: ^0.25.4
- svelte: ^3.46.4
+ astro: ^0.26.0
+ svelte: ^3.46.6
dependencies:
- svelte: 3.46.4
+ svelte: 3.46.6
devDependencies:
'@astrojs/svelte': link:../../packages/integrations/svelte
astro: link:../../packages/astro
@@ -216,7 +216,7 @@ importers:
examples/framework-vue:
specifiers:
'@astrojs/vue': ^0.0.2
- astro: ^0.25.4
+ astro: ^0.26.0
vue: ^3.2.31
dependencies:
vue: 3.2.31
@@ -227,28 +227,28 @@ importers:
examples/integrations-playground:
specifiers:
'@astrojs/lit': ^0.0.2
- '@astrojs/partytown': ^0.0.2
- '@astrojs/react': ^0.0.2
- '@astrojs/sitemap': ^0.0.2
- '@astrojs/tailwind': ^0.0.2
+ '@astrojs/partytown': ^0.1.0
+ '@astrojs/react': ^0.1.0
+ '@astrojs/sitemap': ^0.1.0
+ '@astrojs/tailwind': ^0.1.0
'@astrojs/turbolinks': ^0.0.2
'@webcomponents/template-shadowroot': ^0.1.0
- astro: ^0.25.4
+ astro: ^0.26.0
lit: ^2.2.1
- preact: ^10.6.6
+ preact: ^10.7.0
react: ^18.0.0
react-dom: ^18.0.0
solid-js: ^1.3.13
- svelte: ^3.46.4
+ svelte: ^3.46.6
vue: ^3.2.31
dependencies:
'@webcomponents/template-shadowroot': 0.1.0
lit: 2.2.1
- preact: 10.6.6
+ preact: 10.7.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
solid-js: 1.3.13
- svelte: 3.46.4
+ svelte: 3.46.6
vue: 3.2.31
devDependencies:
'@astrojs/lit': link:../../packages/integrations/lit
@@ -261,89 +261,89 @@ importers:
examples/minimal:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
examples/non-html-pages:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
examples/portfolio:
specifiers:
'@astrojs/preact': ^0.0.2
- astro: ^0.25.4
- preact: ^10.6.6
- sass: ^1.49.9
+ astro: ^0.26.0
+ preact: ^10.7.0
+ sass: ^1.49.11
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
devDependencies:
'@astrojs/preact': link:../../packages/integrations/preact
astro: link:../../packages/astro
- sass: 1.49.9
+ sass: 1.49.11
examples/ssr:
specifiers:
'@astrojs/node': ^0.0.2
'@astrojs/svelte': ^0.0.2
- astro: ^0.25.4
- concurrently: ^7.0.0
+ astro: ^0.26.0
+ concurrently: ^7.1.0
lightcookie: ^1.0.25
- svelte: ^3.46.4
+ svelte: ^3.46.6
unocss: ^0.15.6
vite-imagetools: ^4.0.3
dependencies:
- svelte: 3.46.4
+ svelte: 3.46.6
devDependencies:
'@astrojs/node': link:../../packages/integrations/node
'@astrojs/svelte': link:../../packages/integrations/svelte
astro: link:../../packages/astro
- concurrently: 7.0.0
+ concurrently: 7.1.0
lightcookie: 1.0.25
unocss: 0.15.6
vite-imagetools: 4.0.3
examples/starter:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
devDependencies:
astro: link:../../packages/astro
examples/subpath:
specifiers:
- '@astrojs/react': ^0.0.2
- astro: ^0.25.4
+ '@astrojs/react': ^0.1.0
+ astro: ^0.26.0
react: ^18.0.0
react-dom: ^18.0.0
- sass: ^1.49.9
+ sass: ^1.49.11
dependencies:
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
devDependencies:
'@astrojs/react': link:../../packages/integrations/react
astro: link:../../packages/astro
- sass: 1.49.9
+ sass: 1.49.11
examples/with-markdown:
specifiers:
- '@astrojs/markdown-remark': ^0.7.0
+ '@astrojs/markdown-remark': ^0.8.0
'@astrojs/preact': ^0.0.2
- '@astrojs/react': ^0.0.2
+ '@astrojs/react': ^0.1.0
'@astrojs/svelte': ^0.0.2
'@astrojs/vue': ^0.0.2
- astro: ^0.25.4
- preact: ^10.6.6
+ astro: ^0.26.0
+ preact: ^10.7.0
react: ^18.0.0
react-dom: ^18.0.0
- svelte: ^3.46.4
+ svelte: ^3.46.6
vue: ^3.2.31
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
- svelte: 3.46.4
+ svelte: 3.46.6
vue: 3.2.31
devDependencies:
'@astrojs/markdown-remark': link:../../packages/markdown/remark
@@ -355,8 +355,8 @@ importers:
examples/with-markdown-plugins:
specifiers:
- '@astrojs/markdown-remark': ^0.7.0
- astro: ^0.25.4
+ '@astrojs/markdown-remark': ^0.8.0
+ astro: ^0.26.0
hast-util-select: 5.0.1
rehype-autolink-headings: ^6.1.1
rehype-slug: ^5.0.1
@@ -373,8 +373,8 @@ importers:
examples/with-markdown-shiki:
specifiers:
- '@astrojs/markdown-remark': ^0.7.0
- astro: ^0.25.4
+ '@astrojs/markdown-remark': ^0.8.0
+ astro: ^0.26.0
devDependencies:
'@astrojs/markdown-remark': link:../../packages/markdown/remark
astro: link:../../packages/astro
@@ -382,26 +382,26 @@ importers:
examples/with-nanostores:
specifiers:
'@astrojs/preact': ^0.0.2
- '@astrojs/react': ^0.0.2
+ '@astrojs/react': ^0.1.0
'@astrojs/solid-js': ^0.0.3
'@astrojs/svelte': ^0.0.2
'@astrojs/vue': ^0.0.2
'@nanostores/preact': ^0.1.3
'@nanostores/react': ^0.1.5
'@nanostores/vue': ^0.4.1
- astro: ^0.25.4
+ astro: ^0.26.0
nanostores: ^0.5.12
- preact: ^10.6.6
+ preact: ^10.7.0
react: ^18.0.0
react-dom: ^18.0.0
solid-nanostores: 0.0.6
vue: ^3.2.31
dependencies:
- '@nanostores/preact': 0.1.3_nanostores@0.5.12+preact@10.6.6
+ '@nanostores/preact': 0.1.3_nanostores@0.5.12+preact@10.7.0
'@nanostores/react': 0.1.5_33de46f26c75888291546388c72611d1
'@nanostores/vue': 0.4.1_nanostores@0.5.12+vue@3.2.31
nanostores: 0.5.12
- preact: 10.6.6
+ preact: 10.7.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
solid-nanostores: 0.0.6
@@ -416,8 +416,8 @@ importers:
examples/with-tailwindcss:
specifiers:
- '@astrojs/tailwind': ^0.0.2
- astro: ^0.25.4
+ '@astrojs/tailwind': ^0.1.0
+ astro: ^0.26.0
autoprefixer: ^10.4.4
canvas-confetti: ^1.5.1
postcss: ^8.4.12
@@ -432,7 +432,7 @@ importers:
examples/with-vite-plugin-pwa:
specifiers:
- astro: ^0.25.4
+ astro: ^0.26.0
vite-plugin-pwa: 0.11.11
workbox-window: ^6.5.2
devDependencies:
@@ -442,9 +442,9 @@ importers:
packages/astro:
specifiers:
- '@astrojs/compiler': ^0.13.1
- '@astrojs/language-server': ^0.13.2
- '@astrojs/markdown-remark': ^0.7.0
+ '@astrojs/compiler': ^0.14.1
+ '@astrojs/language-server': ^0.13.3
+ '@astrojs/markdown-remark': ^0.8.0
'@astrojs/prism': 0.4.1
'@astrojs/webapi': ^0.11.0
'@babel/core': ^7.17.8
@@ -511,7 +511,7 @@ importers:
rehype-slug: ^5.0.1
resolve: ^1.22.0
rollup: ^2.70.1
- sass: ^1.49.9
+ sass: ^1.49.11
semver: ^7.3.5
serialize-javascript: ^6.0.0
shiki: ^0.10.1
@@ -524,12 +524,12 @@ importers:
strip-ansi: ^7.0.1
supports-esm: ^1.0.0
tsconfig-resolver: ^3.0.1
- vite: ^2.8.6
+ vite: ^2.9.1
yargs-parser: ^21.0.1
zod: ^3.14.3
dependencies:
- '@astrojs/compiler': 0.13.1
- '@astrojs/language-server': 0.13.2
+ '@astrojs/compiler': 0.14.1
+ '@astrojs/language-server': 0.13.3
'@astrojs/markdown-remark': link:../markdown/remark
'@astrojs/prism': link:../astro-prism
'@astrojs/webapi': link:../webapi
@@ -585,7 +585,7 @@ importers:
strip-ansi: 7.0.1
supports-esm: 1.0.0
tsconfig-resolver: 3.0.1
- vite: 2.8.6_sass@1.49.9
+ vite: 2.9.1_sass@1.49.11
yargs-parser: 21.0.1
zod: 3.14.3
devDependencies:
@@ -613,7 +613,7 @@ importers:
chai: 4.3.6
cheerio: 1.0.0-rc.10
mocha: 9.2.2
- sass: 1.49.9
+ sass: 1.49.11
packages/astro-prism:
specifiers:
@@ -1037,10 +1037,10 @@ importers:
packages/astro/test/fixtures/sass:
specifiers:
astro: workspace:*
- sass: ^1.49.9
+ sass: ^1.49.11
dependencies:
astro: link:../../..
- sass: 1.49.9
+ sass: 1.49.11
packages/astro/test/fixtures/slots-preact:
specifiers:
@@ -1269,15 +1269,15 @@ importers:
'@babel/plugin-transform-react-jsx': ^7.17.3
astro: workspace:*
astro-scripts: workspace:*
- preact: ^10.6.6
+ preact: ^10.7.0
preact-render-to-string: ^5.1.20
dependencies:
'@babel/plugin-transform-react-jsx': 7.17.3
- preact-render-to-string: 5.1.20_preact@10.6.6
+ preact-render-to-string: 5.1.20_preact@10.7.0
devDependencies:
astro: link:../../astro
astro-scripts: link:../../../scripts
- preact: 10.6.6
+ preact: 10.7.0
packages/integrations/react:
specifiers:
@@ -1328,21 +1328,21 @@ importers:
astro: workspace:*
astro-scripts: workspace:*
postcss-load-config: ^3.1.4
- svelte: ^3.46.4
+ svelte: ^3.46.6
svelte-preprocess: ^4.10.4
dependencies:
- '@sveltejs/vite-plugin-svelte': 1.0.0-next.40_svelte@3.46.4
+ '@sveltejs/vite-plugin-svelte': 1.0.0-next.40_svelte@3.46.6
postcss-load-config: 3.1.4
- svelte-preprocess: 4.10.4_ec4868a778d68da3f0d21a10f4ea83cd
+ svelte-preprocess: 4.10.4_4fb28cead04100f31b0e8b0196137d75
devDependencies:
astro: link:../../astro
astro-scripts: link:../../../scripts
- svelte: 3.46.4
+ svelte: 3.46.6
packages/integrations/tailwind:
specifiers:
'@proload/core': ^0.2.2
- '@types/tailwindcss': ^3.0.9
+ '@types/tailwindcss': ^3.0.10
astro: workspace:*
astro-scripts: workspace:*
autoprefixer: ^10.4.4
@@ -1354,7 +1354,7 @@ importers:
postcss: 8.4.12
tailwindcss: 3.0.23_autoprefixer@10.4.4
devDependencies:
- '@types/tailwindcss': 3.0.9
+ '@types/tailwindcss': 3.0.10
astro: link:../../astro
astro-scripts: link:../../../scripts
@@ -1384,12 +1384,12 @@ importers:
packages/integrations/vue:
specifiers:
- '@vitejs/plugin-vue': ^2.2.4
+ '@vitejs/plugin-vue': ^2.3.1
astro: workspace:*
astro-scripts: workspace:*
vue: ^3.2.31
dependencies:
- '@vitejs/plugin-vue': 2.2.4_vue@3.2.31
+ '@vitejs/plugin-vue': 2.3.1_vue@3.2.31
devDependencies:
astro: link:../../astro
astro-scripts: link:../../../scripts
@@ -1461,12 +1461,12 @@ importers:
packages/renderers/renderer-preact:
specifiers:
'@babel/plugin-transform-react-jsx': ^7.17.3
- preact: ^10.6.6
+ preact: ^10.7.0
preact-render-to-string: ^5.1.20
dependencies:
'@babel/plugin-transform-react-jsx': 7.17.3
- preact: 10.6.6
- preact-render-to-string: 5.1.20_preact@10.6.6
+ preact: 10.7.0
+ preact-render-to-string: 5.1.20_preact@10.7.0
packages/renderers/renderer-react:
specifiers:
@@ -1489,23 +1489,23 @@ importers:
packages/renderers/renderer-svelte:
specifiers:
'@sveltejs/vite-plugin-svelte': ^1.0.0-next.40
- svelte: ^3.46.4
+ svelte: ^3.46.6
svelte-preprocess: ^4.10.4
- vite: ^2.8.6
+ vite: ^2.9.1
dependencies:
- '@sveltejs/vite-plugin-svelte': 1.0.0-next.40_svelte@3.46.4+vite@2.8.6
- svelte: 3.46.4
- svelte-preprocess: 4.10.4_svelte@3.46.4+typescript@4.6.3
- vite: 2.8.6
+ '@sveltejs/vite-plugin-svelte': 1.0.0-next.40_svelte@3.46.6+vite@2.9.1
+ svelte: 3.46.6
+ svelte-preprocess: 4.10.4_svelte@3.46.6+typescript@4.6.3
+ vite: 2.9.1
packages/renderers/renderer-vue:
specifiers:
- '@vitejs/plugin-vue': ^2.2.4
- vite: ^2.8.6
+ '@vitejs/plugin-vue': ^2.3.1
+ vite: ^2.9.1
vue: ^3.2.31
dependencies:
- '@vitejs/plugin-vue': 2.2.4_vite@2.8.6+vue@3.2.31
- vite: 2.8.6
+ '@vitejs/plugin-vue': 2.3.1_vite@2.9.1+vue@3.2.31
+ vite: 2.9.1
vue: 3.2.31
packages/webapi:
@@ -1562,7 +1562,7 @@ importers:
esbuild: 0.14.25
globby: ^12.2.0
kleur: ^4.1.4
- svelte: ^3.46.4
+ svelte: ^3.46.6
tar: ^6.1.11
dependencies:
'@astrojs/renderer-preact': link:../packages/renderers/renderer-preact
@@ -1575,7 +1575,7 @@ importers:
esbuild: 0.14.25
globby: 12.2.0
kleur: 4.1.4
- svelte: 3.46.4
+ svelte: 3.46.6
tar: 6.1.11
packages:
@@ -1726,15 +1726,15 @@ packages:
leven: 3.1.0
dev: true
- /@astrojs/compiler/0.13.1:
- resolution: {integrity: sha512-iRAwvJ8/uVRtK/4ofSYKx4MTsuG8YjSgz8Lti7tPGoFaQzSNEU8J5cXvpTSV/F2SspSWB9EHjk2v7204pOxlrQ==}
+ /@astrojs/compiler/0.14.1:
+ resolution: {integrity: sha512-dYgb52JvZE8jyDg84JkdJ/dTxRgHVbC47ou6Ymok/nZDh9kvlU7TJtEDCLlGfpfZTGvnkFTHMrz1kdbqCbFVCw==}
dependencies:
tsm: 2.2.1
uvu: 0.5.3
dev: false
- /@astrojs/language-server/0.13.2:
- resolution: {integrity: sha512-4YM4hM02ILvvsSQljAlwLY7OWymlhbikY7O/gsZqELVGMXixemA6dI3GTr2K6duU4ktPBJ3JexuU/OFyb5jvtQ==}
+ /@astrojs/language-server/0.13.3:
+ resolution: {integrity: sha512-i+m49XGg52LBDsi+zT5Wo9uhundfWHdA2uzC0xMn5AOmQXXzlDgSo29/SFRsHx3shT3kZ5Uf/Jkm6BNed/bs3g==}
hasBin: true
dependencies:
'@astrojs/svelte-language-integration': 0.1.2_typescript@4.6.3
@@ -1742,7 +1742,7 @@ packages:
lodash: 4.17.21
source-map: 0.7.3
typescript: 4.6.3
- vscode-css-languageservice: 5.3.0
+ vscode-css-languageservice: 5.4.1
vscode-html-languageservice: 4.2.4
vscode-languageserver: 7.0.0
vscode-languageserver-protocol: 3.16.0
@@ -1754,8 +1754,8 @@ packages:
/@astrojs/svelte-language-integration/0.1.2_typescript@4.6.3:
resolution: {integrity: sha512-O6LYL9igYSzxCxDHYWUqEquuuUlMG0UL1SliZ7rF/vx9GwU71TCpsRe4iHZ0bcemM5ju9ihoTzGCmLXzYrNw0g==}
dependencies:
- svelte: 3.46.4
- svelte2tsx: 0.5.6_svelte@3.46.4+typescript@4.6.3
+ svelte: 3.46.6
+ svelte2tsx: 0.5.6_svelte@3.46.6+typescript@4.6.3
transitivePeerDependencies:
- typescript
dev: false
@@ -3384,8 +3384,8 @@ packages:
resolution: {integrity: sha512-Jh0llaK2LRXQoYsorIH8maClebsnzTcve+7U3rQUSnC11X4jtPnFuyatqFLvMxZ8MLG8dB4zfHsbPfuvxluONw==}
dev: true
- /@iconify/utils/1.0.31:
- resolution: {integrity: sha512-sBksCt6kI4WaMHwXo1c/MQVuQfWwwd87qHiAPASN8neoQvMCdYTLn+2khc3/OmYPbmg6kYisCxVLkAv0pcy9Ig==}
+ /@iconify/utils/1.0.32:
+ resolution: {integrity: sha512-m+rnw7qKHq/XF7DAi4BcFoEAcXBfqqMgQJh8brGEHeqE/RUvgDMjmxsHgWnVpFsG+VmjGyAiI7nwXdliCwEU0Q==}
dependencies:
'@antfu/install-pkg': 0.1.0
'@antfu/utils': 0.5.0
@@ -3468,7 +3468,7 @@ packages:
read-yaml-file: 1.1.0
dev: true
- /@nanostores/preact/0.1.3_nanostores@0.5.12+preact@10.6.6:
+ /@nanostores/preact/0.1.3_nanostores@0.5.12+preact@10.7.0:
resolution: {integrity: sha512-uiX1ned0LrzASot+sPUjyJzr8Js3pX075omazgsSdLf0zPp4ss8xwTiuNh5FSKigTSQEVqZFiS+W8CnHIrX62A==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
peerDependencies:
@@ -3476,7 +3476,7 @@ packages:
preact: '>=10.0.0'
dependencies:
nanostores: 0.5.12
- preact: 10.6.6
+ preact: 10.7.0
dev: false
/@nanostores/react/0.1.5_33de46f26c75888291546388c72611d1:
@@ -3783,7 +3783,7 @@ packages:
string.prototype.matchall: 4.0.7
dev: true
- /@sveltejs/vite-plugin-svelte/1.0.0-next.40_svelte@3.46.4:
+ /@sveltejs/vite-plugin-svelte/1.0.0-next.40_svelte@3.46.6:
resolution: {integrity: sha512-DtXF01fYGEJkbC7GntU/7jaq9M1SwyyNCkbDA+cfQSXRpm3H7zbu0M80wSQBSpntdd+hgSdxKCxv4GgX6/zI6w==}
engines: {node: ^14.13.1 || >= 16}
peerDependencies:
@@ -3800,13 +3800,13 @@ packages:
debug: 4.3.4
kleur: 4.1.4
magic-string: 0.26.1
- svelte: 3.46.4
- svelte-hmr: 0.14.11_svelte@3.46.4
+ svelte: 3.46.6
+ svelte-hmr: 0.14.11_svelte@3.46.6
transitivePeerDependencies:
- supports-color
dev: false
- /@sveltejs/vite-plugin-svelte/1.0.0-next.40_svelte@3.46.4+vite@2.8.6:
+ /@sveltejs/vite-plugin-svelte/1.0.0-next.40_svelte@3.46.6+vite@2.9.1:
resolution: {integrity: sha512-DtXF01fYGEJkbC7GntU/7jaq9M1SwyyNCkbDA+cfQSXRpm3H7zbu0M80wSQBSpntdd+hgSdxKCxv4GgX6/zI6w==}
engines: {node: ^14.13.1 || >= 16}
peerDependencies:
@@ -3823,9 +3823,9 @@ packages:
debug: 4.3.4
kleur: 4.1.4
magic-string: 0.26.1
- svelte: 3.46.4
- svelte-hmr: 0.14.11_svelte@3.46.4
- vite: 2.8.6
+ svelte: 3.46.6
+ svelte-hmr: 0.14.11_svelte@3.46.6
+ vite: 2.9.1
transitivePeerDependencies:
- supports-color
dev: false
@@ -4092,8 +4092,8 @@ packages:
'@types/node': 17.0.23
dev: true
- /@types/tailwindcss/3.0.9:
- resolution: {integrity: sha512-uZjNKNjlA6cr6py/GWsDjevJb/Bl0fmaMNUdIpNMW3TJGJzxN9O6uFWx97LiSK7ithWNrrDSytq1FdvHpgSvWg==}
+ /@types/tailwindcss/3.0.10:
+ resolution: {integrity: sha512-1UnZIHO0NOPyPlPFV0HuMjki2SHkvG9uBA1ZehWj/OQMSROk503nuNyyfmJSIT289yewxTbKoPG+KLxYRvfIIg==}
dev: true
/@types/throttle-debounce/2.1.0:
@@ -4288,7 +4288,7 @@ packages:
/@unocss/preset-icons/0.15.6:
resolution: {integrity: sha512-o5NWtOu3OKVaWYVieQ1pVmsj7jvWvMgE5TXPKRr3OTRR2u8M5wo+yRX4+m1sVjAtWiUz8e49TpbbsQTM42Lv7A==}
dependencies:
- '@iconify/utils': 1.0.31
+ '@iconify/utils': 1.0.32
'@unocss/core': 0.15.6
local-pkg: 0.4.1
transitivePeerDependencies:
@@ -4334,8 +4334,8 @@ packages:
'@unocss/scope': 0.15.6
dev: true
- /@vitejs/plugin-vue/2.2.4_vite@2.8.6+vue@3.2.31:
- resolution: {integrity: sha512-ev9AOlp0ljCaDkFZF3JwC/pD2N4Hh+r5srl5JHM6BKg5+99jiiK0rE/XaRs3pVm1wzyKkjUy/StBSoXX5fFzcw==}
+ /@vitejs/plugin-vue/2.3.1_vite@2.9.1+vue@3.2.31:
+ resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==}
engines: {node: '>=12.0.0'}
peerDependencies:
vite: ^2.5.10
@@ -4344,12 +4344,12 @@ packages:
vite:
optional: true
dependencies:
- vite: 2.8.6
+ vite: 2.9.1
vue: 3.2.31
dev: false
- /@vitejs/plugin-vue/2.2.4_vue@3.2.31:
- resolution: {integrity: sha512-ev9AOlp0ljCaDkFZF3JwC/pD2N4Hh+r5srl5JHM6BKg5+99jiiK0rE/XaRs3pVm1wzyKkjUy/StBSoXX5fFzcw==}
+ /@vitejs/plugin-vue/2.3.1_vue@3.2.31:
+ resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==}
engines: {node: '>=12.0.0'}
peerDependencies:
vite: ^2.5.10
@@ -4693,7 +4693,7 @@ packages:
postcss: ^8.1.0
dependencies:
browserslist: 4.20.2
- caniuse-lite: 1.0.30001322
+ caniuse-lite: 1.0.30001324
fraction.js: 4.2.0
normalize-range: 0.1.2
picocolors: 1.0.0
@@ -4784,8 +4784,8 @@ packages:
/base64-js/1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
- /bcp-47-match/2.0.1:
- resolution: {integrity: sha512-+8o7axFDN/h8xATDM87FhnU1eod87dX0eZz1+cW3gggcicBqrmkZc33KBPWoE49qt5Asi5OhcxSOMOzp3opTfg==}
+ /bcp-47-match/2.0.2:
+ resolution: {integrity: sha512-zy5swVXwQ25ttElhoN9Dgnqm6VFlMkeDNljvHSGqGNr4zClUosdFzxD+fQHJVmx3g3KY+r//wV/fmBHsa1ErnA==}
/before-after-hook/2.2.2:
resolution: {integrity: sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==}
@@ -4830,7 +4830,7 @@ packages:
chalk: 4.1.2
cli-boxes: 3.0.0
string-width: 5.1.2
- type-fest: 2.12.1
+ type-fest: 2.12.2
widest-line: 4.0.1
wrap-ansi: 8.0.1
dev: false
@@ -4862,8 +4862,8 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
dependencies:
- caniuse-lite: 1.0.30001322
- electron-to-chromium: 1.4.98
+ caniuse-lite: 1.0.30001324
+ electron-to-chromium: 1.4.103
escalade: 3.1.1
node-releases: 2.0.2
picocolors: 1.0.0
@@ -4937,8 +4937,8 @@ packages:
resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==}
engines: {node: '>=10'}
- /caniuse-lite/1.0.30001322:
- resolution: {integrity: sha512-neRmrmIrCGuMnxGSoh+x7zYtQFFgnSY2jaomjU56sCkTA6JINqQrxutF459JpWcWRajvoyn95sOXq4Pqrnyjew==}
+ /caniuse-lite/1.0.30001324:
+ resolution: {integrity: sha512-/eYp1J6zYh1alySQB4uzYFkLmxxI8tk0kxldbNHXp8+v+rdMKdUBNjRLz7T7fz6Iox+1lIdYpc7rq6ZcXfTukg==}
/canvas-confetti/1.5.1:
resolution: {integrity: sha512-Ncz+oZJP6OvY7ti4E1slxVlyAV/3g7H7oQtcCDXgwGgARxPnwYY9PW5Oe+I8uvspYNtuHviAdgA0LfcKFWJfpg==}
@@ -5017,7 +5017,7 @@ packages:
resolution: {integrity: sha512-eq0GdBvxVFbqWgmCm7M3XGs1I8oLy/nExUnh6oLqmBditPO9AqQJrkslDpMun/hZ0yyTs8L0m85OHp4ho6Qm9g==}
dependencies:
css-select: 4.3.0
- css-what: 6.0.1
+ css-what: 6.1.0
domelementtype: 2.2.0
domhandler: 4.3.1
domutils: 2.8.0
@@ -5164,8 +5164,8 @@ packages:
/concat-map/0.0.1:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
- /concurrently/7.0.0:
- resolution: {integrity: sha512-WKM7PUsI8wyXpF80H+zjHP32fsgsHNQfPLw/e70Z5dYkV7hF+rf8q3D+ScWJIEr57CpkO3OWBko6hwhQLPR8Pw==}
+ /concurrently/7.1.0:
+ resolution: {integrity: sha512-Bz0tMlYKZRUDqJlNiF/OImojMB9ruKUz6GCfmhFnSapXgPe+3xzY4byqoKG9tUZ7L2PGEUjfLPOLfIX3labnmw==}
engines: {node: ^12.20.0 || ^14.13.0 || >=16.0.0}
hasBin: true
dependencies:
@@ -5238,7 +5238,7 @@ packages:
resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==}
dependencies:
boolbase: 1.0.0
- css-what: 6.0.1
+ css-what: 6.1.0
domhandler: 4.3.1
domutils: 2.8.0
nth-check: 2.0.1
@@ -5247,8 +5247,8 @@ packages:
/css-selector-parser/1.4.1:
resolution: {integrity: sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==}
- /css-what/6.0.1:
- resolution: {integrity: sha512-z93ZGFLNc6yaoXAmVhqoSIb+BduplteCt1fepvwhBUQK6MNE4g6fgjpuZKJKp0esUe+vXWlIkwZZjNWoOKw0ZA==}
+ /css-what/6.1.0:
+ resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==}
engines: {node: '>= 6'}
dev: true
@@ -5542,8 +5542,8 @@ packages:
jake: 10.8.4
dev: true
- /electron-to-chromium/1.4.98:
- resolution: {integrity: sha512-1IdsuSAnIGVxoYT1LkcUFb9MfjRxdHhCU9qiaDzhl1XvYgK9c8E2O9aJOPgGMQ68CSI8NxmLwrYhjvGauT8yuw==}
+ /electron-to-chromium/1.4.103:
+ resolution: {integrity: sha512-c/uKWR1Z/W30Wy/sx3dkZoj4BijbXX85QKWu9jJfjho3LBAXNEGAEW3oWiGb+dotA6C6BzCTxL2/aLes7jlUeg==}
/emmet/2.3.6:
resolution: {integrity: sha512-pLS4PBPDdxuUAmw7Me7+TcHbykTsBKN/S9XJbUOMFQrNv9MoshzyMFK/R57JBm94/6HSL4vHnDeEmxlC82NQ4A==}
@@ -5604,7 +5604,7 @@ packages:
is-callable: 1.2.4
is-negative-zero: 2.0.2
is-regex: 1.1.4
- is-shared-array-buffer: 1.0.1
+ is-shared-array-buffer: 1.0.2
is-string: 1.0.7
is-weakref: 1.0.2
object-inspect: 1.12.0
@@ -5642,8 +5642,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-android-64/0.14.28:
- resolution: {integrity: sha512-A52C3zq+9tNwCqZ+4kVLBxnk/WnrYM8P2+QNvNE9B6d2OVPs214lp3g6UyO+dKDhUdefhfPCuwkP8j2A/+szNA==}
+ /esbuild-android-64/0.14.30:
+ resolution: {integrity: sha512-vdJ7t8A8msPfKpYUGUV/KaTQRiZ0vDa2XSTlzXVkGGVHLKPeb85PBUtYJcEgw3htW3IdX5i1t1IMdQCwJJgNAg==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
@@ -5659,8 +5659,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-android-arm64/0.14.28:
- resolution: {integrity: sha512-sm0fDEGElZhMC3HLZeECI2juE4aG7uPfMBMqNUhy9CeX399Pz8rC6e78OXMXInGjSdEAwQmCOHmfsP7uv3Q8rA==}
+ /esbuild-android-arm64/0.14.30:
+ resolution: {integrity: sha512-BdgGfxeA5hBQNErLr7BWJUA8xjflEfyaARICy8e0OJYNSAwDbEzOf8LyiKWSrDcgV129mWhi3VpbNQvOIDEHcg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
@@ -5676,8 +5676,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-darwin-64/0.14.28:
- resolution: {integrity: sha512-nzDd7mQ44FvsFHtOafZdBgn3Li5SMsnMnoz1J2MM37xJmR3wGNTFph88KypjHgWqwbxCI7MXS1U+sN4qDeeW6Q==}
+ /esbuild-darwin-64/0.14.30:
+ resolution: {integrity: sha512-VRaOXMMrsG5n53pl4qFZQdXy2+E0NoLP/QH3aDUI0+bQP+ZHDmbINKcDy2IX7GVFI9kqPS18iJNAs5a6/G2LZg==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
@@ -5693,8 +5693,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-darwin-arm64/0.14.28:
- resolution: {integrity: sha512-XEq/bLR/glsUl+uGrBimQzOVs/CmwI833fXUhP9xrLI3IJ+rKyrZ5IA8u+1crOEf1LoTn8tV+hInmX6rGjbScw==}
+ /esbuild-darwin-arm64/0.14.30:
+ resolution: {integrity: sha512-qDez+fHMOrO9Oc9qjt/x+sy09RJVh62kik5tVybKRLmezeV4qczM9/sAYY57YN0aWLdHbcCj2YqJUWYJNsgKnw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
@@ -5710,8 +5710,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-freebsd-64/0.14.28:
- resolution: {integrity: sha512-rTKLgUj/HEcPeE5XZ7IZwWpFx7IWMfprN7QRk/TUJE1s1Ipb58esboIesUpjirJz/BwrgHq+FDG9ChAI8dZAtQ==}
+ /esbuild-freebsd-64/0.14.30:
+ resolution: {integrity: sha512-mec1jENcImVVagddZlGWsdAUwBnzR5cgnhzCxv+9fSMxKbx1uZYLLUAnLPp8m/i934zrumR1xGjJ5VoWdPlI2w==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
@@ -5727,8 +5727,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-freebsd-arm64/0.14.28:
- resolution: {integrity: sha512-sBffxD1UMOsB7aWMoExmipycjcy3HJGwmqE4GQZUTZvdiH4GhjgUiVdtPyt7kSCdL40JqnWQJ4b1l8Y51oCF4Q==}
+ /esbuild-freebsd-arm64/0.14.30:
+ resolution: {integrity: sha512-cpjbTs6Iok/AfeB0JgTzyUJTMStC1SQULmany5nHx6S4GTkSgaAHuJzZO0GcVWqghI4e0YL/bjXAhN5Mn6feNw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
@@ -5744,8 +5744,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-32/0.14.28:
- resolution: {integrity: sha512-+Wxidh3fBEQ9kHcCsD4etlBTMb1n6QY2uXv3rFhVn88CY/JP782MhA57/ipLMY4kOLeSKEuFGN4rtjHuhmRMig==}
+ /esbuild-linux-32/0.14.30:
+ resolution: {integrity: sha512-liIONVT4F2kZmOMwtwASqZ8WkIjb5HHBR9HUffdHiuotSTF3CyZO+EJf+Og+SYYuuVIvt0qHNSFjBA/iSESteQ==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
@@ -5761,8 +5761,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-64/0.14.28:
- resolution: {integrity: sha512-7+xgsC4LvR6cnzaBdiljNnPDjbkwzahogN+S9uy9AoYw7ZjPnnXc6sjQAVCbqGb7MEgrWdpa6u/Tao79i4lWxg==}
+ /esbuild-linux-64/0.14.30:
+ resolution: {integrity: sha512-LUnpzoMpRqFON5En4qEj6NWiyH6a1K+Y2qYNKrCy5qPTjDoG/EWeqMz69n8Uv7pRuvDKl3FNGJ1dufTrA5i0sw==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
@@ -5778,8 +5778,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-arm/0.14.28:
- resolution: {integrity: sha512-L5isjmlLbh9E0WVllXiVETbScgMbth/+XkXQii1WwgO1RvLIfaGrVFz8d2n6EH/ImtgYxPYGx+OcvIKQBc91Rg==}
+ /esbuild-linux-arm/0.14.30:
+ resolution: {integrity: sha512-97T+bbXnpqf7mfIG49UR7ZSJFGgvc22byn74qw3Kx2GDCBSQoVFjyWuKOHGXp8nXk3XYrdFF+mQ8yQ7aNsgQvg==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
@@ -5795,8 +5795,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-arm64/0.14.28:
- resolution: {integrity: sha512-EjRHgwg+kgXABzyoPGPOPg4d5wZqRnZ/ZAxBDzLY+i6DS8OUfTSlZHWIOZzU4XF7125WxRBg9ULbrFJBl+57Eg==}
+ /esbuild-linux-arm64/0.14.30:
+ resolution: {integrity: sha512-DHZHn6FK5q/KL0fpNT/0jE38Nnyk2rXxKE9WENi95EXtqfOLPgE8tzjTZQNgpr61R95QX4ymQU26ni3IZk8buQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
@@ -5812,8 +5812,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-mips64le/0.14.28:
- resolution: {integrity: sha512-krx9SSg7yfiUKk64EmjefOyiEF6nv2bRE4um/LiTaQ6Y/6FP4UF3/Ou/AxZVyR154uSRq63xejcAsmswXAYRsw==}
+ /esbuild-linux-mips64le/0.14.30:
+ resolution: {integrity: sha512-fLUzTFZ7uknC0aPTk7/lM7NmaG/9ZqE3SaHEphcaM009SZK/mDOvZugWi1ss6WGNhk13dUrhkfHcc4FSb9hYhg==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
@@ -5829,8 +5829,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-ppc64le/0.14.28:
- resolution: {integrity: sha512-LD0Xxu9g+DNuhsEBV5QuVZ4uKVBMup0xPIruLweuAf9/mHXFnaCuNXUBF5t0DxKl7GQ5MSioKtnb92oMo+QXEw==}
+ /esbuild-linux-ppc64le/0.14.30:
+ resolution: {integrity: sha512-2Oudm2WEfj0dNU9bzIl5L/LrsMEmHWsOsYgJJqu8fDyUDgER+J1d33qz3cUdjsJk7gAENayIxDSpsuCszx0w3A==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
@@ -5846,8 +5846,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-riscv64/0.14.28:
- resolution: {integrity: sha512-L/DWfRh2P0vxq4Y+qieSNXKGdMg+e9Qe8jkbN2/8XSGYDTPzO2OcAxSujob4qIh7iSl+cknbXV+BvH0YFR0jbg==}
+ /esbuild-linux-riscv64/0.14.30:
+ resolution: {integrity: sha512-RPMucPW47rV4t2jlelaE948iCRtbZf5RhifxSwzlpM1Mqdyu99MMNK0w4jFreGTmLN+oGomxIOxD6n+2E/XqHw==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
@@ -5863,8 +5863,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-linux-s390x/0.14.28:
- resolution: {integrity: sha512-rrgxmsbmL8QQknWGnAL9bGJRQYLOi2AzXy5OTwfhxnj9eqjo5mSVbJXjgiq5LPUAMQZGdPH5yaNK0obAXS81Zw==}
+ /esbuild-linux-s390x/0.14.30:
+ resolution: {integrity: sha512-OZ68r7ok6qO7hdwrwQn2p5jbIRRcUcVaAykB7e0uCA0ODwfeGunILM6phJtq2Oz4dlEEFvd+tSuma3paQKwt+A==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
@@ -5880,8 +5880,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-netbsd-64/0.14.28:
- resolution: {integrity: sha512-h8wntIyOR8/xMVVM6TvJxxWKh4AjmLK87IPKpuVi8Pq0kyk0RMA+eo4PFGk5j2XK0D7dj8PcSF5NSlP9kN/j0A==}
+ /esbuild-netbsd-64/0.14.30:
+ resolution: {integrity: sha512-iyejQUKn0TzpPkufq8pSCxOg9NheycQbMbPCmjefTe9wYuUlBt1TcHvdoJnYbQzsAhAh1BNq+s0ycRsIJFZzaQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
@@ -5897,8 +5897,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-openbsd-64/0.14.28:
- resolution: {integrity: sha512-HBv18rVapbuDx52/fhZ/c/w6TXyaQAvRxiDDn5Hz/pBcwOs3cdd2WxeIKlWmDoqm2JMx5EVlq4IWgoaRX9mVkw==}
+ /esbuild-openbsd-64/0.14.30:
+ resolution: {integrity: sha512-UyK1MTMcy4j5fH260fsE1o6MVgWNhb62eCK2yCKCRazZv8Nqdc2WiP9ygjWidmEdCDS+A6MuVp9ozk9uoQtQpA==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
@@ -5914,8 +5914,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-sunos-64/0.14.28:
- resolution: {integrity: sha512-zlIxePhZxKYheR2vBCgPVvTixgo/ozOfOMoP6RZj8dxzquU1NgeyhjkcRXucbLCtmoNJ+i4PtWwPZTLuDd3bGg==}
+ /esbuild-sunos-64/0.14.30:
+ resolution: {integrity: sha512-aQRtRTNKHB4YuG+xXATe5AoRTNY48IJg5vjE8ElxfmjO9+KdX7MHFkTLhlKevCD6rNANtB3qOlSIeAiXTwHNqw==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
@@ -5931,8 +5931,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-windows-32/0.14.28:
- resolution: {integrity: sha512-am9DIJxXlld1BOAY/VlvBQHMUCPL7S3gB/lnXIY3M4ys0gfuRqPf4EvMwZMzYUbFKBY+/Qb8SRgPRRGhwnJ8Kg==}
+ /esbuild-windows-32/0.14.30:
+ resolution: {integrity: sha512-9/fb1tPtpacMqxAXp3fGHowUDg/l9dVch5hKmCLEZC6PdGljh6h372zMdJwYfH0Bd5CCPT0Wx95uycBLJiqpXA==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
@@ -5948,8 +5948,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-windows-64/0.14.28:
- resolution: {integrity: sha512-78PhySDnmRZlsPNp/W/5Fim8iivlBQQxfhBFIqR7xwvfDmCFUSByyMKP7LCHgNtb04yNdop8nJJkJaQ8Xnwgiw==}
+ /esbuild-windows-64/0.14.30:
+ resolution: {integrity: sha512-DHgITeUhPAnN9I5O6QBa1GVyPOhiYCn4S4TtQr7sO4+X0LNyqnlmA1M0qmGkUdDC1QQfjI8uQ4G/whdWb2pWIQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
@@ -5965,8 +5965,8 @@ packages:
requiresBuild: true
optional: true
- /esbuild-windows-arm64/0.14.28:
- resolution: {integrity: sha512-VhXGBTo6HELD8zyHXynV6+L2jWx0zkKnGx4TmEdSBK7UVFACtOyfUqpToG0EtnYyRZ0HESBhzPSVpP781ovmvA==}
+ /esbuild-windows-arm64/0.14.30:
+ resolution: {integrity: sha512-F1kLyQH7zSgjh5eLxogGZN7C9+KNs9m+s7Q6WZoMmCWT/6j998zlaoECHyM8izJRRfsvw2eZlEa1jO6/IOU1AQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
@@ -6001,32 +6001,32 @@ packages:
esbuild-windows-64: 0.14.25
esbuild-windows-arm64: 0.14.25
- /esbuild/0.14.28:
- resolution: {integrity: sha512-YLNprkCcMVKQ5sekmCKEQ3Obu/L7s6+iij38xNKyBeSmSsTWur4Ky/9zB3XIGT8SCJITG/bZwAR2l7YOAXch4Q==}
+ /esbuild/0.14.30:
+ resolution: {integrity: sha512-wCecQSBkIjp2xjuXY+wcXS/PpOQo9rFh4NAKPh4Pm9f3fuLcnxkR0rDzA+mYP88FtXIUcXUyYmaIgfrzRl55jA==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
- esbuild-android-64: 0.14.28
- esbuild-android-arm64: 0.14.28
- esbuild-darwin-64: 0.14.28
- esbuild-darwin-arm64: 0.14.28
- esbuild-freebsd-64: 0.14.28
- esbuild-freebsd-arm64: 0.14.28
- esbuild-linux-32: 0.14.28
- esbuild-linux-64: 0.14.28
- esbuild-linux-arm: 0.14.28
- esbuild-linux-arm64: 0.14.28
- esbuild-linux-mips64le: 0.14.28
- esbuild-linux-ppc64le: 0.14.28
- esbuild-linux-riscv64: 0.14.28
- esbuild-linux-s390x: 0.14.28
- esbuild-netbsd-64: 0.14.28
- esbuild-openbsd-64: 0.14.28
- esbuild-sunos-64: 0.14.28
- esbuild-windows-32: 0.14.28
- esbuild-windows-64: 0.14.28
- esbuild-windows-arm64: 0.14.28
+ esbuild-android-64: 0.14.30
+ esbuild-android-arm64: 0.14.30
+ esbuild-darwin-64: 0.14.30
+ esbuild-darwin-arm64: 0.14.30
+ esbuild-freebsd-64: 0.14.30
+ esbuild-freebsd-arm64: 0.14.30
+ esbuild-linux-32: 0.14.30
+ esbuild-linux-64: 0.14.30
+ esbuild-linux-arm: 0.14.30
+ esbuild-linux-arm64: 0.14.30
+ esbuild-linux-mips64le: 0.14.30
+ esbuild-linux-ppc64le: 0.14.30
+ esbuild-linux-riscv64: 0.14.30
+ esbuild-linux-s390x: 0.14.30
+ esbuild-netbsd-64: 0.14.30
+ esbuild-openbsd-64: 0.14.30
+ esbuild-sunos-64: 0.14.30
+ esbuild-windows-32: 0.14.30
+ esbuild-windows-64: 0.14.30
+ esbuild-windows-arm64: 0.14.30
dev: false
/escalade/3.1.1:
@@ -6069,7 +6069,7 @@ packages:
eslint: 8.12.0
dev: true
- /eslint-plugin-prettier/4.0.0_b253a92c95b42c3296c682f11cccb3bd:
+ /eslint-plugin-prettier/4.0.0_f2c91d0f54113167d2bd9214a5ab5a36:
resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==}
engines: {node: '>=6.0.0'}
peerDependencies:
@@ -6082,7 +6082,7 @@ packages:
dependencies:
eslint: 8.12.0
eslint-config-prettier: 8.5.0_eslint@8.12.0
- prettier: 2.6.1
+ prettier: 2.6.2
prettier-linter-helpers: 1.0.0
dev: true
@@ -6740,7 +6740,7 @@ packages:
hast-util-to-parse5: 7.0.0
html-void-elements: 2.0.1
parse5: 6.0.1
- unist-util-position: 4.0.2
+ unist-util-position: 4.0.3
unist-util-visit: 4.1.0
vfile: 5.3.2
web-namespaces: 2.0.1
@@ -6752,7 +6752,7 @@ packages:
dependencies:
'@types/hast': 2.3.4
'@types/unist': 2.0.6
- bcp-47-match: 2.0.1
+ bcp-47-match: 2.0.2
comma-separated-tokens: 2.0.2
css-selector-parser: 1.4.1
direction: 2.0.1
@@ -7105,8 +7105,8 @@ packages:
resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==}
engines: {node: '>= 0.4'}
- /is-number-object/1.0.6:
- resolution: {integrity: sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==}
+ /is-number-object/1.0.7:
+ resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==}
engines: {node: '>= 0.4'}
dependencies:
has-tostringtag: 1.0.0
@@ -7165,8 +7165,10 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
- /is-shared-array-buffer/1.0.1:
- resolution: {integrity: sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==}
+ /is-shared-array-buffer/1.0.2:
+ resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==}
+ dependencies:
+ call-bind: 1.0.2
/is-stream/2.0.1:
resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
@@ -7665,7 +7667,7 @@ packages:
micromark-util-sanitize-uri: 1.0.0
unist-builder: 3.0.0
unist-util-generated: 2.0.0
- unist-util-position: 4.0.2
+ unist-util-position: 4.0.3
unist-util-visit: 4.1.0
dev: false
@@ -8615,10 +8617,10 @@ packages:
postcss: ^8.2.14
dependencies:
postcss: 8.4.12
- postcss-selector-parser: 6.0.9
+ postcss-selector-parser: 6.0.10
- /postcss-selector-parser/6.0.9:
- resolution: {integrity: sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ==}
+ /postcss-selector-parser/6.0.10:
+ resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
engines: {node: '>=4'}
dependencies:
cssesc: 3.0.0
@@ -8635,17 +8637,21 @@ packages:
picocolors: 1.0.0
source-map-js: 1.0.2
- /preact-render-to-string/5.1.20_preact@10.6.6:
+ /preact-render-to-string/5.1.20_preact@10.7.0:
resolution: {integrity: sha512-ivh2oOGzth0o7XqbatWUQ81WQGoJwSqDKP5z917SoqTWYCAr7dlBzMv3SAMTAu3Gr5g47BJwrvyO44H2Y10ubg==}
peerDependencies:
preact: '>=10'
dependencies:
- preact: 10.6.6
+ preact: 10.7.0
pretty-format: 3.8.0
dev: false
/preact/10.6.6:
resolution: {integrity: sha512-dgxpTFV2vs4vizwKohYKkk7g7rmp1wOOcfd4Tz3IB3Wi+ivZzsn/SpeKJhRENSE+n8sUfsAl4S3HiCVT923ABw==}
+ dev: false
+
+ /preact/10.7.0:
+ resolution: {integrity: sha512-9MEURwzNMKpAil/t6+wabDIJI6oG6GnwypYxiJDvQnW+fHDTt51PYuLZ1QUM31hFr7sDaj9qTaShAF9VIxuxGQ==}
/prebuild-install/7.0.1:
resolution: {integrity: sha512-QBSab31WqkyxpnMWQxubYAHR5S9B2+r81ucocew34Fkl98FhvKIF50jIJnNOBmAZfyNV7vE5T6gd3hTVWgY6tg==}
@@ -8699,8 +8705,8 @@ packages:
hasBin: true
dev: true
- /prettier/2.6.1:
- resolution: {integrity: sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==}
+ /prettier/2.6.2:
+ resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
engines: {node: '>=10.13.0'}
hasBin: true
dev: true
@@ -9204,8 +9210,8 @@ packages:
rimraf: 2.7.1
dev: false
- /sass/1.49.9:
- resolution: {integrity: sha512-YlYWkkHP9fbwaFRZQRXgDi3mXZShslVmmo+FVK3kHLUELHHEYrCmL1x6IUjC7wLS6VuJSAFXRQS/DxdsC4xL1A==}
+ /sass/1.49.11:
+ resolution: {integrity: sha512-wvS/geXgHUGs6A/4ud5BFIWKO1nKd7wYIGimDk4q4GFkJicILActpv9ueMT4eRGSsp1BdKHuw1WwAHXbhsJELQ==}
engines: {node: '>=12.0.0'}
hasBin: true
dependencies:
@@ -9719,16 +9725,16 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
- /svelte-hmr/0.14.11_svelte@3.46.4:
+ /svelte-hmr/0.14.11_svelte@3.46.6:
resolution: {integrity: sha512-R9CVfX6DXxW1Kn45Jtmx+yUe+sPhrbYSUp7TkzbW0jI5fVPn6lsNG9NEs5dFg5qRhFNAoVdRw5qQDLALNKhwbQ==}
engines: {node: ^12.20 || ^14.13.1 || >= 16}
peerDependencies:
svelte: '>=3.19.0'
dependencies:
- svelte: 3.46.4
+ svelte: 3.46.6
dev: false
- /svelte-preprocess/4.10.4_ec4868a778d68da3f0d21a10f4ea83cd:
+ /svelte-preprocess/4.10.4_4fb28cead04100f31b0e8b0196137d75:
resolution: {integrity: sha512-fuwol0N4UoHsNQolLFbMqWivqcJ9N0vfWO9IuPAiX/5okfoGXURyJ6nECbuEIv0nU3M8Xe2I1ONNje2buk7l6A==}
engines: {node: '>= 9.11.2'}
requiresBuild: true
@@ -9776,11 +9782,11 @@ packages:
postcss-load-config: 3.1.4
sorcery: 0.10.0
strip-indent: 3.0.0
- svelte: 3.46.4
+ svelte: 3.46.6
typescript: 4.6.3
dev: false
- /svelte-preprocess/4.10.4_svelte@3.46.4+typescript@4.6.3:
+ /svelte-preprocess/4.10.4_svelte@3.46.6+typescript@4.6.3:
resolution: {integrity: sha512-fuwol0N4UoHsNQolLFbMqWivqcJ9N0vfWO9IuPAiX/5okfoGXURyJ6nECbuEIv0nU3M8Xe2I1ONNje2buk7l6A==}
engines: {node: '>= 9.11.2'}
requiresBuild: true
@@ -9827,15 +9833,15 @@ packages:
magic-string: 0.25.9
sorcery: 0.10.0
strip-indent: 3.0.0
- svelte: 3.46.4
+ svelte: 3.46.6
typescript: 4.6.3
dev: false
- /svelte/3.46.4:
- resolution: {integrity: sha512-qKJzw6DpA33CIa+C/rGp4AUdSfii0DOTCzj/2YpSKKayw5WGSS624Et9L1nU1k2OVRS9vaENQXp2CVZNU+xvIg==}
+ /svelte/3.46.6:
+ resolution: {integrity: sha512-o9nNft/OzCz/9kJpmWa1S52GAM+huCjPIsNWydYmgei74ZWlOA9/hN9+Z12INdklghu31seEXZMRHhS1+8DETw==}
engines: {node: '>= 8'}
- /svelte2tsx/0.5.6_svelte@3.46.4+typescript@4.6.3:
+ /svelte2tsx/0.5.6_svelte@3.46.6+typescript@4.6.3:
resolution: {integrity: sha512-B4WZUtoTdVD+F73H1RQEH3Hrv7m2/ahThmAUkjT5CTWRigQaJqYQpSjisCH1Pzfi9B37YikDnAi4u4uxwYM+iw==}
peerDependencies:
svelte: ^3.24
@@ -9843,7 +9849,7 @@ packages:
dependencies:
dedent-js: 1.0.1
pascal-case: 3.1.2
- svelte: 3.46.4
+ svelte: 3.46.6
typescript: 4.6.3
dev: false
@@ -9872,7 +9878,7 @@ packages:
postcss-js: 4.0.0_postcss@8.4.12
postcss-load-config: 3.1.4_postcss@8.4.12
postcss-nested: 5.0.6_postcss@8.4.12
- postcss-selector-parser: 6.0.9
+ postcss-selector-parser: 6.0.10
postcss-value-parser: 4.2.0
quick-lru: 5.1.1
resolve: 1.22.0
@@ -10224,8 +10230,8 @@ packages:
engines: {node: '>=8'}
dev: true
- /type-fest/2.12.1:
- resolution: {integrity: sha512-AiknQSEqKVGDDjtZqeKrUoTlcj7FKhupmnVUgz6KoOKtvMwRGE6hUNJ/nVear+h7fnUPO1q/htSkYKb1pyntkQ==}
+ /type-fest/2.12.2:
+ resolution: {integrity: sha512-qt6ylCGpLjZ7AaODxbpyBZSs9fCI9SkL3Z9q2oxMBQhs/uyY+VD8jHA8ULCGmWQJlBgqvO3EJeAngOHD8zQCrQ==}
engines: {node: '>=12.20'}
dev: false
@@ -10330,8 +10336,8 @@ packages:
'@types/unist': 2.0.6
dev: false
- /unist-util-position/4.0.2:
- resolution: {integrity: sha512-Y6+plxR41dOLbyyqVDLuGWgXDmxdXslCSRYQkSDagBnOT9oFsQH0J8FzhirSklUEe0xZTT0WDnAE1gXPaDFljA==}
+ /unist-util-position/4.0.3:
+ resolution: {integrity: sha512-p/5EMGIa1qwbXjA+QgcBXaPWjSnZfQ2Sc3yBEEfgPwsEmJd8Qh+DSk3LGnmOM4S1bY2C0AjmMnB8RuEYxpPwXQ==}
dependencies:
'@types/unist': 2.0.6
dev: false
@@ -10525,8 +10531,8 @@ packages:
- supports-color
dev: true
- /vite/2.8.6:
- resolution: {integrity: sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==}
+ /vite/2.9.1:
+ resolution: {integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==}
engines: {node: '>=12.2.0'}
hasBin: true
peerDependencies:
@@ -10541,7 +10547,7 @@ packages:
stylus:
optional: true
dependencies:
- esbuild: 0.14.28
+ esbuild: 0.14.30
postcss: 8.4.12
resolve: 1.22.0
rollup: 2.70.1
@@ -10549,8 +10555,8 @@ packages:
fsevents: 2.3.2
dev: false
- /vite/2.8.6_sass@1.49.9:
- resolution: {integrity: sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==}
+ /vite/2.9.1_sass@1.49.11:
+ resolution: {integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==}
engines: {node: '>=12.2.0'}
hasBin: true
peerDependencies:
@@ -10565,11 +10571,11 @@ packages:
stylus:
optional: true
dependencies:
- esbuild: 0.14.28
+ esbuild: 0.14.30
postcss: 8.4.12
resolve: 1.22.0
rollup: 2.70.1
- sass: 1.49.9
+ sass: 1.49.11
optionalDependencies:
fsevents: 2.3.2
dev: false
@@ -10583,8 +10589,8 @@ packages:
acorn-walk: 8.2.0
dev: true
- /vscode-css-languageservice/5.3.0:
- resolution: {integrity: sha512-ujWW855AoJlE4ETU17Gff7unlZZTHDA0w26itk9EQFMfJqi9lE6S67zOsMvcPmJf55MrnGQbojDYZRiDVaFjdA==}
+ /vscode-css-languageservice/5.4.1:
+ resolution: {integrity: sha512-W7D3GKFXf97ReAaU4EZ2nxVO1kQhztbycJgc1b/Ipr0h8zYWr88BADmrXu02z+lsCS84D7Sr4hoUzDKeaFn2Kg==}
dependencies:
vscode-languageserver-textdocument: 1.0.4
vscode-languageserver-types: 3.16.0
@@ -10696,7 +10702,7 @@ packages:
dependencies:
is-bigint: 1.0.4
is-boolean-object: 1.1.2
- is-number-object: 1.0.6
+ is-number-object: 1.0.7
is-string: 1.0.7
is-symbol: 1.0.4
diff --git a/scripts/cmd/build.js b/scripts/cmd/build.js
index 3a182c656..b2d402890 100644
--- a/scripts/cmd/build.js
+++ b/scripts/cmd/build.js
@@ -26,9 +26,17 @@ export default async function build(...args) {
const patterns = args
.filter((f) => !!f) // remove empty args
.map((f) => f.replace(/^'/, '').replace(/'$/, '')); // Needed for Windows: glob strings contain surrounding string chars??? remove these
- let entryPoints = [].concat(...(await Promise.all(patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true })))));
+ let entryPoints = [].concat(
+ ...(await Promise.all(
+ patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true }))
+ ))
+ );
- const { type = 'module', version, dependencies = {} } = await fs.readFile('./package.json').then((res) => JSON.parse(res.toString()));
+ const {
+ type = 'module',
+ version,
+ dependencies = {},
+ } = await fs.readFile('./package.json').then((res) => JSON.parse(res.toString()));
// expose PACKAGE_VERSION on process.env for CLI utils
config.define = { 'process.env.PACKAGE_VERSION': JSON.stringify(version) };
const format = type === 'module' ? 'esm' : 'cjs';
@@ -56,7 +64,9 @@ export default async function build(...args) {
console.error(dim(`[${date}] `) + red(error || result.errors.join('\n')));
} else {
if (result.warnings.length) {
- console.log(dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n')));
+ console.log(
+ dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n'))
+ );
}
console.log(dim(`[${date}] `) + green('✔ updated'));
}
diff --git a/scripts/cmd/copy.js b/scripts/cmd/copy.js
index 925990fe4..1700e56c4 100644
--- a/scripts/cmd/copy.js
+++ b/scripts/cmd/copy.js
@@ -63,7 +63,9 @@ export default async function copy() {
await Promise.all(
files.map((file) => {
const dest = resolve(file.replace(/^[^/]+/, 'dist'));
- return fs.mkdir(dirname(dest), { recursive: true }).then(() => fs.copyFile(resolve(file), dest));
+ return fs
+ .mkdir(dirname(dest), { recursive: true })
+ .then(() => fs.copyFile(resolve(file), dest));
})
);
}
diff --git a/scripts/memory/index.js b/scripts/memory/index.js
index 969b1bb17..da55acb71 100644
--- a/scripts/memory/index.js
+++ b/scripts/memory/index.js
@@ -18,8 +18,6 @@ let config = await loadConfig({
cwd: fileURLToPath(projDir),
});
-config.buildOptions.legacyBuild = false;
-
const server = await dev(config, { logging: { level: 'error' } });
// Prime the server so initial memory is created
@@ -37,7 +35,9 @@ const startSize = v8.getHeapStatistics().used_heap_size;
// HUMAN mode: Runs forever. Optimized for accurate results on each snapshot Slower than CI.
if (!isCI) {
- console.log(`Greetings, human. This test will run forever. Run with the "--ci" flag to finish with a result.`);
+ console.log(
+ `Greetings, human. This test will run forever. Run with the "--ci" flag to finish with a result.`
+ );
let i = 1;
while (i++) {
await run();
@@ -64,7 +64,9 @@ const TEST_THRESHOLD = 1.5;
const isPass = percentage < TEST_THRESHOLD;
console.log(``);
console.log(`Result: ${isPass ? 'PASS' : 'FAIL'} (${percentage * 100}%)`);
-console.log(`Memory usage began at ${prettyBytes(startSize)} and finished at ${prettyBytes(endSize)}.`);
+console.log(
+ `Memory usage began at ${prettyBytes(startSize)} and finished at ${prettyBytes(endSize)}.`
+);
console.log(`The threshold for a probable memory leak is ${TEST_THRESHOLD * 100}%`);
console.log(``);
console.log(`Exiting...`);
diff --git a/scripts/notify/index.js b/scripts/notify/index.js
index a0505c9ae..fa699372a 100755
--- a/scripts/notify/index.js
+++ b/scripts/notify/index.js
@@ -5,7 +5,16 @@ import { readFile } from 'node:fs/promises';
const baseUrl = new URL('https://github.com/withastro/astro/blob/main/');
const emojis = ['🎉', '🥳', '🚀', '🧑‍🚀', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
-const descriptors = ['new releases', 'hot and fresh updates', 'shiny updates', 'exciting changes', 'package updates', 'awesome updates', 'bug fixes and features', 'updates'];
+const descriptors = [
+ 'new releases',
+ 'hot and fresh updates',
+ 'shiny updates',
+ 'exciting changes',
+ 'package updates',
+ 'awesome updates',
+ 'bug fixes and features',
+ 'updates',
+];
const verbs = [
'just went out!',
'just launched!',
@@ -47,7 +56,9 @@ const plurals = new Map([
]);
function pluralize(text) {
- return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) => (plurals.has(match) ? plurals.get(match) : `${match}s`));
+ return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) =>
+ plurals.has(match) ? plurals.get(match) : `${match}s`
+ );
}
function singularlize(text) {
@@ -57,7 +68,9 @@ function singularlize(text) {
const packageMap = new Map();
async function generatePackageMap() {
const packageRoot = new URL('../../packages/', import.meta.url);
- const packages = await glob(['*/package.json', '*/*/package.json'], { cwd: fileURLToPath(packageRoot) });
+ const packages = await glob(['*/package.json', '*/*/package.json'], {
+ cwd: fileURLToPath(packageRoot),
+ });
await Promise.all(
packages.map(async (pkg) => {
const pkgFile = fileURLToPath(new URL(pkg, packageRoot));
@@ -77,7 +90,11 @@ async function run() {
if (!p) {
throw new Error(`Unable to find entrypoint for "${name}"!`);
}
- return { name, version, url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString() };
+ return {
+ name,
+ version,
+ url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString(),
+ };
})
);
@@ -87,7 +104,9 @@ async function run() {
if (packages.length === 1) {
const { name, version, url } = packages[0];
- console.log(`${emoji} \`${name}@${version}\` ${singularlize(verb)}\nRead the [release notes →](<${url}>)`);
+ console.log(
+ `${emoji} \`${name}@${version}\` ${singularlize(verb)}\nRead the [release notes →](<${url}>)`
+ );
} else {
console.log(`${emoji} Some ${descriptor} ${pluralize(verb)}\n`);
for (const { name, version, url } of packages) {
diff --git a/scripts/package.json b/scripts/package.json
index c66bd0f48..d0d04dfae 100644
--- a/scripts/package.json
+++ b/scripts/package.json
@@ -18,7 +18,7 @@
"esbuild": "0.14.25",
"globby": "^12.2.0",
"kleur": "^4.1.4",
- "svelte": "^3.46.4",
+ "svelte": "^3.46.6",
"tar": "^6.1.11"
}
}
diff --git a/scripts/stats/index.js b/scripts/stats/index.js
index 435bb5c56..659df2f2b 100644
--- a/scripts/stats/index.js
+++ b/scripts/stats/index.js
@@ -78,12 +78,21 @@ export async function run() {
per_page: 100,
since: twentyFourHoursAgo.toISOString(),
});
- const issuesLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && !iss.pull_request);
- const pullsLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && iss.pull_request);
+ const issuesLastTwentyFourHours = allIssuesLastTwentyFourHours.filter(
+ (iss) => new Date(iss.created_at) > twentyFourHoursAgo && !iss.pull_request
+ );
+ const pullsLastTwentyFourHours = allIssuesLastTwentyFourHours.filter(
+ (iss) => new Date(iss.created_at) > twentyFourHoursAgo && iss.pull_request
+ );
const entry = [
// Date (Human Readable)
- `"${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}"`,
+ `"${new Date().toLocaleDateString('en-US', {
+ weekday: 'long',
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ })}"`,
// Commits in last 24 hours
(await countCommits(twentyFourHoursAgo)).length,
// New Issues(All) in last 24 hours
@@ -103,7 +112,8 @@ export async function run() {
// Bugs: Needs Triage
(await countCards(COLUMN_ID_BUGS_NEEDS_TRIAGE)).length,
// Bugs: Accepted
- (await countCards(COLUMN_ID_BUGS_ACCEPTED)).length + (await countCards(COLUMN_ID_BUGS_PRIORITIZED)).length,
+ (await countCards(COLUMN_ID_BUGS_ACCEPTED)).length +
+ (await countCards(COLUMN_ID_BUGS_PRIORITIZED)).length,
// RFC: In Progress
0, // (await countCards(COLUMN_ID_RFCS_IN_PROGRESS)).length,
// RFC: Accepted
diff --git a/scripts/stats/stats.csv b/scripts/stats/stats.csv
index 7ab3641a8..dcf1654ca 100644
--- a/scripts/stats/stats.csv
+++ b/scripts/stats/stats.csv
@@ -1,4 +1,6 @@
Date,Commits (24hr),Issues (24hr),Issues:BUG (24hr),Issues:RFC (24hr),Issues:DOC (24hr),PRs (24hr),Open PRs,Open Issues,Bugs: Needs Triage,Bugs: Accepted,RFC: In Progress,RFC: Accepted,Date (ISO)
+"Saturday, April 2, 2022",5,0,0,0,0,4,8,88,42,40,0,0,"2022-04-02T12:01:53.880Z"
+"Friday, April 1, 2022",13,0,0,0,0,7,7,90,43,41,0,0,"2022-04-01T12:04:00.672Z"
"Thursday, March 31, 2022",6,4,4,0,0,6,10,93,46,41,0,0,"2022-03-31T12:02:11.044Z"
"Wednesday, March 30, 2022",9,2,2,0,0,10,10,90,43,41,0,0,"2022-03-30T12:02:39.303Z"
"Tuesday, March 29, 2022",19,8,8,0,0,9,5,88,41,41,0,0,"2022-03-29T12:06:39.897Z"
diff --git a/scripts/utils/svelte-plugin.js b/scripts/utils/svelte-plugin.js
index 29e60c2d5..4bbd8cdaf 100644
--- a/scripts/utils/svelte-plugin.js
+++ b/scripts/utils/svelte-plugin.js
@@ -26,7 +26,12 @@ const handleLoad = async (args, generate, { isDev }) => {
let { js, warnings } = compile(source, { ...compileOptions, filename });
let contents = js.code + `\n//# sourceMappingURL=` + js.map.toUrl();
- return { loader: 'js', contents, resolveDir: dirname(path), warnings: warnings.map((w) => convertMessage(w)) };
+ return {
+ loader: 'js',
+ contents,
+ resolveDir: dirname(path),
+ warnings: warnings.map((w) => convertMessage(w)),
+ };
} catch (e) {
return { errors: [convertMessage(e)] };
}
@@ -54,8 +59,12 @@ export default function sveltePlugin({ isDev = false }) {
};
}
});
- build.onLoad({ filter: /.*/, namespace: 'svelte:client' }, (args) => handleLoad(args, 'dom', { isDev }));
- build.onLoad({ filter: /.*/, namespace: 'svelte:server' }, (args) => handleLoad(args, 'ssr', { isDev }));
+ build.onLoad({ filter: /.*/, namespace: 'svelte:client' }, (args) =>
+ handleLoad(args, 'dom', { isDev })
+ );
+ build.onLoad({ filter: /.*/, namespace: 'svelte:server' }, (args) =>
+ handleLoad(args, 'ssr', { isDev })
+ );
},
};
}