ember-live-compiler 0.1.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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +104 -15
  3. package/package.json +13 -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 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.1.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",
@@ -46,18 +46,6 @@
46
46
  "files": [
47
47
  "dist"
48
48
  ],
49
- "scripts": {
50
- "build": "tsc -p tsconfig.json",
51
- "format": "prettier . --cache --write",
52
- "format:check": "prettier . --cache --check",
53
- "lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'",
54
- "lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'",
55
- "lint:format": "prettier . --cache --check",
56
- "lint:format:fix": "prettier . --cache --write",
57
- "lint:js": "eslint .",
58
- "lint:js:fix": "eslint . --fix",
59
- "lint:types": "tsc --noEmit"
60
- },
61
49
  "dependencies": {
62
50
  "@babel/core": "^7.29.0",
63
51
  "@babel/plugin-transform-typescript": "^7.28.6",
@@ -86,5 +74,17 @@
86
74
  },
87
75
  "publishConfig": {
88
76
  "access": "public"
77
+ },
78
+ "scripts": {
79
+ "build": "tsc -p tsconfig.json",
80
+ "format": "prettier . --cache --write",
81
+ "format:check": "prettier . --cache --check",
82
+ "lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'",
83
+ "lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'",
84
+ "lint:format": "prettier . --cache --check",
85
+ "lint:format:fix": "prettier . --cache --write",
86
+ "lint:js": "eslint .",
87
+ "lint:js:fix": "eslint . --fix",
88
+ "lint:types": "tsc --noEmit"
89
89
  }
90
90
  }