Skip to content

Commit 761ad73

Browse files
committed
Finish refactor
1 parent 4b7125c commit 761ad73

File tree

14 files changed

+667
-558
lines changed

14 files changed

+667
-558
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"@nullvoxpopuli/eslint-configs": "^3.2.2",
4343
"@embroider/addon-shim": "1.8.7",
4444
"ember-element-helper": "^0.8.5",
45-
"ember-auto-import": "^2.7.0"
45+
"ember-auto-import": "^2.7.0",
46+
"ember-source": ">= 5.5.0",
47+
"webpack": "5.90.3"
4648
},
4749
"allowedDeprecatedVersions": {
4850
"source-map-url": "^0.3.0",

packages/ember-repl/addon/package.json

+19-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@
3131
"types": "./declarations/index.d.ts",
3232
"default": "./dist/index.js"
3333
},
34-
"./markdown/parse": {
35-
"types": "./declarations/compile/markdown-to-ember.d.ts",
36-
"default": "./dist/compile/markdown-to-ember.js"
34+
"./formats/markdown": {
35+
"types": "./declarations/compile/formats/markdown.d.ts",
36+
"default": "./dist/compile/formats/markdown.js"
37+
},
38+
"./formats/hbs": {
39+
"types": "./declarations/compile/formats/hbs.d.ts",
40+
"default": "./dist/compile/formats/hbs.js"
41+
},
42+
"./formats/gjs": {
43+
"types": "./declarations/compile/formats/gjs/index.d.ts",
44+
"default": "./dist/compile/formats/gjs/index.js"
3745
},
3846
"./test-support": {
3947
"types": "./declarations/test-support/index.d.ts",
@@ -66,6 +74,7 @@
6674
"lint:prettier": "pnpm -w exec lint prettier"
6775
},
6876
"dependencies": {
77+
"ember-resources": ">= 6.4.2",
6978
"@babel/helper-plugin-utils": "^7.22.5",
7079
"@babel/standalone": "^7.23.10",
7180
"@embroider/addon-shim": "1.8.7",
@@ -155,8 +164,13 @@
155164
},
156165
"peerDependencies": {
157166
"@glint/template": ">= 1.3.0",
158-
"ember-resources": ">= 6.4.2",
159-
"ember-source": ">= 5.5.0"
167+
"@glimmer/compiler": ">= 0.86.0",
168+
"@glimmer/syntax": ">= 0.86.0"
169+
},
170+
"peerDependenciesMeta": {
171+
"@glint/template": { "optional": true },
172+
"@glimmer/compiler": { "optional": true },
173+
"@glimmer/syntax": { "optional": true }
160174
},
161175
"engines": {
162176
"node": ">= v16",

packages/ember-repl/addon/rollup.config.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig({
1414
output: addon.output(),
1515
external: ["@glimmer/compiler", "@glimmer/syntax"],
1616
plugins: [
17-
addon.publicEntrypoints(["browser/**/*.js", "test-support/*.js"]),
17+
addon.publicEntrypoints(["**/*.js"]),
1818
addon.appReexports([]),
1919
babel({
2020
extensions: [".js", ".gjs", ".ts", ".gts"],
@@ -29,6 +29,7 @@ export default defineConfig({
2929
{
3030
async closeBundle() {
3131
await execaCommand("tsc --emitDeclarationOnly --noEmit false", { stdio: "inherit" });
32+
console.info("Declarations built successfully");
3233
},
3334
},
3435
],

packages/ember-repl/addon/src/compile/formats/gjs/babel.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ export interface Babel {
55
availablePresets: typeof availablePresets;
66
transform: typeof transform;
77
}
8-

packages/ember-repl/addon/src/compile/formats/gjs/eval.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export function evalSnippet(
2020
return preConfigured || window.require(moduleName);
2121
}
2222

23-
// https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts
2423
eval(compiled);
2524

2625
return Object.assign(exports, { require }) as {

packages/ember-repl/addon/src/compile/formats/gjs/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-com
55
import { nameFor } from '../../utils.ts';
66
import { evalSnippet } from './eval.ts';
77

8-
import type { CompileResult, ExtraModules } from '../../types.ts';
8+
import type { CompileResult } from '../../types.ts';
99
import type { ComponentLike } from '@glint/template';
1010

1111
export interface Info {
@@ -30,7 +30,10 @@ export interface Info {
3030
* are not provided by extraModules will be searched on npm to see if a package
3131
* needs to be downloaded before running the `code` / invoking the component
3232
*/
33-
export async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {
33+
export async function compileJS(
34+
code: string,
35+
extraModules?: Record<string, unknown>
36+
): Promise<CompileResult> {
3437
let name = nameFor(code);
3538
let component: undefined | ComponentLike;
3639
let error: undefined | Error;

packages/ember-repl/addon/src/compile/formats/hbs.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
7979
let value = localScope[key];
8080

8181
if (!value) {
82-
throw new Error(`Attempt to use ${key} in compiled hbs, but it was not available in scope. `
83-
+`Available scope includes: ${Object.keys(localScope)}`);
82+
throw new Error(
83+
`Attempt to use ${key} in compiled hbs, but it was not available in scope. ` +
84+
`Available scope includes: ${Object.keys(localScope)}`
85+
);
8486
}
8587

8688
return value;

packages/ember-repl/addon/src/compile/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from './formats.ts';
88
import { nameFor } from './utils.ts';
99

10-
import type { CompileResult,UnifiedPlugin } from './types.ts';
10+
import type { CompileResult, UnifiedPlugin } from './types.ts';
1111
import type { EvalImportMap, ScopeMap } from './types.ts';
1212
import type { ComponentLike } from '@glint/template';
1313
type Format = 'glimdown' | 'gjs' | 'hbs';

packages/ember-repl/addon/src/compile/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface ScopeMap {
1111

1212
export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
1313

14-
1514
export interface CompileResult {
1615
component?: ComponentLike;
1716
error?: Error;
@@ -25,4 +24,3 @@ export type Options = {
2524
*/
2625
skypack?: boolean;
2726
};
28-

packages/ember-repl/test-app/package.json

-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
"ember-resources": "^7.0.0",
3232
"unist-util-visit": "^5.0.0"
3333
},
34-
"dependenciesMeta": {
35-
"ember-repl": {
36-
"injected": true
37-
}
38-
},
3934
"devDependencies": {
4035
"@babel/core": "^7.23.9",
4136
"@babel/plugin-proposal-decorators": "^7.23.9",

packages/ember-repl/test-app/tests/rendering/compile-hbs-test.gts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render } from '@ember/test-helpers';
22
import { module, test } from 'qunit';
33
import { setupRenderingTest } from 'ember-qunit';
44

5-
import { compileHBS } from 'ember-repl';
5+
import { compileHBS } from 'ember-repl/formats/hbs';
66

77
import { Await } from '../helpers/await';
88

packages/ember-repl/test-app/tests/rendering/compile-js-test.gts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { click, render } from '@ember/test-helpers';
22
import { module, skip, test } from 'qunit';
33
import { setupRenderingTest } from 'ember-qunit';
44

5-
import { compileJS } from 'ember-repl';
5+
import { compileJS } from 'ember-repl/formats/gjs';
66
// import this so we don't tree-shake it away
77
import ExampleComponent from 'test-app/components/example-component';
88

packages/ember-repl/test-app/tests/unit/markdown-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { module, test } from 'qunit';
22

33
import { stripIndent } from 'common-tags';
44
import { invocationOf, nameFor } from 'ember-repl';
5-
import { parseMarkdown } from 'ember-repl/markdown/parse';
5+
import { parseMarkdown } from 'ember-repl/formats/markdown';
66

77
/**
88
* NOTE: there is a problem(?) with remark-hbs where all extra newlines and

0 commit comments

Comments
 (0)