Skip to content

Commit

Permalink
Add Vite section to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Oct 6, 2023
1 parent a7ed482 commit 3ae4bc1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ const g = fn([Real, Real], Vec(3, Real), (x, y) => {
console.log(interp(g)(2, 3)); // [6, 3, 2]
```

### With Vite

If you are using [Vite][] then you will need to also install the
[vite-plugin-top-level-await][] package, because Rose internally uses [top-level
`await`][], which Vite does not directly support. You must also include the
following in your Vite config:

```js
import { defineConfig } from "vite";
import topLevelAwait from "vite-plugin-top-level-await";

export default defineConfig({
// the plugin described above
plugins: [topLevelAwait()],

// Vite bundles external dependencies by default in development mode, but that
// process does not include assets; this option disables that particular kind
// of bundling for Rose so that it can use its internal WebAssembly module
optimizeDeps: { exclude: ["rose"] },
});
```

## Contributing

See [`CONTRIBUTING.md`][].
Expand All @@ -64,4 +86,7 @@ Rose is licensed under the [MIT License][].
[MIT License]: https://github.com/rose-lang/rose/blob/main/LICENSE
[npm]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
[pnpm]: https://pnpm.io/installation
[top-level `await`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await
[vite-plugin-top-level-await]: https://www.npmjs.com/package/vite-plugin-top-level-await
[Vite]: https://vitejs.dev/
[Yarn]: https://classic.yarnpkg.com/lang/en/docs/install/

0 comments on commit 3ae4bc1

Please sign in to comment.