ember-live-compiler 0.1.0
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/README.md +26 -0
- package/dist/compile.node.d.ts +115 -0
- package/dist/compile.node.d.ts.map +1 -0
- package/dist/compile.node.js +140 -0
- package/dist/compile.node.js.map +1 -0
- package/dist/create-owner.d.ts +27 -0
- package/dist/create-owner.d.ts.map +1 -0
- package/dist/create-owner.js +28 -0
- package/dist/create-owner.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver/ember-modules.d.ts +13 -0
- package/dist/resolver/ember-modules.d.ts.map +1 -0
- package/dist/resolver/ember-modules.js +19 -0
- package/dist/resolver/ember-modules.js.map +1 -0
- package/dist/resolver/index.d.ts +10 -0
- package/dist/resolver/index.d.ts.map +1 -0
- package/dist/resolver/index.js +10 -0
- package/dist/resolver/index.js.map +1 -0
- package/dist/resolver/macros-shim.d.ts +19 -0
- package/dist/resolver/macros-shim.d.ts.map +1 -0
- package/dist/resolver/macros-shim.js +30 -0
- package/dist/resolver/macros-shim.js.map +1 -0
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +14 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/render.d.ts +26 -0
- package/dist/runtime/render.d.ts.map +1 -0
- package/dist/runtime/render.js +40 -0
- package/dist/runtime/render.js.map +1 -0
- package/package.json +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# ember-live-compiler
|
|
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.
|
|
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:
|
|
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)
|
|
15
|
+
|
|
16
|
+
## Subpath exports
|
|
17
|
+
|
|
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/*`. |
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler` — Node / build-time compile pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Consumed by bundler plugins (Vite, Webpack, Rollup, esbuild) that need to
|
|
5
|
+
* turn `.gjs` / `.gts` source into a Babel-compiled JavaScript module.
|
|
6
|
+
*
|
|
7
|
+
* The engine is bundler-agnostic and DOM-free: callers are responsible for
|
|
8
|
+
* locating their project's `ember-source` template compiler and for any
|
|
9
|
+
* file-id sniffing / virtual-module bookkeeping their bundler requires.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createNodeCompiler } from 'ember-live-compiler';
|
|
15
|
+
*
|
|
16
|
+
* const compiler = createNodeCompiler({
|
|
17
|
+
* templateCompiler: { compiler }, // or { compilerPath }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const result = await compiler.compile(source, {
|
|
21
|
+
* filename: '/abs/path/MyButton.gts',
|
|
22
|
+
* kind: 'gts',
|
|
23
|
+
* sourceMaps: true,
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import type { ParserOptions, PluginItem } from '@babel/core';
|
|
28
|
+
type ParserPluginList = NonNullable<ParserOptions['plugins']>;
|
|
29
|
+
/**
|
|
30
|
+
* Source kind passed to {@link NodeCompiler.compile}. The consumer is
|
|
31
|
+
* responsible for sniffing this from the file id / extension.
|
|
32
|
+
*/
|
|
33
|
+
export type CompileKind = 'gjs' | 'gts'
|
|
34
|
+
/**
|
|
35
|
+
* A `.js` file emitted by a V2 Ember addon with
|
|
36
|
+
* `targetFormat: 'hbs'` — i.e. it contains `precompileTemplate()` calls
|
|
37
|
+
* that need template-compilation but no content-tag preprocessing and
|
|
38
|
+
* no decorator transform.
|
|
39
|
+
*/
|
|
40
|
+
| 'precompiled-template';
|
|
41
|
+
/**
|
|
42
|
+
* Options passed once to {@link createNodeCompiler}. Heavy work (building the
|
|
43
|
+
* Babel plugin/preset lists) happens here so per-file `compile()` calls stay
|
|
44
|
+
* cheap.
|
|
45
|
+
*/
|
|
46
|
+
export interface NodeCompilerOptions {
|
|
47
|
+
/**
|
|
48
|
+
* How `babel-plugin-ember-template-compilation` should locate the Ember
|
|
49
|
+
* template compiler. Pass either a preloaded `compiler` module (fast path
|
|
50
|
+
* for Ember ≤ 6.x) or a `compilerPath` (Ember 7+ ESM, lazily loaded by the
|
|
51
|
+
* Babel plugin). When both are omitted the Babel plugin runs its own
|
|
52
|
+
* default ember-source resolution.
|
|
53
|
+
*/
|
|
54
|
+
templateCompiler?: {
|
|
55
|
+
compiler?: unknown;
|
|
56
|
+
compilerPath?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Additional Babel plugins. Either an array (appended **after** the
|
|
60
|
+
* built-ins, matching legacy behavior) or `{ before, after }` for fine
|
|
61
|
+
* ordering relative to the built-ins:
|
|
62
|
+
*
|
|
63
|
+
* 1. `before` plugins
|
|
64
|
+
* 2. `babel-plugin-ember-template-compilation`
|
|
65
|
+
* 3. `module:decorator-transforms`
|
|
66
|
+
* 4. `after` plugins
|
|
67
|
+
* 5. `@babel/plugin-transform-typescript` (only for `.gts`)
|
|
68
|
+
*/
|
|
69
|
+
babelPlugins?: PluginItem[] | {
|
|
70
|
+
before?: PluginItem[];
|
|
71
|
+
after?: PluginItem[];
|
|
72
|
+
};
|
|
73
|
+
/** Additional Babel presets (forwarded as-is). */
|
|
74
|
+
babelPresets?: PluginItem[];
|
|
75
|
+
/**
|
|
76
|
+
* Additional Babel parser plugins (forwarded to `parserOpts.plugins`).
|
|
77
|
+
* The built-ins (`classProperties`, `classPrivateProperties`,
|
|
78
|
+
* `classPrivateMethods`, plus `typescript` for `.gts`) are always
|
|
79
|
+
* included; these are appended.
|
|
80
|
+
*/
|
|
81
|
+
parserPlugins?: ParserPluginList;
|
|
82
|
+
}
|
|
83
|
+
/** Per-file options for {@link NodeCompiler.compile}. */
|
|
84
|
+
export interface CompileFileOptions {
|
|
85
|
+
/** Absolute path used for source-map `filename` and error reporting. */
|
|
86
|
+
filename: string;
|
|
87
|
+
/** What kind of source this is. */
|
|
88
|
+
kind: CompileKind;
|
|
89
|
+
/** Whether to produce a source map. Defaults to `true`. */
|
|
90
|
+
sourceMaps?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** Result of a single compile. */
|
|
93
|
+
export interface CompileResult {
|
|
94
|
+
code: string;
|
|
95
|
+
/** Babel's source-map object. Shape matches `BabelFileResult['map']`. */
|
|
96
|
+
map?: unknown;
|
|
97
|
+
}
|
|
98
|
+
/** Stateful compiler returned by {@link createNodeCompiler}. */
|
|
99
|
+
export interface NodeCompiler {
|
|
100
|
+
/**
|
|
101
|
+
* Compile a single source file. Returns `null` when Babel produces no
|
|
102
|
+
* output (matches Vite/Rollup's `transform` contract).
|
|
103
|
+
*
|
|
104
|
+
* Throws on content-tag or Babel failures — the caller is expected to
|
|
105
|
+
* narrow / report those (e.g. via Rollup's `this.error`).
|
|
106
|
+
*/
|
|
107
|
+
compile(source: string, opts: CompileFileOptions): Promise<CompileResult | null>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Build the shared Babel configs (one for `.gjs`, one for `.gts`,
|
|
111
|
+
* one for `precompiled-template` `.js`) once at compiler-creation time.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createNodeCompiler(options?: NodeCompilerOptions): NodeCompiler;
|
|
114
|
+
export type { PluginItem, ParserOptions } from '@babel/core';
|
|
115
|
+
//# sourceMappingURL=compile.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.node.d.ts","sourceRoot":"","sources":["../src/compile.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,KAAK,gBAAgB,GAAG,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,KAAK,GACL,KAAK;AACP;;;;;GAKG;GACD,sBAAsB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEjE;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,UAAU,EAAE,GAAG;QAAE,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAE9E,kDAAkD;IAClD,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CAClC;AAQD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAgHd;AAED,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler` — Node / build-time compile pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Consumed by bundler plugins (Vite, Webpack, Rollup, esbuild) that need to
|
|
5
|
+
* turn `.gjs` / `.gts` source into a Babel-compiled JavaScript module.
|
|
6
|
+
*
|
|
7
|
+
* The engine is bundler-agnostic and DOM-free: callers are responsible for
|
|
8
|
+
* locating their project's `ember-source` template compiler and for any
|
|
9
|
+
* file-id sniffing / virtual-module bookkeeping their bundler requires.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createNodeCompiler } from 'ember-live-compiler';
|
|
15
|
+
*
|
|
16
|
+
* const compiler = createNodeCompiler({
|
|
17
|
+
* templateCompiler: { compiler }, // or { compilerPath }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const result = await compiler.compile(source, {
|
|
21
|
+
* filename: '/abs/path/MyButton.gts',
|
|
22
|
+
* kind: 'gts',
|
|
23
|
+
* sourceMaps: true,
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import templateCompilation from 'babel-plugin-ember-template-compilation';
|
|
28
|
+
import { transformAsync } from '@babel/core';
|
|
29
|
+
import { Preprocessor } from 'content-tag';
|
|
30
|
+
const BASE_PARSER_PLUGINS = [
|
|
31
|
+
'classProperties',
|
|
32
|
+
'classPrivateProperties',
|
|
33
|
+
'classPrivateMethods',
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Build the shared Babel configs (one for `.gjs`, one for `.gts`,
|
|
37
|
+
* one for `precompiled-template` `.js`) once at compiler-creation time.
|
|
38
|
+
*/
|
|
39
|
+
export function createNodeCompiler(options = {}) {
|
|
40
|
+
const preprocessor = new Preprocessor();
|
|
41
|
+
const templateCompilationOpts = (() => {
|
|
42
|
+
const tc = options.templateCompiler;
|
|
43
|
+
if (!tc)
|
|
44
|
+
return {};
|
|
45
|
+
if (tc.compiler)
|
|
46
|
+
return { compiler: tc.compiler };
|
|
47
|
+
if (tc.compilerPath)
|
|
48
|
+
return { compilerPath: tc.compilerPath };
|
|
49
|
+
return {};
|
|
50
|
+
})();
|
|
51
|
+
// Normalize `babelPlugins` (array | { before, after }) into ordered slots
|
|
52
|
+
// around the built-ins.
|
|
53
|
+
let userBefore = [];
|
|
54
|
+
let userAfter = [];
|
|
55
|
+
if (Array.isArray(options.babelPlugins)) {
|
|
56
|
+
userAfter = options.babelPlugins;
|
|
57
|
+
}
|
|
58
|
+
else if (options.babelPlugins) {
|
|
59
|
+
userBefore = options.babelPlugins.before ?? [];
|
|
60
|
+
userAfter = options.babelPlugins.after ?? [];
|
|
61
|
+
}
|
|
62
|
+
const basePlugins = [
|
|
63
|
+
...userBefore,
|
|
64
|
+
[templateCompilation, templateCompilationOpts],
|
|
65
|
+
[
|
|
66
|
+
'module:decorator-transforms',
|
|
67
|
+
{ runtime: { import: 'decorator-transforms/runtime' } },
|
|
68
|
+
],
|
|
69
|
+
...userAfter,
|
|
70
|
+
];
|
|
71
|
+
const presets = [...(options.babelPresets ?? [])];
|
|
72
|
+
const userParserPlugins = options.parserPlugins ?? [];
|
|
73
|
+
const gjsConfig = {
|
|
74
|
+
plugins: basePlugins,
|
|
75
|
+
presets,
|
|
76
|
+
parserPlugins: [...BASE_PARSER_PLUGINS, ...userParserPlugins],
|
|
77
|
+
};
|
|
78
|
+
const gtsConfig = {
|
|
79
|
+
plugins: [
|
|
80
|
+
...basePlugins,
|
|
81
|
+
[
|
|
82
|
+
'@babel/plugin-transform-typescript',
|
|
83
|
+
{
|
|
84
|
+
allExtensions: true,
|
|
85
|
+
onlyRemoveTypeImports: true,
|
|
86
|
+
allowDeclareFields: true,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
],
|
|
90
|
+
presets,
|
|
91
|
+
parserPlugins: [
|
|
92
|
+
...BASE_PARSER_PLUGINS,
|
|
93
|
+
'typescript',
|
|
94
|
+
...userParserPlugins,
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
// V2-addon `.js` with precompileTemplate calls: template-compilation only.
|
|
98
|
+
const precompiledTemplatePlugins = [
|
|
99
|
+
[templateCompilation, templateCompilationOpts],
|
|
100
|
+
];
|
|
101
|
+
async function compile(source, opts) {
|
|
102
|
+
const sourceMaps = opts.sourceMaps ?? true;
|
|
103
|
+
if (opts.kind === 'precompiled-template') {
|
|
104
|
+
const result = await transformAsync(source, {
|
|
105
|
+
filename: opts.filename,
|
|
106
|
+
babelrc: false,
|
|
107
|
+
configFile: false,
|
|
108
|
+
plugins: precompiledTemplatePlugins,
|
|
109
|
+
parserOpts: { sourceType: 'module' },
|
|
110
|
+
sourceMaps,
|
|
111
|
+
});
|
|
112
|
+
if (!result?.code)
|
|
113
|
+
return null;
|
|
114
|
+
return { code: result.code, map: result.map ?? undefined };
|
|
115
|
+
}
|
|
116
|
+
// .gjs / .gts: content-tag preprocessing, then babel.
|
|
117
|
+
const preResult = preprocessor.process(source, {
|
|
118
|
+
filename: opts.filename,
|
|
119
|
+
});
|
|
120
|
+
const preprocessed = typeof preResult === 'string' ? preResult : preResult.code;
|
|
121
|
+
const cfg = opts.kind === 'gts' ? gtsConfig : gjsConfig;
|
|
122
|
+
const result = await transformAsync(preprocessed, {
|
|
123
|
+
filename: opts.filename,
|
|
124
|
+
babelrc: false,
|
|
125
|
+
configFile: false,
|
|
126
|
+
plugins: cfg.plugins,
|
|
127
|
+
presets: cfg.presets,
|
|
128
|
+
parserOpts: {
|
|
129
|
+
sourceType: 'module',
|
|
130
|
+
plugins: cfg.parserPlugins,
|
|
131
|
+
},
|
|
132
|
+
sourceMaps,
|
|
133
|
+
});
|
|
134
|
+
if (!result?.code)
|
|
135
|
+
return null;
|
|
136
|
+
return { code: result.code, map: result.map ?? undefined };
|
|
137
|
+
}
|
|
138
|
+
return { compile };
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=compile.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.node.js","sourceRoot":"","sources":["../src/compile.node.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal Ember-compatible owner backed by a simple `Map`.
|
|
3
|
+
*/
|
|
4
|
+
export interface EmberOwner {
|
|
5
|
+
/** Register a pre-built instance under a full name (e.g. `'service:greeting'`). */
|
|
6
|
+
register(fullName: string, instance: unknown): void;
|
|
7
|
+
/** Look up a previously registered instance. */
|
|
8
|
+
lookup(fullName: string): unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a minimal Ember-compatible "owner" backed by a simple Map.
|
|
12
|
+
*
|
|
13
|
+
* A full Ember app uses an `ApplicationInstance` as the owner, but for
|
|
14
|
+
* standalone `renderComponent` usage this lightweight implementation is
|
|
15
|
+
* enough to satisfy `getOwner(this).lookup(...)` and the `@service`
|
|
16
|
+
* decorator.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createOwner } from 'ember-live-compiler';
|
|
21
|
+
*
|
|
22
|
+
* const owner = createOwner();
|
|
23
|
+
* owner.register('service:greeting', new GreetingService());
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function createOwner(): EmberOwner;
|
|
27
|
+
//# sourceMappingURL=create-owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-owner.d.ts","sourceRoot":"","sources":["../src/create-owner.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACpD,gDAAgD;IAChD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAYxC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a minimal Ember-compatible "owner" backed by a simple Map.
|
|
3
|
+
*
|
|
4
|
+
* A full Ember app uses an `ApplicationInstance` as the owner, but for
|
|
5
|
+
* standalone `renderComponent` usage this lightweight implementation is
|
|
6
|
+
* enough to satisfy `getOwner(this).lookup(...)` and the `@service`
|
|
7
|
+
* decorator.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createOwner } from 'ember-live-compiler';
|
|
12
|
+
*
|
|
13
|
+
* const owner = createOwner();
|
|
14
|
+
* owner.register('service:greeting', new GreetingService());
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function createOwner() {
|
|
18
|
+
const services = new Map();
|
|
19
|
+
return {
|
|
20
|
+
register(fullName, instance) {
|
|
21
|
+
services.set(fullName, instance);
|
|
22
|
+
},
|
|
23
|
+
lookup(fullName) {
|
|
24
|
+
return services.get(fullName);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=create-owner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-owner.js","sourceRoot":"","sources":["../src/create-owner.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE5C,OAAO;QACL,QAAQ,CAAC,QAAgB,EAAE,QAAiB;YAC1C,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,CAAC,QAAgB;YACrB,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler` — Node / build-time entry point.
|
|
3
|
+
*
|
|
4
|
+
* Hosts {@link createNodeCompiler}, the Babel + content-tag pipeline that
|
|
5
|
+
* turns `.gjs` / `.gts` source (and V2-addon `precompileTemplate()` `.js`)
|
|
6
|
+
* into compiled JavaScript modules. Bundler plugins wrap this with their
|
|
7
|
+
* own file-id sniffing and module-resolution logic.
|
|
8
|
+
*
|
|
9
|
+
* Also re-exports the small runtime owner helper so consumers can depend
|
|
10
|
+
* on a single package for both build-time and minimal runtime needs.
|
|
11
|
+
*/
|
|
12
|
+
export { createNodeCompiler } from './compile.node.js';
|
|
13
|
+
export { createOwner } from './create-owner.js';
|
|
14
|
+
export type { NodeCompiler, NodeCompilerOptions, CompileFileOptions, CompileKind, CompileResult, } from './compile.node.js';
|
|
15
|
+
export type { EmberOwner } from './create-owner.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler` — Node / build-time entry point.
|
|
3
|
+
*
|
|
4
|
+
* Hosts {@link createNodeCompiler}, the Babel + content-tag pipeline that
|
|
5
|
+
* turns `.gjs` / `.gts` source (and V2-addon `precompileTemplate()` `.js`)
|
|
6
|
+
* into compiled JavaScript modules. Bundler plugins wrap this with their
|
|
7
|
+
* own file-id sniffing and module-resolution logic.
|
|
8
|
+
*
|
|
9
|
+
* Also re-exports the small runtime owner helper so consumers can depend
|
|
10
|
+
* on a single package for both build-time and minimal runtime needs.
|
|
11
|
+
*/
|
|
12
|
+
export { createNodeCompiler } from './compile.node.js';
|
|
13
|
+
export { createOwner } from './create-owner.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bare-specifier prefixes that should be resolved into `ember-source`'s
|
|
3
|
+
* `dist/packages/` tree.
|
|
4
|
+
*
|
|
5
|
+
* E.g. `@ember/renderer` → `<ember-source>/dist/packages/@ember/renderer/index.js`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EMBER_PACKAGE_PREFIXES: readonly ["@ember/", "@glimmer/"];
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` when the given bare specifier belongs to one of the
|
|
10
|
+
* Ember-owned package namespaces ({@link EMBER_PACKAGE_PREFIXES}).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isEmberSpecifier(id: string): boolean;
|
|
13
|
+
//# sourceMappingURL=ember-modules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ember-modules.d.ts","sourceRoot":"","sources":["../../src/resolver/ember-modules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,mCAAoC,CAAC;AAExE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAKpD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bare-specifier prefixes that should be resolved into `ember-source`'s
|
|
3
|
+
* `dist/packages/` tree.
|
|
4
|
+
*
|
|
5
|
+
* E.g. `@ember/renderer` → `<ember-source>/dist/packages/@ember/renderer/index.js`.
|
|
6
|
+
*/
|
|
7
|
+
export const EMBER_PACKAGE_PREFIXES = ['@ember/', '@glimmer/'];
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` when the given bare specifier belongs to one of the
|
|
10
|
+
* Ember-owned package namespaces ({@link EMBER_PACKAGE_PREFIXES}).
|
|
11
|
+
*/
|
|
12
|
+
export function isEmberSpecifier(id) {
|
|
13
|
+
for (const prefix of EMBER_PACKAGE_PREFIXES) {
|
|
14
|
+
if (id.startsWith(prefix))
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ember-modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ember-modules.js","sourceRoot":"","sources":["../../src/resolver/ember-modules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,WAAW,CAAU,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAU;IACzC,KAAK,MAAM,MAAM,IAAI,sBAAsB,EAAE,CAAC;QAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/resolver` — pure bundler-helper utilities.
|
|
3
|
+
*
|
|
4
|
+
* These helpers contain no DOM, no Babel, and no Node-only APIs, so they
|
|
5
|
+
* are safe to import from any environment (build tools, runtime bundlers,
|
|
6
|
+
* tests).
|
|
7
|
+
*/
|
|
8
|
+
export { EMBROIDER_MACROS_VIRTUAL_ID, EMBROIDER_MACROS_SHIM_SOURCE, } from './macros-shim.js';
|
|
9
|
+
export { EMBER_PACKAGE_PREFIXES, isEmberSpecifier } from './ember-modules.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/resolver` — pure bundler-helper utilities.
|
|
3
|
+
*
|
|
4
|
+
* These helpers contain no DOM, no Babel, and no Node-only APIs, so they
|
|
5
|
+
* are safe to import from any environment (build tools, runtime bundlers,
|
|
6
|
+
* tests).
|
|
7
|
+
*/
|
|
8
|
+
export { EMBROIDER_MACROS_VIRTUAL_ID, EMBROIDER_MACROS_SHIM_SOURCE, } from './macros-shim.js';
|
|
9
|
+
export { EMBER_PACKAGE_PREFIXES, isEmberSpecifier } from './ember-modules.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime shim for `@embroider/macros`.
|
|
3
|
+
*
|
|
4
|
+
* `ember-source`'s ESM modules import compile-time helpers from
|
|
5
|
+
* `@embroider/macros` (`isDevelopingApp`, `macroCondition`, …). Outside of
|
|
6
|
+
* the Embroider build pipeline those imports have no implementation, so
|
|
7
|
+
* any bundler that wants to serve ember-source ESM directly must supply
|
|
8
|
+
* runtime versions instead.
|
|
9
|
+
*
|
|
10
|
+
* Bundler plugins typically:
|
|
11
|
+
* 1. resolve `@embroider/macros` to {@link EMBROIDER_MACROS_VIRTUAL_ID}
|
|
12
|
+
* 2. load that id and return {@link EMBROIDER_MACROS_SHIM_SOURCE}
|
|
13
|
+
*
|
|
14
|
+
* The `\0`-prefixed id follows the Rollup / Vite convention for virtual
|
|
15
|
+
* modules. Consumers using other bundlers may pick any unique id.
|
|
16
|
+
*/
|
|
17
|
+
export declare const EMBROIDER_MACROS_VIRTUAL_ID = "\0embroider-macros-shim";
|
|
18
|
+
export declare const EMBROIDER_MACROS_SHIM_SOURCE = "\nexport function isDevelopingApp() { return true; }\nexport function isTesting() { return false; }\nexport function macroCondition(condition) { return condition; }\nexport function dependencySatisfies() { return true; }\nexport function getOwnConfig() { return {}; }\nexport function getConfig() { return {}; }\nexport function importSync(specifier) {\n throw new Error('[embroider-macros shim] importSync is not supported at runtime: ' + specifier);\n}\nexport function getGlobalConfig() { return { isDevelopingApp: true, isTesting: false }; }\n";
|
|
19
|
+
//# sourceMappingURL=macros-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macros-shim.d.ts","sourceRoot":"","sources":["../../src/resolver/macros-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAErE,eAAO,MAAM,4BAA4B,yiBAWxC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime shim for `@embroider/macros`.
|
|
3
|
+
*
|
|
4
|
+
* `ember-source`'s ESM modules import compile-time helpers from
|
|
5
|
+
* `@embroider/macros` (`isDevelopingApp`, `macroCondition`, …). Outside of
|
|
6
|
+
* the Embroider build pipeline those imports have no implementation, so
|
|
7
|
+
* any bundler that wants to serve ember-source ESM directly must supply
|
|
8
|
+
* runtime versions instead.
|
|
9
|
+
*
|
|
10
|
+
* Bundler plugins typically:
|
|
11
|
+
* 1. resolve `@embroider/macros` to {@link EMBROIDER_MACROS_VIRTUAL_ID}
|
|
12
|
+
* 2. load that id and return {@link EMBROIDER_MACROS_SHIM_SOURCE}
|
|
13
|
+
*
|
|
14
|
+
* The `\0`-prefixed id follows the Rollup / Vite convention for virtual
|
|
15
|
+
* modules. Consumers using other bundlers may pick any unique id.
|
|
16
|
+
*/
|
|
17
|
+
export const EMBROIDER_MACROS_VIRTUAL_ID = '\0embroider-macros-shim';
|
|
18
|
+
export const EMBROIDER_MACROS_SHIM_SOURCE = `
|
|
19
|
+
export function isDevelopingApp() { return true; }
|
|
20
|
+
export function isTesting() { return false; }
|
|
21
|
+
export function macroCondition(condition) { return condition; }
|
|
22
|
+
export function dependencySatisfies() { return true; }
|
|
23
|
+
export function getOwnConfig() { return {}; }
|
|
24
|
+
export function getConfig() { return {}; }
|
|
25
|
+
export function importSync(specifier) {
|
|
26
|
+
throw new Error('[embroider-macros shim] importSync is not supported at runtime: ' + specifier);
|
|
27
|
+
}
|
|
28
|
+
export function getGlobalConfig() { return { isDevelopingApp: true, isTesting: false }; }
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=macros-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macros-shim.js","sourceRoot":"","sources":["../../src/resolver/macros-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;CAW3C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/runtime` — browser-safe entry point.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `createOwner` — Map-backed Ember owner factory (no DOM, no Babel).
|
|
6
|
+
* - `render` — mount a component module into a DOM element via
|
|
7
|
+
* `@ember/renderer` (lazy-imported).
|
|
8
|
+
*
|
|
9
|
+
* Future work: `compile()` (lazy `@babel/standalone` + content-tag wasm) so
|
|
10
|
+
* browsers can also do source → component without a build step.
|
|
11
|
+
*/
|
|
12
|
+
export { createOwner } from '../create-owner.js';
|
|
13
|
+
export { render } from './render.js';
|
|
14
|
+
export type { EmberOwner } from '../create-owner.js';
|
|
15
|
+
export type { Mount, RenderOptions } from './render.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/runtime` — browser-safe entry point.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `createOwner` — Map-backed Ember owner factory (no DOM, no Babel).
|
|
6
|
+
* - `render` — mount a component module into a DOM element via
|
|
7
|
+
* `@ember/renderer` (lazy-imported).
|
|
8
|
+
*
|
|
9
|
+
* Future work: `compile()` (lazy `@babel/standalone` + content-tag wasm) so
|
|
10
|
+
* browsers can also do source → component without a build step.
|
|
11
|
+
*/
|
|
12
|
+
export { createOwner } from '../create-owner.js';
|
|
13
|
+
export { render } from './render.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/runtime` — browser-safe `render()`.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper around `@ember/renderer` (Ember 6.8+) that:
|
|
5
|
+
* - lazily imports the renderer so apps that never call `render()` don't pay
|
|
6
|
+
* the import cost,
|
|
7
|
+
* - unwraps a module's `default` export when callers pass an ESM namespace
|
|
8
|
+
* object instead of a component class,
|
|
9
|
+
* - normalizes the disposer into the documented `Mount` shape.
|
|
10
|
+
*/
|
|
11
|
+
import type { EmberOwner } from '../create-owner.js';
|
|
12
|
+
export interface Mount {
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderOptions {
|
|
16
|
+
/** DOM element to mount into. */
|
|
17
|
+
into: Element;
|
|
18
|
+
/** Optional Ember owner. Recommended for services / DI. */
|
|
19
|
+
owner?: EmberOwner | object;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Mount an Ember component (or an ESM module whose `default` export is one)
|
|
23
|
+
* into a DOM element. Returns a `Mount` whose `destroy()` tears it down.
|
|
24
|
+
*/
|
|
25
|
+
export declare function render(component: unknown, options: RenderOptions): Promise<Mount>;
|
|
26
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/runtime/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,2DAA2D;IAC3D,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAC7B;AAeD;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,KAAK,CAAC,CAiBhB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ember-live-compiler/runtime` — browser-safe `render()`.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper around `@ember/renderer` (Ember 6.8+) that:
|
|
5
|
+
* - lazily imports the renderer so apps that never call `render()` don't pay
|
|
6
|
+
* the import cost,
|
|
7
|
+
* - unwraps a module's `default` export when callers pass an ESM namespace
|
|
8
|
+
* object instead of a component class,
|
|
9
|
+
* - normalizes the disposer into the documented `Mount` shape.
|
|
10
|
+
*/
|
|
11
|
+
let rendererPromise;
|
|
12
|
+
function loadRenderer() {
|
|
13
|
+
// `@ember/renderer` is a virtual subpath provided by ember-source 6.8+ and
|
|
14
|
+
// resolved by the host bundler (vite-plugin-ember maps `@ember/*` onto
|
|
15
|
+
// `ember-source/dist/...`). The literal specifier is intentional so Vite's
|
|
16
|
+
// import analyzer can see it and pre-bundle the module — wrapping it in a
|
|
17
|
+
// variable would ship the bare specifier to the browser unresolved.
|
|
18
|
+
rendererPromise ??= import('@ember/renderer');
|
|
19
|
+
return rendererPromise;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Mount an Ember component (or an ESM module whose `default` export is one)
|
|
23
|
+
* into a DOM element. Returns a `Mount` whose `destroy()` tears it down.
|
|
24
|
+
*/
|
|
25
|
+
export async function render(component, options) {
|
|
26
|
+
const { renderComponent } = await loadRenderer();
|
|
27
|
+
const target = component && typeof component === 'object' && 'default' in component
|
|
28
|
+
? component.default
|
|
29
|
+
: component;
|
|
30
|
+
const disposer = renderComponent(target, {
|
|
31
|
+
into: options.into,
|
|
32
|
+
...(options.owner ? { owner: options.owner } : {}),
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
destroy() {
|
|
36
|
+
disposer?.destroy?.();
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/runtime/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,IAAI,eAAoD,CAAC;AACzD,SAAS,YAAY;IACnB,2EAA2E;IAC3E,uEAAuE;IACvE,2EAA2E;IAC3E,0EAA0E;IAC1E,oEAAoE;IACpE,eAAe,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,SAAkB,EAClB,OAAsB;IAEtB,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,YAAY,EAAE,CAAC;IACjD,MAAM,MAAM,GACV,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,IAAI,SAAS;QAClE,CAAC,CAAE,SAAkC,CAAC,OAAO;QAC7C,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE;QACvC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;YACL,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ember-live-compiler",
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"ember",
|
|
7
|
+
"emberjs",
|
|
8
|
+
"ember-source",
|
|
9
|
+
"glimmer",
|
|
10
|
+
"gjs",
|
|
11
|
+
"gts",
|
|
12
|
+
"template-tag",
|
|
13
|
+
"compiler",
|
|
14
|
+
"live-preview",
|
|
15
|
+
"documentation"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/aklkv/vite-plugin-ember/tree/main/ember-live-compiler#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/aklkv/vite-plugin-ember/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/aklkv/vite-plugin-ember.git",
|
|
24
|
+
"directory": "ember-live-compiler"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": "Alexey Kulakov",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./runtime": {
|
|
36
|
+
"types": "./dist/runtime/index.d.ts",
|
|
37
|
+
"default": "./dist/runtime/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./resolver": {
|
|
40
|
+
"types": "./dist/resolver/index.d.ts",
|
|
41
|
+
"default": "./dist/resolver/index.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"main": "dist/index.js",
|
|
45
|
+
"types": "dist/index.d.ts",
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
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
|
+
"dependencies": {
|
|
62
|
+
"@babel/core": "^7.29.0",
|
|
63
|
+
"@babel/plugin-transform-typescript": "^7.28.6",
|
|
64
|
+
"babel-plugin-ember-template-compilation": "^4.0.0",
|
|
65
|
+
"content-tag": "^4.2.0",
|
|
66
|
+
"decorator-transforms": "^2.3.2"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@eslint/js": "^10.0.1",
|
|
70
|
+
"@types/babel__core": "^7.20.5",
|
|
71
|
+
"@types/node": "^25.9.1",
|
|
72
|
+
"concurrently": "^9.2.1",
|
|
73
|
+
"eslint": "^10.4.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"globals": "^17.6.0",
|
|
76
|
+
"typescript": "^6.0.3",
|
|
77
|
+
"typescript-eslint": "^8.59.4"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"ember-source": ">= 6.8.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"ember-source": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
}
|
|
90
|
+
}
|