ember-live-compiler 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +104 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,25 +1,114 @@
1
1
  # ember-live-compiler
2
2
 
3
- > **Status: 0.0.1 scaffold only.** The public surface is being extracted from
4
- > [`vite-plugin-ember`](../vite-plugin-ember). Today only `createOwner` is
5
- > implemented; the build-time and runtime compile pipelines land in 0.1.
3
+ > Bundler-agnostic engine for compiling and rendering `.gjs` / `.gts` Ember
4
+ > components. Extracted from [`vite-plugin-ember`](../vite-plugin-ember) so the
5
+ > same core can power live Ember demos in any docs/preview stack.
6
6
 
7
- A bundler-agnostic engine for compiling and rendering `.gjs` / `.gts` Ember
8
- components. It will be the shared core that powers live Ember demos in:
7
+ [![npm](https://img.shields.io/npm/v/ember-live-compiler.svg)](https://www.npmjs.com/package/ember-live-compiler)
8
+ [![license](https://img.shields.io/npm/l/ember-live-compiler.svg)](./LICENSE)
9
9
 
10
- - VitePress (via `vite-plugin-ember`)
11
- - Docusaurus (via `docusaurus-plugin-ember`, planned)
12
- - Storybook (after [storybookjs/storybook#33048](https://github.com/storybookjs/storybook/pull/33048))
13
- - Backstage TechDocs (via a runtime-only addon, planned)
14
- - [kolay](https://github.com/universal-ember/kolay) and `ember-cli-addon-docs` (as a shared dependency, planned)
10
+ ## Why
11
+
12
+ Every "live Ember demo" tool needs the same two pieces: a Babel + content-tag
13
+ pipeline at build time, and a minimal owner + renderer at runtime. Until now
14
+ those lived inside `vite-plugin-ember`. This package lifts them out so the
15
+ ecosystem can share one implementation:
16
+
17
+ - VitePress — via [`vite-plugin-ember`](../vite-plugin-ember)
18
+ - Docusaurus — via `docusaurus-plugin-ember` (planned)
19
+ - Storybook — after [storybookjs/storybook#33048](https://github.com/storybookjs/storybook/pull/33048)
20
+ - Backstage TechDocs — runtime-only addon (planned)
21
+ - [kolay](https://github.com/universal-ember/kolay), `ember-cli-addon-docs` — as a shared dependency (planned)
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ npm install ember-live-compiler
27
+ # peer (optional, only needed for runtime/render):
28
+ npm install ember-source
29
+ ```
30
+
31
+ `ember-source >= 6.8.0` is declared as an optional peer — required only if you
32
+ call `render()`, since it dynamically imports `@ember/renderer`.
15
33
 
16
34
  ## Subpath exports
17
35
 
18
- | Import | Environment | Purpose |
19
- | ------------------------------ | ----------- | ----------------------------------------------------- |
20
- | `ember-live-compiler` | Node | Build-time `compile()` for bundler plugins. |
21
- | `ember-live-compiler/runtime` | Browser | In-browser `compile()` + `render()`. |
22
- | `ember-live-compiler/resolver` | Both | Pure helpers for resolving `@ember/*` / `@glimmer/*`. |
36
+ | Import | Environment | Purpose |
37
+ | ------------------------------ | ------------- | -------------------------------------------------------------- |
38
+ | `ember-live-compiler` | Node | Build-time `createNodeCompiler()` Babel + content-tag. |
39
+ | `ember-live-compiler/runtime` | Browser | `render()` + `createOwner()` for mounting compiled components. |
40
+ | `ember-live-compiler/resolver` | Node, Browser | Pure helpers for resolving `@ember/*` / `@glimmer/*`. |
41
+
42
+ ## Node — build-time compile
43
+
44
+ ```ts
45
+ import { createNodeCompiler } from 'ember-live-compiler';
46
+
47
+ const compiler = createNodeCompiler({
48
+ // Optional: pass a pre-loaded ember-template-compiler, or a path to one
49
+ templateCompiler: {
50
+ compilerPath: 'ember-source/dist/ember-template-compiler.js',
51
+ },
52
+ babelPlugins: [],
53
+ babelPresets: [],
54
+ parserPlugins: [],
55
+ });
56
+
57
+ const { code, map } = await compiler.compile(source, {
58
+ filename: 'demo.gjs',
59
+ kind: 'gjs', // 'gjs' | 'gts' | 'precompiled-template'
60
+ sourceMaps: true,
61
+ });
62
+ ```
63
+
64
+ Wrap it in a Vite / Rollup / esbuild / Webpack plugin and you've got Ember SFC
65
+ support.
66
+
67
+ ## Browser — render
68
+
69
+ ```ts
70
+ import { render } from 'ember-live-compiler/runtime';
71
+ import * as DemoModule from './demo.gjs';
72
+
73
+ const mount = await render(DemoModule, {
74
+ into: document.getElementById('preview')!,
75
+ });
76
+
77
+ // later
78
+ mount.destroy();
79
+ ```
80
+
81
+ `render()` lazily imports `@ember/renderer` (Ember 6.8+) so apps that never
82
+ call it don't pay the import cost. The host bundler must be able to resolve
83
+ `@ember/*` specifiers — `vite-plugin-ember`'s `resolveId` hook and
84
+ `ssr.noExternal` rule already handle this; equivalent wiring is needed for
85
+ other bundlers.
86
+
87
+ ## Resolver helpers
88
+
89
+ For bundler authors who need to wire up `@ember/*` resolution themselves:
90
+
91
+ ```ts
92
+ import {
93
+ EMBER_PACKAGE_PREFIXES,
94
+ EMBROIDER_MACROS_VIRTUAL_ID,
95
+ EMBROIDER_MACROS_SHIM_SOURCE,
96
+ isEmberSpecifier,
97
+ } from 'ember-live-compiler/resolver';
98
+ ```
99
+
100
+ Pure, bundler-free. No I/O, no Babel, safe to import from anywhere.
101
+
102
+ ## Status
103
+
104
+ `0.1.x` — public but pre-stable. The Node compile pipeline and runtime
105
+ `render()` are exercised in production by `vite-plugin-ember`'s VitePress
106
+ docs. Planned for upcoming minors:
107
+
108
+ - `compile()` in `runtime` (lazy `@babel/standalone` + content-tag wasm) for
109
+ fully in-browser source → component.
110
+ - Stable 1.0 once at least one additional bundler integration ships against
111
+ the engine.
23
112
 
24
113
  ## License
25
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-live-compiler",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Bundler-agnostic engine for compiling and rendering .gjs/.gts Ember components — the core that powers live Ember demos in VitePress, Docusaurus, Storybook, Backstage TechDocs, kolay, and more.",
5
5
  "keywords": [
6
6
  "ember",