-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Remove deprecated APIs #5707
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 deprecated APIs #5707
Changes from all commits
7dbc260
6346ee6
dc79907
92e7f7e
17efccd
b27537d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| '@astrojs/cloudflare': major | ||
| '@astrojs/deno': major | ||
| '@astrojs/image': minor | ||
| '@astrojs/netlify': major | ||
| '@astrojs/node': major | ||
| '@astrojs/vercel': major | ||
| --- | ||
|
|
||
| Remove `astro:build:start` backwards compatibility code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Remove deprecated `Astro` global APIs, including `Astro.resolve`, `Astro.fetchContent`, and `Astro.canonicalURL`. | ||
|
|
||
| #### `Astro.resolve` | ||
|
|
||
| You can resolve asset paths using `import` instead. For example: | ||
|
|
||
| ```astro | ||
| --- | ||
| import 'style.css' | ||
| import imageUrl from './image.png' | ||
| --- | ||
|
|
||
| <img src={imageUrl} /> | ||
| ``` | ||
|
|
||
| See the [v0.25 migration guide](https://docs.astro.build/en/migrate/#deprecated-astroresolve) for more information. | ||
|
|
||
| #### `Astro.fetchContent` | ||
|
|
||
| Use `Astro.glob` instead to fetch markdown files, or migrate to the [Content Collections](https://docs.astro.build/en/guides/content-collections/) feature. | ||
|
|
||
| ```js | ||
| let allPosts = await Astro.glob('./posts/*.md'); | ||
| ``` | ||
|
|
||
| #### `Astro.canonicalURL` | ||
|
|
||
| Use `Astro.url` instead to construct the canonical URL. | ||
|
|
||
| ```js | ||
| const canonicalURL = new URL(Astro.url.pathname, Astro.site); | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Remove `buildConfig` option parameter from integration `astro:build:start` hook in favour of the `build.config` option in the `astro:config:setup` hook. | ||
|
|
||
| ```js | ||
| export default function myIntegration() { | ||
| return { | ||
| name: 'my-integration', | ||
| hooks: { | ||
| 'astro:config:setup': ({ updateConfig }) => { | ||
| updateConfig({ | ||
| build: { | ||
| client: '...', | ||
| server: '...', | ||
| serverEntry: '...', | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,6 @@ | ||
| import type { AstroGlobalPartial } from '../../@types/astro'; | ||
| import { ASTRO_VERSION } from '../../core/constants.js'; | ||
|
|
||
| /** Create the Astro.fetchContent() runtime function. */ | ||
| function createDeprecatedFetchContentFn() { | ||
| return () => { | ||
| throw new Error('Deprecated: Astro.fetchContent() has been replaced with Astro.glob().'); | ||
| }; | ||
| } | ||
|
|
||
| /** Create the Astro.glob() runtime function. */ | ||
| function createAstroGlobFn() { | ||
| const globHandler = (importMetaGlobResult: Record<string, any>, globValue: () => any) => { | ||
|
|
@@ -25,29 +18,15 @@ function createAstroGlobFn() { | |
|
|
||
| // This is used to create the top-level Astro global; the one that you can use | ||
| // Inside of getStaticPaths. | ||
| // TODO: remove `_filePathname` and `_projectRootStr` from the compiler | ||
| export function createAstro( | ||
| filePathname: string, | ||
| _site: string | undefined, | ||
| projectRootStr: string | ||
| _filePathname: string, | ||
| site: string | undefined, | ||
| _projectRootStr: string | ||
| ): AstroGlobalPartial { | ||
| const site = _site ? new URL(_site) : undefined; | ||
| const referenceURL = new URL(filePathname, `http://localhost`); | ||
| const projectRoot = new URL(projectRootStr); | ||
| return { | ||
| site, | ||
| site: site ? new URL(site) : undefined, | ||
| generator: `Astro v${ASTRO_VERSION}`, | ||
| fetchContent: createDeprecatedFetchContentFn(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
RIP... |
||
| glob: createAstroGlobFn(), | ||
| // INVESTIGATE is there a use-case for multi args? | ||
| // TODO remove in 2.0 | ||
| resolve(...segments: string[]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah |
||
| let resolved = segments.reduce((u, segment) => new URL(segment, u), referenceURL).pathname; | ||
| // When inside of project root, remove the leading path so you are | ||
| // left with only `/src/images/tower.png` | ||
| if (resolved.startsWith(projectRoot.pathname)) { | ||
| resolved = '/' + resolved.slice(projectRoot.pathname.length); | ||
| } | ||
| return resolved; | ||
| }, | ||
| }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.