Skip to content

Commit 3cbd8ea

Browse files
bluwysarah11918
andauthoredDec 1, 2023
Remove remaining deprecated APIs (#9263)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
1 parent ac41820 commit 3cbd8ea

File tree

15 files changed

+28
-126
lines changed

15 files changed

+28
-126
lines changed
 

‎.changeset/green-parrots-brake.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'astro': major
3+
---
4+
5+
Removes additional deprecated APIs:
6+
7+
- The Astro preview server now returns a 404 status instead of a 301 redirect when requesting assets from the public directory without a base.
8+
- Removes special handling when referencing the `astro/client-image` type. You should use the `astro/client` type instead.
9+
- Removes deprecated built-in `rss` support in `getStaticPaths`. You should use `@astrojs/rss` instead.
10+
- Removes deprecated `Astro.request.params` support. You should use `Astro.params` instead.

‎.changeset/little-beers-sit.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/markdoc': minor
3+
---
4+
5+
Removes internal `propagators` handling for Astro 3

‎.changeset/slimy-jeans-peel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/vercel': major
3+
---
4+
5+
Removes the deprecated `@astrojs/vercel/edge` export. You should use `@astrojs/vercel/serverless` instead with the `edgeMiddleware` option.

‎packages/astro/src/@types/astro.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1793,13 +1793,9 @@ export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
17931793
* getStaticPaths() options
17941794
*
17951795
* [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
1796-
*/ export interface GetStaticPathsOptions {
1796+
*/
1797+
export interface GetStaticPathsOptions {
17971798
paginate: PaginateFunction;
1798-
/**
1799-
* The RSS helper has been removed from getStaticPaths! Try the new @astrojs/rss package instead.
1800-
* @see https://docs.astro.build/en/guides/rss/
1801-
*/
1802-
rss(): never;
18031799
}
18041800

18051801
export type GetStaticPathsItem = {

‎packages/astro/src/core/build/plugins/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
22
import { astroHeadBuildPlugin } from '../../../vite-plugin-head/index.js';
33
import type { AstroBuildPluginContainer } from '../plugin.js';
4-
import { pluginAliasResolve } from './plugin-alias-resolve.js';
54
import { pluginAnalyzer } from './plugin-analyzer.js';
65
import { pluginChunks } from './plugin-chunks.js';
76
import { pluginComponentEntry } from './plugin-component-entry.js';
@@ -18,7 +17,6 @@ import { pluginSSR, pluginSSRSplit } from './plugin-ssr.js';
1817

1918
export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
2019
register(pluginComponentEntry(internals));
21-
register(pluginAliasResolve(internals));
2220
register(pluginAnalyzer(options, internals));
2321
register(pluginInternals(internals));
2422
register(pluginManifest(options, internals));

‎packages/astro/src/core/build/plugins/plugin-alias-resolve.ts

-64
This file was deleted.

‎packages/astro/src/core/errors/errors-data.ts

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export const InvalidGetStaticPathsReturn = {
292292

293293
/**
294294
* @docs
295+
* @deprecated Deprecated since Astro 4.0. The RSS helper no longer exists with an error fallback.
295296
* @see
296297
* - [RSS Guide](https://docs.astro.build/en/guides/rss/)
297298
* @description

‎packages/astro/src/core/render/route-cache.ts

-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ export async function callGetStaticPaths({
5959
// Q: Why the cast?
6060
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
6161
paginate: generatePaginateFunction(route) as PaginateFunction,
62-
rss() {
63-
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
64-
},
6562
});
6663

6764
validateGetStaticPathsResult(staticPaths, logger, route);

‎packages/astro/src/core/request.ts

-9
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ export function createRequest({
3939
body,
4040
});
4141

42-
Object.defineProperties(request, {
43-
params: {
44-
get() {
45-
logger.warn('deprecated', `Astro.request.params has been moved to Astro.params`);
46-
return undefined;
47-
},
48-
},
49-
});
50-
5142
if (!ssr) {
5243
// Warn when accessing headers in SSG mode
5344
const _headers = request.headers;

‎packages/astro/src/vite-plugin-astro-server/base.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,18 @@ export function baseMiddleware(
4343
}
4444

4545
// Check to see if it's in public and if so 404
46-
// TODO: Remove redirect, turn this warning into an error in Astro 4.0
4746
const publicPath = new URL('.' + req.url, config.publicDir);
4847
fs.stat(publicPath, (_err, stats) => {
4948
if (stats) {
5049
const expectedLocation = new URL('.' + url, devRootURL).pathname;
51-
logger.warn(
50+
logger.error(
5251
'router',
5352
`Request URLs for ${bold(
5453
'public/'
5554
)} assets must also include your base. "${expectedLocation}" expected, but received "${url}".`
5655
);
57-
res.writeHead(301, {
58-
Location: expectedLocation,
59-
});
60-
res.end();
56+
const html = subpathNotUsedTemplate(devRoot, pathname);
57+
return writeHtmlResponse(res, 404, html);
6158
} else {
6259
next();
6360
}

‎packages/astro/src/vite-plugin-inject-env-ts/index.ts

-10
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ export async function setUpEnvTs({
5050
if (fs.existsSync(envTsPath)) {
5151
let typesEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');
5252

53-
// TODO: Remove this in 4.0, this code is only to help users migrate away from assets being experimental for a long time
54-
if (typesEnvContents.includes('types="astro/client-image"')) {
55-
typesEnvContents = typesEnvContents.replace(
56-
'types="astro/client-image"',
57-
'types="astro/client"'
58-
);
59-
await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8');
60-
logger.info('types', `Removed ${bold(envTsPathRelativetoRoot)} type declarations`);
61-
}
62-
6353
if (!fs.existsSync(dotAstroDir))
6454
// Add `.astro` types reference if none exists
6555
return;

‎packages/astro/test/units/dev/dev.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ describe('dev container', () => {
253253
container.handle(r.req, r.res);
254254
await r.done;
255255

256-
expect(r.res.statusCode).to.equal(301);
257-
expect(r.res.getHeader('location')).to.equal('/sub/test.txt');
256+
expect(r.res.statusCode).to.equal(404);
258257
}
259258
);
260259
});

‎packages/integrations/markdoc/components/TreeNode.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ export const ComponentNode = createComponent({
8989
);
9090

9191
// Let the runtime know that this component is being used.
92-
// `result.propagators` has been moved to `result._metadata.propagators`
93-
// TODO: remove this fallback in the next markdoc integration major
94-
const propagators = result._metadata.propagators || result.propagators;
95-
propagators.add({
92+
result._metadata.propagators.add({
9693
init() {
9794
return headAndContent;
9895
},

‎packages/integrations/vercel/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
"bugs": "https://github.com/withastro/astro/issues",
1818
"homepage": "https://docs.astro.build/en/guides/integrations-guide/vercel/",
1919
"exports": {
20-
"./edge": "./dist/edge/throw.js",
21-
"./edge/entrypoint": "./dist/edge/throw.js",
2220
"./serverless": "./dist/serverless/adapter.js",
2321
"./serverless/entrypoint": "./dist/serverless/entrypoint.js",
2422
"./static": "./dist/static/adapter.js",

‎packages/integrations/vercel/src/edge/throw.ts

-18
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.