Merge branch 'main' into add-Minification
This commit is contained in:
commit
1cbc00bfca
24 changed files with 88 additions and 120 deletions
5
.changeset/hungry-lizards-float.md
Normal file
5
.changeset/hungry-lizards-float.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/vercel': patch
|
||||
---
|
||||
|
||||
Refactor static adapter to use updateConfig method
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -24,6 +24,9 @@ env:
|
|||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
FORCE_COLOR: true
|
||||
ASTRO_TELEMETRY_DISABLED: true
|
||||
# 7 GiB by default on GitHub, setting to 6 GiB
|
||||
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
@ -112,11 +115,13 @@ jobs:
|
|||
needs: build
|
||||
strategy:
|
||||
matrix:
|
||||
OS: [ubuntu-latest, windows-latest]
|
||||
OS: [ubuntu-latest]
|
||||
NODE_VERSION: [16, 18]
|
||||
include:
|
||||
- os: macos-latest
|
||||
NODE_VERSION: 16
|
||||
- os: windows-latest
|
||||
NODE_VERSION: 16
|
||||
fail-fast: false
|
||||
env:
|
||||
NODE_VERSION: ${{ matrix.NODE_VERSION }}
|
||||
|
@ -221,4 +226,3 @@ jobs:
|
|||
run: pnpm run test:smoke
|
||||
env:
|
||||
SKIP_OG: 1
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
|
|
|
@ -7,17 +7,17 @@ We welcome contributions of any size and skill level. As an open source project,
|
|||
|
||||
## Quick Guide
|
||||
|
||||
### Prerequisite
|
||||
### Prerequisites
|
||||
|
||||
```shell
|
||||
node: "^14.18.0 || >=16.12.0"
|
||||
pnpm: "^7.9.5"
|
||||
node: "^>=16.12.0"
|
||||
pnpm: "^8.2.0"
|
||||
# otherwise, your build will fail
|
||||
```
|
||||
|
||||
### Setting up your local repo
|
||||
|
||||
Astro uses pnpm workspaces, so you should **always run `pnpm install` from the top-level project directory.** running `pnpm install` in the top-level project root will install dependencies for `astro`, and every package in the repo.
|
||||
Astro uses pnpm workspaces, so you should **always run `pnpm install` from the top-level project directory**. Running `pnpm install` in the top-level project root will install dependencies for `astro`, and every package in the repo.
|
||||
|
||||
```shell
|
||||
git clone && cd ...
|
||||
|
@ -35,7 +35,7 @@ To automatically handle merge conflicts in `pnpm-lock.yaml`, you should run the
|
|||
|
||||
```shell
|
||||
pnpm add -g @pnpm/merge-driver
|
||||
pnpx npm-merge-driver install --driver-name pnpm-merge-driver --driver "pnpm-merge-driver %A %O %B %P" --files pnpm-lock.yaml
|
||||
pnpm dlx npm-merge-driver install --driver-name pnpm-merge-driver --driver "pnpm-merge-driver %A %O %B %P" --files pnpm-lock.yaml
|
||||
```
|
||||
|
||||
### Using GitHub Codespaces for development
|
||||
|
@ -44,7 +44,7 @@ To get started, create a codespace for this repository by clicking this 👇
|
|||
|
||||
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro)
|
||||
|
||||
Your new codespace will open in a web-based version of Visual Studio Code. All development dependcies will be preinstalled and the tests will run automatically ensuring you've got a green base from which to start working.
|
||||
Your new codespace will open in a web-based version of Visual Studio Code. All development dependencies will be preinstalled, and the tests will run automatically ensuring you've got a green base from which to start working.
|
||||
|
||||
**Note**: Dev containers is now an open spec which is supported by [GitHub Codespaces](https://github.com/codespaces) and [other supporting tools](https://containers.dev/supporting).
|
||||
|
||||
|
@ -63,7 +63,7 @@ During the development process, you may want to test your changes to ensure they
|
|||
|
||||
1. Run any of the examples in the `/examples` folder. They are linked to use the local Astro source code, so you can see the effects of your changes.
|
||||
|
||||
```
|
||||
```shell
|
||||
pnpm --filter @example/minimal run dev
|
||||
```
|
||||
|
||||
|
@ -77,7 +77,7 @@ Overall, it's up to personal preference which method to use. For smaller changes
|
|||
|
||||
You can debug vite by prefixing any command with `DEBUG` like so:
|
||||
|
||||
```
|
||||
```shell
|
||||
DEBUG=vite:* astro dev # debug everything in Vite
|
||||
DEBUG=vite:[name] astro dev # debug specific process, e.g. "vite:deps" or "vite:transform"
|
||||
```
|
||||
|
@ -168,7 +168,7 @@ Server-side rendering (SSR) can be complicated. The Astro package (`packages/ast
|
|||
- `core/`: Code that executes **in the top-level scope** (in Node). Within, you’ll find code that powers the `astro build` and `astro dev` commands, as well as top-level SSR code.
|
||||
- `runtime/`: Code that executes **in different scopes** (i.e. not in a pure Node context). You’ll have to think about code differently here.
|
||||
- `client/`: Code that executes **in the browser.** Astro’s partial hydration code lives here, and only browser-compatible code can be used.
|
||||
- `server/`: Code that executes **inside Vite’s SSR.** Though this is a Node environment inside, this will be executed independently from `core/` and may have to be structured differently.
|
||||
- `server/`: Code that executes **inside Vite’s SSR.** Though this is a Node environment inside, this will be executed independently of `core/` and may have to be structured differently.
|
||||
- `vite-plugin-*/`: Any Vite plugins that Astro needs to run. For the most part, these also execute within Vite similar to `src/runtime/server/`, but it’s also helpful to think about them as independent modules. _Note: at the moment these are internal while they’re in development_
|
||||
|
||||
### Thinking about SSR
|
||||
|
@ -198,7 +198,7 @@ By default, `create-astro` and [astro.new](https://astro.new) point to this bran
|
|||
|
||||
## Releasing Astro
|
||||
|
||||
_Note: Only [core maintainers (L3+)](https://github.com/withastro/.github/blob/main/GOVERNANCE.md#level-3-l3---core-maintainer) can release new versions of Astro._
|
||||
_Note: Only [core maintainers (L3+)](https://github.com/withastro/.github/blob/main/GOVERNANCE.md#level-3-l3---core) can release new versions of Astro._
|
||||
|
||||
The repo is set up with automatic releases, using the changeset GitHub action & bot.
|
||||
|
||||
|
@ -230,15 +230,15 @@ git reset --hard
|
|||
|
||||
By default, every package with a changeset will be released. If you only want to target a smaller subset of packages for release, you can consider clearing out the `.changesets` directory to replace all existing changesets with a single changeset of only the packages that you want to release. Just be sure not to commit or push this to `main`, since it will destroy existing changesets that you will still want to eventually release.
|
||||
|
||||
Full documentation: https://github.com/atlassian/changesets/blob/main/docs/snapshot-releases.md
|
||||
Full documentation: https://github.com/changesets/changesets/blob/main/docs/snapshot-releases.md
|
||||
|
||||
### Releasing `astro@next` (aka "prerelease mode")
|
||||
|
||||
Sometimes, the repo will enter into "prerelease mode". In prerelease mode, our normal release process will publish npm versions under the `next` dist-tag, instead of the default `latest` tag. We do this from time-to-time to test large features before sharing them with the larger Astro audience.
|
||||
|
||||
While in prerelease mode, follow the normal release process to release `astro@next` instead of `astro@latest`. To release `astro@latest` instead, see [Releasing `astro@latest` while in prerelease mode](#user-content-releasing-astrolatest-while-in-prerelease-mode).
|
||||
While in prerelease mode, follow the normal release process to release `astro@next` instead of `astro@latest`. To release `astro@latest` instead, see [Releasing `astro@latest` while in prerelease mode](#releasing-astrolatest-while-in-prerelease-mode).
|
||||
|
||||
Full documentation: https://github.com/atlassian/changesets/blob/main/docs/prereleases.md
|
||||
Full documentation: https://github.com/changesets/changesets/blob/main/docs/prereleases.md
|
||||
|
||||
### Entering prerelease mode
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ ${chosenMethod} requests are not available when building a static site. Update y
|
|||
return response;
|
||||
}
|
||||
|
||||
// TODO: Remove support for old API in Astro 3.0
|
||||
if (handler.length > 1) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`
|
||||
|
@ -57,6 +58,7 @@ Update your code to remove this warning.`);
|
|||
if (prop in target) {
|
||||
return Reflect.get(target, prop);
|
||||
} else if (prop in params) {
|
||||
// TODO: Remove support for old API in Astro 3.0
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`
|
||||
API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
|
||||
|
|
|
@ -10,38 +10,6 @@ describe('API routes', () => {
|
|||
await fixture.build();
|
||||
});
|
||||
|
||||
describe('Deprecated API', () => {
|
||||
it('two argument supported', async () => {
|
||||
const one = JSON.parse(await fixture.readFile('/old-api/twoarg/one.json'));
|
||||
expect(one).to.deep.equal({
|
||||
param: 'one',
|
||||
pathname: '/old-api/twoarg/one.json',
|
||||
});
|
||||
const two = JSON.parse(await fixture.readFile('/old-api/twoarg/two.json'));
|
||||
expect(two).to.deep.equal({
|
||||
param: 'two',
|
||||
pathname: '/old-api/twoarg/two.json',
|
||||
});
|
||||
});
|
||||
|
||||
it('param first argument is supported', async () => {
|
||||
const one = JSON.parse(await fixture.readFile('/old-api/onearg/one.json'));
|
||||
expect(one).to.deep.equal({
|
||||
param: 'one',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('1.0 API', () => {
|
||||
it('Receives a context argument', async () => {
|
||||
const one = JSON.parse(await fixture.readFile('/context/data/one.json'));
|
||||
expect(one).to.deep.equal({
|
||||
param: 'one',
|
||||
pathname: '/context/data/one.json',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Binary data', () => {
|
||||
it('can be returned from a response', async () => {
|
||||
const dat = await fixture.readFile('/binary.dat', null);
|
||||
|
|
|
@ -53,7 +53,6 @@ describe('Environment Variables', () => {
|
|||
|
||||
it('includes public env in client-side JS', async () => {
|
||||
let dirs = await fixture.readdir('/_astro');
|
||||
console.log(dirs);
|
||||
let found = false;
|
||||
|
||||
// Look in all of the .js files to see if the public env is inlined.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import { loadFixture, silentLogging } from './test-utils.js';
|
||||
|
||||
describe('Development Routing', () => {
|
||||
describe('No site config', () => {
|
||||
|
@ -10,7 +10,9 @@ describe('Development Routing', () => {
|
|||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({ root: './fixtures/without-site-config/' });
|
||||
devServer = await fixture.startDevServer();
|
||||
devServer = await fixture.startDevServer({
|
||||
logging: silentLogging,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
import { load as cheerioLoad } from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import { loadFixture, silentLogging } from './test-utils.js';
|
||||
|
||||
describe('Dynamic endpoint collision', () => {
|
||||
describe('build', () => {
|
||||
|
@ -31,7 +31,9 @@ describe('Dynamic endpoint collision', () => {
|
|||
root: './fixtures/dynamic-endpoint-collision/',
|
||||
});
|
||||
|
||||
devServer = await fixture.startDevServer();
|
||||
devServer = await fixture.startDevServer({
|
||||
logging: silentLogging,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import { loadFixture, silentLogging } from './test-utils.js';
|
||||
|
||||
describe('Errors in JavaScript', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
|
@ -12,8 +12,13 @@ describe('Errors in JavaScript', () => {
|
|||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/error-bad-js',
|
||||
vite: {
|
||||
logLevel: 'silent',
|
||||
},
|
||||
});
|
||||
devServer = await fixture.startDevServer({
|
||||
logging: silentLogging,
|
||||
});
|
||||
devServer = await fixture.startDevServer();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import { loadFixture, silentLogging } from './test-utils.js';
|
||||
|
||||
describe('Can handle errors that are not instanceof Error', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
|
@ -12,7 +12,9 @@ describe('Can handle errors that are not instanceof Error', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/error-non-error',
|
||||
});
|
||||
devServer = await fixture.startDevServer();
|
||||
devServer = await fixture.startDevServer({
|
||||
logging: silentLogging,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
export function getStaticPaths() {
|
||||
return [
|
||||
{
|
||||
params: {
|
||||
param: 'one'
|
||||
}
|
||||
},
|
||||
{
|
||||
params: {
|
||||
param: 'two'
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export function get(params) {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
param: params.param
|
||||
})
|
||||
};
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
export function getStaticPaths() {
|
||||
return [
|
||||
{
|
||||
params: {
|
||||
param: 'one'
|
||||
}
|
||||
},
|
||||
{
|
||||
params: {
|
||||
param: 'two'
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export function get(params, request) {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
param: params.param,
|
||||
pathname: new URL(request.url).pathname
|
||||
})
|
||||
};
|
||||
}
|
|
@ -8,7 +8,9 @@
|
|||
"@astrojs/svelte": "workspace:*",
|
||||
"@test/component-library-shared": "workspace:*",
|
||||
"astro": "workspace:*",
|
||||
"preact": "^10.13.2",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0"
|
||||
"react-dom": "^18.1.0",
|
||||
"svelte": "^3.58.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,4 @@
|
|||
margin-top: 2em;
|
||||
place-items: center;
|
||||
}
|
||||
.message {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -9,7 +9,7 @@ export function get() {
|
|||
};
|
||||
}
|
||||
|
||||
export async function post(params, request) {
|
||||
export async function post({ params, request }) {
|
||||
const body = await request.text();
|
||||
return new Response(body === `some data` ? `ok` : `not ok`, {
|
||||
status: 200,
|
||||
|
|
|
@ -5,7 +5,7 @@ export async function getStaticPaths() {
|
|||
]
|
||||
}
|
||||
|
||||
export async function get(params) {
|
||||
export async function get({ params }) {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
slug: params.slug,
|
||||
|
|
|
@ -5,7 +5,7 @@ export async function getStaticPaths() {
|
|||
];
|
||||
}
|
||||
|
||||
export async function get(params) {
|
||||
export async function get({ params }) {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
slug: params.slug,
|
||||
|
|
|
@ -5,7 +5,7 @@ export async function getStaticPaths() {
|
|||
];
|
||||
}
|
||||
|
||||
export async function get(params) {
|
||||
export async function get({ params }) {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
slug: params.slug,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
import { load as cheerioLoad } from 'cheerio';
|
||||
import { isWindows, loadFixture } from './test-utils.js';
|
||||
import { isWindows, loadFixture, silentLogging } from './test-utils.js';
|
||||
|
||||
let fixture;
|
||||
|
||||
|
@ -103,7 +103,9 @@ describe('React Components', () => {
|
|||
let devServer;
|
||||
|
||||
before(async () => {
|
||||
devServer = await fixture.startDevServer();
|
||||
devServer = await fixture.startDevServer({
|
||||
logging: silentLogging,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -18,7 +18,6 @@ describe('srcDir', () => {
|
|||
|
||||
const relPath = $('link').attr('href');
|
||||
const css = await fixture.readFile(relPath);
|
||||
console.log(css);
|
||||
expect(css).to.match(/body{color:green}/);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -68,6 +68,12 @@ export const defaultLogging = {
|
|||
level: 'error',
|
||||
};
|
||||
|
||||
/** @type {import('../src/core/logger/core').LogOptions} */
|
||||
export const silentLogging = {
|
||||
dest: nodeLogDestination,
|
||||
level: 'silent',
|
||||
};
|
||||
|
||||
/**
|
||||
* Load Astro fixture
|
||||
* @param {AstroConfig} inlineConfig Astro config partial (note: must specify `root`)
|
||||
|
|
|
@ -19,12 +19,17 @@ export default function vercelStatic({ analytics }: VercelStaticConfig = {}): As
|
|||
return {
|
||||
name: '@astrojs/vercel',
|
||||
hooks: {
|
||||
'astro:config:setup': ({ command, config, injectScript }) => {
|
||||
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
|
||||
if (command === 'build' && analytics) {
|
||||
injectScript('page', 'import "@astrojs/vercel/analytics"');
|
||||
}
|
||||
config.outDir = new URL('./static/', getVercelOutput(config.root));
|
||||
config.build.format = 'directory';
|
||||
const outDir = new URL('./static/', getVercelOutput(config.root));
|
||||
updateConfig({
|
||||
outDir,
|
||||
build: {
|
||||
format: 'directory',
|
||||
},
|
||||
});
|
||||
},
|
||||
'astro:config:done': ({ setAdapter, config }) => {
|
||||
setAdapter(getAdapter());
|
||||
|
|
|
@ -13,13 +13,13 @@ describe('Fetch', () => {
|
|||
it('Fetch with https', async () => {
|
||||
const { fetch } = target
|
||||
|
||||
const response = await fetch('https://api.openbrewerydb.org/breweries')
|
||||
const response = await fetch('https://astro.build')
|
||||
|
||||
expect(response.constructor).to.equal(target.Response)
|
||||
|
||||
const json = await response.json()
|
||||
const html = await response.text()
|
||||
|
||||
expect(json).to.be.an('array')
|
||||
expect(html).to.include('<html')
|
||||
})
|
||||
|
||||
it('Fetch with data', async () => {
|
||||
|
|
|
@ -2242,12 +2242,18 @@ importers:
|
|||
astro:
|
||||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
preact:
|
||||
specifier: ^10.13.2
|
||||
version: 10.13.2
|
||||
react:
|
||||
specifier: ^18.1.0
|
||||
version: 18.2.0
|
||||
react-dom:
|
||||
specifier: ^18.1.0
|
||||
version: 18.2.0(react@18.2.0)
|
||||
svelte:
|
||||
specifier: ^3.58.0
|
||||
version: 3.58.0
|
||||
|
||||
packages/astro/test/fixtures/component-library-shared:
|
||||
dependencies:
|
||||
|
@ -15363,6 +15369,10 @@ packages:
|
|||
/preact@10.12.0:
|
||||
resolution: {integrity: sha512-+w8ix+huD8CNZemheC53IPjMUFk921i02o30u0K6h53spMX41y/QhVDnG/nU2k42/69tvqWmVsgNLIiwRAcmxg==}
|
||||
|
||||
/preact@10.13.2:
|
||||
resolution: {integrity: sha512-q44QFLhOhty2Bd0Y46fnYW0gD/cbVM9dUVtNTDKPcdXSMA7jfY+Jpd6rk3GB0lcQss0z5s/6CmVP0Z/hV+g6pw==}
|
||||
dev: false
|
||||
|
||||
/prebuild-install@7.1.1:
|
||||
resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==}
|
||||
engines: {node: '>=10'}
|
||||
|
@ -16705,6 +16715,11 @@ packages:
|
|||
resolution: {integrity: sha512-S+87/P0Ve67HxKkEV23iCdAh/SX1xiSfjF1HOglno/YTbSTW7RniICMCofWGdJJbdjw3S+0PfFb1JtGfTXE0oQ==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
/svelte@3.58.0:
|
||||
resolution: {integrity: sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: false
|
||||
|
||||
/svg-tags@1.0.0:
|
||||
resolution: {integrity: sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue