Skip to content

Commit

Permalink
🚀 Astro Next (0.21.0) (#1406)
Browse files Browse the repository at this point in the history
* make astro-root uids unique

* Move Astro to Vite

* Update tests

* More test improvements

* fred fixes

* Update compiler, improve tests

* Fix runtime, improve code frame

* Add Markdown support

* Tycho fixes

* Fred fixes part 2

* Throw Error for WIP Features

* Improve testing suite

* Allow users to pass config to Vite

* Fix npm install (#1407)

* Automate publish on merge (#1408)

* Add NPM_TOKEN to publish script (#1409)

* Create .npmrc

* Clean up astro deps (#1411)

* Use new renderers (#1412)

* feat: update compiler (#1421)

* Try mocha/chai test runners (#1418)

* Try mocha/chai test runners

* Disable failing smoke test for now

Will revert when next can build docs

* Enable mocha in parallel mode

* Remove warning

* Update docs

* Fix Windows bug

* Fix internal imports

* Fix styles

* Fix CI release on merge to next (#1427)

* Fix logger locale parsing (#1439)

* fix(logger): locale parsing
* Fixed issue of compiler crash when "c" locale was encountered
* Return default locale if parsed locale is less than 2 chars long

* chore: add changeset

* Apply changes from #1387

* Add back in support for children (#1486)

* Add back in support for children

* Be more careful

* Enables most slot tests (#1494)

* Enables most slot tests

* Use spreadAttributes

* Add hydration to Solid renderer (#1479) (#1495)

* feat: add hydration to Solid renderer

* fix: intersection observer, move script to the end

Co-authored-by: Ryan Carniato <[email protected]>

* [next] support Astro.slots API (#1516)

* [next] Support for custom elements (#1528)

* [next] Support for custom elements

* Fix eslint errors

* eslint again

* [next] Fix Astro.fetchContent (#1480)

* fix Astro.fetchContent

* fix(fetchContent): cast type

Co-authored-by: Nate Moore <[email protected]>

* Move hydration to the compiler (#1547)

* Move hydration to the compiler

* Move extracting url, export to util fn

* Brings back astro-dynamic tests (#1548)

* Implements top-level Astro + Astro.resolve (#1556)

* Implements top-level Astro + Astro.resolve

* Fix linting

* [next] Update renderers (#1509)

* chore: update vite

* fix(renderers): point renderers to resolved server/client entrypoints

* Chore: Enable more tests with new compiler changes (#1558)

* [Next] `fetch` support (#1563)

* fix: polyfill fetch in every ssr scenario

* test(fetch): update fetch tests

* docs: update data fetching guide to remove caveats about `fetch` and isomorphic usage

* refactor: update regex for clarity

* Restructure (#1569)

* Upgrade to @astrojs/compiler 0.2.0 (#1584)

* Use Vite fork (#1585)

* Use Vite fork

* Fix linting

* Move Vite to vendor/ and add a license

* Fix linting

* Include the dist folder

* Update files config

* Markdown compilation (#1593)

* Markdown compilation

* remove debugger

* Gets lit hydration working (#1595)

* Gets Astro.fetchContent compilation to work (#1596)

* Gets Astro.fetchContent compilation to work

This fixes Astro.fetchContent so that we handle esbuild transforming the
name of the nested Astro call.

* Remove debugging

* Update the tests

* Remove another debugger

* Update Vite to latest (#1597)

* Add Prism syntax highlighting (#1598)

* Scoped styles with markdown (#1599)

* Bugfix: fix getStaticPaths() cache miss (#1602)

* Fix build order (#1609)

* Bugfix: restore build to get all paths earlier, when build. Same as main.

* Also re-add timings

* [next] blog example fully working (#1610)

* Add environment variables docs (Closes #873) (#1587)

* Added environment variables docs (Closes #873)

* Fixed prefix

* Remove numbered comments (#1611)

* Chore: remove numbered comments

* Clean up block comments

* comment style fixes (#1614)

* [next] Upgrade compiler (#1619)

* [next] Upgrade compiler

* Upgrade to latest compiler

* Fix the path to global css

* Removed debugger

* feat: add fragment support to vite-plugin-astro (#1600)

* [next] fix `.tsx` handling (#1620)

* fix: support tsx in JSX plugin

* fix: preserve JSX via esbuild, only use Babel for JSX compilation

* fix: handle upcoming Vite API for `ssr` flag

* [next] Add CSS preprocessing  (#1589)

* Add concept for style support in Astro

* Update style preprocessor to use new compiler

* fix: massage preprocessStyle type

* fix: @astrojs/compiler types

Co-authored-by: Nate Moore <[email protected]>

* fix issues in blog-multiple-authors (#1621)

* Move Sass to deps (#1622)

* Update renderer API for Vite (#1623)

* Update renderer API for Vite

* Fix lit-element tests

* Clean up comments

* Throw friendly error if renderer provides viteConfig in a bad format

* Fix changesets (#1628)

* Remove cheerio scanning from build stats (#1629)

* Minor change to jsxTransformOptions, update Renderer API docs (#1630)

* [next] docs example fully working (#1627)

* [next] docs example fully working

* Upgrade compiler to unlock docs

* Add `class:list` directive (#1612)

* Add support for class:list directive

The `class:list` directive serializes an expression of css class names. For React components, `className:list` is also supported.

* Remove `className` support and React tests

* Add tests for the absence of omitted classes

* fix: `define:vars` scoping for styles (#1632)

* feat: fix Debug component (#1633)

* [next] Fix `<Markdown>` component (#1631)

* fix: cleanup issues with <Markdown> component

* fix: fix `content` usage with Markdown

* [next] Fix `<Code>` component (#1635)

* fix: enable Code component

* test: update expect to chai format

* Fixes solid (#1634)

* Fixes solid

* Rename the test

* Rebase with next

* Skip solid test for now

* Add support for markdown plugins (#1650)

* Fix broken next release (#1652)

* Prevent passing  to Svelte components

* Prevent passing class to Vue components

* Add CSS injection, fix portfolio example (#1648)

* Fix portfolio example

* Add .pcss extension

* Update load ssr opts

* Update packages/astro/src/runtime/server/index.ts

Co-authored-by: Jonathan Neal <[email protected]>

Co-authored-by: Nate Moore <[email protected]>
Co-authored-by: Jonathan Neal <[email protected]>

* Fixes external HMR (#1654)

* Upgrade compiler version (#1655)

Fixes docs and blog examples

* Resolve renderers relative to the projectRoot (#1659)

* Template fixes (#1656)

* fix: dedupe hashes for identical islands (#1660)

* fix: scope `define:vars` to `:root` for `<style global>` (#1663)

* chore: update compiler to latest (#1664)

* [next] fix island hydration inside of `<Markdown>` (#1665)

* fix: create rehype plugin to smooth over island hydration bugs

* refactor: remove debug code

* chore: explain need for `rehypeIslands`

* Bugfix: renderer-lit missing files on npm (#1669)

* Force Vite to rebuild dependencies (#1670)

* [next] Add `preact/compat` renderer (#1668)

* feat: add preact/compat entry for `@astrojs/renderer-preact`

* Update index.js

* Bugfix: plugin-astro-fetch tries to append node-fetch to node-fetch (#1671)

* Fix Vite race condition (#1674)

* Fix with-nanostore deps (#1675)

Adds missing Solid renderer

* [next] Fix `resolveDependency` on Windows (#1666)

* fix: Windows issue with resolveDependency util

* chore: add comment

* Update CONTRIBUTING.md (#1677)

* Prevent scanning a user's deps (#1678)

* Prevent scanning a user's deps

* Remove unused things

* remove unused util

* Adding a changeset for the remark plugin

* Config changes needed for stater template (#1680)

This does 2 things:

1. Adds prismjs as a dep.
2. Adds shiki as an external.

* Next bugs (#1681)

* fix(#1679): hoisted <script> rendering

* fix(#1679): do not print global for styles, but do for scripts

* fix: update ObjectSet implementation

* fix: dedupe elements in sets

* [next] update compiler (#1683)

* chore: update compiler

* chore: update compiler (again)

* Fix Astro HMR bottleneck (#1684)

* Bugfix: JSX renderers can be declared in any order (#1686)

* chore: update compiler (#1690)

* Exclude lit-server from being optimized (#1691)

This should get the lit example working from `npm`.

* fix: exclude all renderer server entrypoints (#1692)

* chore: update compiler (#1705)

* fix: do not crash when Markdown has no content (#1702)

* feat: improve support for third-party React packages (#1701)

* Remove prism warning when no language is provided (#1703)

* Remove prism warning when no language is provided

* Add the plaintext language instead

* retry deploy

* chore: enter prerelease mode under `next` (#1707)

* Updates to the changesets (#1708)

* Updates to the changesets

* Adds a changeset for astro-prism

Co-authored-by: Fred K. Schott <[email protected]>
Co-authored-by: Nate Moore <[email protected]>
Co-authored-by: Nate Moore <[email protected]>
Co-authored-by: Pranav Karawale <[email protected]>
Co-authored-by: Matthew Phillips <[email protected]>
Co-authored-by: Matthew Phillips <[email protected]>
Co-authored-by: Ryan Carniato <[email protected]>
Co-authored-by: AsyncBanana <[email protected]>
Co-authored-by: Jonathan Neal <[email protected]>
  • Loading branch information
10 people authored Oct 29, 2021
1 parent 61e6bff commit d84bfe7
Show file tree
Hide file tree
Showing 456 changed files with 191,413 additions and 11,977 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-bikes-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/prism': minor
---

Adds typings for the main entrypoint
11 changes: 11 additions & 0 deletions .changeset/pink-trainers-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'astro': minor
---

Astro 0.21 Beta release! This introduces the new version of Astro that includes:

- A new, faster, Go-based compiler
- A runtime backed by Vite, with faster dev experience
- New features

See more at https://astro.build/blog/astro-021-preview/
40 changes: 40 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"docs": "0.0.7",
"@example/blog": "0.0.1",
"@example/blog-multiple-authors": "0.0.1",
"@example/docs": "0.0.1",
"@example/framework-lit": "0.0.1",
"@example/framework-multiple": "0.0.1",
"@example/framework-preact": "0.0.1",
"@example/framework-react": "0.0.1",
"@example/framework-solid": "0.0.1",
"@example/framework-svelte": "0.0.1",
"@example/framework-vue": "0.0.1",
"@example/minimal": "0.0.1",
"@example/portfolio": "0.0.1",
"@example/starter": "0.0.1",
"@example/with-markdown": "0.0.1",
"@example/with-markdown-plugins": "0.0.2",
"@example/with-nanostores": "0.0.1",
"@example/with-tailwindcss": "0.0.1",
"astro": "0.20.12",
"@astrojs/parser": "0.20.2",
"@astrojs/prism": "0.2.2",
"@astrojs/astro-test-builtins-dep": "0.0.1",
"@astrojs/test-custom-element-renderer": "0.0.1",
"create-astro": "0.6.6",
"@astrojs/markdown-remark": "0.3.1",
"@astrojs/renderer-lit": "0.1.2",
"@astrojs/renderer-preact": "0.2.2",
"@astrojs/renderer-react": "0.2.2",
"@astrojs/renderer-solid": "0.1.1",
"@astrojs/renderer-svelte": "0.1.2",
"@astrojs/renderer-vue": "0.1.9",
"astro-scripts": "0.0.1",
"www": "1.1.0"
},
"changesets": []
}
5 changes: 5 additions & 0 deletions .changeset/silly-apples-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': minor
---

Adds prism support within the Markdown plugin.
10 changes: 10 additions & 0 deletions .changeset/tiny-bulldogs-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@astrojs/renderer-lit': minor
'@astrojs/renderer-preact': minor
'@astrojs/renderer-react': minor
'@astrojs/renderer-solid': minor
'@astrojs/renderer-svelte': minor
'@astrojs/renderer-vue': minor
---

Updates the renderers to confirm to the new renderer API.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!packages/astro/**/*.js
!packages/astro/**/*.ts
packages/astro/test/**/*.js
packages/astro/vendor/vite/**/*
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'no-console': 'warn',
'no-shadow': 'error',
'prefer-const': 'off',
'prefer-rest-params': 'off',
'require-jsdoc': 'off',
// 'require-jsdoc': 'error', // re-enable this to enforce JSDoc for all functions
},
};
71 changes: 37 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
matrix:
os: [ubuntu-latest]
node_version: [12, 14, 16]
include:
- os: windows-latest
node_version: 14
# TODO: uncomment this (Vite has trouble resolving imports on Windows)
# include:
# - os: windows-latest
# node_version: 14
fail-fast: false

env:
LANG: en-us
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
steps:
- name: Checkout
Expand Down Expand Up @@ -72,33 +74,34 @@ jobs:
- name: Lint
run: yarn lint

smoke:
runs-on: ubuntu-latest
name: 'Smoke: node-14, ubuntu-latest'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set node version to 14
uses: actions/setup-node@v2
with:
node-version: 14
cache: 'yarn'

- name: Debug
run: yarn versions

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-engines

- name: Build
run: yarn build:all

- name: "Smoke Test: Build 'docs'"
run: yarn build
working-directory: ./docs

- name: "Smoke Test: Build 'www'"
run: yarn build
working-directory: ./www
# NOTE: temporarily disabled until `next` branch can build docs again
# smoke:
# runs-on: ubuntu-latest
# name: 'Smoke: node-14, ubuntu-latest'
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0

# - name: Set node version to 14
# uses: actions/setup-node@v2
# with:
# node-version: 14
# cache: 'yarn'

# - name: Debug
# run: yarn versions

# - name: Install dependencies
# run: yarn install --frozen-lockfile --ignore-engines

# - name: Build
# run: yarn build:all

# - name: "Smoke Test: Build 'docs'"
# run: yarn build
# working-directory: ./docs

# - name: "Smoke Test: Build 'www'"
# run: yarn build
# working-directory: ./www
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ package-lock.json

# do not commit .env files or any files that end with `.env`
*.env

!packages/astro/vendor/vite/dist
61 changes: 48 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ We welcome contributions of any size and skill level. As an open source project,
> **Tip for new contributors:**
> Take a look at [https://github.com/firstcontributions/first-contributions](https://github.com/firstcontributions/first-contributions) for helpful information on contributing
## Prerequisite
## Quick Guide

### Prerequisite

```shell
node: "^12.20.0 || ^14.13.1 || >=16.0.0"
yarn: "^1.22.10"
# otherwise, your build will fail
```

## Setting up your local repo
### Setting up your local repo

Astro uses yarn workspaces, so you should **always run `yarn install` from the top-level project directory.** running `yarn install` in the top-level project root will install dependencies for `astro`, `www`, `docs`, and every package in the repo.

Expand All @@ -23,7 +25,7 @@ yarn install
yarn build:all
```

## Development
### Development

```shell
# starts a file-watching, live-reloading dev script for active development
Expand All @@ -32,17 +34,26 @@ yarn dev
yarn build
```

## Running tests
#### Debugging Vite

You can debug vite by prefixing any command with `DEBUG` like so:

```
DEBUG=vite:* astro dev # debug everything in Vite
DEBUG=vite:[name] astro dev # debug specific process, e.g. "vite:deps" or "vite:transform"
```

### Running tests

```shell
# run this in the top-level project root to run all tests
yarn test
# run only a few tests, great for working on a single feature
# (example - `yarn test rss` runs `astro-rss.test.js` tests)
yarn test $STRING_MATCH
# (example - `yarn test -g "RSS"` runs `astro-rss.test.js`)
yarn test -g "$STRING_MATCH"
```

## Other useful commands
### Other useful commands

```shell
# auto-format the entire project
Expand All @@ -56,15 +67,15 @@ yarn format
yarn lint
```

## Making a Pull Request
### Making a Pull Request

When making a pull request, be sure to add a changeset when something has changed with Astro. Non-packages (`examples/*`, `docs/*`, and `www/*`) do not need changesets.

```shell
yarn changeset
```

## Running benchmarks
### Running benchmarks

We have benchmarks to keep performance under control. You can run these by running (from the project root):

Expand All @@ -83,15 +94,39 @@ node test/benchmark/dev.bench.js --save

Which will update the build and dev benchmarks.

# Releasing Astro
## Code Structure

Server-side rendering (SSR) can be complicated. The Astro package (`packages/astro`) is structured in a way to help think about the different systems.

- `components/`: Built-in components to use in your project (e.g. `import Code from 'astro/components/Code.astro'`)
- `src/`: Astro source
- `@types/`: TypeScript types. These are centralized to cut down on circular dependencies
- `cli/`: Code that powers the `astro` CLI command
- `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.
- `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

There are 3 contexts in which code executes:

- **Node.js**: this code lives in `src/core/`.
- **Inside Vite**: this code lives in `src/runtime/server/`.
- **In the browser**: this code lives in `src/runtime/client/`.

Understanding in which environment code runs, and at which stage in the process, can help clarify thinking about what Astro is doing. It also helps with debugging, for instance, if you’re working within `src/core/`, you know that your code isn’t executing within Vite, so you don’t have to debug Vite’s setup. But you will have to debug vite inside `runtime/server/`.

## Releasing Astro

_Note: Only priviledged contributors (L3+) can release new versions of Astro._

The repo is set up with automatic releases, using the changeset GitHub action & bot.

To release a new version of Astro, find the `Version Packages` PR, read it over, and merge it.

## Releasing PR preview snapshots
### Releasing PR preview snapshots

Our release tool `changeset` has a feature for releasing "snapshot" releases from a PR or custom branch. These are npm package publishes that live temporarily, so that you can give users a way to test a PR before merging. This can be a great way to get early user feedback while still in the PR review process.

Expand All @@ -112,7 +147,7 @@ git reset --hard

Full documentation: https://github.com/atlassian/changesets/blob/main/docs/snapshot-releases.md

## Releasing `astro@next` (aka "prerelease mode")
### 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.

Expand Down Expand Up @@ -154,7 +189,7 @@ When in prerelease mode, the automatic PR release process will no longer release
1. Go to https://github.com/snowpackjs/astro/releases/new and create a new release. Copy the new changelog entry from https://github.com/snowpackjs/astro/blob/latest/packages/astro/CHANGELOG.md.
1. Post in Discord #announcements channel, if needed!

# Translations
## Translations

Help us translate [docs.astro.build](https://docs.astro.build/) into as many languages as possible! This can be a great way to get involved with open source development without having to code.

Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"broken-link-checker": "^0.7.8",
"npm-run-all": "^4.1.5",
"pa11y-ci": "^2.4.2",
"prettier": "^2.3.2",
"prettier": "^2.4.1",
"start-server-and-test": "^1.12.6"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions docs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const SIDEBAR = {
{ text: 'RSS', link: 'guides/rss' },
{ text: 'Supported Imports', link: 'guides/imports' },
{ text: 'Aliases', link: 'guides/aliases' },
{ text: 'Environment Variables', link: 'guides/environment-variables' },
{ text: 'Deploy to the web', link: 'guides/deploy' },
{ text: 'Publish to npm', link: 'guides/publish-to-npm' },

Expand Down
11 changes: 1 addition & 10 deletions docs/src/pages/guides/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ console.log(data);

## Using `fetch()` outside of Astro Components

If you want to use `fetch()` in a non-astro component, use the [`node-fetch`](https://github.com/node-fetch/node-fetch) library:
If you want to use `fetch()` in a non-astro component, it is also globally available:

```tsx
// Movies.tsx
import fetch from 'node-fetch';
import type { FunctionalComponent } from 'preact';
import { h } from 'preact';

Expand All @@ -55,11 +54,3 @@ const Movies: FunctionalComponent = () => {

export default Movies;
```

If you load a component using `node-fetch` [interactively](/core-concepts/component-hydration), with `client:load`, `client:visible`, etc., you'll need to either not use `node-fetch` or switch to an [isomorphic](https://en.wikipedia.org/wiki/Isomorphic_JavaScript) library that will run both at build time and on the client, as the [`node-fetch` README.md](https://github.com/node-fetch/node-fetch#motivation) recommends:

> Instead of implementing XMLHttpRequest in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native http to fetch API directly? Hence, node-fetch, minimal code for a window.fetch compatible API on Node.js runtime.
>
> See Jason Miller's [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports node-fetch for server-side, whatwg-fetch for client-side).
> Quoted from https://github.com/node-fetch/node-fetch#motivation
Loading

0 comments on commit d84bfe7

Please sign in to comment.