Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/lovely-birds-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@powersync/common': minor
'@powersync/react-native': minor
'@powersync/web': minor
---

Revert `event-iterator` externalization in `@powersync/common` rollup config. This now bundles `event-iterator` again in `@powersync/common`'s non Node.js export.
13 changes: 13 additions & 0 deletions .changeset/slow-birds-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@powersync/web': minor
---

Fixes regression introduced in `@powersync/web@1.28.1`. Vite users don't need to include `event-iterator` in included optimized dependencies.

vite.config.js

```diff
include: [
- '@powersync/web > event-iterator'
]
```
27 changes: 27 additions & 0 deletions demos/example-vite/e2e/customers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, expect, it, vi } from 'vitest';
import { setupTestDOM } from './test-setup.js';

describe('Customer List E2E', () => {
it('should display the inserted customer "Fred" in the HTML list', async () => {
// Set up the DOM structure for testing
setupTestDOM();

// Import the main script which will execute and populate the DOM
await import('../src/index.js');

// Trigger DOMContentLoaded if needed (script listens for this)
if (document.readyState === 'complete' || document.readyState === 'interactive') {
document.dispatchEvent(new Event('DOMContentLoaded'));
}

// Wait for the customer list to appear and contain "Fred" using vi.waitFor
await vi.waitFor(() => {
const customersList = document.getElementById('customers-list');
expect(customersList).not.toBeNull();

const listItems = customersList.querySelectorAll('li');
const customerNames = Array.from(listItems).map((li) => li.textContent);
expect(customerNames).toContain('Fred');
});
});
});
12 changes: 12 additions & 0 deletions demos/example-vite/e2e/test-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Test setup: Creates the DOM structure needed for tests
* This mimics the structure in index.html
*/
export function setupTestDOM() {
// Set up the HTML structure to match index.html
document.body.innerHTML = `
<h1>Vite bundling test: Check the console to see it in action!</h1>
<h2>Customers:</h2>
<ul id="customers-list"></ul>
`;
}
8 changes: 6 additions & 2 deletions demos/example-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
"build": "vite build",
"preview": "vite preview",
"start": "pnpm build && pnpm preview",
"test:build": "pnpm build"
"prepare:isolated:test": "pnpm exec playwright install ",
"test:build": "pnpm build && vitest run"
},
"dependencies": {
"@powersync/web": "workspace:*"
},
"devDependencies": {
"@swc/core": "~1.6.0",
"@vitest/browser": "^3.2.4",
"playwright": "^1.51.0",
"vite": "^5.0.12",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0"
"vite-plugin-wasm": "^3.3.0",
"vitest": "^3.2.4"
}
}
19 changes: 12 additions & 7 deletions demos/example-vite/src/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<!doctype html>
<html>
<head>
<script type="module" src="./index.js"></script>
</head>
<body>
Vite bundling test: Check the console to see it in action!
</body>
</html>

<head>
<script type="module" src="./index.js"></script>
</head>

<body>
<h1>Vite bundling test: Check the console to see it in action!</h1>
<h2>Customers:</h2>
<ul id="customers-list"></ul>
</body>

</html>
15 changes: 14 additions & 1 deletion demos/example-vite/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { column, Schema, Table, PowerSyncDatabase, createBaseLogger } from '@powersync/web';
import { PowerSyncDatabase, Schema, Table, column, createBaseLogger } from '@powersync/web';

createBaseLogger().useDefaults();

Expand Down Expand Up @@ -38,6 +38,19 @@ const openDatabase = async () => {
const result = await PowerSync.getAll('SELECT * FROM customers');
console.log('contents of customers: ', result);

// Display customers in the HTML list
const customersList = document.getElementById('customers-list');
if (customersList) {
// Clear existing list items
customersList.textContent = '';
// Create and append list items
result.forEach((customer) => {
const listItem = document.createElement('li');
listItem.textContent = customer.name || 'Unknown';
customersList.appendChild(listItem);
});
}

console.log(
`Attempting to connect in order to verify web workers are correctly loaded.
This doesn't use any actual network credentials.
Expand Down
20 changes: 18 additions & 2 deletions demos/example-vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import { defineConfig } from 'vite';
import topLevelAwait from 'vite-plugin-top-level-await';
import wasm from 'vite-plugin-wasm';

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -22,5 +22,21 @@ export default defineConfig({
worker: {
format: 'es',
plugins: () => [wasm(), topLevelAwait()]
},
test: {
globals: true,
include: ['../e2e/**/*.test.js'],
maxConcurrency: 1,
browser: {
enabled: true,
isolate: true,
provider: 'playwright',
headless: true,
instances: [
{
browser: 'chromium'
}
]
}
}
});
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
},
"dependencies": {
"async-mutex": "^0.5.0",
"buffer": "^6.0.3",
"event-iterator": "^2.0.0"
},
"devDependencies": {
Expand All @@ -66,6 +65,7 @@
"@rollup/plugin-node-resolve": "^16.0.3",
"@types/node": "^20.5.9",
"@types/uuid": "^9.0.1",
"buffer": "^6.0.3",
"rollup": "^4.52.5",
"cross-fetch": "^4.1.0",
"js-logger": "^1.6.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/common/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'node:path';

import commonjs from '@rollup/plugin-commonjs';
import inject from '@rollup/plugin-inject';
import json from '@rollup/plugin-json';
Expand Down Expand Up @@ -33,7 +31,7 @@ function defineBuild(isNode) {
})
]
],
external: ['async-mutex', 'bson', 'buffer/', 'event-iterator']
external: ['async-mutex', 'bson', isNode ? 'event-iterator' : undefined]
};
}

Expand Down
4 changes: 4 additions & 0 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- Updated dependencies [3e4a25c]
- @powersync/common@1.41.1

Note for Vite users:

This release introduced a regression which requires including `'@powersync/web > event-iterator'` in the Vite `optimizeDeps -> include` config. This regression was fixed in `@powersync/web@1.29.0`.

## 1.28.0

### Minor Changes
Expand Down
Loading