Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain authored Apr 12, 2024
2 parents 2ac9373 + 174ce25 commit a1b2a26
Show file tree
Hide file tree
Showing 45 changed files with 136 additions and 77 deletions.
5 changes: 0 additions & 5 deletions .changeset/four-zoos-taste.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/mean-candles-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes `astro add` sometimes modifying `baseUrl` unintentionally
5 changes: 0 additions & 5 deletions .changeset/old-pugs-jog.md

This file was deleted.

2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@astrojs/mdx": "^2.3.0",
"@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.1.2",
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
},
"peerDependencies": {
"astro": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@astrojs/alpinejs": "^0.4.0",
"@types/alpinejs": "^3.13.5",
"alpinejs": "^3.13.3",
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/framework-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/lit": "^4.0.1",
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^4.6.0",
"astro": "^4.6.1",
"lit": "^3.1.2"
}
}
2 changes: 1 addition & 1 deletion examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@astrojs/vue": "^4.1.0",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"astro": "^4.6.0",
"astro": "^4.6.1",
"preact": "^10.19.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.2.0",
"@preact/signals": "^1.2.1",
"astro": "^4.6.0",
"astro": "^4.6.1",
"preact": "^10.19.2"
}
}
2 changes: 1 addition & 1 deletion examples/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/react": "^3.3.0",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"astro": "^4.6.0",
"astro": "^4.6.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^4.1.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"solid-js": "^1.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/svelte": "^5.4.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"svelte": "^4.2.5"
}
}
2 changes: 1 addition & 1 deletion examples/framework-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/vue": "^4.1.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"vue": "^3.3.8"
}
}
2 changes: 1 addition & 1 deletion examples/hackernews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/node": "^8.2.5",
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
},
"peerDependencies": {
"astro": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@astrojs/node": "^8.2.5",
"astro": "^4.6.0",
"astro": "^4.6.1",
"html-minifier": "^4.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/non-html-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@astrojs/node": "^8.2.5",
"@astrojs/svelte": "^5.4.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"svelte": "^4.2.5"
}
}
2 changes: 1 addition & 1 deletion examples/starlog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0",
"astro": "^4.6.1",
"sass": "^1.69.5",
"sharp": "^0.32.6"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/view-transitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"devDependencies": {
"@astrojs/tailwind": "^5.1.0",
"@astrojs/node": "^8.2.5",
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/with-markdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.10.0",
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/with-markdown-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/markdown-remark": "^5.1.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"hast-util-select": "^6.0.2",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-markdown-shiki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.6.0"
"astro": "^4.6.1"
}
}
2 changes: 1 addition & 1 deletion examples/with-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/mdx": "^2.3.0",
"@astrojs/preact": "^3.2.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"preact": "^10.19.2"
}
}
2 changes: 1 addition & 1 deletion examples/with-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.2.0",
"@nanostores/preact": "^0.5.0",
"astro": "^4.6.0",
"astro": "^4.6.1",
"nanostores": "^0.9.5",
"preact": "^10.19.2"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/mdx": "^2.3.0",
"@astrojs/tailwind": "^5.1.0",
"@types/canvas-confetti": "^1.6.3",
"astro": "^4.6.0",
"astro": "^4.6.1",
"autoprefixer": "^10.4.15",
"canvas-confetti": "^1.9.1",
"postcss": "^8.4.28",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^4.6.0",
"astro": "^4.6.1",
"vitest": "^1.3.1"
}
}
8 changes: 8 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# astro

## 4.6.1

### Patch Changes

- [#10708](https://github.com/withastro/astro/pull/10708) [`742866c5669a2be4f8b5a4c861cadb933c381415`](https://github.com/withastro/astro/commit/742866c5669a2be4f8b5a4c861cadb933c381415) Thanks [@horo-fox](https://github.com/horo-fox)! - Limits parallel imports within `getCollection()` to prevent EMFILE errors when accessing files

- [#10755](https://github.com/withastro/astro/pull/10755) [`c6d59b6fb7db20af957a8706c8159c50619235ef`](https://github.com/withastro/astro/commit/c6d59b6fb7db20af957a8706c8159c50619235ef) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a case where the i18n fallback failed to correctly redirect to the index page with SSR enabled

## 4.6.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "4.6.0",
"version": "4.6.1",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,16 +968,16 @@ async function updateTSConfig(
inputConfig = {
tsconfig: defaultTSConfig,
tsconfigFile: path.join(cwd, 'tsconfig.json'),
rawConfig: { tsconfig: defaultTSConfig, tsconfigFile: path.join(cwd, 'tsconfig.json') },
rawConfig: defaultTSConfig,
};
} else {
inputConfigText = JSON.stringify(inputConfig.rawConfig.tsconfig, null, 2);
inputConfigText = JSON.stringify(inputConfig.rawConfig, null, 2);
}

const configFileName = path.basename(inputConfig.tsconfigFile);

const outputConfig = updateTSConfigForFramework(
inputConfig.rawConfig.tsconfig,
inputConfig.rawConfig,
firstIntegrationWithTSSettings
);

Expand Down
18 changes: 15 additions & 3 deletions packages/astro/src/core/config/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import {
TSConfckParseError,
type TSConfckParseOptions,
type TSConfckParseResult,
find,
parse,
toJson,
} from 'tsconfck';
import type { CompilerOptions, TypeAcquisition } from 'typescript';

Expand Down Expand Up @@ -64,7 +66,7 @@ type TSConfigResult<T = {}> = Promise<
export async function loadTSConfig(
root: string | undefined,
findUp = false
): Promise<TSConfigResult<{ rawConfig: TSConfckParseResult }>> {
): Promise<TSConfigResult<{ rawConfig: TSConfig }>> {
const safeCwd = root ?? process.cwd();

const [jsconfig, tsconfig] = await Promise.all(
Expand All @@ -85,7 +87,13 @@ export async function loadTSConfig(
return parsedConfig;
}

return { ...parsedConfig, rawConfig: parsedConfig.extended?.[0] ?? parsedConfig.tsconfig };
// tsconfck does not return the original config, so we need to parse it ourselves
// https://github.com/dominikg/tsconfck/issues/138
const rawConfig = await readFile(tsconfig, 'utf-8')
.then(toJson)
.then((content) => JSON.parse(content) as TSConfig);

return { ...parsedConfig, rawConfig };
}

if (jsconfig) {
Expand All @@ -95,7 +103,11 @@ export async function loadTSConfig(
return parsedConfig;
}

return { ...parsedConfig, rawConfig: parsedConfig.extended?.[0] ?? parsedConfig.tsconfig };
const rawConfig = await readFile(jsconfig, 'utf-8')
.then(toJson)
.then((content) => JSON.parse(content) as TSConfig);

return { ...parsedConfig, rawConfig: rawConfig };
}

return 'missing-config';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ export const IncorrectStrategyForI18n = {
name: 'IncorrectStrategyForI18n',
title: "You can't use the current function with the current strategy",
message: (functionName: string) =>
`The function \`${functionName}\' can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`,
`The function \`${functionName}\` can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`,
} satisfies ErrorData;

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/core/render-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ export class RenderContext {

// `Astro.self` is added by the compiler
const astroGlobalCombined: Omit<AstroGlobal, 'self'> = {
...astroGlobalPartial,
generator: astroGlobalPartial.generator,
glob: astroGlobalPartial.glob,
cookies,
get clientAddress() {
return renderContext.clientAddress();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files": ["i-have-base-url"],
"compilerOptions": {
"baseUrl": ".",
}
}
11 changes: 11 additions & 0 deletions packages/astro/test/units/config/config-tsconfig.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import * as path from 'node:path';
import { describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import { toJson } from 'tsconfck';
import { loadTSConfig, updateTSConfigForFramework } from '../../../dist/core/config/index.js';

const cwd = fileURLToPath(new URL('../../fixtures/tsconfig-handling/', import.meta.url));
Expand Down Expand Up @@ -37,6 +39,15 @@ describe('TSConfig handling', () => {
assert.equal(invalidConfig, 'invalid-config');
assert.equal(missingConfig, 'missing-config');
});

it('does not change baseUrl in raw config', async () => {
const loadedConfig = await loadTSConfig(path.join(cwd, 'baseUrl'));
const rawConfig = await readFile(path.join(cwd, 'baseUrl', 'tsconfig.json'), 'utf-8')
.then(toJson)
.then((content) => JSON.parse(content));

assert.deepEqual(loadedConfig.rawConfig, rawConfig);
});
});

describe('tsconfig / jsconfig updates', () => {
Expand Down
Loading

0 comments on commit a1b2a26

Please sign in to comment.