Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
pull_request:
push:
branches: ["main"]
workflow_dispatch:

env:
# Node 22, not the 18 used by deploy.yaml: vitest 4 needs `styleText` from
# node:util (Node 20+). This only affects how tests and the build are run --
# the published artifacts target browsers, not a Node runtime.
NODE_VERSION: 22

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout current git repository
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

# The files under v3/ and v5/ are committed build artifacts, and the
# build is run by hand. Rebuild here and fail if the result differs from
# what was committed, so a fix to src/ can never be published without its
# corresponding artifact.
- name: Verify committed artifacts match src/
run: |
npm run build
if ! git diff --exit-code -- v3/ v5/; then
echo "::error::Committed build artifacts are stale. Run 'npm run build' and commit the result."
exit 1
fi
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@ export default function MyPageComponent() {
window.disableDefaultStyles = true;
```

# Development

```bash
npm install
npm test # vitest + jsdom
npm run build # regenerate the published artifacts
```

## ⚠️ The published code is a committed build artifact

`src/` is **not** what npm ships. The files under `v3/` and `v5/` are checked-in
build output, produced from `src/` by `npm run build` (buble for React, vue-cli
for Vue). Editing `src/` alone changes nothing for customers.

Any change therefore needs three steps:

1. edit the file in `src/`
2. run `npm run build`
3. commit `src/` **and** the regenerated `v3/` / `v5/` files together

CI enforces this: the test workflow rebuilds and fails if the committed
artifacts differ from what `src/` produces.

Note that merging to `main` only redeploys the web component to the CDN. The
React and Vue entry points are published to GitHub Packages by hand
(`npm publish`), so a merged fix is not a released fix.

# Breaking Changes

With the release of the major version 1.0.0, the import paths have changed. It is now required that the plugin's version is specified within the path. Ex:
Expand Down
Loading
Loading