ember-repl 1.8.10 → 2.0.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/.github/workflows/ci.yml +4 -3
- package/CHANGELOG.md +13 -0
- package/addon/cjs/eval.ts +2 -42
- package/addon/cjs/index.ts +1 -19
- package/addon/esm/index.ts +131 -0
- package/addon/index.ts +2 -1
- package/addon/js.ts +38 -0
- package/addon/known-modules.ts +40 -0
- package/addon/types.ts +14 -0
- package/cjs/eval.d.ts +1 -1
- package/cjs/index.d.ts +1 -18
- package/esm/index.d.ts +11 -0
- package/index.d.ts +2 -1
- package/index.js +31 -0
- package/js.d.ts +23 -0
- package/known-modules.d.ts +37 -0
- package/package.json +21 -19
- package/tsconfig.json +1 -1
- package/types.d.ts +10 -0
- package/addon/cjs/types.ts +0 -7
- package/cjs/types.d.ts +0 -6
package/.github/workflows/ci.yml
CHANGED
|
@@ -21,8 +21,8 @@ jobs:
|
|
|
21
21
|
strategy:
|
|
22
22
|
matrix:
|
|
23
23
|
node:
|
|
24
|
-
- "12"
|
|
25
24
|
- "14"
|
|
25
|
+
- "16"
|
|
26
26
|
steps:
|
|
27
27
|
- uses: actions/checkout@v2
|
|
28
28
|
- uses: volta-cli/action@v1
|
|
@@ -42,8 +42,8 @@ jobs:
|
|
|
42
42
|
strategy:
|
|
43
43
|
matrix:
|
|
44
44
|
node:
|
|
45
|
-
- "12"
|
|
46
45
|
- "14"
|
|
46
|
+
- "16"
|
|
47
47
|
|
|
48
48
|
steps:
|
|
49
49
|
- uses: actions/checkout@v2
|
|
@@ -68,6 +68,7 @@ jobs:
|
|
|
68
68
|
matrix:
|
|
69
69
|
ember-try-scenario:
|
|
70
70
|
- ember-3.27
|
|
71
|
+
- ember-3.28
|
|
71
72
|
- ember-release
|
|
72
73
|
- ember-beta
|
|
73
74
|
- ember-canary
|
|
@@ -77,7 +78,7 @@ jobs:
|
|
|
77
78
|
- uses: actions/checkout@v2
|
|
78
79
|
- uses: volta-cli/action@v1
|
|
79
80
|
with:
|
|
80
|
-
node-version:
|
|
81
|
+
node-version: 14.x
|
|
81
82
|
- name: install dependencies
|
|
82
83
|
run: yarn install --frozen-lockfile
|
|
83
84
|
- name: test
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [2.0.0](https://github.com/NullVoxPopuli/ember-repl/compare/v1.8.10...v2.0.0) (2021-12-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### chore
|
|
5
|
+
|
|
6
|
+
* **internal:** ci updates, drop node 12 ([77637a9](https://github.com/NullVoxPopuli/ember-repl/commit/77637a94c5d30809ceeb4895a21434dfb3bd4d3a))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **internal:** drop support for node 12
|
|
12
|
+
Add support for Node 16, Ember 3.28
|
|
13
|
+
|
|
1
14
|
## [1.8.10](https://github.com/NullVoxPopuli/ember-repl/compare/v1.8.9...v1.8.10) (2021-11-19)
|
|
2
15
|
|
|
3
16
|
|
package/addon/cjs/eval.ts
CHANGED
|
@@ -1,48 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
|
|
3
|
-
* We need to import and hang on to these references so that they
|
|
4
|
-
* don't get optimized away during deploy
|
|
5
|
-
*/
|
|
6
|
-
import _GlimmerComponent from '@glimmer/component';
|
|
7
|
-
import * as _tracking from '@glimmer/tracking';
|
|
8
|
-
import * as _application from '@ember/application';
|
|
9
|
-
import * as _array from '@ember/array';
|
|
10
|
-
import * as _EmberComponent from '@ember/component';
|
|
11
|
-
import _TO from '@ember/component/template-only';
|
|
12
|
-
import * as _debug from '@ember/debug';
|
|
13
|
-
import * as _destroyable from '@ember/destroyable';
|
|
14
|
-
import * as _helpers from '@ember/helper';
|
|
15
|
-
import * as _modifier from '@ember/modifier';
|
|
16
|
-
import * as _object from '@ember/object';
|
|
17
|
-
import * as _runloop from '@ember/runloop';
|
|
18
|
-
import * as _service from '@ember/service';
|
|
19
|
-
import * as _string from '@ember/string';
|
|
20
|
-
import { createTemplateFactory } from '@ember/template-factory';
|
|
21
|
-
import * as _utils from '@ember/utils';
|
|
2
|
+
import { modules } from '../known-modules';
|
|
22
3
|
|
|
23
4
|
import type Component from '@glimmer/component';
|
|
24
|
-
|
|
25
|
-
const modules = {
|
|
26
|
-
'@ember/application': _application,
|
|
27
|
-
'@ember/array': _array,
|
|
28
|
-
'@ember/component': _EmberComponent,
|
|
29
|
-
'@ember/component/template-only': _TO,
|
|
30
|
-
'@ember/debug': _debug,
|
|
31
|
-
'@ember/destroyable': _destroyable,
|
|
32
|
-
'@ember/helper': _helpers,
|
|
33
|
-
'@ember/modifier': _modifier,
|
|
34
|
-
'@ember/object': _object,
|
|
35
|
-
'@ember/runloop': _runloop,
|
|
36
|
-
'@ember/service': _service,
|
|
37
|
-
'@ember/string': _string,
|
|
38
|
-
'@ember/template-factory': { createTemplateFactory },
|
|
39
|
-
'@ember/utils': _utils,
|
|
40
|
-
|
|
41
|
-
'@glimmer/component': _GlimmerComponent,
|
|
42
|
-
'@glimmer/tracking': _tracking,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type ExtraModules = Record<string, unknown>;
|
|
5
|
+
import type { ExtraModules } from 'ember-repl/types';
|
|
46
6
|
|
|
47
7
|
export function evalSnippet(
|
|
48
8
|
compiled: string,
|
package/addon/cjs/index.ts
CHANGED
|
@@ -6,31 +6,13 @@ import { precompile as precompileTemplate } from 'ember-template-compiler';
|
|
|
6
6
|
import { nameFor } from '../utils';
|
|
7
7
|
import { evalSnippet } from './eval';
|
|
8
8
|
|
|
9
|
-
import type { ExtraModules } from '
|
|
10
|
-
import type { Babel } from './types';
|
|
9
|
+
import type { Babel, ExtraModules } from '../types';
|
|
11
10
|
|
|
12
11
|
export interface Info {
|
|
13
12
|
code: string;
|
|
14
13
|
name: string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
20
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
21
|
-
*
|
|
22
|
-
* SEE: README for example usage
|
|
23
|
-
*
|
|
24
|
-
* @param {string} code: the code to be compiled
|
|
25
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
26
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
27
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
28
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
29
|
-
*
|
|
30
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
31
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
32
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
33
|
-
*/
|
|
34
16
|
export async function compileJS(code: string, extraModules?: ExtraModules) {
|
|
35
17
|
let name = nameFor(code);
|
|
36
18
|
let component: undefined | unknown;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { getTemplateLocals } from '@glimmer/syntax';
|
|
2
|
+
|
|
3
|
+
import HTMLBars, { preprocessEmbeddedTemplates } from 'babel-plugin-htmlbars-inline-precompile';
|
|
4
|
+
import { modules } from 'ember-repl/known-modules';
|
|
5
|
+
import { precompile as precompileTemplate } from 'ember-template-compiler';
|
|
6
|
+
|
|
7
|
+
import { nameFor } from '../utils';
|
|
8
|
+
|
|
9
|
+
import type { ExtraModules } from '../types';
|
|
10
|
+
import type Component from '@glimmer/component';
|
|
11
|
+
|
|
12
|
+
export interface Info {
|
|
13
|
+
code: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function compileJS(code: string, extraModules?: ExtraModules) {
|
|
18
|
+
let name = nameFor(code);
|
|
19
|
+
let component: undefined | unknown;
|
|
20
|
+
let error: undefined | Error;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
let compiled = await compileGJS({ code: code, name });
|
|
24
|
+
|
|
25
|
+
if (!compiled) {
|
|
26
|
+
throw new Error(`Compiled output is missing`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// NOTE: we cannot `eval` ESM
|
|
30
|
+
compiled = proxyToSkypack(compiled, extraModules);
|
|
31
|
+
component = await evalSnippet(compiled);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
error = e;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { name, component, error };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function proxyToSkypack(code: string, extraModules?: ExtraModules) {
|
|
40
|
+
let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];
|
|
41
|
+
let origin = location.origin;
|
|
42
|
+
|
|
43
|
+
let result = code.replaceAll(/from ('|")([^"']+)('|")/g, (_, __, modulePath) => {
|
|
44
|
+
if (knownModules.includes(modulePath)) {
|
|
45
|
+
return `from '${origin}/${modulePath}'`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return `from 'https://cdn.skypack.dev/${modulePath}'`;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function evalSnippet(code: string) {
|
|
55
|
+
let encodedJs = encodeURIComponent(code);
|
|
56
|
+
let result = await import(
|
|
57
|
+
/* webpackIgnore: true */ `data:text/javascript;charset=utf-8,${encodedJs}`
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (!result.default) {
|
|
61
|
+
throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result as {
|
|
65
|
+
default: Component;
|
|
66
|
+
services?: { [key: string]: unknown };
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function compileGJS({ code: input, name }: Info) {
|
|
71
|
+
let babel = await import('@babel/standalone');
|
|
72
|
+
|
|
73
|
+
let preprocessed = preprocessEmbeddedTemplates(input, {
|
|
74
|
+
getTemplateLocals,
|
|
75
|
+
relativePath: `${name}.js`,
|
|
76
|
+
includeSourceMaps: false,
|
|
77
|
+
includeTemplateTokens: true,
|
|
78
|
+
templateTag: 'template',
|
|
79
|
+
templateTagReplacement: 'GLIMMER_TEMPLATE',
|
|
80
|
+
getTemplateLocalsExportPath: 'getTemplateLocals',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
let result = babel.transform(preprocessed.output, {
|
|
84
|
+
filename: `${name}.js`,
|
|
85
|
+
plugins: [
|
|
86
|
+
[
|
|
87
|
+
HTMLBars,
|
|
88
|
+
{
|
|
89
|
+
precompile: precompileTemplate,
|
|
90
|
+
// this needs to be true until Ember 3.27+
|
|
91
|
+
ensureModuleApiPolyfill: false,
|
|
92
|
+
modules: {
|
|
93
|
+
'ember-template-imports': {
|
|
94
|
+
export: 'hbs',
|
|
95
|
+
useTemplateLiteralProposalSemantics: 1,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
'TEMPLATE-TAG-MODULE': {
|
|
99
|
+
export: 'GLIMMER_TEMPLATE',
|
|
100
|
+
debugName: '<template>',
|
|
101
|
+
useTemplateTagProposalSemantics: 1,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
[babel.availablePlugins['proposal-decorators'], { legacy: true }],
|
|
107
|
+
[babel.availablePlugins['proposal-class-properties']],
|
|
108
|
+
],
|
|
109
|
+
presets: [
|
|
110
|
+
[
|
|
111
|
+
babel.availablePresets['env'],
|
|
112
|
+
{
|
|
113
|
+
// false -- keeps ES Modules...
|
|
114
|
+
// it means "compile modules to this: ..."
|
|
115
|
+
modules: false,
|
|
116
|
+
targets: { esmodules: true },
|
|
117
|
+
loose: true,
|
|
118
|
+
forceAllTransforms: false,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
if (!result) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let { code } = result;
|
|
129
|
+
|
|
130
|
+
return code;
|
|
131
|
+
}
|
package/addon/index.ts
CHANGED
package/addon/js.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { compileJS as compileAMD } from './cjs';
|
|
2
|
+
import { compileJS as compileESM } from './esm';
|
|
3
|
+
|
|
4
|
+
import type { ExtraModules, Options } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
9
|
+
* The returned component can be invoked explicitly in the consuming project.
|
|
10
|
+
*
|
|
11
|
+
* SEE: README for example usage
|
|
12
|
+
*
|
|
13
|
+
* @param {string} code: the code to be compiled
|
|
14
|
+
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
15
|
+
* for classic ember projects, but for strict static ember projects, extraModules
|
|
16
|
+
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
17
|
+
* if there are additional modules that could be imported in the passed `code`.
|
|
18
|
+
*
|
|
19
|
+
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
20
|
+
* are not provided by extraModules will be searched on npm to see if a package
|
|
21
|
+
* needs to be downloaded before running the `code` / invoking the component
|
|
22
|
+
*/
|
|
23
|
+
export function compileJS(code: string, extraModules?: ExtraModules, options?: Options) {
|
|
24
|
+
if (options?.skypack) {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
// if (!(window as any).webpackChunkDummy) {
|
|
27
|
+
// return {
|
|
28
|
+
// component: undefined,
|
|
29
|
+
// name: undefined,
|
|
30
|
+
// error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,
|
|
31
|
+
// };
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
return compileESM(code, extraModules);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return compileAMD(code, extraModules);
|
|
38
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We need to import and hang on to these references so that they
|
|
3
|
+
* don't get optimized away during deploy
|
|
4
|
+
*/
|
|
5
|
+
import _GlimmerComponent from '@glimmer/component';
|
|
6
|
+
import * as _tracking from '@glimmer/tracking';
|
|
7
|
+
import * as _application from '@ember/application';
|
|
8
|
+
import * as _array from '@ember/array';
|
|
9
|
+
import * as _EmberComponent from '@ember/component';
|
|
10
|
+
import _TO from '@ember/component/template-only';
|
|
11
|
+
import * as _debug from '@ember/debug';
|
|
12
|
+
import * as _destroyable from '@ember/destroyable';
|
|
13
|
+
import * as _helpers from '@ember/helper';
|
|
14
|
+
import * as _modifier from '@ember/modifier';
|
|
15
|
+
import * as _object from '@ember/object';
|
|
16
|
+
import * as _runloop from '@ember/runloop';
|
|
17
|
+
import * as _service from '@ember/service';
|
|
18
|
+
import * as _string from '@ember/string';
|
|
19
|
+
import { createTemplateFactory } from '@ember/template-factory';
|
|
20
|
+
import * as _utils from '@ember/utils';
|
|
21
|
+
|
|
22
|
+
export const modules = {
|
|
23
|
+
'@ember/application': _application,
|
|
24
|
+
'@ember/array': _array,
|
|
25
|
+
'@ember/component': _EmberComponent,
|
|
26
|
+
'@ember/component/template-only': _TO,
|
|
27
|
+
'@ember/debug': _debug,
|
|
28
|
+
'@ember/destroyable': _destroyable,
|
|
29
|
+
'@ember/helper': _helpers,
|
|
30
|
+
'@ember/modifier': _modifier,
|
|
31
|
+
'@ember/object': _object,
|
|
32
|
+
'@ember/runloop': _runloop,
|
|
33
|
+
'@ember/service': _service,
|
|
34
|
+
'@ember/string': _string,
|
|
35
|
+
'@ember/template-factory': { createTemplateFactory },
|
|
36
|
+
'@ember/utils': _utils,
|
|
37
|
+
|
|
38
|
+
'@glimmer/component': _GlimmerComponent,
|
|
39
|
+
'@glimmer/tracking': _tracking,
|
|
40
|
+
};
|
package/addon/types.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
|
|
2
|
+
|
|
1
3
|
export interface CompileResult {
|
|
2
4
|
component?: unknown;
|
|
3
5
|
error?: Error;
|
|
4
6
|
name: string;
|
|
5
7
|
}
|
|
8
|
+
|
|
9
|
+
export interface Babel {
|
|
10
|
+
availablePlugins: typeof availablePlugins;
|
|
11
|
+
availablePresets: typeof availablePresets;
|
|
12
|
+
transform: typeof transform;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Options = {
|
|
16
|
+
skypack?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ExtraModules = Record<string, unknown>;
|
package/cjs/eval.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type Component from '@glimmer/component';
|
|
2
|
-
|
|
2
|
+
import type { ExtraModules } from 'ember-repl/types';
|
|
3
3
|
export declare function evalSnippet(compiled: string, extraModules?: ExtraModules): {
|
|
4
4
|
default: Component;
|
|
5
5
|
services?: {
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import type { ExtraModules } from '
|
|
1
|
+
import type { ExtraModules } from '../types';
|
|
2
2
|
export interface Info {
|
|
3
3
|
code: string;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
9
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
10
|
-
*
|
|
11
|
-
* SEE: README for example usage
|
|
12
|
-
*
|
|
13
|
-
* @param {string} code: the code to be compiled
|
|
14
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
15
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
16
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
17
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
18
|
-
*
|
|
19
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
20
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
21
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
22
|
-
*/
|
|
23
6
|
export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<{
|
|
24
7
|
name: string;
|
|
25
8
|
component: unknown;
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExtraModules } from '../types';
|
|
2
|
+
export interface Info {
|
|
3
|
+
code: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
component: unknown;
|
|
9
|
+
error: Error | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { compileJS } from './cjs';
|
|
2
1
|
export { compileHBS } from './hbs';
|
|
2
|
+
export { compileJS } from './js';
|
|
3
|
+
export { modules as frameworkModules } from './known-modules';
|
|
3
4
|
export { invocationName, invocationOf, nameFor } from './utils';
|
|
4
5
|
export type { CompileResult } from './types';
|
package/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const path = require('path');
|
|
3
4
|
const { stripIndents } = require('common-tags');
|
|
5
|
+
const Funnel = require('broccoli-funnel');
|
|
6
|
+
const mergeTrees = require('broccoli-merge-trees');
|
|
4
7
|
|
|
5
8
|
module.exports = {
|
|
6
9
|
name: require('./package').name,
|
|
@@ -38,6 +41,34 @@ module.exports = {
|
|
|
38
41
|
// - @glimmer/syntax
|
|
39
42
|
app.import('vendor/ember/ember-template-compiler.js');
|
|
40
43
|
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This technique can't be used because it duplicates the modules
|
|
47
|
+
* in traditional builds. Additionally, because this way
|
|
48
|
+
* doesn't utilize a service worker, we can't also point all the
|
|
49
|
+
* imports within these files to the other files we've copied.
|
|
50
|
+
*/
|
|
51
|
+
__treeForPublic() {
|
|
52
|
+
const publicTree = this._super.treeForPublic.apply(this, arguments);
|
|
53
|
+
|
|
54
|
+
const app = this._findHost(this);
|
|
55
|
+
const root = app.project.root;
|
|
56
|
+
const dist = path.join(root, 'node_modules/ember-source/dist/packages');
|
|
57
|
+
const trees = [];
|
|
58
|
+
|
|
59
|
+
if (publicTree) {
|
|
60
|
+
trees.push(publicTree);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let packages = new Funnel(dist, {
|
|
64
|
+
annotation: 'ember-repl adding ember ESM from ember-source/dist/packages',
|
|
65
|
+
destDir: '/',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
trees.push(packages);
|
|
69
|
+
|
|
70
|
+
return mergeTrees(trees);
|
|
71
|
+
},
|
|
41
72
|
};
|
|
42
73
|
|
|
43
74
|
/**
|
package/js.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ExtraModules, Options } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
5
|
+
* The returned component can be invoked explicitly in the consuming project.
|
|
6
|
+
*
|
|
7
|
+
* SEE: README for example usage
|
|
8
|
+
*
|
|
9
|
+
* @param {string} code: the code to be compiled
|
|
10
|
+
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
11
|
+
* for classic ember projects, but for strict static ember projects, extraModules
|
|
12
|
+
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
13
|
+
* if there are additional modules that could be imported in the passed `code`.
|
|
14
|
+
*
|
|
15
|
+
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
16
|
+
* are not provided by extraModules will be searched on npm to see if a package
|
|
17
|
+
* needs to be downloaded before running the `code` / invoking the component
|
|
18
|
+
*/
|
|
19
|
+
export declare function compileJS(code: string, extraModules?: ExtraModules, options?: Options): Promise<{
|
|
20
|
+
name: string;
|
|
21
|
+
component: unknown;
|
|
22
|
+
error: Error | undefined;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We need to import and hang on to these references so that they
|
|
3
|
+
* don't get optimized away during deploy
|
|
4
|
+
*/
|
|
5
|
+
import _GlimmerComponent from '@glimmer/component';
|
|
6
|
+
import * as _tracking from '@glimmer/tracking';
|
|
7
|
+
import * as _application from '@ember/application';
|
|
8
|
+
import * as _array from '@ember/array';
|
|
9
|
+
import * as _EmberComponent from '@ember/component';
|
|
10
|
+
import _TO from '@ember/component/template-only';
|
|
11
|
+
import * as _debug from '@ember/debug';
|
|
12
|
+
import * as _destroyable from '@ember/destroyable';
|
|
13
|
+
import * as _object from '@ember/object';
|
|
14
|
+
import * as _runloop from '@ember/runloop';
|
|
15
|
+
import * as _service from '@ember/service';
|
|
16
|
+
import * as _string from '@ember/string';
|
|
17
|
+
import * as _utils from '@ember/utils';
|
|
18
|
+
export declare const modules: {
|
|
19
|
+
'@ember/application': typeof _application;
|
|
20
|
+
'@ember/array': typeof _array;
|
|
21
|
+
'@ember/component': typeof _EmberComponent;
|
|
22
|
+
'@ember/component/template-only': typeof _TO;
|
|
23
|
+
'@ember/debug': typeof _debug;
|
|
24
|
+
'@ember/destroyable': typeof _destroyable;
|
|
25
|
+
'@ember/helper': any;
|
|
26
|
+
'@ember/modifier': any;
|
|
27
|
+
'@ember/object': typeof _object;
|
|
28
|
+
'@ember/runloop': typeof _runloop;
|
|
29
|
+
'@ember/service': typeof _service;
|
|
30
|
+
'@ember/string': typeof _string;
|
|
31
|
+
'@ember/template-factory': {
|
|
32
|
+
createTemplateFactory: any;
|
|
33
|
+
};
|
|
34
|
+
'@ember/utils': typeof _utils;
|
|
35
|
+
'@glimmer/component': typeof _GlimmerComponent;
|
|
36
|
+
'@glimmer/tracking': typeof _tracking;
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-repl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"@glimmer/tracking": "^1.0.4",
|
|
35
35
|
"babel-plugin-htmlbars-inline-precompile": "^5.3.1",
|
|
36
36
|
"broccoli-file-creator": "^2.1.1",
|
|
37
|
+
"broccoli-funnel": "^3.0.8",
|
|
38
|
+
"broccoli-merge-trees": "^4.2.0",
|
|
37
39
|
"common-tags": "^1.8.2",
|
|
38
40
|
"ember-auto-import": "2.2.4",
|
|
39
41
|
"ember-cli-babel": "^7.26.6",
|
|
@@ -44,8 +46,8 @@
|
|
|
44
46
|
"uuid": "8.3.2"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"@commitlint/cli": "^
|
|
48
|
-
"@commitlint/config-conventional": "^
|
|
49
|
+
"@commitlint/cli": "^15.0.0",
|
|
50
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
49
51
|
"@ember/optional-features": "^2.0.0",
|
|
50
52
|
"@ember/test-helpers": "^2.6.0",
|
|
51
53
|
"@ember/test-waiters": "^3.0.0",
|
|
@@ -53,12 +55,12 @@
|
|
|
53
55
|
"@glimmer/interfaces": "^0.83.1",
|
|
54
56
|
"@glimmer/reference": "^0.83.1",
|
|
55
57
|
"@glimmer/util": "^0.83.1",
|
|
56
|
-
"@nullvoxpopuli/eslint-configs": "^2.1.
|
|
58
|
+
"@nullvoxpopuli/eslint-configs": "^2.1.9",
|
|
57
59
|
"@semantic-release/changelog": "^5.0.1",
|
|
58
60
|
"@semantic-release/git": "^9.0.1",
|
|
59
61
|
"@types/babel__core": "^7.1.16",
|
|
60
62
|
"@types/babel__standalone": "^7.1.3",
|
|
61
|
-
"@types/ember-qunit": "^3.4.
|
|
63
|
+
"@types/ember-qunit": "^3.4.15",
|
|
62
64
|
"@types/ember-resolver": "^5.0.10",
|
|
63
65
|
"@types/ember__application": "^3.16.3",
|
|
64
66
|
"@types/ember__array": "^3.16.4",
|
|
@@ -75,14 +77,14 @@
|
|
|
75
77
|
"@types/ember__string": "^3.16.3",
|
|
76
78
|
"@types/ember__template": "^3.16.1",
|
|
77
79
|
"@types/ember__test": "^3.16.1",
|
|
78
|
-
"@types/ember__test-helpers": "^2.0
|
|
80
|
+
"@types/ember__test-helpers": "^2.6.0",
|
|
79
81
|
"@types/ember__utils": "^3.16.2",
|
|
80
82
|
"@types/htmlbars-inline-precompile": "^1.0.1",
|
|
81
83
|
"@types/qunit": "^2.11.2",
|
|
82
84
|
"@types/rsvp": "^4.0.4",
|
|
83
|
-
"@types/uuid": "^8.3.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
85
|
-
"@typescript-eslint/parser": "^
|
|
85
|
+
"@types/uuid": "^8.3.3",
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
86
88
|
"babel-eslint": "^10.1.0",
|
|
87
89
|
"broccoli-asset-rev": "^3.0.0",
|
|
88
90
|
"ember-cli": "~3.28.4",
|
|
@@ -97,27 +99,27 @@
|
|
|
97
99
|
"ember-page-title": "^7.0.0",
|
|
98
100
|
"ember-qunit": "^5.1.5",
|
|
99
101
|
"ember-resolver": "^8.0.3",
|
|
100
|
-
"ember-source": "~4.0.
|
|
102
|
+
"ember-source": "~4.0.1",
|
|
101
103
|
"ember-source-channel-url": "^3.0.0",
|
|
102
|
-
"ember-template-lint": "^3.
|
|
103
|
-
"ember-try": "^
|
|
104
|
+
"ember-template-lint": "^3.14.0",
|
|
105
|
+
"ember-try": "^2.0.0",
|
|
104
106
|
"eslint": "^7.32.0",
|
|
105
107
|
"eslint-config-prettier": "^8.3.0",
|
|
106
|
-
"eslint-plugin-decorator-position": "^
|
|
107
|
-
"eslint-plugin-ember": "^10.5.
|
|
108
|
+
"eslint-plugin-decorator-position": "^4.0.1",
|
|
109
|
+
"eslint-plugin-ember": "^10.5.8",
|
|
108
110
|
"eslint-plugin-import": "^2.25.3",
|
|
109
111
|
"eslint-plugin-node": "^11.1.0",
|
|
110
112
|
"eslint-plugin-prettier": "^4.0.0",
|
|
111
|
-
"eslint-plugin-qunit": "^
|
|
113
|
+
"eslint-plugin-qunit": "^7.1.0",
|
|
112
114
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
113
115
|
"loader.js": "^4.7.0",
|
|
114
116
|
"npm-run-all": "^4.1.5",
|
|
115
|
-
"prettier": "^2.
|
|
117
|
+
"prettier": "^2.5.1",
|
|
116
118
|
"qunit": "^2.17.2",
|
|
117
119
|
"qunit-dom": "^2.0.0",
|
|
118
120
|
"semantic-release": "^17.4.7",
|
|
119
121
|
"typescript": "^4.5.2",
|
|
120
|
-
"webpack": "^5.64.
|
|
122
|
+
"webpack": "^5.64.4"
|
|
121
123
|
},
|
|
122
124
|
"release": {
|
|
123
125
|
"branches": [
|
|
@@ -134,11 +136,11 @@
|
|
|
134
136
|
]
|
|
135
137
|
},
|
|
136
138
|
"volta": {
|
|
137
|
-
"node": "16.13.
|
|
139
|
+
"node": "16.13.1",
|
|
138
140
|
"yarn": "1.22.17"
|
|
139
141
|
},
|
|
140
142
|
"engines": {
|
|
141
|
-
"node": "
|
|
143
|
+
"node": "12.* || >= 14.*"
|
|
142
144
|
},
|
|
143
145
|
"ember": {
|
|
144
146
|
"edition": "octane"
|
package/tsconfig.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
|
|
1
2
|
export interface CompileResult {
|
|
2
3
|
component?: unknown;
|
|
3
4
|
error?: Error;
|
|
4
5
|
name: string;
|
|
5
6
|
}
|
|
7
|
+
export interface Babel {
|
|
8
|
+
availablePlugins: typeof availablePlugins;
|
|
9
|
+
availablePresets: typeof availablePresets;
|
|
10
|
+
transform: typeof transform;
|
|
11
|
+
}
|
|
12
|
+
export declare type Options = {
|
|
13
|
+
skypack?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type ExtraModules = Record<string, unknown>;
|
package/addon/cjs/types.ts
DELETED
package/cjs/types.d.ts
DELETED