Skip to content

Commit 52209ca

Browse files
authored
[Content collections] Remove experimental flag (#5825)
* refactor: remove experimental.cc from core * chore: remove experimental flag from tests * fix: mock contentDir in remark tests * fix: check vfile.path in rel-image-error plugin * fix: move .astro/ excludes to all test/fixtures * fix: include test/**/fixtures in ignore * chore: changeset
1 parent 665a2c2 commit 52209ca

File tree

27 files changed

+58
-103
lines changed

27 files changed

+58
-103
lines changed

.changeset/thin-beers-drive.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'astro': major
3+
'@astrojs/mdx': major
4+
'@astrojs/markdown-remark': major
5+
---
6+
7+
Baseline the experimental `contentCollections` flag. You're free to remove this from your astro config!
8+
9+
```diff
10+
import { defineConfig } from 'astro/config';
11+
12+
export default defineConfig({
13+
- experimental: { contentCollections: true }
14+
})

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ packages/integrations/**/.netlify/
2424

2525
# exclude IntelliJ/WebStorm stuff
2626
.idea
27+
28+
# ignore content collection generated files
29+
packages/**/test/**/fixtures/**/.astro/
30+
packages/**/test/**/fixtures/**/env.d.ts

examples/with-content/astro.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ import sitemap from '@astrojs/sitemap';
77
export default defineConfig({
88
site: 'https://example.com',
99
integrations: [mdx(), sitemap()],
10-
experimental: {
11-
contentCollections: true,
12-
},
1310
});

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export interface CLIFlags {
8383
port?: number;
8484
config?: string;
8585
drafts?: boolean;
86-
experimentalContentCollections?: boolean;
8786
}
8887

8988
export interface BuildConfig {
@@ -911,34 +910,13 @@ export interface AstroUserConfig {
911910
legacy?: object;
912911

913912
/**
914-
* @docs
915913
* @kind heading
916914
* @name Experimental Flags
917915
* @description
918916
* Astro offers experimental flags to give users early access to new features.
919917
* These flags are not guaranteed to be stable.
920918
*/
921-
experimental?: {
922-
/**
923-
* @docs
924-
* @name experimental.contentCollections
925-
* @type {boolean}
926-
* @default `false`
927-
* @version 1.7.0
928-
* @description
929-
* Enable experimental support for [Content Collections](https://docs.astro.build/en/guides/content-collections/). This makes the `src/content/` directory a reserved directory for Astro to manage, and introduces the `astro:content` module for querying this content.
930-
*
931-
* To enable this feature, set `experimental.contentCollections` to `true` in your Astro config:
932-
*
933-
* ```js
934-
* {
935-
* experimental: {
936-
* contentCollections: true,
937-
* },
938-
* }
939-
*/
940-
contentCollections?: boolean;
941-
};
919+
experimental?: object;
942920

943921
// Legacy options to be removed
944922

packages/astro/src/core/build/generate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ async function generatePath(
349349
logging,
350350
markdown: {
351351
...settings.config.markdown,
352-
isExperimentalContentCollections: settings.config.experimental.contentCollections,
353352
contentDir: getContentPaths(settings.config).contentDir,
354353
},
355354
mode: opts.mode,

packages/astro/src/core/build/static-build.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
157157
}),
158158
vitePluginPrerender(opts, internals),
159159
...(viteConfig.plugins || []),
160-
settings.config.experimental.contentCollections &&
161-
astroBundleDelayedAssetPlugin({ internals }),
160+
astroBundleDelayedAssetPlugin({ internals }),
162161
// SSR needs to be last
163162
ssr && vitePluginSSR(internals, settings.adapter!),
164163
],

packages/astro/src/core/build/vite-plugin-css.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
7676
// For CSS, create a hash of all of the pages that use it.
7777
// This causes CSS to be built into shared chunks when used by multiple pages.
7878
if (isCSSRequest(id)) {
79-
if (settings.config.experimental.contentCollections) {
80-
for (const [pageInfo] of walkParentInfos(id, {
81-
getModuleInfo: args[0].getModuleInfo,
82-
})) {
83-
if (new URL(pageInfo.id, 'file://').searchParams.has(DELAYED_ASSET_FLAG)) {
84-
// Split delayed assets to separate modules
85-
// so they can be injected where needed
86-
return createNameHash(id, [id]);
87-
}
79+
for (const [pageInfo] of walkParentInfos(id, {
80+
getModuleInfo: args[0].getModuleInfo,
81+
})) {
82+
if (new URL(pageInfo.id, 'file://').searchParams.has(DELAYED_ASSET_FLAG)) {
83+
// Split delayed assets to separate modules
84+
// so they can be injected where needed
85+
return createNameHash(id, [id]);
8886
}
8987
}
9088
return createNameForParentPages(id, args[0]);
@@ -174,17 +172,10 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
174172
id,
175173
this,
176174
function until(importer) {
177-
if (settings.config.experimental.contentCollections) {
178-
// Short circuit when `contentCollections` is enabled.
179-
return new URL(importer, 'file://').searchParams.has(DELAYED_ASSET_FLAG);
180-
}
181-
return false;
175+
return new URL(importer, 'file://').searchParams.has(DELAYED_ASSET_FLAG);
182176
}
183177
)) {
184-
if (
185-
settings.config.experimental.contentCollections &&
186-
new URL(pageInfo.id, 'file://').searchParams.has(DELAYED_ASSET_FLAG)
187-
) {
178+
if (new URL(pageInfo.id, 'file://').searchParams.has(DELAYED_ASSET_FLAG)) {
188179
for (const parent of walkParentInfos(id, this)) {
189180
const parentInfo = parent[0];
190181
if (moduleIsTopLevelPage(parentInfo)) {

packages/astro/src/core/build/vite-plugin-ssr.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ function buildManifest(
210210
base: settings.config.base,
211211
markdown: {
212212
...settings.config.markdown,
213-
isExperimentalContentCollections: settings.config.experimental.contentCollections,
214213
contentDir: getContentPaths(settings.config).contentDir,
215214
},
216215
pageMap: null as any,

packages/astro/src/core/config/config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ export function resolveFlags(flags: Partial<Flags>): CLIFlags {
100100
host:
101101
typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
102102
drafts: typeof flags.drafts === 'boolean' ? flags.drafts : undefined,
103-
experimentalContentCollections:
104-
typeof flags.experimentalContentCollections === 'boolean'
105-
? flags.experimentalContentCollections
106-
: undefined,
107103
};
108104
}
109105

@@ -132,7 +128,6 @@ function mergeCLIFlags(astroConfig: AstroUserConfig, flags: CLIFlags) {
132128
// TODO: Come back here and refactor to remove this expected error.
133129
astroConfig.server.host = flags.host;
134130
}
135-
if (flags.experimentalContentCollections) astroConfig.experimental.contentCollections = true;
136131
return astroConfig;
137132
}
138133

packages/astro/src/core/config/schema.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
3434
},
3535
vite: {},
3636
legacy: {},
37-
experimental: {
38-
contentCollections: false,
39-
},
4037
};
4138

4239
export const AstroConfigSchema = z.object({
@@ -167,15 +164,7 @@ export const AstroConfigSchema = z.object({
167164
vite: z
168165
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
169166
.default(ASTRO_CONFIG_DEFAULTS.vite),
170-
experimental: z
171-
.object({
172-
contentCollections: z
173-
.boolean()
174-
.optional()
175-
.default(ASTRO_CONFIG_DEFAULTS.experimental.contentCollections),
176-
})
177-
.optional()
178-
.default({}),
167+
experimental: z.object({}).optional().default({}),
179168
legacy: z.object({}).optional().default({}),
180169
});
181170

0 commit comments

Comments
 (0)