Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining deprecated APIs #9263

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/green-parrots-brake.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions .changeset/little-beers-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/markdoc': minor
---

Removes internal `propagators` handling for Astro 3
5 changes: 5 additions & 0 deletions .changeset/slimy-jeans-peel.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 2 additions & 6 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 0 additions & 2 deletions packages/astro/src/core/build/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,7 +17,6 @@ import { pluginSSR, pluginSSRSplit } from './plugin-ssr.js';

export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
register(pluginComponentEntry(internals));
register(pluginAliasResolve(internals));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a silent change that's not documented in the changesets as it's fixed from a Vite 5 upgrade. Users shouldn't notice importing components with aliases not working.

register(pluginAnalyzer(options, internals));
register(pluginInternals(internals));
register(pluginManifest(options, internals));
Expand Down
64 changes: 0 additions & 64 deletions packages/astro/src/core/build/plugins/plugin-alias-resolve.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export const InvalidGetStaticPathsReturn = {

/**
* @docs
* @deprecated Deprecated since Astro 4.0. The RSS helper no longer exists with an error fallback.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

* @see
* - [RSS Guide](https://docs.astro.build/en/guides/rss/)
* @description
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/src/core/render/route-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 0 additions & 9 deletions packages/astro/src/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions packages/astro/src/vite-plugin-astro-server/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 0 additions & 10 deletions packages/astro/src/vite-plugin-inject-env-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/test/units/dev/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
});
Expand Down
5 changes: 1 addition & 4 deletions packages/integrations/markdoc/components/TreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
2 changes: 0 additions & 2 deletions packages/integrations/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 0 additions & 18 deletions packages/integrations/vercel/src/edge/throw.ts

This file was deleted.