Skip to content

Commit

Permalink
feat: add unplugin integration and test HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix-ru committed Nov 28, 2023
1 parent 85e0e0a commit 64b3072
Show file tree
Hide file tree
Showing 12 changed files with 3,718 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
**/node_modules
*.node
*.node
**/dist
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ Code generator
- [x] defineModel
- [ ] Tests
- [x] DEV/PROD mode
- [x] Hot Module Replacement (HMR)
- [ ] Vue 2.7 support
- [ ] SSR with inline critical CSS support
- [ ] Eager pre-compilation of Vue imports (avoid unneccessary bundler->compiler calls)

Integrations
- [x] WASM binary (unpublished)
- [x] NAPI binary (unpublished)
- [ ] [unplugin](https://github.com/unjs/unplugin)
- [x] NAPI binary [@fervid/napi](https://www.npmjs.com/package/@fervid/napi)
- [x] [unplugin](https://github.com/unjs/unplugin) (in progress)
- [ ] [Farm](https://github.com/farm-fe/farm) native plugin
- [ ] [Turbopack](https://github.com/vercel/turbo) plugin (when plugin system is defined)
51 changes: 51 additions & 0 deletions node/examples/hello-world/HelloInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div class="hello-input">
<input
v-model="innerModelValue"
:class="{
'w-full': fullwidth
}"
class="hello-input__input"
>
</div>
</template>

<script lang="ts" setup>
import { computed, ref, watch } from 'vue'
const props = defineProps({
fullwidth: {
type: Boolean,
required: false,
default: true
},
modelValue: {
type: String,
required: true
}
})
const emit = defineEmits(['update:model-value'])
const innerModelValue = ref(props.modelValue)
const computedModelValue = computed(() => props.modelValue)
watch(computedModelValue, (value) => {
innerModelValue.value = value
})
watch([innerModelValue], (values) => {
emit('update:model-value', values[0])
})
</script>

<style scoped>
.hello-input__input {
padding: 1rem 1.5rem;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 999px;
}
.hello-input__input:hover, .hello-input__input:focus {
border-color: #000;
}
</style>
24 changes: 24 additions & 0 deletions node/examples/hello-world/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<h1>
Hello {{ name }}!
</h1>
<input v-model="name">

<!-- This is a challenge: SWC does not accept `HelloInput` and modifies the tag name to `helloinput` -->
<hello-input v-model="name"></hello-input>
</template>

<script setup>
import { ref } from 'vue'
import HelloInput from './HelloInput.vue'
const name = ref('fervid')
</script>

<script>
// This hack is needed because `fervid` doesn't support component resolution yet
// TODO Remove when component resolutions are properly supported
export default {
components: { HelloInput }
}
</script>
11 changes: 11 additions & 0 deletions node/examples/hello-world/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="app"></div>
</body>
</html>
5 changes: 5 additions & 0 deletions node/examples/hello-world/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import HelloWorld from './HelloWorld.vue'

const app = createApp(HelloWorld)
app.mount('#app')
29 changes: 29 additions & 0 deletions node/examples/hello-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"serve": "webpack serve"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@fervid/unplugin": "^0.0.1",
"html-webpack-plugin": "^5.5.3",
"rollup": "^4.6.0",
"unplugin": "^1.5.1",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"vue": "^3.3.9"
},
"pnpm": {
"overrides": {
"@fervid/unplugin": "../../unplugin"
}
}
}
Loading

0 comments on commit 64b3072

Please sign in to comment.