summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2023-12-02 00:59:22 +0800
committerGravatar GitHub <noreply@github.com> 2023-12-02 00:59:22 +0800
commit3cbd8ea7534910e3beae396dcfa93ce87dcdd91f (patch)
tree8c46fc0ddf3cf49cec7ea04811b2488255dcbe31
parentac41820821b138d69f5c16effac243726e6ee439 (diff)
downloadastro-3cbd8ea7534910e3beae396dcfa93ce87dcdd91f.tar.gz
astro-3cbd8ea7534910e3beae396dcfa93ce87dcdd91f.tar.zst
astro-3cbd8ea7534910e3beae396dcfa93ce87dcdd91f.zip
Remove remaining deprecated APIs (#9263)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to '')
-rw-r--r--.changeset/green-parrots-brake.md10
-rw-r--r--.changeset/little-beers-sit.md5
-rw-r--r--.changeset/slimy-jeans-peel.md5
-rw-r--r--packages/astro/src/@types/astro.ts8
-rw-r--r--packages/astro/src/core/build/plugins/index.ts2
-rw-r--r--packages/astro/src/core/build/plugins/plugin-alias-resolve.ts64
-rw-r--r--packages/astro/src/core/errors/errors-data.ts1
-rw-r--r--packages/astro/src/core/render/route-cache.ts3
-rw-r--r--packages/astro/src/core/request.ts9
-rw-r--r--packages/astro/src/vite-plugin-astro-server/base.ts9
-rw-r--r--packages/astro/src/vite-plugin-inject-env-ts/index.ts10
-rw-r--r--packages/astro/test/units/dev/dev.test.js3
-rw-r--r--packages/integrations/markdoc/components/TreeNode.ts5
-rw-r--r--packages/integrations/vercel/package.json2
-rw-r--r--packages/integrations/vercel/src/edge/throw.ts18
15 files changed, 28 insertions, 126 deletions
diff --git a/.changeset/green-parrots-brake.md b/.changeset/green-parrots-brake.md
new file mode 100644
index 000000000..f2d9db4be
--- /dev/null
+++ b/.changeset/green-parrots-brake.md
@@ -0,0 +1,10 @@
+---
+'astro': major
+---
+
+Removes additional deprecated APIs:
+
+- The Astro preview server now returns a 404 status instead of a 301 redirect when requesting assets from the public directory without a base.
+- Removes special handling when referencing the `astro/client-image` type. You should use the `astro/client` type instead.
+- Removes deprecated built-in `rss` support in `getStaticPaths`. You should use `@astrojs/rss` instead.
+- Removes deprecated `Astro.request.params` support. You should use `Astro.params` instead.
diff --git a/.changeset/little-beers-sit.md b/.changeset/little-beers-sit.md
new file mode 100644
index 000000000..97dd63873
--- /dev/null
+++ b/.changeset/little-beers-sit.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/markdoc': minor
+---
+
+Removes internal `propagators` handling for Astro 3
diff --git a/.changeset/slimy-jeans-peel.md b/.changeset/slimy-jeans-peel.md
new file mode 100644
index 000000000..c4ba769e3
--- /dev/null
+++ b/.changeset/slimy-jeans-peel.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/vercel': major
+---
+
+Removes the deprecated `@astrojs/vercel/edge` export. You should use `@astrojs/vercel/serverless` instead with the `edgeMiddleware` option.
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts
index 82d44d5e5..8cb9a0f68 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/@types/astro.ts
@@ -1793,13 +1793,9 @@ export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
* getStaticPaths() options
*
* [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
- */ export interface GetStaticPathsOptions {
+ */
+export interface GetStaticPathsOptions {
paginate: PaginateFunction;
- /**
- * The RSS helper has been removed from getStaticPaths! Try the new @astrojs/rss package instead.
- * @see https://docs.astro.build/en/guides/rss/
- */
- rss(): never;
}
export type GetStaticPathsItem = {
diff --git a/packages/astro/src/core/build/plugins/index.ts b/packages/astro/src/core/build/plugins/index.ts
index 879f72210..9c1f9b550 100644
--- a/packages/astro/src/core/build/plugins/index.ts
+++ b/packages/astro/src/core/build/plugins/index.ts
@@ -1,7 +1,6 @@
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
import { astroHeadBuildPlugin } from '../../../vite-plugin-head/index.js';
import type { AstroBuildPluginContainer } from '../plugin.js';
-import { pluginAliasResolve } from './plugin-alias-resolve.js';
import { pluginAnalyzer } from './plugin-analyzer.js';
import { pluginChunks } from './plugin-chunks.js';
import { pluginComponentEntry } from './plugin-component-entry.js';
@@ -18,7 +17,6 @@ import { pluginSSR, pluginSSRSplit } from './plugin-ssr.js';
export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
register(pluginComponentEntry(internals));
- register(pluginAliasResolve(internals));
register(pluginAnalyzer(options, internals));
register(pluginInternals(internals));
register(pluginManifest(options, internals));
diff --git a/packages/astro/src/core/build/plugins/plugin-alias-resolve.ts b/packages/astro/src/core/build/plugins/plugin-alias-resolve.ts
deleted file mode 100644
index 6fb09acf8..000000000
--- a/packages/astro/src/core/build/plugins/plugin-alias-resolve.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import type { Alias, Plugin as VitePlugin } from 'vite';
-import type { BuildInternals } from '../internal.js';
-import type { AstroBuildPlugin } from '../plugin.js';
-
-/**
- * `@rollup/plugin-alias` doesn't resolve aliases in Rollup input by default. This plugin fixes it
- * with a partial fork of it's resolve function. https://github.com/rollup/plugins/blob/master/packages/alias/src/index.ts
- * When https://github.com/rollup/plugins/pull/1402 is merged, we can remove this plugin.
- */
-export function vitePluginAliasResolve(internals: BuildInternals): VitePlugin {
- let aliases: Alias[];
-
- return {
- name: '@astro/plugin-alias-resolve',
- enforce: 'pre',
- configResolved(config) {
- aliases = config.resolve.alias;
- },
- async resolveId(id, importer, opts) {
- if (
- !importer &&
- (internals.discoveredHydratedComponents.has(id) ||
- internals.discoveredClientOnlyComponents.has(id))
- ) {
- const matchedEntry = aliases.find((entry) => matches(entry.find, id));
- if (!matchedEntry) {
- return null;
- }
-
- const updatedId = id.replace(matchedEntry.find, matchedEntry.replacement);
-
- return this.resolve(updatedId, importer, Object.assign({ skipSelf: true }, opts)).then(
- (resolved) => resolved || { id: updatedId }
- );
- }
- },
- };
-}
-
-function matches(pattern: string | RegExp, importee: string) {
- if (pattern instanceof RegExp) {
- return pattern.test(importee);
- }
- if (importee.length < pattern.length) {
- return false;
- }
- if (importee === pattern) {
- return true;
- }
- return importee.startsWith(pattern + '/');
-}
-
-export function pluginAliasResolve(internals: BuildInternals): AstroBuildPlugin {
- return {
- targets: ['client'],
- hooks: {
- 'build:before': () => {
- return {
- vitePlugin: vitePluginAliasResolve(internals),
- };
- },
- },
- };
-}
diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts
index cf49c57c7..5c30495d6 100644
--- a/packages/astro/src/core/errors/errors-data.ts
+++ b/packages/astro/src/core/errors/errors-data.ts
@@ -292,6 +292,7 @@ export const InvalidGetStaticPathsReturn = {
/**
* @docs
+ * @deprecated Deprecated since Astro 4.0. The RSS helper no longer exists with an error fallback.
* @see
* - [RSS Guide](https://docs.astro.build/en/guides/rss/)
* @description
diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts
index 8aca230f4..4db5b75fd 100644
--- a/packages/astro/src/core/render/route-cache.ts
+++ b/packages/astro/src/core/render/route-cache.ts
@@ -59,9 +59,6 @@ export async function callGetStaticPaths({
// Q: Why the cast?
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
paginate: generatePaginateFunction(route) as PaginateFunction,
- rss() {
- throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
- },
});
validateGetStaticPathsResult(staticPaths, logger, route);
diff --git a/packages/astro/src/core/request.ts b/packages/astro/src/core/request.ts
index 6d55caa15..8bf52d11a 100644
--- a/packages/astro/src/core/request.ts
+++ b/packages/astro/src/core/request.ts
@@ -39,15 +39,6 @@ export function createRequest({
body,
});
- Object.defineProperties(request, {
- params: {
- get() {
- logger.warn('deprecated', `Astro.request.params has been moved to Astro.params`);
- return undefined;
- },
- },
- });
-
if (!ssr) {
// Warn when accessing headers in SSG mode
const _headers = request.headers;
diff --git a/packages/astro/src/vite-plugin-astro-server/base.ts b/packages/astro/src/vite-plugin-astro-server/base.ts
index e757515d7..68eeae21a 100644
--- a/packages/astro/src/vite-plugin-astro-server/base.ts
+++ b/packages/astro/src/vite-plugin-astro-server/base.ts
@@ -43,21 +43,18 @@ export function baseMiddleware(
}
// Check to see if it's in public and if so 404
- // TODO: Remove redirect, turn this warning into an error in Astro 4.0
const publicPath = new URL('.' + req.url, config.publicDir);
fs.stat(publicPath, (_err, stats) => {
if (stats) {
const expectedLocation = new URL('.' + url, devRootURL).pathname;
- logger.warn(
+ logger.error(
'router',
`Request URLs for ${bold(
'public/'
)} assets must also include your base. "${expectedLocation}" expected, but received "${url}".`
);
- res.writeHead(301, {
- Location: expectedLocation,
- });
- res.end();
+ const html = subpathNotUsedTemplate(devRoot, pathname);
+ return writeHtmlResponse(res, 404, html);
} else {
next();
}
diff --git a/packages/astro/src/vite-plugin-inject-env-ts/index.ts b/packages/astro/src/vite-plugin-inject-env-ts/index.ts
index 116b45e3c..855d3a2e0 100644
--- a/packages/astro/src/vite-plugin-inject-env-ts/index.ts
+++ b/packages/astro/src/vite-plugin-inject-env-ts/index.ts
@@ -50,16 +50,6 @@ export async function setUpEnvTs({
if (fs.existsSync(envTsPath)) {
let typesEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');
- // TODO: Remove this in 4.0, this code is only to help users migrate away from assets being experimental for a long time
- if (typesEnvContents.includes('types="astro/client-image"')) {
- typesEnvContents = typesEnvContents.replace(
- 'types="astro/client-image"',
- 'types="astro/client"'
- );
- await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8');
- logger.info('types', `Removed ${bold(envTsPathRelativetoRoot)} type declarations`);
- }
-
if (!fs.existsSync(dotAstroDir))
// Add `.astro` types reference if none exists
return;
diff --git a/packages/astro/test/units/dev/dev.test.js b/packages/astro/test/units/dev/dev.test.js
index 52fb203c3..9b713d62a 100644
--- a/packages/astro/test/units/dev/dev.test.js
+++ b/packages/astro/test/units/dev/dev.test.js
@@ -253,8 +253,7 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(301);
- expect(r.res.getHeader('location')).to.equal('/sub/test.txt');
+ expect(r.res.statusCode).to.equal(404);
}
);
});
diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts
index 01bd20d71..dce10f6cc 100644
--- a/packages/integrations/markdoc/components/TreeNode.ts
+++ b/packages/integrations/markdoc/components/TreeNode.ts
@@ -89,10 +89,7 @@ export const ComponentNode = createComponent({
);
// Let the runtime know that this component is being used.
- // `result.propagators` has been moved to `result._metadata.propagators`
- // TODO: remove this fallback in the next markdoc integration major
- const propagators = result._metadata.propagators || result.propagators;
- propagators.add({
+ result._metadata.propagators.add({
init() {
return headAndContent;
},
diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json
index 8e770376c..7b1359acc 100644
--- a/packages/integrations/vercel/package.json
+++ b/packages/integrations/vercel/package.json
@@ -17,8 +17,6 @@
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/vercel/",
"exports": {
- "./edge": "./dist/edge/throw.js",
- "./edge/entrypoint": "./dist/edge/throw.js",
"./serverless": "./dist/serverless/adapter.js",
"./serverless/entrypoint": "./dist/serverless/entrypoint.js",
"./static": "./dist/static/adapter.js",
diff --git a/packages/integrations/vercel/src/edge/throw.ts b/packages/integrations/vercel/src/edge/throw.ts
deleted file mode 100644
index 5041370e0..000000000
--- a/packages/integrations/vercel/src/edge/throw.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-const msg = `
-The Astro Vercel Edge adapter has been removed. We recommend switching to @astrojs/vercel/serverless and enabling Edge middleware.
-
-import { defineConfig } from 'astro/config';
-import vercel from '@astrojs/vercel/serverless';
-
-export default defineConfig({
- output: 'server',
- adapter: vercel({
- edgeMiddleware: true,
- })
-})
-`.trim();
-
-throw new Error(msg);
-
-// Make sure bundlers treat this as ESM.
-export default {};