Compare commits
46 commits
main
...
update-vit
Author | SHA1 | Date | |
---|---|---|---|
|
a0543a3378 | ||
|
d18168c275 | ||
|
8139a3cc52 | ||
|
8b9bfcc88a | ||
|
e86e0d3c8e | ||
|
626db1ee16 | ||
|
1ebf042575 | ||
|
95e5d13bba | ||
|
1a34fab1e4 | ||
|
73eadfe79a | ||
|
0457e2a8ee | ||
|
f30d95c3ea | ||
|
104c0ac6b6 | ||
|
5e75ab1fc6 | ||
|
cd365d2a08 | ||
|
12bbe4730e | ||
|
abbd505003 | ||
|
356b9ec073 | ||
|
2fb0b68a12 | ||
|
9df3571d96 | ||
|
a199bf3d2e | ||
|
ad518106a3 | ||
|
4c21b35ea6 | ||
|
9388fd0cdf | ||
|
3667e8b421 | ||
|
3d7c4b0247 | ||
|
ec6c6169dc | ||
|
bedb8cf82b | ||
|
e976f95529 | ||
|
ab7b03f18a | ||
|
50217148b2 | ||
|
a597e1c517 | ||
|
693cd41a1c | ||
|
95229a4d0b | ||
|
4a5750dbf0 | ||
|
b5246d1d4b | ||
|
8d3c7b6286 | ||
|
72b136498b | ||
|
85ecaab0cf | ||
|
45fd06c9ed | ||
|
f185b90d3a | ||
|
0aad491156 | ||
|
aa6109daca | ||
|
ce2b2848c6 | ||
|
b81691c9d5 | ||
|
2f8a6a2542 |
148 changed files with 10880 additions and 192895 deletions
5
.changeset/stupid-kings-lay.md
Normal file
5
.changeset/stupid-kings-lay.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Update vite to 2.7.0-beta.7
|
|
@ -3,6 +3,5 @@
|
|||
!packages/astro/**/*.js
|
||||
!packages/astro/**/*.ts
|
||||
packages/astro/test/**/*.js
|
||||
packages/astro/vendor/vite/**/*
|
||||
.github
|
||||
.changeset
|
||||
|
|
80
.github/workflows/ci.yml
vendored
80
.github/workflows/ci.yml
vendored
|
@ -21,7 +21,7 @@ defaults:
|
|||
|
||||
jobs:
|
||||
# Lint can run in parallel with Build.
|
||||
# We also run `yarn install` with the `--prefer-offline` flag to speed things up.
|
||||
# We also run `pnpm install` with the `--prefer-offline` flag to speed things up.
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -29,14 +29,18 @@ jobs:
|
|||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
|
@ -46,7 +50,7 @@ jobs:
|
|||
# Lint autofix cannot run on forks, so just skip those! See https://github.com/wearerequired/lint-action/issues/13
|
||||
- name: Lint (External)
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != github.repository_owner }}
|
||||
run: yarn lint
|
||||
run: pnpm run lint
|
||||
|
||||
# Otherwise, run lint autofixer
|
||||
- name: Lint
|
||||
|
@ -76,29 +80,33 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Cache Node Modules
|
||||
id: cache-node
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: "**/node_modules"
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build --force
|
||||
run: pnpm run build
|
||||
|
||||
- name: Upload Package Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
|
@ -108,7 +116,7 @@ jobs:
|
|||
if-no-files-found: error
|
||||
|
||||
# Test depends on Build's output, which allows us to skip any build process!
|
||||
# We also run `yarn install` with the `--prefer-offline` flag to speed things up.
|
||||
# We also run `pnpm install` with the `--prefer-offline` flag to speed things up.
|
||||
test:
|
||||
name: 'Test: ${{ matrix.os }} (node@${{ matrix.node_version }})'
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
@ -128,11 +136,15 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup node@${{ matrix.node_version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
|
@ -145,24 +157,24 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
with:
|
||||
path: "**/node_modules"
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Test
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: yarn test
|
||||
run: pnpm run test
|
||||
|
||||
# Turbo seems to make the tests hang on Windows, just run them directly
|
||||
- name: Test (Windows)
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: yarn workspace astro run test
|
||||
run: pnpm run test --filter=astro
|
||||
|
||||
smoke:
|
||||
name: 'Test (Smoke) ${{ matrix.os }}'
|
||||
|
@ -176,11 +188,15 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
|
@ -193,19 +209,19 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
with:
|
||||
path: "**/node_modules"
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Test
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: yarn run build:examples --concurrency=1
|
||||
run: pnpm run build:examples
|
||||
|
||||
# Turbo seems to fail on Windows, so run a custom script directly.
|
||||
- name: Test (Windows)
|
||||
|
@ -225,11 +241,15 @@ jobs:
|
|||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
|
@ -242,13 +262,13 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
with:
|
||||
path: "**/node_modules"
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.run_id }}
|
||||
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
|
@ -256,7 +276,7 @@ jobs:
|
|||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
publish: yarn changeset publish
|
||||
publish: pnpm exec changeset publish
|
||||
commit: '[ci] release'
|
||||
title: '[ci] release'
|
||||
env:
|
||||
|
|
11
.github/workflows/format.yml
vendored
11
.github/workflows/format.yml
vendored
|
@ -13,19 +13,22 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
- name: Set Node version to 16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
- name: Install dependencies
|
||||
run: yarn --frozen-lockfile --ignore-engines
|
||||
run: pnpm install
|
||||
env:
|
||||
CI: true
|
||||
- name: Format code
|
||||
run: yarn format
|
||||
run: pnpm run format
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: '[ci] yarn format'
|
||||
commit_message: '[ci] format'
|
||||
branch: ${{ github.head_ref }}
|
||||
|
|
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
|
@ -39,20 +39,24 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
if: steps.cache-npm.outputs.cache-hit != 'true'
|
||||
run: yarn install --prefer-offline --frozen-lockfile --ignore-engines --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: pnpm install --prefer-offline --registry https://registry.npmjs.org
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Check Modified
|
||||
run: yarn changeset status --output ./status.json
|
||||
run: pnpm changeset status --output ./status.json
|
||||
|
||||
- name: Check Output
|
||||
id: check_files
|
||||
|
|
17
.github/workflows/nightly.yml
vendored
17
.github/workflows/nightly.yml
vendored
|
@ -13,13 +13,16 @@ jobs:
|
|||
steps:
|
||||
- name: Check out code using Git
|
||||
uses: actions/checkout@v2
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
- name: Set Node version to 16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
|
||||
run: pnpm install --ignore-scripts
|
||||
- name: Collect stats
|
||||
run: node scripts/stats/index.js
|
||||
env:
|
||||
|
@ -38,17 +41,21 @@ jobs:
|
|||
- name: Check out code using Git
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.23.x
|
||||
|
||||
- name: Set Node version to 16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Clear lockfile
|
||||
run: rm -rf yarn.lock node_modules
|
||||
run: rm -rf pnpm-lock.yaml node_modules
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --ignore-engines --ignore-scripts
|
||||
run: pnpm install --ignore-engines --ignore-scripts
|
||||
|
||||
- name: Create Pull Request
|
||||
id: createpr
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,5 +13,3 @@ package-lock.json
|
|||
|
||||
# do not commit .env files or any files that end with `.env`
|
||||
*.env
|
||||
|
||||
!packages/astro/vendor/vite/dist
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
# Commands to start on workspace startup
|
||||
tasks:
|
||||
- init: yarn install
|
||||
command: yarn build
|
||||
- init: pnpm install
|
||||
command: pnpm build
|
||||
vscode:
|
||||
extensions:
|
||||
# TODO Once astro is on [vsx](https://open-vsx.org/), we should be able to specify it as an extension as well!
|
||||
|
|
1
.npmrc
Normal file
1
.npmrc
Normal file
|
@ -0,0 +1 @@
|
|||
shamefully-hoist=true
|
|
@ -11,18 +11,18 @@ We welcome contributions of any size and skill level. As an open source project,
|
|||
|
||||
```shell
|
||||
node: "^14.15.0 || >=16.0.0"
|
||||
yarn: "^1.22.10"
|
||||
pnpm: "^6.23.6"
|
||||
# otherwise, your build will fail
|
||||
```
|
||||
|
||||
### 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`, `docs`, 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`, `docs`, and every package in the repo.
|
||||
|
||||
```shell
|
||||
git clone && cd ...
|
||||
yarn install
|
||||
yarn build
|
||||
pnpm install
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
In [#2254](https://github.com/withastro/astro/pull/2254) a `.git-blame-ignore-revs` file was added to ignore repo-wide formatting changes. To improve your experience, you should run the following command locally.
|
||||
|
@ -35,9 +35,9 @@ git config --local blame.ignoreRevsFile .git-blame-ignore-revs
|
|||
|
||||
```shell
|
||||
# starts a file-watching, live-reloading dev script for active development
|
||||
yarn dev
|
||||
pnpm run dev
|
||||
# build the entire project, one time.
|
||||
yarn build
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
#### Debugging Vite
|
||||
|
@ -53,10 +53,10 @@ DEBUG=vite:[name] astro dev # debug specific process, e.g. "vite:deps" or "vit
|
|||
|
||||
```shell
|
||||
# run this in the top-level project root to run all tests
|
||||
yarn test
|
||||
pnpm run test
|
||||
# run only a few tests, great for working on a single feature
|
||||
# (example - `yarn test -g "RSS"` runs `astro-rss.test.js`)
|
||||
yarn test -g "$STRING_MATCH"
|
||||
# (example - `pnpm run test -g "RSS"` runs `astro-rss.test.js`)
|
||||
pnpm test -g "$STRING_MATCH"
|
||||
```
|
||||
|
||||
### Other useful commands
|
||||
|
@ -64,13 +64,13 @@ yarn test -g "$STRING_MATCH"
|
|||
```shell
|
||||
# auto-format the entire project
|
||||
# (optional - a GitHub Action formats every commit after a PR is merged)
|
||||
yarn format
|
||||
pnpm run format
|
||||
```
|
||||
|
||||
```shell
|
||||
# lint the project
|
||||
# (optional - our linter creates helpful warnings, but not errors.)
|
||||
yarn lint
|
||||
pnpm run lint
|
||||
```
|
||||
|
||||
### Making a Pull Request
|
||||
|
@ -78,7 +78,7 @@ yarn lint
|
|||
When making a pull request, be sure to add a changeset when something has changed with Astro. Non-packages (`examples/*`, `docs/*`) do not need changesets.
|
||||
|
||||
```shell
|
||||
yarn changeset
|
||||
pnpm exec changeset
|
||||
```
|
||||
|
||||
### Running benchmarks
|
||||
|
@ -86,7 +86,7 @@ yarn changeset
|
|||
We have benchmarks to keep performance under control. You can run these by running (from the project root):
|
||||
|
||||
```shell
|
||||
yarn workspace astro run benchmark
|
||||
pnpm run benchmark --filter=astro
|
||||
```
|
||||
|
||||
Which will fail if the performance has regressed by **10%** or more.
|
||||
|
@ -142,11 +142,11 @@ To release a snapshot, run the following locally:
|
|||
# Note: XXX should be a keyword to identify this release. Ex: `--snapshot routing` & `--tag next--routing`
|
||||
|
||||
# 1:
|
||||
yarn changeset version --snapshot XXX
|
||||
pnpm exec changeset version --snapshot XXX
|
||||
# 2: (Manual) review the diff, and make sure that you're not releasing more than you need to.
|
||||
git checkout -- examples/ docs/
|
||||
# 3:
|
||||
yarn release --tag next--XXX
|
||||
pnpm run release --tag next--XXX
|
||||
# 4: (Manual) review the publish, and if you're happy then you can throw out all local changes
|
||||
git reset --hard
|
||||
```
|
||||
|
@ -165,7 +165,7 @@ Full documentation: https://github.com/atlassian/changesets/blob/main/docs/prere
|
|||
|
||||
If you have gotten permission from the core contributors, you can enter into prerelease mode by following the following steps:
|
||||
|
||||
- Run: `yarn changeset pre enter next` in the project root
|
||||
- Run: `pnpm exec changeset pre enter next` in the project root
|
||||
- Create a new PR from the changes created by this command
|
||||
- Review, approve, and more the PR to enter prerelease mode.
|
||||
- If successful, The "Version Packages" PR (if one exists) will now say "Version Packages (next)".
|
||||
|
@ -174,7 +174,7 @@ If you have gotten permission from the core contributors, you can enter into pre
|
|||
|
||||
Exiting prerelease mode should happen once an experimental release is ready to go from `npm install astro@next` to `npm install astro`. Only a core contributor run these steps. These steps should be run before
|
||||
|
||||
- Run: `yarn changeset pre exit` in the project root
|
||||
- Run: `pnpm exec changeset pre exit` in the project root
|
||||
- Create a new PR from the changes created by this command.
|
||||
- Review, approve, and more the PR to enter prerelease mode.
|
||||
- If successful, The "Version Packages (next)" PR (if one exists) will now say "Version Packages".
|
||||
|
@ -187,9 +187,9 @@ When in prerelease mode, the automatic PR release process will no longer release
|
|||
1. Create a new `release/0.X` branch, if none exists.
|
||||
1. Point `release/0.X` to the latest commit for the `v0.X` version.
|
||||
1. `git cherry-pick` commits from `main`, as needed.
|
||||
1. Make sure that all changesets for the new release are included. You can create some manually (via `yarn changeset`) if needed.
|
||||
1. Run `yarn changeset version` to create your new release.
|
||||
1. Run `yarn release` to publish your new release.
|
||||
1. Make sure that all changesets for the new release are included. You can create some manually (via `pnpm exec changeset`) if needed.
|
||||
1. Run `pnpm exec changeset version` to create your new release.
|
||||
1. Run `pnpm run release` to publish your new release.
|
||||
1. Run `git push && git push --tags` to push your new release to GitHub.
|
||||
1. Run `git push release/0.X:latest` to push your release branch to `latest`. This will trigger an update to the docs site, etc.
|
||||
1. Go to https://github.com/withastro/astro/releases/new and create a new release. Copy the new changelog entry from https://github.com/withastro/astro/blob/latest/packages/astro/CHANGELOG.md.
|
||||
|
|
|
@ -10,9 +10,9 @@ For the RFC writing guide, check out the [RFC issue template](https://github.com
|
|||
|
||||
### Linting (Style Rules)
|
||||
|
||||
We use tools like ESLint and TypeScript to automatically enforce some parts of our style guide. Run the `yarn lint` command to lint the codebase. We also use tools like Prettier to automatically enforce code formatting. Run the `yarn format` command to format the entire codebase.
|
||||
We use tools like ESLint and TypeScript to automatically enforce some parts of our style guide. Run the `pnpm run lint` command to lint the codebase. We also use tools like Prettier to automatically enforce code formatting. Run the `pnpm run format` command to format the entire codebase.
|
||||
|
||||
Anything enforced by linting and formatting is considered a **style rule.** It is strictly required that you follow all style rules while working in the codebase. Run the `yarn lint` and `yarn format` commands to check your code at any time.
|
||||
Anything enforced by linting and formatting is considered a **style rule.** It is strictly required that you follow all style rules while working in the codebase. Run the `pnpm run lint` and `pnpm run format` commands to check your code at any time.
|
||||
|
||||
These style rules are maintained in configuration files, and therefore not documented in this document. Read any of the following configuration files to learn more about the style rules that we strictly enforced across the codebase:
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ Every pull request needs to be reviewed by another contributor to the documentat
|
|||
- Clone the Project
|
||||
|
||||
`git clone git@github.com:withastro/astro.git`
|
||||
- Run `yarn install` to install latest dependencies.
|
||||
> This project uses yarn to manage dependencies. [Make sure that you have yarn v1 installed.](https://classic.yarnpkg.com/)
|
||||
- Run `yarn workspace docs dev` to start the dev server.
|
||||
- Run `yarn workspace docs build` to build the final site for production.
|
||||
- Run `pnpm install` to install latest dependencies.
|
||||
> This project uses pnpm to manage dependencies.
|
||||
- Run `pnpm run dev --filter docs` to start the dev server.
|
||||
- Run `pnpm run build --filter docs` to build the final site for production.
|
||||
> The environment variable `SNOWPACK_PUBLIC_GITHUB_TOKEN` must be set to a personal access token with `public_repo` permissions to prevent rate-limiting.
|
||||
|
||||
## Deploying
|
||||
|
|
|
@ -8,20 +8,20 @@
|
|||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"lint": "run-p --aggregate-output lint:linkcheck",
|
||||
"lint:a11y": "start-test 'yarn build && yarn preview' 3000 'yarn lint:a11y:local'",
|
||||
"lint:a11y": "start-test 'pnpm run build && pnpm run preview' 3000 'pnpm run lint:a11y:local'",
|
||||
"lint:a11y:local": "pa11y-ci --sitemap 'http://localhost:3000/sitemap.xml' --sitemap-find 'https://docs.astro.build' --sitemap-replace 'http://localhost:3000'",
|
||||
"lint:a11y:remote": "pa11y-ci --sitemap 'https://docs.astro.build/sitemap.xml'",
|
||||
"lint:linkcheck": "start-test 'yarn dev --silent' 3000 'yarn lint:linkcheck:local'",
|
||||
"lint:linkcheck": "start-test 'pnpm run dev --silent' 3000 'pnpm run lint:linkcheck:local'",
|
||||
"lint:linkcheck:local": "blc -roe --user-agent 'broken-link-checker/0.7.8' 'http://localhost:3000/en/getting-started'",
|
||||
"lint:linkcheck:remote": "blc -ro --user-agent 'broken-link-checker/0.7.8' 'https://docs.astro.build/'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"astro": "^0.22.0",
|
||||
"astro": "workspace:^0.22.14",
|
||||
"broken-link-checker": "^0.7.8",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pa11y-ci": "^3.0.1",
|
||||
"prettier": "^2.4.1",
|
||||
"start-server-and-test": "^1.12.6"
|
||||
"prettier": "^2.5.1",
|
||||
"start-server-and-test": "^1.14.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/react": "^1.0.0-alpha.28"
|
||||
|
|
21
package.json
21
package.json
|
@ -7,7 +7,7 @@
|
|||
"url": "https://github.com/withastro/astro.git"
|
||||
},
|
||||
"scripts": {
|
||||
"release": "yarn build && changeset publish",
|
||||
"release": "pnpm run build && changeset publish",
|
||||
"build": "turbo run build --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
||||
"build:examples": "turbo run build --scope=docs --scope=\"@example/*\"",
|
||||
"dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
||||
|
@ -65,24 +65,23 @@
|
|||
],
|
||||
"volta": {
|
||||
"node": "14.17.0",
|
||||
"npm": "7.11.2",
|
||||
"yarn": "1.22.10"
|
||||
"npm": "7.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/changelog-github": "^0.4.2",
|
||||
"@changesets/cli": "^2.16.0",
|
||||
"@octokit/action": "^3.15.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"@changesets/cli": "^2.19.0",
|
||||
"@octokit/action": "^3.18.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
"del": "^6.0.0",
|
||||
"esbuild": "0.13.7",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint": "^8.7.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"execa": "^6.0.0",
|
||||
"prettier": "^2.4.1",
|
||||
"tiny-glob": "^0.2.8",
|
||||
"turbo": "^1.0.0",
|
||||
"prettier": "^2.5.1",
|
||||
"tiny-glob": "^0.2.9",
|
||||
"turbo": "^1.0.28",
|
||||
"typescript": "4.5.2"
|
||||
},
|
||||
"engines": {
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prepublish": "yarn build",
|
||||
"prepublish": "pnpm run build",
|
||||
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p tsconfig.json",
|
||||
"dev": "astro-scripts dev \"src/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": "^8.6.0",
|
||||
"acorn": "^8.7.0",
|
||||
"locate-character": "^2.0.5",
|
||||
"magic-string": "^0.25.3"
|
||||
"magic-string": "^0.25.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"astro-scripts": "0.0.1"
|
||||
"astro-scripts": "workspace:0.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0",
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"types": "./index.d.ts",
|
||||
"keywords": [],
|
||||
"devDependencies": {
|
||||
"prismjs": "^1.23.0"
|
||||
"prismjs": "^1.26.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0"
|
||||
|
|
|
@ -56,79 +56,80 @@
|
|||
"test": "mocha --parallel --timeout 15000"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/compiler": "^0.8.0",
|
||||
"@astrojs/language-server": "^0.8.6",
|
||||
"@astrojs/markdown-remark": "^0.6.0",
|
||||
"@astrojs/prism": "0.4.0",
|
||||
"@astrojs/renderer-preact": "^0.4.0",
|
||||
"@astrojs/renderer-react": "0.4.1",
|
||||
"@astrojs/renderer-svelte": "0.3.1",
|
||||
"@astrojs/renderer-vue": "0.3.0",
|
||||
"@astropub/webapi": "^0.10.1",
|
||||
"@babel/core": "^7.15.8",
|
||||
"@babel/traverse": "^7.15.4",
|
||||
"@proload/core": "^0.2.1",
|
||||
"@proload/plugin-tsm": "^0.1.0",
|
||||
"@types/babel__core": "^7.1.15",
|
||||
"@astrojs/compiler": "^0.8.2",
|
||||
"@astrojs/language-server": "^0.8.7",
|
||||
"@astrojs/markdown-remark": "workspace:^0.6.0",
|
||||
"@astrojs/prism": "workspace:0.4.0",
|
||||
"@astrojs/renderer-preact": "workspace:^0.4.0",
|
||||
"@astrojs/renderer-react": "workspace:0.4.1",
|
||||
"@astrojs/renderer-svelte": "workspace:0.3.1",
|
||||
"@astrojs/renderer-vue": "workspace:0.3.0",
|
||||
"@astropub/webapi": "^0.10.2",
|
||||
"@babel/core": "^7.16.7",
|
||||
"@babel/traverse": "^7.16.8",
|
||||
"@proload/core": "^0.2.2",
|
||||
"@proload/plugin-tsm": "^0.1.1",
|
||||
"@types/babel__core": "^7.1.18",
|
||||
"@web/parse5-utils": "^1.3.0",
|
||||
"astring": "^1.7.5",
|
||||
"ci-info": "^3.2.0",
|
||||
"babel-plugin-module-resolver": "^4.1.0",
|
||||
"ci-info": "^3.3.0",
|
||||
"common-ancestor-path": "^1.0.1",
|
||||
"connect": "^3.7.0",
|
||||
"eol": "^0.9.1",
|
||||
"es-module-lexer": "^0.9.3",
|
||||
"esbuild": "0.13.7",
|
||||
"estree-util-value-to-estree": "^1.2.0",
|
||||
"estree-walker": "^3.0.0",
|
||||
"fast-glob": "^3.2.7",
|
||||
"fast-xml-parser": "^4.0.0-beta.3",
|
||||
"estree-walker": "^3.0.1",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fast-xml-parser": "^4.0.1",
|
||||
"html-entities": "^2.3.2",
|
||||
"htmlparser2": "^7.1.2",
|
||||
"htmlparser2": "^7.2.0",
|
||||
"kleur": "^4.1.4",
|
||||
"magic-string": "^0.25.7",
|
||||
"mime": "^3.0.0",
|
||||
"morphdom": "^2.6.1",
|
||||
"node-fetch": "^3.0.0",
|
||||
"node-fetch": "^3.1.1",
|
||||
"parse5": "^6.0.1",
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"postcss": "^8.3.8",
|
||||
"prismjs": "^1.25.0",
|
||||
"rehype-slug": "^5.0.0",
|
||||
"resolve": "^1.20.0",
|
||||
"rollup": "^2.57.0",
|
||||
"sass": "^1.43.4",
|
||||
"postcss": "^8.4.5",
|
||||
"prismjs": "^1.26.0",
|
||||
"rehype-slug": "^5.0.1",
|
||||
"resolve": "^1.21.0",
|
||||
"rollup": "^2.64.0",
|
||||
"sass": "^1.48.0",
|
||||
"semver": "^7.3.5",
|
||||
"send": "^0.17.1",
|
||||
"shiki": "^0.9.10",
|
||||
"send": "^0.17.2",
|
||||
"serialize-javascript": "^6.0.0",
|
||||
"shiki": "^0.9.15",
|
||||
"shorthash": "^0.0.2",
|
||||
"slash": "^4.0.0",
|
||||
"sourcemap-codec": "^1.4.8",
|
||||
"srcset-parse": "^1.1.0",
|
||||
"string-width": "^5.0.0",
|
||||
"string-width": "^5.1.0",
|
||||
"strip-ansi": "^7.0.1",
|
||||
"supports-esm": "^1.0.0",
|
||||
"tsconfig-resolver": "^3.0.1",
|
||||
"vite": "~2.6.10",
|
||||
"vite": "^2.7.13",
|
||||
"yargs-parser": "^21.0.0",
|
||||
"zod": "^3.8.1"
|
||||
"zod": "^3.11.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/parser": "^0.22.0",
|
||||
"@babel/types": "^7.15.6",
|
||||
"@types/chai": "^4.2.22",
|
||||
"@astrojs/parser": "workspace:^0.22.0",
|
||||
"@babel/types": "^7.16.8",
|
||||
"@types/chai": "^4.3.0",
|
||||
"@types/common-ancestor-path": "^1.0.0",
|
||||
"@types/connect": "^3.4.35",
|
||||
"@types/mime": "^2.0.3",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node-fetch": "^3.0.0",
|
||||
"@types/node": "^14.18.8",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"@types/resolve": "^1.20.1",
|
||||
"@types/rimraf": "^3.0.2",
|
||||
"@types/send": "^0.17.1",
|
||||
"@types/yargs-parser": "^20.2.1",
|
||||
"astro-scripts": "workspace:0.0.1",
|
||||
"chai": "^4.3.4",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"mocha": "^9.1.3",
|
||||
"vite": "~2.6.10"
|
||||
"mocha": "^9.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || >=16.0.0",
|
||||
|
|
5
packages/astro/src/@types/serialize-javascript.d.ts
vendored
Normal file
5
packages/astro/src/@types/serialize-javascript.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
declare module 'serialize-javascript' {
|
||||
function serialize(value: any): string;
|
||||
|
||||
export default serialize;
|
||||
}
|
|
@ -21,7 +21,7 @@ export interface ScanBasedBuildOptions {
|
|||
viteServer: ViteDevServer;
|
||||
}
|
||||
|
||||
export async function build(opts: ScanBasedBuildOptions) {
|
||||
export async function build(opts: ScanBasedBuildOptions): ReturnType<typeof vite.build> {
|
||||
const { allPages, astroConfig, logging, origin, pageNames, routeCache, viteConfig, viteServer } = opts;
|
||||
|
||||
// Internal maps used to coordinate the HTML and CSS plugins.
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { AstroConfig } from '../@types/astro';
|
|||
import type { AstroDevServer } from './dev';
|
||||
import type { LogOptions } from './logger';
|
||||
|
||||
import { builtinModules } from 'module';
|
||||
import { builtinModules, createRequire } from 'module';
|
||||
import { fileURLToPath } from 'url';
|
||||
import vite from './vite.js';
|
||||
import astroVitePlugin from '../vite-plugin-astro/index.js';
|
||||
|
@ -12,11 +12,16 @@ import markdownVitePlugin from '../vite-plugin-markdown/index.js';
|
|||
import jsxVitePlugin from '../vite-plugin-jsx/index.js';
|
||||
import { resolveDependency } from './util.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
// Some packages are just external, and that’s the way it goes.
|
||||
const ALWAYS_EXTERNAL = new Set([
|
||||
...builtinModules.map((name) => `node:${name}`),
|
||||
'@sveltejs/vite-plugin-svelte',
|
||||
'estree-util-value-to-estree',
|
||||
'@proload/core',
|
||||
'@babel/core',
|
||||
'babel-plugin-module-resolver',
|
||||
'serialize-javascript',
|
||||
'micromark-util-events-to-acorn',
|
||||
'node-fetch',
|
||||
'prismjs',
|
||||
|
@ -24,9 +29,8 @@ const ALWAYS_EXTERNAL = new Set([
|
|||
'shorthash',
|
||||
'unified',
|
||||
'whatwg-url',
|
||||
]);
|
||||
const ALWAYS_NOEXTERNAL = new Set([
|
||||
'astro', // This is only because Vite's native ESM doesn't resolve "exports" correctly.
|
||||
'astro/dist/core/config.js',
|
||||
'rollup',
|
||||
]);
|
||||
|
||||
// note: ssr is still an experimental API hence the type omission
|
||||
|
@ -47,13 +51,14 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig,
|
|||
logLevel: 'error', // log errors only
|
||||
optimizeDeps: {
|
||||
entries: ['src/**/*'], // Try and scan a user’s project (won’t catch everything),
|
||||
exclude: [...ALWAYS_EXTERNAL],
|
||||
},
|
||||
plugins: [
|
||||
configAliasVitePlugin({ config: astroConfig }),
|
||||
astroVitePlugin({ config: astroConfig, devServer, logging }),
|
||||
markdownVitePlugin({ config: astroConfig, devServer }),
|
||||
jsxVitePlugin({ config: astroConfig, logging }),
|
||||
astroPostprocessVitePlugin({ config: astroConfig, devServer }),
|
||||
astroPostprocessVitePlugin({ config: astroConfig, devServer })
|
||||
],
|
||||
publicDir: fileURLToPath(astroConfig.public),
|
||||
root: fileURLToPath(astroConfig.projectRoot),
|
||||
|
@ -69,7 +74,7 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig,
|
|||
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
|
||||
ssr: {
|
||||
external: [...ALWAYS_EXTERNAL],
|
||||
noExternal: [...ALWAYS_NOEXTERNAL],
|
||||
noExternal: [],
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
export * from '../../vendor/vite/dist/node/index.js';
|
||||
export { default } from '../../vendor/vite/dist/node/index.js';
|
||||
export * from 'vite';
|
||||
export { default } from 'vite';
|
||||
|
|
|
@ -1,34 +1,11 @@
|
|||
import type { AstroComponentMetadata } from '../../@types/astro';
|
||||
import type { SSRElement, SSRResult } from '../../@types/astro';
|
||||
import { valueToEstree } from 'estree-util-value-to-estree';
|
||||
import * as astring from 'astring';
|
||||
import { hydrationSpecifier, serializeListValue } from './util.js';
|
||||
|
||||
const { generate, GENERATOR } = astring;
|
||||
|
||||
// INVESTIGATE: What features are we getting from this that we need?
|
||||
// JSON.stringify has a "replacer" argument.
|
||||
// A more robust version alternative to `JSON.stringify` that can handle most values
|
||||
// see https://github.com/remcohaszing/estree-util-value-to-estree#readme
|
||||
const customGenerator: astring.Generator = {
|
||||
...GENERATOR,
|
||||
Literal(node, state) {
|
||||
if (node.raw != null) {
|
||||
// escape closing script tags in strings so browsers wouldn't interpret them as
|
||||
// closing the actual end tag in HTML
|
||||
state.write(node.raw.replace('</script>', '<\\/script>'));
|
||||
} else {
|
||||
GENERATOR.Literal(node, state);
|
||||
}
|
||||
},
|
||||
};
|
||||
import { serializeListValue, hydrationSpecifier } from './util.js';
|
||||
import serialize from 'serialize-javascript';
|
||||
|
||||
// Serializes props passed into a component so that they can be reused during hydration.
|
||||
// The value is any
|
||||
export function serializeProps(value: any) {
|
||||
return generate(valueToEstree(value), {
|
||||
generator: customGenerator,
|
||||
});
|
||||
return serialize(value);
|
||||
}
|
||||
|
||||
const HydrationDirectives = ['load', 'idle', 'media', 'visible', 'only'];
|
||||
|
|
|
@ -12,21 +12,7 @@ type CompilationCache = Map<string, TransformResult>;
|
|||
|
||||
const configCache = new WeakMap<AstroConfig, CompilationCache>();
|
||||
|
||||
// https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
|
||||
function isSSR(options: undefined | boolean | { ssr: boolean }): boolean {
|
||||
if (options === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (typeof options === 'boolean') {
|
||||
return options;
|
||||
}
|
||||
if (typeof options == 'object') {
|
||||
return !!options.ssr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function compile(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts: boolean | undefined) {
|
||||
async function compile(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts?: { ssr?: boolean }) {
|
||||
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
|
||||
// everything else is treated as a fragment
|
||||
const filenameURL = new URL(`file://${filename}`);
|
||||
|
@ -57,7 +43,7 @@ async function compile(config: AstroConfig, filename: string, source: string, vi
|
|||
lang,
|
||||
id: filename,
|
||||
transformHook: viteTransform,
|
||||
ssr: isSSR(opts),
|
||||
ssr: Boolean(opts?.ssr),
|
||||
});
|
||||
|
||||
let map: SourceMapInput | undefined;
|
||||
|
@ -91,7 +77,7 @@ export function invalidateCompilation(config: AstroConfig, filename: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function cachedCompilation(config: AstroConfig, filename: string, source: string | null, viteTransform: TransformHook, opts: boolean | undefined) {
|
||||
export async function cachedCompilation(config: AstroConfig, filename: string, source: string | null, viteTransform: TransformHook, opts?: { ssr?: boolean; }) {
|
||||
let cache: CompilationCache;
|
||||
if (!configCache.has(config)) {
|
||||
cache = new Map();
|
||||
|
|
|
@ -9,9 +9,9 @@ import { STYLE_EXTENSIONS } from '../core/ssr/css.js';
|
|||
const PLUGIN_NAME = '@astrojs/rollup-plugin-build-css';
|
||||
|
||||
// This is a virtual module that represents the .astro <style> usage on a page
|
||||
const ASTRO_STYLE_PREFIX = '@astro-inline-style';
|
||||
const ASTRO_STYLE_PREFIX = '\0astro-inline-style';
|
||||
|
||||
const ASTRO_PAGE_STYLE_PREFIX = '@astro-page-all-styles';
|
||||
const ASTRO_PAGE_STYLE_PREFIX = '\0astro-page-all-styles';
|
||||
|
||||
const cssRe = new RegExp(
|
||||
`\\.(${Array.from(STYLE_EXTENSIONS)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { InputOptions } from 'rollup';
|
||||
import type { InputOptions } from 'rollup';
|
||||
|
||||
function fromEntries<V>(entries: [string, V][]) {
|
||||
const obj: Record<string, V> = {};
|
||||
|
|
|
@ -61,7 +61,7 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
|
|||
const cssChunkMap = new Map<string, string[]>();
|
||||
const pageStyleImportOrder: string[] = [];
|
||||
|
||||
return {
|
||||
const plugin: VitePlugin = {
|
||||
name: PLUGIN_NAME,
|
||||
|
||||
enforce: 'pre',
|
||||
|
@ -496,4 +496,6 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
|
|||
}
|
||||
},
|
||||
};
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,11 @@ export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL;
|
|||
name: '@astrojs/vite-plugin-config-alias',
|
||||
enforce: 'pre',
|
||||
async resolveId(sourceId: string, importer, options) {
|
||||
let resolvedId;
|
||||
try {
|
||||
/** Resolved ID conditionally handled by any other resolver. (this gives priority to all other resolvers) */
|
||||
const resolvedId = await this.resolve(sourceId, importer, { skipSelf: true, ...options });
|
||||
resolvedId = await this.resolve(sourceId, importer, { skipSelf: true, ...options });
|
||||
} catch (e) {}
|
||||
|
||||
// if any other resolver handles the file, return that resolution
|
||||
if (resolvedId) return resolvedId;
|
||||
|
@ -93,8 +96,11 @@ export default function configAliasVitePlugin(astroConfig: { projectRoot?: URL;
|
|||
/** Processed Source ID with our alias applied. */
|
||||
const aliasedSourceId = sourceId.replace(alias.find, alias.replacement);
|
||||
|
||||
let resolvedAliasedId;
|
||||
try {
|
||||
/** Resolved ID conditionally handled by any other resolver. (this also gives priority to all other resolvers) */
|
||||
const resolvedAliasedId = await this.resolve(aliasedSourceId, importer, { skipSelf: true, ...options });
|
||||
resolvedAliasedId = await this.resolve(aliasedSourceId, importer, { skipSelf: true, ...options });
|
||||
} catch (e) {}
|
||||
|
||||
// if the existing resolvers find the file, return that resolution
|
||||
if (resolvedAliasedId) return resolvedAliasedId;
|
||||
|
|
|
@ -3,20 +3,6 @@ import type { BaseNode, Identifier } from 'estree';
|
|||
import MagicString from 'magic-string';
|
||||
import { walk } from 'estree-walker';
|
||||
|
||||
// https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
|
||||
function isSSR(options: undefined | boolean | { ssr: boolean }): boolean {
|
||||
if (options === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (typeof options === 'boolean') {
|
||||
return options;
|
||||
}
|
||||
if (typeof options == 'object') {
|
||||
return !!options.ssr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// This matches any JS-like file (that we know of)
|
||||
// See https://regex101.com/r/Cgofir/1
|
||||
const SUPPORTED_FILES = /\.(astro|svelte|vue|[cm]?js|jsx|[cm]?ts|tsx)$/;
|
||||
|
@ -32,7 +18,7 @@ export default function pluginFetch(): Plugin {
|
|||
name: '@astrojs/vite-plugin-fetch',
|
||||
enforce: 'post',
|
||||
async transform(code, id, opts) {
|
||||
const ssr = isSSR(opts);
|
||||
const ssr = Boolean(opts?.ssr);
|
||||
// If this isn't an SSR pass, `fetch` will already be available!
|
||||
if (!ssr) {
|
||||
return null;
|
||||
|
|
|
@ -24,21 +24,6 @@ const IMPORT_STATEMENTS: Record<string, string> = {
|
|||
// be careful about esbuild not treating h, React, Fragment, etc. as unused.
|
||||
const PREVENT_UNUSED_IMPORTS = ';;(React,Fragment,h);';
|
||||
|
||||
// This check on a flexible "options" object is needed because Vite uses this flexible argument for ssr.
|
||||
// More context: https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
|
||||
function isSSR(options: undefined | boolean | { ssr: boolean }): boolean {
|
||||
if (options === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (typeof options === 'boolean') {
|
||||
return options;
|
||||
}
|
||||
if (typeof options == 'object') {
|
||||
return !!options.ssr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getEsbuildLoader(fileExt: string): string {
|
||||
return fileExt.substr(1);
|
||||
}
|
||||
|
@ -103,8 +88,8 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
|
|||
configResolved(resolvedConfig) {
|
||||
viteConfig = resolvedConfig;
|
||||
},
|
||||
async transform(code, id, ssrOrOptions) {
|
||||
const ssr = isSSR(ssrOrOptions);
|
||||
async transform(code, id, options) {
|
||||
const ssr = Boolean(options?.ssr);
|
||||
if (!JSX_EXTENSIONS.has(path.extname(id))) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -277,7 +277,8 @@ describe('CSS', function () {
|
|||
expect((await fixture.fetch(href)).status).to.equal(200);
|
||||
});
|
||||
|
||||
it('resolved imported CSS with ?url', async () => {
|
||||
// Waiting on https://github.com/vitejs/vite/pull/5940
|
||||
it.skip('resolved imported CSS with ?url', async () => {
|
||||
const href = $('link[href$="imported-url.css"]').attr('href');
|
||||
expect((await fixture.fetch(href)).status).to.equal(200);
|
||||
});
|
||||
|
|
8
packages/astro/test/fixtures/0-css/package.json
vendored
Normal file
8
packages/astro/test/fixtures/0-css/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-0-css",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-assets/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-assets/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-assets",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-attrs/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-attrs/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-attrs",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-basic/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-basic/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-basic",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-children/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-children/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-children",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-class-list/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-class-list/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-class-list",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-client-only/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-client-only/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-client-only",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-component-code/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-component-code/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-component-code",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-components/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-components/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-components",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-css-bundling-import/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-css-bundling-import/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-css-bundling-import",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-css-bundling-nested-layouts/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-css-bundling-nested-layouts/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-css-bundling-nested-layouts",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-css-bundling/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-css-bundling/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-css-bundling",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-doctype/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-doctype/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-doctype",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-dynamic/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-dynamic/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-dynamic",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-envs/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-envs/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-envs",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-expr/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-expr/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-expr",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-external-files/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-external-files/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-external-files",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-fallback/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-fallback/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-fallback",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-get-static-paths/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-get-static-paths/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-get-static-paths",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-global/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-global/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-global",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
9
packages/astro/test/fixtures/astro-jsx/package.json
vendored
Normal file
9
packages/astro/test/fixtures/astro-jsx/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-jsx",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/renderer-solid": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-markdown-plugins/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-markdown-plugins/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-markdown-plugins",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-markdown/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-markdown/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-markdown",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-page-directory-url/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-page-directory-url/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-page-directory-url",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-pages/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-pages/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-pages",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-pagination/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-pagination/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-pagination",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-partial-html/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-partial-html/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-partial-html",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-public/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-public/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-public",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-scripts/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-scripts/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-scripts",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-sitemap-rss/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-sitemap-rss/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-sitemap-rss",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/astro-slots/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-slots/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-astro-slots",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
"version": "1.2.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/astro-test-builtins-dep": "file:./packages/dep"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/config-hostname/package.json
vendored
Normal file
8
packages/astro/test/fixtures/config-hostname/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-config-hostname",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/config-path/package.json
vendored
Normal file
8
packages/astro/test/fixtures/config-path/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-config-path",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/config-port/package.json
vendored
Normal file
8
packages/astro/test/fixtures/config-port/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-config-port",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@astrojs/test-custom-element-renderer": "0.0.1"
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/test-custom-element-renderer": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
|
8
packages/astro/test/fixtures/debug-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/debug-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-debug-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
9
packages/astro/test/fixtures/errors/package.json
vendored
Normal file
9
packages/astro/test/fixtures/errors/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@astrojs/test-errors",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/renderer-solid": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/fetch/package.json
vendored
Normal file
8
packages/astro/test/fixtures/fetch/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-fetch",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
9
packages/astro/test/fixtures/lit-element/package.json
vendored
Normal file
9
packages/astro/test/fixtures/lit-element/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@astrojs/test-lit-element",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/renderer-lit": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/markdown/package.json
vendored
Normal file
8
packages/astro/test/fixtures/markdown/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-markdown",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
9
packages/astro/test/fixtures/postcss/package.json
vendored
Normal file
9
packages/astro/test/fixtures/postcss/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@astrojs/test-postcss",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/renderer-solid": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/preact-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/preact-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-preact-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/react-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/react-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-react-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/remote-css/package.json
vendored
Normal file
8
packages/astro/test/fixtures/remote-css/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-remote-css",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/route-manifest/package.json
vendored
Normal file
8
packages/astro/test/fixtures/route-manifest/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-route-manifest",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/sass/package.json
vendored
Normal file
8
packages/astro/test/fixtures/sass/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-sass",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/slots-preact/package.json
vendored
Normal file
8
packages/astro/test/fixtures/slots-preact/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-slots-preact",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/slots-react/package.json
vendored
Normal file
8
packages/astro/test/fixtures/slots-react/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-slots-react",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/slots-solid/package.json
vendored
Normal file
8
packages/astro/test/fixtures/slots-solid/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-slots-solid",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/slots-svelte/package.json
vendored
Normal file
8
packages/astro/test/fixtures/slots-svelte/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-slots-svelte",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/slots-vue/package.json
vendored
Normal file
8
packages/astro/test/fixtures/slots-vue/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-slots-vue",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/solid-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/solid-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-solid-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/static-build-code-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/static-build-code-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-static-build-code-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/static-build-frameworks/package.json
vendored
Normal file
8
packages/astro/test/fixtures/static-build-frameworks/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-static-build-frameworks",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/static-build/package.json
vendored
Normal file
8
packages/astro/test/fixtures/static-build/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-static-build",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/svelte-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/svelte-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-svelte-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/vue-component/package.json
vendored
Normal file
8
packages/astro/test/fixtures/vue-component/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-vue-component",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/with-subpath-no-trailing-slash/package.json
vendored
Normal file
8
packages/astro/test/fixtures/with-subpath-no-trailing-slash/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-with-subpath-no-trailing-slash",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/with-subpath-trailing-slash/package.json
vendored
Normal file
8
packages/astro/test/fixtures/with-subpath-trailing-slash/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-with-subpath-trailing-slash",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/without-site-config/package.json
vendored
Normal file
8
packages/astro/test/fixtures/without-site-config/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-without-site-config",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/astro/test/fixtures/without-subpath/package.json
vendored
Normal file
8
packages/astro/test/fixtures/without-subpath/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@astrojs/test-without-subpath",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
2150
packages/astro/vendor/vite/LICENSE.md
vendored
2150
packages/astro/vendor/vite/LICENSE.md
vendored
File diff suppressed because it is too large
Load diff
204
packages/astro/vendor/vite/client.d.ts
vendored
204
packages/astro/vendor/vite/client.d.ts
vendored
|
@ -1,204 +0,0 @@
|
|||
/// <reference lib="dom" />
|
||||
/// <reference path="./types/importMeta.d.ts" />
|
||||
|
||||
// CSS modules
|
||||
type CSSModuleClasses = { readonly [key: string]: string }
|
||||
|
||||
declare module '*.module.css' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.scss' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.sass' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.less' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.styl' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.stylus' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
declare module '*.module.pcss' {
|
||||
const classes: CSSModuleClasses
|
||||
export default classes
|
||||
}
|
||||
|
||||
// CSS
|
||||
declare module '*.css' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.scss' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.sass' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.less' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.styl' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.stylus' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
declare module '*.pcss' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
|
||||
// Built-in asset types
|
||||
// see `src/constants.ts`
|
||||
|
||||
// images
|
||||
declare module '*.jpg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.jpeg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.png' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.gif' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.svg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ico' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.webp' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.avif' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// media
|
||||
declare module '*.mp4' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.webm' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ogg' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.mp3' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.wav' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.flac' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.aac' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// fonts
|
||||
declare module '*.woff' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.woff2' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.eot' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.ttf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.otf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// other
|
||||
declare module '*.wasm' {
|
||||
const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>
|
||||
export default initWasm
|
||||
}
|
||||
declare module '*.webmanifest' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
declare module '*.pdf' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
// web worker
|
||||
declare module '*?worker' {
|
||||
const workerConstructor: {
|
||||
new (): Worker
|
||||
}
|
||||
export default workerConstructor
|
||||
}
|
||||
|
||||
declare module '*?worker&inline' {
|
||||
const workerConstructor: {
|
||||
new (): Worker
|
||||
}
|
||||
export default workerConstructor
|
||||
}
|
||||
|
||||
declare module '*?sharedworker' {
|
||||
const sharedWorkerConstructor: {
|
||||
new (): SharedWorker
|
||||
}
|
||||
export default sharedWorkerConstructor
|
||||
}
|
||||
|
||||
declare module '*?raw' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?url' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
||||
|
||||
declare module '*?inline' {
|
||||
const src: string
|
||||
export default src
|
||||
}
|
553
packages/astro/vendor/vite/dist/client/client.mjs
vendored
553
packages/astro/vendor/vite/dist/client/client.mjs
vendored
|
@ -1,553 +0,0 @@
|
|||
import '@vite/env';
|
||||
|
||||
const template = /*html*/ `
|
||||
<style>
|
||||
:host {
|
||||
position: fixed;
|
||||
z-index: 99999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: scroll;
|
||||
margin: 0;
|
||||
background: rgba(0, 0, 0, 0.66);
|
||||
--monospace: 'SFMono-Regular', Consolas,
|
||||
'Liberation Mono', Menlo, Courier, monospace;
|
||||
--red: #ff5555;
|
||||
--yellow: #e2aa53;
|
||||
--purple: #cfa4ff;
|
||||
--cyan: #2dd9da;
|
||||
--dim: #c9c9c9;
|
||||
}
|
||||
|
||||
.window {
|
||||
font-family: var(--monospace);
|
||||
line-height: 1.5;
|
||||
width: 800px;
|
||||
color: #d8d8d8;
|
||||
margin: 30px auto;
|
||||
padding: 25px 40px;
|
||||
position: relative;
|
||||
background: #181818;
|
||||
border-radius: 6px 6px 8px 8px;
|
||||
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
||||
overflow: hidden;
|
||||
border-top: 8px solid var(--red);
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: var(--monospace);
|
||||
font-size: 16px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1em;
|
||||
overflow-x: scroll;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
pre::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.message {
|
||||
line-height: 1.3;
|
||||
font-weight: 600;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.message-body {
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.plugin {
|
||||
color: var(--purple);
|
||||
}
|
||||
|
||||
.file {
|
||||
color: var(--cyan);
|
||||
margin-bottom: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.frame {
|
||||
color: var(--yellow);
|
||||
}
|
||||
|
||||
.stack {
|
||||
font-size: 13px;
|
||||
color: var(--dim);
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
border-top: 1px dotted #999;
|
||||
padding-top: 13px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 13px;
|
||||
font-family: var(--monospace);
|
||||
color: var(--yellow);
|
||||
}
|
||||
|
||||
.file-link {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<div class="window">
|
||||
<pre class="message"><span class="plugin"></span><span class="message-body"></span></pre>
|
||||
<pre class="file"></pre>
|
||||
<pre class="frame"></pre>
|
||||
<pre class="stack"></pre>
|
||||
<div class="tip">
|
||||
Click outside or fix the code to dismiss.<br>
|
||||
You can also disable this overlay by setting
|
||||
<code>server.hmr.overlay</code> to <code>false</code> in <code>vite.config.js.</code>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
const fileRE = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
||||
const codeframeRE = /^(?:>?\s+\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;
|
||||
class ErrorOverlay extends HTMLElement {
|
||||
constructor(err) {
|
||||
var _a;
|
||||
super();
|
||||
this.root = this.attachShadow({ mode: 'open' });
|
||||
this.root.innerHTML = template;
|
||||
codeframeRE.lastIndex = 0;
|
||||
const hasFrame = err.frame && codeframeRE.test(err.frame);
|
||||
const message = hasFrame
|
||||
? err.message.replace(codeframeRE, '')
|
||||
: err.message;
|
||||
if (err.plugin) {
|
||||
this.text('.plugin', `[plugin:${err.plugin}] `);
|
||||
}
|
||||
this.text('.message-body', message.trim());
|
||||
const [file] = (((_a = err.loc) === null || _a === void 0 ? void 0 : _a.file) || err.id || 'unknown file').split(`?`);
|
||||
if (err.loc) {
|
||||
this.text('.file', `${file}:${err.loc.line}:${err.loc.column}`, true);
|
||||
}
|
||||
else if (err.id) {
|
||||
this.text('.file', file);
|
||||
}
|
||||
if (hasFrame) {
|
||||
this.text('.frame', err.frame.trim());
|
||||
}
|
||||
this.text('.stack', err.stack, true);
|
||||
this.root.querySelector('.window').addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
this.addEventListener('click', () => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
text(selector, text, linkFiles = false) {
|
||||
const el = this.root.querySelector(selector);
|
||||
if (!linkFiles) {
|
||||
el.textContent = text;
|
||||
}
|
||||
else {
|
||||
let curIndex = 0;
|
||||
let match;
|
||||
while ((match = fileRE.exec(text))) {
|
||||
const { 0: file, index } = match;
|
||||
if (index != null) {
|
||||
const frag = text.slice(curIndex, index);
|
||||
el.appendChild(document.createTextNode(frag));
|
||||
const link = document.createElement('a');
|
||||
link.textContent = file;
|
||||
link.className = 'file-link';
|
||||
link.onclick = () => {
|
||||
fetch('/__open-in-editor?file=' + encodeURIComponent(file));
|
||||
};
|
||||
el.appendChild(link);
|
||||
curIndex += frag.length + file.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close() {
|
||||
var _a;
|
||||
(_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this);
|
||||
}
|
||||
}
|
||||
const overlayId = 'vite-error-overlay';
|
||||
if (customElements && !customElements.get(overlayId)) {
|
||||
customElements.define(overlayId, ErrorOverlay);
|
||||
}
|
||||
|
||||
console.log('[vite] connecting...');
|
||||
// use server configuration, then fallback to inference
|
||||
const socketProtocol = __HMR_PROTOCOL__ || (location.protocol === 'https:' ? 'wss' : 'ws');
|
||||
const socketHost = `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`;
|
||||
const socket = new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr');
|
||||
const base = __BASE__ || '/';
|
||||
function warnFailedFetch(err, path) {
|
||||
if (!err.message.match('fetch')) {
|
||||
console.error(err);
|
||||
}
|
||||
console.error(`[hmr] Failed to reload ${path}. ` +
|
||||
`This could be due to syntax errors or importing non-existent ` +
|
||||
`modules. (see errors above)`);
|
||||
}
|
||||
// Listen for messages
|
||||
socket.addEventListener('message', async ({ data }) => {
|
||||
handleMessage(JSON.parse(data));
|
||||
});
|
||||
let isFirstUpdate = true;
|
||||
async function handleMessage(payload) {
|
||||
switch (payload.type) {
|
||||
case 'connected':
|
||||
console.log(`[vite] connected.`);
|
||||
// proxy(nginx, docker) hmr ws maybe caused timeout,
|
||||
// so send ping package let ws keep alive.
|
||||
setInterval(() => socket.send('ping'), __HMR_TIMEOUT__);
|
||||
break;
|
||||
case 'update':
|
||||
notifyListeners('vite:beforeUpdate', payload);
|
||||
// if this is the first update and there's already an error overlay, it
|
||||
// means the page opened with existing server compile error and the whole
|
||||
// module script failed to load (since one of the nested imports is 500).
|
||||
// in this case a normal update won't work and a full reload is needed.
|
||||
if (isFirstUpdate && hasErrorOverlay()) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
clearErrorOverlay();
|
||||
isFirstUpdate = false;
|
||||
}
|
||||
payload.updates.forEach((update) => {
|
||||
if (update.type === 'js-update') {
|
||||
queueUpdate(fetchUpdate(update));
|
||||
}
|
||||
else {
|
||||
// css-update
|
||||
// this is only sent when a css file referenced with <link> is updated
|
||||
let { path, timestamp } = update;
|
||||
path = path.replace(/\?.*/, '');
|
||||
// can't use querySelector with `[href*=]` here since the link may be
|
||||
// using relative paths so we need to use link.href to grab the full
|
||||
// URL for the include check.
|
||||
const el = [].slice.call(document.querySelectorAll(`link`)).find((e) => e.href.includes(path));
|
||||
if (el) {
|
||||
const newPath = `${base}${path.slice(1)}${path.includes('?') ? '&' : '?'}t=${timestamp}`;
|
||||
el.href = new URL(newPath, el.href).href;
|
||||
}
|
||||
console.log(`[vite] css hot updated: ${path}`);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'custom': {
|
||||
notifyListeners(payload.event, payload.data);
|
||||
break;
|
||||
}
|
||||
case 'full-reload':
|
||||
notifyListeners('vite:beforeFullReload', payload);
|
||||
if (payload.path && payload.path.endsWith('.html')) {
|
||||
// if html file is edited, only reload the page if the browser is
|
||||
// currently on that page.
|
||||
const pagePath = location.pathname;
|
||||
const payloadPath = base + payload.path.slice(1);
|
||||
if (pagePath === payloadPath ||
|
||||
(pagePath.endsWith('/') && pagePath + 'index.html' === payloadPath)) {
|
||||
location.reload();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
break;
|
||||
case 'prune':
|
||||
notifyListeners('vite:beforePrune', payload);
|
||||
// After an HMR update, some modules are no longer imported on the page
|
||||
// but they may have left behind side effects that need to be cleaned up
|
||||
// (.e.g style injections)
|
||||
// TODO Trigger their dispose callbacks.
|
||||
payload.paths.forEach((path) => {
|
||||
const fn = pruneMap.get(path);
|
||||
if (fn) {
|
||||
fn(dataMap.get(path));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'error': {
|
||||
notifyListeners('vite:error', payload);
|
||||
const err = payload.err;
|
||||
if (enableOverlay) {
|
||||
createErrorOverlay(err);
|
||||
}
|
||||
else {
|
||||
console.error(`[vite] Internal Server Error\n${err.message}\n${err.stack}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
const check = payload;
|
||||
return check;
|
||||
}
|
||||
}
|
||||
}
|
||||
function notifyListeners(event, data) {
|
||||
const cbs = customListenersMap.get(event);
|
||||
if (cbs) {
|
||||
cbs.forEach((cb) => cb(data));
|
||||
}
|
||||
}
|
||||
const enableOverlay = __HMR_ENABLE_OVERLAY__;
|
||||
function createErrorOverlay(err) {
|
||||
if (!enableOverlay)
|
||||
return;
|
||||
clearErrorOverlay();
|
||||
document.body.appendChild(new ErrorOverlay(err));
|
||||
}
|
||||
function clearErrorOverlay() {
|
||||
document
|
||||
.querySelectorAll(overlayId)
|
||||
.forEach((n) => n.close());
|
||||
}
|
||||
function hasErrorOverlay() {
|
||||
return document.querySelectorAll(overlayId).length;
|
||||
}
|
||||
let pending = false;
|
||||
let queued = [];
|
||||
/**
|
||||
* buffer multiple hot updates triggered by the same src change
|
||||
* so that they are invoked in the same order they were sent.
|
||||
* (otherwise the order may be inconsistent because of the http request round trip)
|
||||
*/
|
||||
async function queueUpdate(p) {
|
||||
queued.push(p);
|
||||
if (!pending) {
|
||||
pending = true;
|
||||
await Promise.resolve();
|
||||
pending = false;
|
||||
const loading = [...queued];
|
||||
queued = [];
|
||||
(await Promise.all(loading)).forEach((fn) => fn && fn());
|
||||
}
|
||||
}
|
||||
async function waitForSuccessfulPing(ms = 1000) {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
try {
|
||||
await fetch(`${base}__vite_ping`);
|
||||
break;
|
||||
}
|
||||
catch (e) {
|
||||
await new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
}
|
||||
// ping server
|
||||
socket.addEventListener('close', async ({ wasClean }) => {
|
||||
if (wasClean)
|
||||
return;
|
||||
console.log(`[vite] server connection lost. polling for restart...`);
|
||||
await waitForSuccessfulPing();
|
||||
location.reload();
|
||||
});
|
||||
const sheetsMap = new Map();
|
||||
function updateStyle(id, content) {
|
||||
let style = sheetsMap.get(id);
|
||||
{
|
||||
if (style && !(style instanceof HTMLStyleElement)) {
|
||||
removeStyle(id);
|
||||
style = undefined;
|
||||
}
|
||||
if (!style) {
|
||||
style = document.createElement('style');
|
||||
style.setAttribute('type', 'text/css');
|
||||
style.innerHTML = content;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
else {
|
||||
style.innerHTML = content;
|
||||
}
|
||||
}
|
||||
sheetsMap.set(id, style);
|
||||
}
|
||||
function removeStyle(id) {
|
||||
const style = sheetsMap.get(id);
|
||||
if (style) {
|
||||
if (style instanceof CSSStyleSheet) {
|
||||
// @ts-ignore
|
||||
document.adoptedStyleSheets.indexOf(style);
|
||||
// @ts-ignore
|
||||
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== style);
|
||||
}
|
||||
else {
|
||||
document.head.removeChild(style);
|
||||
}
|
||||
sheetsMap.delete(id);
|
||||
}
|
||||
}
|
||||
async function fetchUpdate({ path, acceptedPath, timestamp }) {
|
||||
const mod = hotModulesMap.get(path);
|
||||
if (!mod) {
|
||||
// In a code-splitting project,
|
||||
// it is common that the hot-updating module is not loaded yet.
|
||||
// https://github.com/vitejs/vite/issues/721
|
||||
return;
|
||||
}
|
||||
const moduleMap = new Map();
|
||||
const isSelfUpdate = path === acceptedPath;
|
||||
// make sure we only import each dep once
|
||||
const modulesToUpdate = new Set();
|
||||
if (isSelfUpdate) {
|
||||
// self update - only update self
|
||||
modulesToUpdate.add(path);
|
||||
}
|
||||
else {
|
||||
// dep update
|
||||
for (const { deps } of mod.callbacks) {
|
||||
deps.forEach((dep) => {
|
||||
if (acceptedPath === dep) {
|
||||
modulesToUpdate.add(dep);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// determine the qualified callbacks before we re-import the modules
|
||||
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => {
|
||||
return deps.some((dep) => modulesToUpdate.has(dep));
|
||||
});
|
||||
await Promise.all(Array.from(modulesToUpdate).map(async (dep) => {
|
||||
const disposer = disposeMap.get(dep);
|
||||
if (disposer)
|
||||
await disposer(dataMap.get(dep));
|
||||
const [path, query] = dep.split(`?`);
|
||||
try {
|
||||
const newMod = await import(
|
||||
/* @vite-ignore */
|
||||
base +
|
||||
path.slice(1) +
|
||||
`?import&t=${timestamp}${query ? `&${query}` : ''}`);
|
||||
moduleMap.set(dep, newMod);
|
||||
}
|
||||
catch (e) {
|
||||
warnFailedFetch(e, dep);
|
||||
}
|
||||
}));
|
||||
return () => {
|
||||
for (const { deps, fn } of qualifiedCallbacks) {
|
||||
fn(deps.map((dep) => moduleMap.get(dep)));
|
||||
}
|
||||
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
||||
console.log(`[vite] hot updated: ${loggedPath}`);
|
||||
};
|
||||
}
|
||||
const hotModulesMap = new Map();
|
||||
const disposeMap = new Map();
|
||||
const pruneMap = new Map();
|
||||
const dataMap = new Map();
|
||||
const customListenersMap = new Map();
|
||||
const ctxToListenersMap = new Map();
|
||||
// Just infer the return type for now
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
const createHotContext = (ownerPath) => {
|
||||
if (!dataMap.has(ownerPath)) {
|
||||
dataMap.set(ownerPath, {});
|
||||
}
|
||||
// when a file is hot updated, a new context is created
|
||||
// clear its stale callbacks
|
||||
const mod = hotModulesMap.get(ownerPath);
|
||||
if (mod) {
|
||||
mod.callbacks = [];
|
||||
}
|
||||
// clear stale custom event listeners
|
||||
const staleListeners = ctxToListenersMap.get(ownerPath);
|
||||
if (staleListeners) {
|
||||
for (const [event, staleFns] of staleListeners) {
|
||||
const listeners = customListenersMap.get(event);
|
||||
if (listeners) {
|
||||
customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
|
||||
}
|
||||
}
|
||||
}
|
||||
const newListeners = new Map();
|
||||
ctxToListenersMap.set(ownerPath, newListeners);
|
||||
function acceptDeps(deps, callback = () => { }) {
|
||||
const mod = hotModulesMap.get(ownerPath) || {
|
||||
id: ownerPath,
|
||||
callbacks: []
|
||||
};
|
||||
mod.callbacks.push({
|
||||
deps,
|
||||
fn: callback
|
||||
});
|
||||
hotModulesMap.set(ownerPath, mod);
|
||||
}
|
||||
const hot = {
|
||||
get data() {
|
||||
return dataMap.get(ownerPath);
|
||||
},
|
||||
accept(deps, callback) {
|
||||
if (typeof deps === 'function' || !deps) {
|
||||
// self-accept: hot.accept(() => {})
|
||||
acceptDeps([ownerPath], ([mod]) => deps && deps(mod));
|
||||
}
|
||||
else if (typeof deps === 'string') {
|
||||
// explicit deps
|
||||
acceptDeps([deps], ([mod]) => callback && callback(mod));
|
||||
}
|
||||
else if (Array.isArray(deps)) {
|
||||
acceptDeps(deps, callback);
|
||||
}
|
||||
else {
|
||||
throw new Error(`invalid hot.accept() usage.`);
|
||||
}
|
||||
},
|
||||
acceptDeps() {
|
||||
throw new Error(`hot.acceptDeps() is deprecated. ` +
|
||||
`Use hot.accept() with the same signature instead.`);
|
||||
},
|
||||
dispose(cb) {
|
||||
disposeMap.set(ownerPath, cb);
|
||||
},
|
||||
prune(cb) {
|
||||
pruneMap.set(ownerPath, cb);
|
||||
},
|
||||
// TODO
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
decline() { },
|
||||
invalidate() {
|
||||
// TODO should tell the server to re-perform hmr propagation
|
||||
// from this module as root
|
||||
location.reload();
|
||||
},
|
||||
// custom events
|
||||
on: (event, cb) => {
|
||||
const addToMap = (map) => {
|
||||
const existing = map.get(event) || [];
|
||||
existing.push(cb);
|
||||
map.set(event, existing);
|
||||
};
|
||||
addToMap(customListenersMap);
|
||||
addToMap(newListeners);
|
||||
}
|
||||
};
|
||||
return hot;
|
||||
};
|
||||
/**
|
||||
* urls here are dynamic import() urls that couldn't be statically analyzed
|
||||
*/
|
||||
function injectQuery(url, queryToInject) {
|
||||
// skip urls that won't be handled by vite
|
||||
if (!url.startsWith('.') && !url.startsWith('/')) {
|
||||
return url;
|
||||
}
|
||||
// can't use pathname from URL since it may be relative like ../
|
||||
const pathname = url.replace(/#.*$/, '').replace(/\?.*$/, '');
|
||||
const { search, hash } = new URL(url, 'http://vitejs.dev');
|
||||
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash || ''}`;
|
||||
}
|
||||
|
||||
export { createHotContext, injectQuery, removeStyle, updateStyle };
|
||||
//# sourceMappingURL=client.mjs.map
|
File diff suppressed because one or more lines are too long
30
packages/astro/vendor/vite/dist/client/env.mjs
vendored
30
packages/astro/vendor/vite/dist/client/env.mjs
vendored
|
@ -1,30 +0,0 @@
|
|||
const context = (() => {
|
||||
if (typeof globalThis !== 'undefined') {
|
||||
return globalThis;
|
||||
}
|
||||
else if (typeof self !== 'undefined') {
|
||||
return self;
|
||||
}
|
||||
else if (typeof window !== 'undefined') {
|
||||
return window;
|
||||
}
|
||||
else {
|
||||
return Function('return this')();
|
||||
}
|
||||
})();
|
||||
// assign defines
|
||||
const defines = __DEFINES__;
|
||||
Object.keys(defines).forEach((key) => {
|
||||
const segments = key.split('.');
|
||||
let target = context;
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
const segment = segments[i];
|
||||
if (i === segments.length - 1) {
|
||||
target[segment] = defines[key];
|
||||
}
|
||||
else {
|
||||
target = target[segment] || (target[segment] = {});
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=env.mjs.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"env.mjs","sources":["../../src/client/env.ts"],"sourcesContent":["declare const __MODE__: string\ndeclare const __DEFINES__: Record<string, any>\n\nconst context = (() => {\n if (typeof globalThis !== 'undefined') {\n return globalThis\n } else if (typeof self !== 'undefined') {\n return self\n } else if (typeof window !== 'undefined') {\n return window\n } else {\n return Function('return this')()\n }\n})()\n\n// assign defines\nconst defines = __DEFINES__\nObject.keys(defines).forEach((key) => {\n const segments = key.split('.')\n let target = context\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n if (i === segments.length - 1) {\n target[segment] = defines[key]\n } else {\n target = target[segment] || (target[segment] = {})\n }\n }\n})\n"],"names":[],"mappings":"AAGA,MAAM,OAAO,GAAG,CAAC;IACf,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;QACrC,OAAO,UAAU,CAAA;KAClB;SAAM,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QACtC,OAAO,IAAI,CAAA;KACZ;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACxC,OAAO,MAAM,CAAA;KACd;SAAM;QACL,OAAO,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAA;KACjC;AACH,CAAC,GAAG,CAAA;AAEJ;AACA,MAAM,OAAO,GAAG,WAAW,CAAA;AAC3B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG;IAC/B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,MAAM,GAAG,OAAO,CAAA;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;SAC/B;aAAM;YACL,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;SACnD;KACF;AACH,CAAC,CAAC"}
|
29182
packages/astro/vendor/vite/dist/node/chunks/dep-34d2edc0.js
vendored
29182
packages/astro/vendor/vite/dist/node/chunks/dep-34d2edc0.js
vendored
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue