diff options
Diffstat (limited to 'packages')
72 files changed, 240 insertions, 92 deletions
diff --git a/packages/astro-rss/src/util.ts b/packages/astro-rss/src/util.ts index 0dad6b239..7218cc934 100644 --- a/packages/astro-rss/src/util.ts +++ b/packages/astro-rss/src/util.ts @@ -1,10 +1,8 @@ -import npath from 'path-browserify'; - /** Normalize URL to its canonical form */ export function createCanonicalURL(url: string, base?: string): URL { let pathname = url.replace(/\/index.html$/, ''); // index.html is not canonical pathname = pathname.replace(/\/1\/?$/, ''); // neither is a trailing /1/ (impl. detail of collections) - if (!npath.extname(pathname)) pathname = pathname.replace(/(\/+)?$/, '/'); // add trailing slash if there’s no extension + if (!getUrlExtension(url)) pathname = pathname.replace(/(\/+)?$/, '/'); // add trailing slash if there’s no extension pathname = pathname.replace(/\/+/g, '/'); // remove duplicate slashes (URL() won’t) return new URL(pathname, base); } @@ -17,3 +15,9 @@ export function isValidURL(url: string): boolean { } catch (e) {} return false; } + +function getUrlExtension(url: string) { + const lastDot = url.lastIndexOf('.'); + const lastSlash = url.lastIndexOf('/'); + return lastDot > lastSlash ? url.slice(lastDot + 1) : ''; +} diff --git a/packages/astro/e2e/fixtures/astro-component/astro.config.mjs b/packages/astro/e2e/fixtures/astro-component/astro.config.mjs index 882e6515a..44371fc32 100644 --- a/packages/astro/e2e/fixtures/astro-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/astro-component/astro.config.mjs @@ -1,4 +1,7 @@ import { defineConfig } from 'astro/config'; +import preact from '@astrojs/preact' // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + integrations: [preact()] +}); diff --git a/packages/astro/e2e/fixtures/astro-component/package.json b/packages/astro/e2e/fixtures/astro-component/package.json index 33a377834..a994d4936 100644 --- a/packages/astro/e2e/fixtures/astro-component/package.json +++ b/packages/astro/e2e/fixtures/astro-component/package.json @@ -3,6 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*" + "@astrojs/preact": "^1.1.0", + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/e2e/fixtures/error-cyclic/package.json b/packages/astro/e2e/fixtures/error-cyclic/package.json index 46cce7a02..a1c170e71 100644 --- a/packages/astro/e2e/fixtures/error-cyclic/package.json +++ b/packages/astro/e2e/fixtures/error-cyclic/package.json @@ -3,7 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "@astrojs/preact": "workspace:*" + "preact": "^10.11.0" } } diff --git a/packages/astro/e2e/fixtures/errors/package.json b/packages/astro/e2e/fixtures/errors/package.json index 1821e074f..cbcab17d3 100644 --- a/packages/astro/e2e/fixtures/errors/package.json +++ b/packages/astro/e2e/fixtures/errors/package.json @@ -3,13 +3,17 @@ "version": "0.0.0", "private": true, "dependencies": { - "@astrojs/react": "workspace:*", "@astrojs/preact": "workspace:*", + "@astrojs/react": "workspace:*", "@astrojs/solid-js": "workspace:*", "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", + "preact": "^10.11.0", "react": "^18.1.0", - "react-dom": "^18.1.0" + "react-dom": "^18.1.0", + "solid-js": "^1.5.6", + "svelte": "^3.50.1", + "vue": "^3.2.39" } } diff --git a/packages/astro/e2e/fixtures/hydration-race/package.json b/packages/astro/e2e/fixtures/hydration-race/package.json index ee28e25f9..2d2ca0673 100644 --- a/packages/astro/e2e/fixtures/hydration-race/package.json +++ b/packages/astro/e2e/fixtures/hydration-race/package.json @@ -7,7 +7,8 @@ "build": "astro build" }, "dependencies": { + "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "@astrojs/preact": "workspace:*" + "preact": "^10.11.0" } } diff --git a/packages/astro/e2e/fixtures/solid-component/package.json b/packages/astro/e2e/fixtures/solid-component/package.json index 1ed5a5742..aee1bddab 100644 --- a/packages/astro/e2e/fixtures/solid-component/package.json +++ b/packages/astro/e2e/fixtures/solid-component/package.json @@ -3,11 +3,9 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "@astrojs/mdx": "workspace:*" - }, - "devDependencies": { - "solid-js": "^1.4.3" + "solid-js": "^1.5.5" } } diff --git a/packages/astro/e2e/fixtures/tailwindcss/package.json b/packages/astro/e2e/fixtures/tailwindcss/package.json index f06e3ea91..6c7e4eb64 100644 --- a/packages/astro/e2e/fixtures/tailwindcss/package.json +++ b/packages/astro/e2e/fixtures/tailwindcss/package.json @@ -3,7 +3,10 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/tailwind": "workspace:*", "astro": "workspace:*", - "@astrojs/tailwind": "workspace:*" + "autoprefixer": "^10.4.7", + "postcss": "^8.4.14", + "tailwindcss": "^3.0.24" } } diff --git a/packages/astro/e2e/fixtures/vue-component/package.json b/packages/astro/e2e/fixtures/vue-component/package.json index 206bb68ca..a0411f31f 100644 --- a/packages/astro/e2e/fixtures/vue-component/package.json +++ b/packages/astro/e2e/fixtures/vue-component/package.json @@ -3,8 +3,9 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "@astrojs/mdx": "workspace:*" + "vue": "^3.2.39" } } diff --git a/packages/astro/package.json b/packages/astro/package.json index 709e5cd9e..0792f118a 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -164,11 +164,13 @@ "@types/debug": "^4.1.7", "@types/diff": "^5.0.2", "@types/estree": "^0.0.51", + "@types/hast": "^2.3.4", "@types/mime": "^2.0.3", "@types/mocha": "^9.1.1", "@types/parse5": "^6.0.3", "@types/path-browserify": "^1.0.0", "@types/prettier": "^2.6.3", + "@types/prompts": "^2.0.14", "@types/resolve": "^1.20.2", "@types/rimraf": "^3.0.2", "@types/send": "^0.17.1", @@ -178,8 +180,14 @@ "chai": "^4.3.6", "cheerio": "^1.0.0-rc.11", "mocha": "^9.2.2", + "node-fetch": "^3.2.5", + "rehype-autolink-headings": "^6.1.1", + "rehype-slug": "^5.0.1", + "rehype-toc": "^3.0.2", + "remark-code-titles": "^0.1.2", "sass": "^1.52.2", - "srcset-parse": "^1.1.0" + "srcset-parse": "^1.1.0", + "unified": "^10.1.2" }, "engines": { "node": "^14.18.0 || >=16.12.0", diff --git a/packages/astro/playwright.config.js b/packages/astro/playwright.config.js index 0e7cbf659..10a5c2023 100644 --- a/packages/astro/playwright.config.js +++ b/packages/astro/playwright.config.js @@ -1,4 +1,7 @@ -import { devices } from '@playwright/test'; +// NOTE: Sometimes, tests fail with `TypeError: process.stdout.clearLine is not a function` +// for some reason. This comes from Vite, and is conditionally called based on `isTTY`. +// We set it to false here to skip this odd behavior. +process.stdout.isTTY = false; const config = { testMatch: 'e2e/*.test.js', diff --git a/packages/astro/src/core/config/config.ts b/packages/astro/src/core/config/config.ts index a5c8faa14..bbaeee186 100644 --- a/packages/astro/src/core/config/config.ts +++ b/packages/astro/src/core/config/config.ts @@ -263,6 +263,12 @@ async function tryLoadConfig( optimizeDeps: { entries: [] }, clearScreen: false, appType: 'custom', + // NOTE: Vite doesn't externalize linked packages by default. During testing locally, + // these dependencies trip up Vite's dev SSR transform. In the future, we should + // avoid `vite.createServer` and use `loadConfigFromFile` instead. + ssr: { + external: ['@astrojs/mdx', '@astrojs/react'], + }, }); try { const mod = await viteServer.ssrLoadModule(configPath); diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 9c4757f44..bf7033c0e 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -130,6 +130,10 @@ export async function createVite( }, ssr: { noExternal: [...getSsrNoExternalDeps(settings.config.root), ...thirdPartyAstroPackages], + // shiki is imported by Code.astro, which is no-externalized (processed by Vite). + // However, shiki's deps are in CJS and trips up Vite's dev SSR transform, externalize + // shiki to load it with node instead. + external: mode === 'dev' ? ['shiki'] : [], }, }; diff --git a/packages/astro/test/api-routes.test.js b/packages/astro/test/api-routes.test.js index a911de332..ba229c095 100644 --- a/packages/astro/test/api-routes.test.js +++ b/packages/astro/test/api-routes.test.js @@ -1,8 +1,5 @@ import { expect } from 'chai'; -import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -import * as fs from 'fs'; -import { FormData, File } from 'node-fetch'; describe('API routes', () => { /** @type {import('./test-utils').Fixture} */ diff --git a/packages/astro/test/fixtures/0-css/package.json b/packages/astro/test/fixtures/0-css/package.json index ad5f5d825..bec81c0fb 100644 --- a/packages/astro/test/fixtures/0-css/package.json +++ b/packages/astro/test/fixtures/0-css/package.json @@ -8,6 +8,8 @@ "@astrojs/vue": "workspace:*", "astro": "workspace:*", "react": "^18.1.0", - "react-dom": "^18.1.0" + "react-dom": "^18.1.0", + "svelte": "^3.48.0", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/alias-tsconfig/package.json b/packages/astro/test/fixtures/alias-tsconfig/package.json index 0217d35fe..61e7fb4cb 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/alias/package.json b/packages/astro/test/fixtures/alias/package.json index 1390fe040..c3f6f56d8 100644 --- a/packages/astro/test/fixtures/alias/package.json +++ b/packages/astro/test/fixtures/alias/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/astro-basic/package.json b/packages/astro/test/fixtures/astro-basic/package.json index f9aba8565..a63125658 100644 --- a/packages/astro/test/fixtures/astro-basic/package.json +++ b/packages/astro/test/fixtures/astro-basic/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/astro-children/package.json b/packages/astro/test/fixtures/astro-children/package.json index 2b1ccec4c..0ba89d0a9 100644 --- a/packages/astro/test/fixtures/astro-children/package.json +++ b/packages/astro/test/fixtures/astro-children/package.json @@ -6,6 +6,9 @@ "@astrojs/preact": "workspace:*", "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0", + "svelte": "^3.48.0", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/astro-client-only/package.json b/packages/astro/test/fixtures/astro-client-only/package.json index 69bef83c6..219a1a6a7 100644 --- a/packages/astro/test/fixtures/astro-client-only/package.json +++ b/packages/astro/test/fixtures/astro-client-only/package.json @@ -3,11 +3,12 @@ "version": "0.0.0", "private": true, "dependencies": { - "@astrojs/svelte": "workspace:*", "@astrojs/react": "workspace:*", + "@astrojs/svelte": "workspace:*", + "@test/astro-client-only-pkg": "file:./pkg", "astro": "workspace:*", "react": "^18.1.0", "react-dom": "^18.1.0", - "@test/astro-client-only-pkg": "file:./pkg" + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/astro-dynamic/package.json b/packages/astro/test/fixtures/astro-dynamic/package.json index c9c8c194a..844513ebf 100644 --- a/packages/astro/test/fixtures/astro-dynamic/package.json +++ b/packages/astro/test/fixtures/astro-dynamic/package.json @@ -7,6 +7,7 @@ "@astrojs/svelte": "workspace:*", "astro": "workspace:*", "react": "^18.1.0", - "react-dom": "^18.1.0" + "react-dom": "^18.1.0", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/astro-envs/package.json b/packages/astro/test/fixtures/astro-envs/package.json index 4309d0833..a90a9c01c 100644 --- a/packages/astro/test/fixtures/astro-envs/package.json +++ b/packages/astro/test/fixtures/astro-envs/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/vue": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/astro-expr/package.json b/packages/astro/test/fixtures/astro-expr/package.json index 491e6cdaf..31ecdeb13 100644 --- a/packages/astro/test/fixtures/astro-expr/package.json +++ b/packages/astro/test/fixtures/astro-expr/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/astro-fallback/package.json b/packages/astro/test/fixtures/astro-fallback/package.json index 71b110f11..31e7941ed 100644 --- a/packages/astro/test/fixtures/astro-fallback/package.json +++ b/packages/astro/test/fixtures/astro-fallback/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/before-hydration/package.json b/packages/astro/test/fixtures/before-hydration/package.json index 70e0c684d..a4994e2d1 100644 --- a/packages/astro/test/fixtures/before-hydration/package.json +++ b/packages/astro/test/fixtures/before-hydration/package.json @@ -1,7 +1,8 @@ { "name": "@test/before-hydration", "dependencies": { + "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "@astrojs/preact": "workspace:*" + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/component-library-shared/package.json b/packages/astro/test/fixtures/component-library-shared/package.json index a30f0d20f..f5c344316 100644 --- a/packages/astro/test/fixtures/component-library-shared/package.json +++ b/packages/astro/test/fixtures/component-library-shared/package.json @@ -16,5 +16,9 @@ ], "devDependencies": { "astro": "workspace:*" + }, + "dependencies": { + "preact": "^10.11.0", + "react": "^18.2.0" } } diff --git a/packages/astro/test/fixtures/entry-file-names/package.json b/packages/astro/test/fixtures/entry-file-names/package.json index 760acaedb..392886491 100644 --- a/packages/astro/test/fixtures/entry-file-names/package.json +++ b/packages/astro/test/fixtures/entry-file-names/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/fetch/package.json b/packages/astro/test/fixtures/fetch/package.json index 7527db97a..39d0a4e86 100644 --- a/packages/astro/test/fixtures/fetch/package.json +++ b/packages/astro/test/fixtures/fetch/package.json @@ -6,6 +6,9 @@ "@astrojs/preact": "workspace:*", "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0", + "svelte": "^3.48.0", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/hydration-race/package.json b/packages/astro/test/fixtures/hydration-race/package.json index 57882c32b..4b97e86f6 100644 --- a/packages/astro/test/fixtures/hydration-race/package.json +++ b/packages/astro/test/fixtures/hydration-race/package.json @@ -7,7 +7,8 @@ "build": "astro build" }, "dependencies": { + "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "@astrojs/preact": "workspace:*" + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/large-array/package.json b/packages/astro/test/fixtures/large-array/package.json index c8e001365..b5061ebf5 100644 --- a/packages/astro/test/fixtures/large-array/package.json +++ b/packages/astro/test/fixtures/large-array/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/solid-js": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "solid-js": "^1.5.6" } } diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json index e5a54cf7c..ba6bd41cf 100644 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json +++ b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json @@ -5,6 +5,8 @@ "dependencies": { "@astrojs/preact": "workspace:*", "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/lit-element/package.json b/packages/astro/test/fixtures/lit-element/package.json index cfd45e9dc..5a84713a9 100644 --- a/packages/astro/test/fixtures/lit-element/package.json +++ b/packages/astro/test/fixtures/lit-element/package.json @@ -4,6 +4,8 @@ "private": true, "dependencies": { "@astrojs/lit": "workspace:*", - "astro": "workspace:*" + "@webcomponents/template-shadowroot": "^0.1.0", + "astro": "workspace:*", + "lit": "^2.2.5" } } diff --git a/packages/astro/test/fixtures/postcss/package.json b/packages/astro/test/fixtures/postcss/package.json index 417914c12..fcb30c06f 100644 --- a/packages/astro/test/fixtures/postcss/package.json +++ b/packages/astro/test/fixtures/postcss/package.json @@ -8,7 +8,10 @@ "@astrojs/vue": "workspace:*", "astro": "workspace:*", "autoprefixer": "^10.4.7", - "postcss": "^8.4.14" + "postcss": "^8.4.14", + "solid-js": "^1.5.6", + "svelte": "^3.48.0", + "vue": "^3.2.39" }, "devDependencies": { "postcss-preset-env": "^7.7.1" diff --git a/packages/astro/test/fixtures/preact-component/package.json b/packages/astro/test/fixtures/preact-component/package.json index a95de2de8..2cb473f69 100644 --- a/packages/astro/test/fixtures/preact-component/package.json +++ b/packages/astro/test/fixtures/preact-component/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/react-and-solid/package.json b/packages/astro/test/fixtures/react-and-solid/package.json index 0ec8ac57e..228c39ea7 100644 --- a/packages/astro/test/fixtures/react-and-solid/package.json +++ b/packages/astro/test/fixtures/react-and-solid/package.json @@ -1,8 +1,11 @@ { "name": "@test/react-and-solid", "dependencies": { - "astro": "workspace:*", "@astrojs/react": "workspace:*", - "@astrojs/solid-js": "workspace:*" + "@astrojs/solid-js": "workspace:*", + "astro": "workspace:*", + "react": "^18.2.0", + "react-dom": "^18.1.0", + "solid-js": "^1.5.6" } } diff --git a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json index 13a0cd46c..15ec0ab64 100644 --- a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json +++ b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json @@ -1,7 +1,8 @@ { "name": "@test/reexport-astro-containing-client-component", "dependencies": { + "@astrojs/preact": "workspace:", "astro": "workspace:", - "@astrojs/preact": "workspace:" + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/slots-preact/package.json b/packages/astro/test/fixtures/slots-preact/package.json index 240071578..d06192b83 100644 --- a/packages/astro/test/fixtures/slots-preact/package.json +++ b/packages/astro/test/fixtures/slots-preact/package.json @@ -5,6 +5,7 @@ "dependencies": { "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/slots-solid/package.json b/packages/astro/test/fixtures/slots-solid/package.json index be9555ace..82bd822cc 100644 --- a/packages/astro/test/fixtures/slots-solid/package.json +++ b/packages/astro/test/fixtures/slots-solid/package.json @@ -5,6 +5,7 @@ "dependencies": { "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "solid-js": "^1.5.6" } } diff --git a/packages/astro/test/fixtures/slots-svelte/package.json b/packages/astro/test/fixtures/slots-svelte/package.json index 95dbd239d..28d7022c6 100644 --- a/packages/astro/test/fixtures/slots-svelte/package.json +++ b/packages/astro/test/fixtures/slots-svelte/package.json @@ -5,6 +5,7 @@ "dependencies": { "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/slots-vue/package.json b/packages/astro/test/fixtures/slots-vue/package.json index 4e2e7dd06..7992ea476 100644 --- a/packages/astro/test/fixtures/slots-vue/package.json +++ b/packages/astro/test/fixtures/slots-vue/package.json @@ -5,6 +5,7 @@ "dependencies": { "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/solid-component/package.json b/packages/astro/test/fixtures/solid-component/package.json index 93148abca..6863b1978 100644 --- a/packages/astro/test/fixtures/solid-component/package.json +++ b/packages/astro/test/fixtures/solid-component/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/solid-js": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "solid-js": "^1.5.6" } } diff --git a/packages/astro/test/fixtures/ssr-env/package.json b/packages/astro/test/fixtures/ssr-env/package.json index f2d339704..7bb284752 100644 --- a/packages/astro/test/fixtures/ssr-env/package.json +++ b/packages/astro/test/fixtures/ssr-env/package.json @@ -3,7 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "@astrojs/preact": "workspace:*" + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/ssr-scripts/package.json b/packages/astro/test/fixtures/ssr-scripts/package.json index 2050dfbec..ac49fda2e 100644 --- a/packages/astro/test/fixtures/ssr-scripts/package.json +++ b/packages/astro/test/fixtures/ssr-scripts/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/static-build-frameworks/package.json b/packages/astro/test/fixtures/static-build-frameworks/package.json index d270ce205..89fd24ee4 100644 --- a/packages/astro/test/fixtures/static-build-frameworks/package.json +++ b/packages/astro/test/fixtures/static-build-frameworks/package.json @@ -3,9 +3,10 @@ "version": "0.0.0", "private": true, "dependencies": { - "@astrojs/react": "workspace:*", "@astrojs/preact": "workspace:*", + "@astrojs/react": "workspace:*", "astro": "workspace:*", + "preact": "^10.11.0", "react": "^18.1.0", "react-dom": "^18.1.0" } diff --git a/packages/astro/test/fixtures/static-build/package.json b/packages/astro/test/fixtures/static-build/package.json index 5796987a3..c57569171 100644 --- a/packages/astro/test/fixtures/static-build/package.json +++ b/packages/astro/test/fixtures/static-build/package.json @@ -4,6 +4,7 @@ "dependencies": { "@astrojs/preact": "workspace:*", "@test/static-build-pkg": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0" } } diff --git a/packages/astro/test/fixtures/svelte-component/package.json b/packages/astro/test/fixtures/svelte-component/package.json index e3d625aad..21d01c911 100644 --- a/packages/astro/test/fixtures/svelte-component/package.json +++ b/packages/astro/test/fixtures/svelte-component/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "svelte": "^3.48.0" } } diff --git a/packages/astro/test/fixtures/vue-component/package.json b/packages/astro/test/fixtures/vue-component/package.json index 2322b5d2d..1096ac057 100644 --- a/packages/astro/test/fixtures/vue-component/package.json +++ b/packages/astro/test/fixtures/vue-component/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@astrojs/vue": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "vue": "^3.2.39" } } diff --git a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json index e36b012a6..968047174 100644 --- a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json +++ b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json @@ -3,8 +3,10 @@ "version": "0.0.0", "private": true, "dependencies": { - "@astrojs/vue": "workspace:*", "@astrojs/svelte": "workspace:*", - "astro": "workspace:*" + "@astrojs/vue": "workspace:*", + "astro": "workspace:*", + "svelte": "^3.48.0", + "vue": "^3.2.39" } } diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 1b018167d..b3745557c 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -35,6 +35,9 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "cheerio": "^1.0.0-rc.11", + "mocha": "^9.2.2", "wrangler": "^2.0.23" } } diff --git a/packages/integrations/image/package.json b/packages/integrations/image/package.json index 62d302003..e1db1fe53 100644 --- a/packages/integrations/image/package.json +++ b/packages/integrations/image/package.json @@ -45,14 +45,29 @@ "@altano/tiny-async-pool": "^1.0.2", "image-size": "^1.0.2", "magic-string": "^0.25.9", - "mime": "^3.0.0" + "mime": "^3.0.0", + "slash": "^4.0.0" }, "devDependencies": { + "@types/mime": "^2.0.3", "@types/sharp": "^0.30.5", "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "cheerio": "^1.0.0-rc.11", "kleur": "^4.1.4", + "mocha": "^9.2.2", "rollup-plugin-copy": "^3.4.0", + "sharp": "^0.31.0", + "vite": "^3.0.0", "web-streams-polyfill": "^3.2.1" + }, + "peerDependencies": { + "sharp": ">=0.31.0" + }, + "peerDependenciesMeta": { + "sharp": { + "optional": true + } } } diff --git a/packages/integrations/lit/package.json b/packages/integrations/lit/package.json index b2f3bca73..9781094c7 100644 --- a/packages/integrations/lit/package.json +++ b/packages/integrations/lit/package.json @@ -38,7 +38,10 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", "cheerio": "^1.0.0-rc.11", + "lit": "^2.2.5", + "mocha": "^9.2.2", "sass": "^1.52.2" }, "peerDependencies": { diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index 840f9d621..6109cdc64 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -49,17 +49,21 @@ "devDependencies": { "@types/chai": "^4.3.1", "@types/estree": "^1.0.0", + "@types/github-slugger": "^1.3.0", "@types/mocha": "^9.1.1", "@types/yargs-parser": "^21.0.0", "astro": "workspace:*", "astro-scripts": "workspace:*", "chai": "^4.3.6", + "cheerio": "^1.0.0-rc.11", "linkedom": "^0.14.12", + "mdast-util-mdx": "^2.0.0", "mdast-util-to-string": "^3.1.0", "mocha": "^9.2.2", "reading-time": "^1.5.0", "remark-shiki-twoslash": "^3.1.0", - "remark-toc": "^8.0.1" + "remark-toc": "^8.0.1", + "vite": "^3.0.0" }, "engines": { "node": "^14.18.0 || >=16.12.0" diff --git a/packages/integrations/mdx/test/fixtures/mdx-namespace/package.json b/packages/integrations/mdx/test/fixtures/mdx-namespace/package.json index 7917f372d..68a482c21 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-namespace/package.json +++ b/packages/integrations/mdx/test/fixtures/mdx-namespace/package.json @@ -1,8 +1,10 @@ { "name": "@test/mdx-namespace", "dependencies": { - "astro": "workspace:*", "@astrojs/mdx": "workspace:*", - "@astrojs/react": "workspace:*" + "@astrojs/react": "workspace:*", + "astro": "workspace:*", + "react": "^18.2.0", + "react-dom": "^18.1.0" } } diff --git a/packages/integrations/mdx/test/fixtures/mdx-page/package.json b/packages/integrations/mdx/test/fixtures/mdx-page/package.json index c8f3217b3..7ff215df1 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-page/package.json +++ b/packages/integrations/mdx/test/fixtures/mdx-page/package.json @@ -1,7 +1,9 @@ { "name": "@test/mdx-page", "dependencies": { + "@astrojs/mdx": "workspace:*", "astro": "workspace:*", - "@astrojs/mdx": "workspace:*" + "react": "^18.2.0", + "react-dom": "^18.2.0" } } diff --git a/packages/integrations/mdx/test/fixtures/mdx-plus-react/package.json b/packages/integrations/mdx/test/fixtures/mdx-plus-react/package.json index 982f4c685..a4c8bb5f4 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-plus-react/package.json +++ b/packages/integrations/mdx/test/fixtures/mdx-plus-react/package.json @@ -1,8 +1,10 @@ { "name": "@test/mdx-plus-react", "dependencies": { - "astro": "workspace:*", "@astrojs/mdx": "workspace:*", - "@astrojs/react": "workspace:*" + "@astrojs/react": "workspace:*", + "astro": "workspace:*", + "react": "^18.2.0", + "react-dom": "^18.2.0" } } diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 23d144716..3818cc3e8 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -42,6 +42,10 @@ "@netlify/functions": "^1.0.0", "@types/node": "^14.18.20", "astro": "workspace:*", - "astro-scripts": "workspace:*" + "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "cheerio": "^1.0.0-rc.11", + "mocha": "^9.2.2", + "vite": "^3.0.0" } } diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 20bd2a32a..490384e27 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -34,6 +34,8 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "mocha": "^9.2.2", "node-mocks-http": "^1.11.0" } } diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index 88c603751..3a7a99856 100644 --- a/packages/integrations/preact/src/index.ts +++ b/packages/integrations/preact/src/index.ts @@ -52,17 +52,9 @@ function getCompatRenderer(development: boolean): AstroRenderer { function getViteConfiguration(compat?: boolean): ViteUserConfig { const viteConfig: ViteUserConfig = { optimizeDeps: { - include: [ - '@astrojs/preact/client.js', - 'preact', - 'preact/jsx-runtime', - 'preact-render-to-string', - ], + include: ['@astrojs/preact/client.js', 'preact', 'preact/jsx-runtime'], exclude: ['@astrojs/preact/server.js'], }, - ssr: { - external: ['preact-render-to-string'], - }, }; if (compat) { @@ -81,12 +73,9 @@ function getViteConfiguration(compat?: boolean): ViteUserConfig { dedupe: ['preact/compat', 'preact'], }; // noExternal React entrypoints to be bundled, resolved, and aliased by Vite - viteConfig.ssr!.noExternal = [ - 'react', - 'react-dom', - 'react-dom/test-utils', - 'react/jsx-runtime', - ]; + viteConfig.ssr = { + noExternal: ['react', 'react-dom', 'react-dom/test-utils', 'react/jsx-runtime'], + }; } return viteConfig; diff --git a/packages/integrations/prefetch/package.json b/packages/integrations/prefetch/package.json index 5575b3cd2..c15eb5eda 100644 --- a/packages/integrations/prefetch/package.json +++ b/packages/integrations/prefetch/package.json @@ -29,6 +29,7 @@ "test:match": "playwright test -g" }, "devDependencies": { + "@playwright/test": "^1.26.0", "@types/chai": "^4.3.1", "@types/chai-as-promised": "^7.1.5", "@types/mocha": "^9.1.1", diff --git a/packages/integrations/prefetch/playwright.config.js b/packages/integrations/prefetch/playwright.config.js index c8353201f..d9600393e 100644 --- a/packages/integrations/prefetch/playwright.config.js +++ b/packages/integrations/prefetch/playwright.config.js @@ -1,4 +1,7 @@ -import { devices } from '@playwright/test'; +// NOTE: Prefetch tests fail with `TypeError: process.stdout.clearLine is not a function` +// for some reason. This comes from Vite, and is conditionally called based on `isTTY`. +// We set it to false here to skip this odd behavior. +process.stdout.isTTY = false; const config = { testMatch: 'test/*.test.js', diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index fa66a1189..a55425b2f 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -39,6 +39,8 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "mocha": "^9.2.2", "xml2js": "0.4.23" } } diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 2d8fc9964..ed8bf4ebd 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -36,13 +36,13 @@ "@sveltejs/vite-plugin-svelte": "^1.0.1", "postcss-load-config": "^3.1.4", "svelte-preprocess": "^4.10.7", - "svelte2tsx": "^0.5.11", - "vite": "^3.0.0" + "svelte2tsx": "^0.5.11" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "svelte": "^3.48.0" + "svelte": "^3.48.0", + "vite": "^3.0.0" }, "peerDependencies": { "svelte": "^3.46.4" diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index 7ed14a1e3..6b2a6cdc3 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -34,7 +34,8 @@ }, "devDependencies": { "astro": "workspace:*", - "astro-scripts": "workspace:*" + "astro-scripts": "workspace:*", + "tailwindcss": "^3.0.24" }, "peerDependencies": { "tailwindcss": "^3.0.24" diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 72a05c0dd..b1323f360 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -49,6 +49,8 @@ }, "devDependencies": { "astro": "workspace:*", - "astro-scripts": "workspace:*" + "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "mocha": "^9.2.2" } } diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 283f029f4..efb18ca12 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -34,11 +34,12 @@ }, "dependencies": { "@vitejs/plugin-vue": "^3.0.0", - "vite": "^3.0.0" + "@vue/compiler-sfc": "^3.2.39" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "vite": "^3.0.0", "vue": "^3.2.37" }, "peerDependencies": { diff --git a/packages/markdown/component/package.json b/packages/markdown/component/package.json index b7878d027..8ba0b78b9 100644 --- a/packages/markdown/component/package.json +++ b/packages/markdown/component/package.json @@ -21,11 +21,16 @@ "test": "mocha --exit --timeout 20000" }, "devDependencies": { + "@types/mocha": "^9.1.1", "astro": "workspace:*", "chai": "^4.3.6", "cheerio": "^1.0.0-rc.11", + "github-slugger": "^1.4.0", "mocha": "^9.2.2", - "@types/mocha": "^9.1.1" + "rehype-autolink-headings": "^6.1.1", + "rehype-slug": "^5.0.1", + "rehype-toc": "^3.0.2", + "remark-code-titles": "^0.1.2" }, "keywords": [ "astro", diff --git a/packages/markdown/component/test/astro-markdown.test.js b/packages/markdown/component/test/astro-markdown.test.js index c0726d2ca..e5a1382a5 100644 --- a/packages/markdown/component/test/astro-markdown.test.js +++ b/packages/markdown/component/test/astro-markdown.test.js @@ -12,6 +12,8 @@ describe('Astro Markdown', () => { await fixture.build(); }); + // NOTE: This test uses legacy markdown, which requires `github-slugger` to be installed. + // This breaks in strict dependency installation, but since it's a legacy feature, ignore for now. it('Can load markdown pages with Astro', async () => { const html = await fixture.readFile('/post/index.html'); const $ = cheerio.load(html); diff --git a/packages/markdown/component/test/fixtures/astro-markdown-plugins/package.json b/packages/markdown/component/test/fixtures/astro-markdown-plugins/package.json index 4babf437a..77481c297 100644 --- a/packages/markdown/component/test/fixtures/astro-markdown-plugins/package.json +++ b/packages/markdown/component/test/fixtures/astro-markdown-plugins/package.json @@ -3,10 +3,11 @@ "version": "0.0.0", "private": true, "dependencies": { - "@astrojs/preact": "workspace:*", "@astrojs/markdown-component": "workspace:*", + "@astrojs/preact": "workspace:*", "astro": "workspace:*", "hast-util-select": "^5.0.2", + "preact": "^10.11.0", "rehype-slug": "^5.0.1" } } diff --git a/packages/markdown/component/test/fixtures/astro-markdown/package.json b/packages/markdown/component/test/fixtures/astro-markdown/package.json index a5864786e..8dec19e14 100644 --- a/packages/markdown/component/test/fixtures/astro-markdown/package.json +++ b/packages/markdown/component/test/fixtures/astro-markdown/package.json @@ -3,9 +3,11 @@ "version": "0.0.0", "private": true, "dependencies": { + "@astrojs/markdown-component": "workspace:*", "@astrojs/preact": "workspace:*", "@astrojs/svelte": "workspace:*", - "@astrojs/markdown-component": "workspace:*", - "astro": "workspace:*" + "astro": "workspace:*", + "preact": "^10.11.0", + "svelte": "^3.48.0" } } diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json index 6178bf014..36b702d93 100644 --- a/packages/markdown/remark/package.json +++ b/packages/markdown/remark/package.json @@ -30,6 +30,8 @@ "acorn-jsx": "^5.3.2", "github-slugger": "^1.4.0", "hast-util-to-html": "^8.0.3", + "import-meta-resolve": "^2.1.0", + "mdast-util-from-markdown": "^1.2.0", "mdast-util-mdx-expression": "^1.2.1", "mdast-util-mdx-jsx": "^1.2.0", "micromark-extension-mdx-expression": "^1.0.3", diff --git a/packages/markdown/remark/src/load-plugins.ts b/packages/markdown/remark/src/load-plugins.ts index c64d13543..37798db14 100644 --- a/packages/markdown/remark/src/load-plugins.ts +++ b/packages/markdown/remark/src/load-plugins.ts @@ -1,8 +1,21 @@ +import path from 'path'; +import { pathToFileURL } from 'url'; import * as unified from 'unified'; +import { resolve as importMetaResolve } from 'import-meta-resolve'; + +const cwdUrlStr = pathToFileURL(path.join(process.cwd(), 'package.json')).toString(); async function importPlugin(p: string | unified.Plugin): Promise<unified.Plugin> { if (typeof p === 'string') { - const importResult = await import(p); + // Try import from this package first + try { + const importResult = await import(p); + return importResult.default; + } catch {} + + // Try import from user project + const resolved = await importMetaResolve(p, cwdUrlStr); + const importResult = await import(resolved); return importResult.default; } diff --git a/packages/telemetry/package.json b/packages/telemetry/package.json index 6faa09098..ae9dbc612 100644 --- a/packages/telemetry/package.json +++ b/packages/telemetry/package.json @@ -36,10 +36,13 @@ "which-pm-runs": "^1.1.0" }, "devDependencies": { + "@types/debug": "^4.1.7", "@types/dlv": "^1.1.2", "@types/node": "^14.18.21", "@types/which-pm-runs": "^1.0.0", - "astro-scripts": "workspace:*" + "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "mocha": "^9.2.2" }, "engines": { "node": "^14.18.0 || >=16.12.0" |