vite-plugin-ember 0.0.0 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/package.json +20 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexey Kulakov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# vite-plugin-ember
|
|
2
|
+
|
|
3
|
+
[](https://github.com/aklkv/vite-plugin-ember/actions/workflows/ci.yml)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
A [Vite](https://vitejs.dev/) plugin that lets you render live, interactive [Ember](https://emberjs.com/) components inside [VitePress](https://vitepress.dev/) documentation pages.
|
|
7
|
+
|
|
8
|
+
Write `.gjs` / `.gts` code fences in markdown and see them rendered on the page — no full Ember app required.
|
|
9
|
+
|
|
10
|
+
**[View the live documentation →](https://aklkv.github.io/vite-plugin-ember/)**
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Inline code fences** — use ` ```gjs live ` in markdown for instant interactive previews
|
|
15
|
+
- **Full Ember support** — class components, `@tracked` state, `{{on}}` modifier, and TypeScript via `.gts`
|
|
16
|
+
- **Zero-config compilation** — content-tag preprocessing, Babel template compilation, decorator transforms, and `@ember/*` / `@glimmer/*` module resolution handled automatically
|
|
17
|
+
- **`@embroider/macros` shim** — runtime stubs so `ember-source` ESM imports just work
|
|
18
|
+
- **Vue wrapper** — ships a `<CodePreview>` component for seamless VitePress integration
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Install
|
|
23
|
+
|
|
24
|
+
Install the plugin along with Ember packages your components need:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
pnpm add vite-plugin-ember ember-source @glimmer/component
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
> **Note:** `ember-source` and `@glimmer/component` are peer dependencies — you manage their versions in your project.
|
|
31
|
+
|
|
32
|
+
### 2. Configure VitePress
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
// .vitepress/config.ts
|
|
36
|
+
import { defineConfig } from 'vitepress';
|
|
37
|
+
import vitePluginEmber, { emberFence } from 'vite-plugin-ember';
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
vite: {
|
|
41
|
+
plugins: [vitePluginEmber()],
|
|
42
|
+
},
|
|
43
|
+
markdown: {
|
|
44
|
+
config(md) {
|
|
45
|
+
emberFence(md);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Register the component
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// .vitepress/theme/index.ts
|
|
55
|
+
import DefaultTheme from 'vitepress/theme';
|
|
56
|
+
import CodePreview from 'vite-plugin-ember/components/code-preview.vue';
|
|
57
|
+
import type { Theme } from 'vitepress';
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
...DefaultTheme,
|
|
61
|
+
enhanceApp({ app }) {
|
|
62
|
+
app.component('CodePreview', CodePreview);
|
|
63
|
+
},
|
|
64
|
+
} satisfies Theme;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 4. Write a live demo
|
|
68
|
+
|
|
69
|
+
In any markdown file:
|
|
70
|
+
|
|
71
|
+
````md
|
|
72
|
+
```gjs live
|
|
73
|
+
import Component from '@glimmer/component';
|
|
74
|
+
import { tracked } from '@glimmer/tracking';
|
|
75
|
+
import { on } from '@ember/modifier';
|
|
76
|
+
|
|
77
|
+
export default class Counter extends Component {
|
|
78
|
+
@tracked count = 0;
|
|
79
|
+
|
|
80
|
+
increment = () => { this.count += 1; };
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<button {{on "click" this.increment}}>
|
|
84
|
+
Clicked {{this.count}} times
|
|
85
|
+
</button>
|
|
86
|
+
</template>
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
````
|
|
90
|
+
|
|
91
|
+
Start the dev server with `pnpm dev` and see it live.
|
|
92
|
+
|
|
93
|
+
## Documentation
|
|
94
|
+
|
|
95
|
+
Full docs (built with this plugin!) are in the [`docs/`](./docs) directory. Run locally:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
pnpm install
|
|
99
|
+
pnpm dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Project Structure
|
|
103
|
+
|
|
104
|
+
````text
|
|
105
|
+
├── vite-plugin-ember/ # The Vite plugin (publishable package)
|
|
106
|
+
│ └── src/
|
|
107
|
+
│ ├── index.ts # Plugin + Ember compilation pipeline
|
|
108
|
+
│ └── vitepress/
|
|
109
|
+
│ ├── ember-fence.ts # markdown-it plugin for ```gjs live fences
|
|
110
|
+
│ └── code-preview.vue # Vue wrapper component
|
|
111
|
+
├── docs/ # VitePress documentation site
|
|
112
|
+
│ ├── demos/ # .gjs/.gts demo components
|
|
113
|
+
│ └── guide/ # Documentation pages
|
|
114
|
+
├── package.json # Workspace root
|
|
115
|
+
└── pnpm-workspace.yaml
|
|
116
|
+
````
|
|
117
|
+
|
|
118
|
+
## Requirements
|
|
119
|
+
|
|
120
|
+
- Node.js ≥ 20
|
|
121
|
+
- pnpm ≥ 10
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
[MIT](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-ember",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Vite plugin for rendering live Ember components in VitePress documentation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,18 +42,6 @@
|
|
|
42
42
|
"dist",
|
|
43
43
|
"src/vitepress/code-preview.vue"
|
|
44
44
|
],
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsc -p tsconfig.json",
|
|
47
|
-
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
48
|
-
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
49
|
-
"lint:js": "eslint .",
|
|
50
|
-
"lint:js:fix": "eslint . --fix",
|
|
51
|
-
"lint:format": "prettier . --cache --check",
|
|
52
|
-
"lint:format:fix": "prettier . --cache --write",
|
|
53
|
-
"lint:types": "tsc --noEmit",
|
|
54
|
-
"format": "prettier . --cache --write",
|
|
55
|
-
"format:check": "prettier . --cache --check"
|
|
56
|
-
},
|
|
57
45
|
"dependencies": {
|
|
58
46
|
"@babel/core": "^7.29.0",
|
|
59
47
|
"@babel/plugin-transform-typescript": "^7.28.6",
|
|
@@ -79,8 +67,27 @@
|
|
|
79
67
|
"vue": "^3.5.28"
|
|
80
68
|
},
|
|
81
69
|
"peerDependencies": {
|
|
70
|
+
"@glimmer/component": ">=1",
|
|
71
|
+
"ember-source": ">=5",
|
|
82
72
|
"vite": ">=5",
|
|
83
73
|
"vitepress": ">=1",
|
|
84
74
|
"vue": ">=3"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"@glimmer/component": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "tsc -p tsconfig.json",
|
|
83
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
84
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
85
|
+
"lint:js": "eslint .",
|
|
86
|
+
"lint:js:fix": "eslint . --fix",
|
|
87
|
+
"lint:format": "prettier . --cache --check",
|
|
88
|
+
"lint:format:fix": "prettier . --cache --write",
|
|
89
|
+
"lint:types": "tsc --noEmit",
|
|
90
|
+
"format": "prettier . --cache --write",
|
|
91
|
+
"format:check": "prettier . --cache --check"
|
|
85
92
|
}
|
|
86
93
|
}
|