Skip to content

Commit

Permalink
feat: Add BA support for SvelteKit (#126)
Browse files Browse the repository at this point in the history
Add new plugin to handle SvelteKit specific cases.

GH #94
  • Loading branch information
nicholas-codecov authored May 24, 2024
1 parent ddcd055 commit 297cd29
Show file tree
Hide file tree
Showing 95 changed files with 38,642 additions and 6,671 deletions.
10 changes: 10 additions & 0 deletions .changeset/light-ants-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@codecov/bundler-plugin-core": patch
"@codecov/nuxt-plugin": patch
"@codecov/rollup-plugin": patch
"@codecov/sveltekit-plugin": patch
"@codecov/vite-plugin": patch
"@codecov/webpack-plugin": patch
---

Add in support for bundle analysis for SvelteKit through new SvelteKit plugin
10 changes: 10 additions & 0 deletions .changeset/orange-lemons-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@codecov/bundler-plugin-core": patch
"@codecov/sveltekit-plugin": patch
"@codecov/webpack-plugin": patch
"@codecov/rollup-plugin": patch
"@codecov/nuxt-plugin": patch
"@codecov/vite-plugin": patch
---

Update license to 2024
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const config = {
"./packages/bundler-plugin-core/tsconfig.json",
"./packages/nuxt-plugin/tsconfig.json",
"./packages/rollup-plugin/tsconfig.json",
"./packages/sveltekit-plugin/tsconfig.json",
"./packages/vite-plugin/tsconfig.json",
"./packages/webpack-plugin/tsconfig.json",
],
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
url: ${{ secrets.CODECOV_STAGING_URL }}

integration-test:
name: Run Integration Tests (Node ${{ matrix.node-version }})
name: Run integration tests (Node ${{ matrix.node-version }})
needs: install
runs-on: ubuntu-latest
services:
Expand All @@ -244,7 +244,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -279,7 +279,7 @@ jobs:
strategy:
fail-fast: false
matrix:
example: ["next-js", "nuxt", "rollup", "vite", "webpack"]
example: ["next-js", "nuxt", "rollup", "sveltekit", "vite", "webpack"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -294,7 +294,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -342,7 +342,7 @@ jobs:
strategy:
fail-fast: false
matrix:
example: ["next-js", "nuxt", "rollup", "vite", "webpack"]
example: ["next-js", "nuxt", "rollup", "sveltekit", "vite", "webpack"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -357,7 +357,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -410,6 +410,7 @@ jobs:
"bundler-plugin-core",
"nuxt-plugin",
"rollup-plugin",
"sveltekit-plugin",
"vite-plugin",
"webpack-plugin",
]
Expand All @@ -427,7 +428,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -474,6 +475,7 @@ jobs:
"bundler-plugin-core",
"nuxt-plugin",
"rollup-plugin",
"sveltekit-plugin",
"vite-plugin",
"webpack-plugin",
]
Expand All @@ -491,7 +493,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup pnpm & install dependencies
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: true

- name: Create Release Pull Request
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Codecov
Copyright (c) 2023-2024 Codecov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 12 additions & 0 deletions examples/sveltekit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
.vercel
.output
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions examples/sveltekit/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
38 changes: 38 additions & 0 deletions examples/sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
25 changes: 25 additions & 0 deletions examples/sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "sveltekit",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@codecov/sveltekit-plugin": "workspace:^",
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3"
},
"type": "module"
}
13 changes: 13 additions & 0 deletions examples/sveltekit/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {};
12 changes: 12 additions & 0 deletions examples/sveltekit/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
16 changes: 16 additions & 0 deletions examples/sveltekit/src/lib/images/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/sveltekit/src/lib/images/svelte-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
53 changes: 53 additions & 0 deletions examples/sveltekit/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script>
import Header from './Header.svelte';
import './styles.css';
</script>

<div class="app">
<Header />

<main>
<slot />
</main>

<footer>
<p>visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to learn SvelteKit</p>
</footer>
</div>

<style>
.app {
display: flex;
flex-direction: column;
min-height: 100vh;
}
main {
flex: 1;
display: flex;
flex-direction: column;
padding: 1rem;
width: 100%;
max-width: 64rem;
margin: 0 auto;
box-sizing: border-box;
}
footer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 12px;
}
footer a {
font-weight: bold;
}
@media (min-width: 480px) {
footer {
padding: 12px 0;
}
}
</style>
Loading

0 comments on commit 297cd29

Please sign in to comment.