-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat: css support #240
feat: css support #240
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7a3fdcb:
|
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.
wow, this look like a great work. i'll try it later.
createServer as viteCreateServer, | ||
resolveConfig as resolveViteConfig, | ||
mergeConfig as mergeViteConfig, |
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.
Let's make our naming convention consistent.
Do you prefer resolveViteConfig
to viteResolveConfig
?
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.
The first one is better I guess.
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.
Fine then. We should change everything. If it's small, it can be done in this PR.
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.
Please check all import { doSomethign as doViteSomething} from 'vite'
throughout the code base. My previous code did viteDoSomething
.
import { createHotContext as __vite__createHotContext } from "/@vite/client" | ||
import.meta.hot = __vite__createHotContext(import.meta.url); | ||
|
||
if (import.meta.hot && !globalThis.__WAKU_HMR_CONFIGURED__) { | ||
globalThis.__WAKU_HMR_CONFIGURED__ = true; | ||
|
||
import.meta.hot.on('hot-import', (data) => import(/* @vite-ignore */ data)); | ||
|
||
import.meta.hot.on('module', (data) => { | ||
const code = data.code | ||
const script = document.createElement('script') | ||
script.type = 'module' | ||
script.text = code | ||
document.head.appendChild(script) | ||
}); |
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.
code format inconstant. semi
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.
You're correct, I'll fix it after Daishi reviews the code. Thank you.
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.
please fix it.
When I run
and, a warning on the bowser console:
Are these expected? |
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 some questions due to my limited understanding of Vite.
const resolvedViteConfig = await resolveViteConfig({}, 'serve'); | ||
const mergedViteConfig = await mergeViteConfig( | ||
{ | ||
...resolvedViteConfig, | ||
|
||
plugins: resolvedViteConfig.plugins.filter( | ||
(plugin) => !plugin.name.startsWith('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.
What happens if we don't have this? Why do we need to remove vite:
plugins?
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.
React refresh would fail
@@ -30,6 +31,7 @@ export type MessageReq = | |||
export type MessageRes = | |||
| { type: 'full-reload' } | |||
| { type: 'hot-import'; source: string } | |||
| { type: 'module'; result: TransformResult } |
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.
It's ambiguous, can we call it module-import
instead of module
?
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.
Why not, let me try.
}); | ||
resolve(worker); | ||
}) | ||
.catch((e) => reject(e)); |
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.
Please don't remove this.
...resolvedViteConfig, | ||
|
||
plugins: resolvedViteConfig.plugins.filter( | ||
(plugin) => !plugin.name.startsWith('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.
Again, I wonder why we need this and if we need both in two places.
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.
It's because we don't vite default plugins to be mentioned two times. For instance react refresh would fail because there would two instances of it.
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.
React refresh would fail
I see. I will play with it later. Does it mean there's only one vite server that keep vite plugins? (Can't guess which from the diff, and I don't remember how many they are...)
Please extract this patch/merge logic in a separate file and reuse it. something like packages/waku/src/lib/plugins/patch-react-refresh.ts
.
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 don't exactly mean patching plugin. It should be a reusable logic and preferably add some comments for the intention.
Co-authored-by: Daishi Kato <[email protected]>
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.
Looking good! Please see comments.
import { createHotContext as __vite__createHotContext } from "/@vite/client" | ||
import.meta.hot = __vite__createHotContext(import.meta.url); | ||
|
||
if (import.meta.hot && !globalThis.__WAKU_HMR_CONFIGURED__) { | ||
globalThis.__WAKU_HMR_CONFIGURED__ = true; | ||
|
||
import.meta.hot.on('hot-import', (data) => import(/* @vite-ignore */ data)); | ||
|
||
import.meta.hot.on('module', (data) => { | ||
const code = data.code | ||
const script = document.createElement('script') | ||
script.type = 'module' | ||
script.text = code | ||
document.head.appendChild(script) | ||
}); |
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.
please fix it.
createServer as viteCreateServer, | ||
resolveConfig as resolveViteConfig, | ||
mergeConfig as mergeViteConfig, |
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.
Please check all import { doSomethign as doViteSomething} from 'vite'
throughout the code base. My previous code did viteDoSomething
.
...resolvedViteConfig, | ||
|
||
plugins: resolvedViteConfig.plugins.filter( | ||
(plugin) => !plugin.name.startsWith('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.
React refresh would fail
I see. I will play with it later. Does it mean there's only one vite server that keep vite plugins? (Can't guess which from the diff, and I don't remember how many they are...)
Please extract this patch/merge logic in a separate file and reuse it. something like packages/waku/src/lib/plugins/patch-react-refresh.ts
.
I don't see the second warning, but for the first one, to be honest I don't have any idea. Can we tackle it in another PR later? |
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.
thanks for your work!
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; | ||
|
||
export default defineConfig({ | ||
root: path.dirname(url.fileURLToPath(import.meta.url)), |
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 think we can omit this. (Can be a separate PR, as I might be wrong, and there are other places like this.)
mergeConfig as mergeViteConfig, | ||
} from 'vite'; | ||
|
||
export async function mergeUserViteConfig(config: UserConfig) { |
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.
It would be nice to add a comment about this workaround is required only (?) for hmr. (Can be a separate PR.)
* Revert "Revert "feat: css support (#240)"" This reverts commit f32f338. * possible fix * possible fix * fix 12_css package.json --------- Co-authored-by: daishi <[email protected]>
Follow up #171