-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builtin Vite support for backend #760
Conversation
@@ -0,0 +1,47 @@ | |||
# imba$stdlib=1 | |||
import np from 'path' | |||
import * as Vite from "vite" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this end up importing vite whenever you run imba in node? Or do you know if it is removed by tree-shaking in esbuild?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply 🙂 There seem to be issues related to this
Running a script complains about
❯ imba index.imba
▲ [WARNING] "esbuild" should be marked as external for use with "require.resolve" [require-resolve-not-external]
../imba/packages/imba/node_modules/esbuild/lib/main.js:1718:36:
1718 │ const libMainJS = require.resolve("esbuild");
╵ ~~~~~~~~~
✘ [ERROR] No loader is configured for ".node" files: ../imba/packages/imba/node_modules/fsevents/fsevents.node
../imba/packages/imba/node_modules/fsevents/fsevents.js:13:23:
13 │ const Native = require("./fsevents.node");
╵ ~~~~~~~~~~~~~~~~~
× failed with 1 errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed setupVite
from imba directly into imba/plugin
. It was indeed causing the issue :) Nice catch
Rebased with master and fixed a bug where it fails if no tsconfig file is found (We use our own fork while waiting on this PR upstream aleclarson/vite-tsconfig-paths#97) |
Here is a list of things I consider important for complete Vite support
The first two are mandatory to merge this PR. But the others can be done later in separate PRs |
rebased with master to have a green CI |
SSR styles to remove the flash of unstyled content in dev
For now, it is used to skip server live reloading if client side reloading kicked in
e516918
to
c9d5156
Compare
This PR adds support for using Vite as a bundler for backend and front-end Imba projects with no configuration.
What's new?
import imbaPlugin from 'imba/plugin'
imba test
command that is a wrapper of vitest with default configurationimba server.imba --vite
. It automatically runs in watch mode and live reloads.tsconfig.json
are automatically picked. This is done by this vite plugin in order to match the built-in bundler behaviour.iife
imports usingimport head from "./head.imba?iife"
import {setupVite} from 'imba/plugin'
method that sets up vite middleware ++, this is the initial API:Notes
src
in ascript
tag:./src/Home.imba
in the example above) is treated as an entry point and is passed as such to Vite to perform the client build. The script tag is transformed to scripts and styles based on the manifest file.