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

Replace openConfig with resolveConfig #7682

Merged
merged 12 commits into from
Jul 20, 2023
Merged

Replace openConfig with resolveConfig #7682

merged 12 commits into from
Jul 20, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 17, 2023

Changes

This PR merges to the js-api branch

  • Changes internal openConfig with resolveConfig (new API)

NOTE: There's one more place using openConfig, that is dev/restart.ts. I'd like refactor how it passes around configs during restarts in general, so holding that change for the next PR. After that, we can remove openConfig.

Testing

Existing tests should pass.

Docs

n/a. internal change.

@changeset-bot
Copy link

changeset-bot bot commented Jul 17, 2023

⚠️ No Changeset found

Latest commit: eee1c3c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jul 17, 2023
@bluwy bluwy marked this pull request as draft July 17, 2023 14:15
@bluwy
Copy link
Member Author

bluwy commented Jul 18, 2023

Fixed it! Awaiting #7701 and #7704 to be merged first, then rebasing it, and should be good.

@natemoo-re natemoo-re added pkg: integration Related to any renderer integration (scope) and removed core labels Jul 18, 2023
@@ -96,7 +96,7 @@ describe('MDX plugins', () => {
it('ignores string-based plugins in markdown config', async () => {
const fixture = await buildFixture({
markdown: {
remarkPlugins: [['remark-toc']],
remarkPlugins: [['remark-toc', {}]],
Copy link
Member Author

Choose a reason for hiding this comment

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

The tuple needs two values or it won't pass config validation. This should be what users have to do right now too it seems.

Copy link
Member

Choose a reason for hiding this comment

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

Is it a change in the public APIs?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it shouldn't be. Currently if I use the same configuration in the basics example, I get

10:06:40 PM [astro] Unable to load /Users/bjorn/Work/oss/astro/examples/basics/astro.config.mjs

[config] Astro found issue(s) with your configuration:
  ! markdown.remarkPlugins.0  Invalid input.

It appears now because the tests will run the zod schema validation for each fixture options.

@@ -23,7 +23,7 @@ describe('getStaticPaths', () => {
const $ = cheerio.load(html);
expect($('p').text()).to.equal('First mdx file');
expect($('#one').text()).to.equal('hello', 'Frontmatter included');
expect($('#url').text()).to.equal('/src/content/1.mdx', 'url is included');
expect($('#url').text()).to.equal('src/content/1.mdx', 'url is included');
Copy link
Member Author

Choose a reason for hiding this comment

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

The base handling in the tests previously patches the config, causing the leading slash. In a normal Astro app, there shouldn't be a leading slash.

@bluwy bluwy marked this pull request as ready for review July 20, 2023 12:46
@@ -96,7 +96,7 @@ describe('MDX plugins', () => {
it('ignores string-based plugins in markdown config', async () => {
const fixture = await buildFixture({
markdown: {
remarkPlugins: [['remark-toc']],
remarkPlugins: [['remark-toc', {}]],
Copy link
Member

Choose a reason for hiding this comment

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

Is it a change in the public APIs?

@bluwy bluwy merged commit 170300e into js-api Jul 20, 2023
@bluwy bluwy deleted the use-resolve-config branch July 20, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants