-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
106 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
import { defineConfig } from "vite" | ||
import react from "@vitejs/plugin-react" | ||
import wasm from "vite-plugin-wasm" | ||
import topLevelAwait from "vite-plugin-top-level-await" | ||
|
||
export default defineConfig({ | ||
plugins: [wasm(), topLevelAwait(), react()], | ||
plugins: [wasm(), react()], | ||
|
||
worker: { | ||
format: "es", | ||
plugins: () => [wasm(), topLevelAwait()], | ||
}, | ||
|
||
optimizeDeps: { | ||
// This is necessary because otherwise `vite dev` includes two separate | ||
// versions of the JS wrapper. This causes problems because the JS | ||
// wrapper has a module level variable to track JS side heap | ||
// allocations, and initializing this twice causes horrible breakage | ||
exclude: [ | ||
"@automerge/automerge-wasm", | ||
"@automerge/automerge-wasm/bundler/bindgen_bg.wasm", | ||
"@syntect/wasm", | ||
], | ||
}, | ||
|
||
server: { | ||
fs: { | ||
strict: false, | ||
}, | ||
plugins: () => [wasm()], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import { defineConfig } from "vite" | ||
import react from "@vitejs/plugin-react-swc" | ||
import wasm from "vite-plugin-wasm" | ||
import topLevelAwait from "vite-plugin-top-level-await" | ||
|
||
export default defineConfig({ | ||
plugins: [react(), wasm(), topLevelAwait()], | ||
plugins: [react(), wasm()], | ||
worker: { | ||
plugins: () => [wasm(), topLevelAwait()], | ||
plugins: () => [wasm()], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
import { defineConfig } from "vite" | ||
import { svelte } from "@sveltejs/vite-plugin-svelte" | ||
import wasm from "vite-plugin-wasm" | ||
import topLevelAwait from "vite-plugin-top-level-await" | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [wasm(), topLevelAwait(), svelte()], | ||
plugins: [wasm(), svelte()], | ||
|
||
worker: { | ||
format: "es", | ||
plugins: () => [wasm(), topLevelAwait()], | ||
}, | ||
|
||
optimizeDeps: { | ||
// This is necessary because otherwise `vite dev` includes two separate | ||
// versions of the JS wrapper. This causes problems because the JS | ||
// wrapper has a module level variable to track JS side heap | ||
// allocations, and initializing this twice causes horrible breakage | ||
exclude: [ | ||
"@automerge/automerge-wasm", | ||
"@automerge/automerge-wasm/bundler/bindgen_bg.wasm", | ||
"@syntect/wasm", | ||
], | ||
}, | ||
|
||
server: { | ||
fs: { | ||
strict: false, | ||
}, | ||
plugins: () => [wasm()], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { execa } from "execa" | ||
import { $ } from "execa" | ||
import path from "path" | ||
import os from "os" | ||
import fs from "fs" | ||
import { exit } from "node:process" | ||
|
||
// This script is used to test the create-vite-app script from local code in a temporary directory | ||
// see https://github.com/automerge/automerge-repo/pull/322#issuecomment-2012354463 for context | ||
|
||
// build | ||
|
||
const { stdout } = await execa("pnpm", ["run", "build"]) | ||
|
||
console.log("building create-vite-app...") | ||
await $`pnpm build` | ||
|
||
// pack | ||
|
||
const { stdout: tarballFile } = await $`pnpm pack` | ||
console.log("creating tarball...") | ||
const tarballPath = path.join(process.cwd(), tarballFile) | ||
|
||
// create a temp dir and test the create-vite-app script by creating an app | ||
|
||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "test-create-")) | ||
|
||
const $$ = $({ cwd: tempDir }) | ||
|
||
console.log("creating test app...") | ||
await $$`pnpm init` | ||
await $$`pnpm install ${tarballPath}` | ||
await $$`./node_modules/@automerge/create-vite-app/dist/index.js test-app` | ||
|
||
// run the app in dev mode | ||
|
||
const cwd = path.join(tempDir, "test-app") | ||
const $$$ = $({ cwd }) | ||
|
||
console.log("installing test app...") | ||
await $$$`pnpm install` | ||
|
||
console.log("running test app in dev mode...") | ||
|
||
// `vite` is a long running command, so we abuse the `timeout` to kill it after a short time. | ||
// This throws an error that we catch in order to capture its output. | ||
const output = await $$$({ timeout: 1000 })`pnpm dev`.catch(result => { | ||
// should look something like | ||
// | ||
// VITE v5.2.6 ready in 415 ms | ||
// | ||
// ➜ Local: http://localhost:5173/ | ||
// ➜ Network: use --host to expose | ||
// ➜ press h + enter to show help | ||
return result.stdout | ||
}) | ||
|
||
const success = output.includes("VITE") && output.includes("ready") | ||
|
||
// cleanup | ||
await $`git clean *.tgz -f` | ||
|
||
if (success) { | ||
console.log("✅ create-vite-app test passed") | ||
exit(0) | ||
} else { | ||
console.log() | ||
console.log(output) | ||
console.log() | ||
console.log("❌ create-vite-app test failed") | ||
exit(1) | ||
} |
Oops, something went wrong.