@embroider/core 2.1.1 → 2.1.2-unstable.3a232cc
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/package.json +3 -4
- package/src/app-differ.d.ts +1 -1
- package/src/app-differ.js +21 -22
- package/src/app-differ.js.map +1 -1
- package/src/app-files.d.ts +1 -2
- package/src/app-files.js +0 -7
- package/src/app-files.js.map +1 -1
- package/src/app.d.ts +9 -7
- package/src/app.js +32 -46
- package/src/app.js.map +1 -1
- package/src/describe-exports.d.ts +0 -1
- package/src/describe-exports.js +8 -9
- package/src/describe-exports.js.map +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/module-resolver.d.ts +66 -25
- package/src/module-resolver.js +698 -131
- package/src/module-resolver.js.map +1 -1
- package/src/options.d.ts +0 -1
- package/src/options.js.map +1 -1
- package/src/virtual-content.d.ts +9 -0
- package/src/virtual-content.js +131 -0
- package/src/virtual-content.js.map +1 -0
- package/src/wait-for-trees.js.map +1 -1
- package/src/babel-plugin-adjust-imports.d.ts +0 -31
- package/src/babel-plugin-adjust-imports.js +0 -224
- package/src/babel-plugin-adjust-imports.js.map +0 -1
- package/src/babel-plugin-inline-hbs-deps-node.d.ts +0 -14
- package/src/babel-plugin-inline-hbs-deps-node.js +0 -27
- package/src/babel-plugin-inline-hbs-deps-node.js.map +0 -1
- package/src/babel-plugin-inline-hbs-deps.d.ts +0 -10
- package/src/babel-plugin-inline-hbs-deps.js +0 -134
- package/src/babel-plugin-inline-hbs-deps.js.map +0 -1
- package/src/babel-plugin-inline-hbs-node.d.ts +0 -7
- package/src/babel-plugin-inline-hbs-node.js +0 -15
- package/src/babel-plugin-inline-hbs-node.js.map +0 -1
- package/src/babel-plugin-inline-hbs.d.ts +0 -24
- package/src/babel-plugin-inline-hbs.js +0 -142
- package/src/babel-plugin-inline-hbs.js.map +0 -1
- package/src/babel-plugin-stage1-inline-hbs-node.d.ts +0 -12
- package/src/babel-plugin-stage1-inline-hbs-node.js +0 -9
- package/src/babel-plugin-stage1-inline-hbs-node.js.map +0 -1
- package/src/babel-plugin-stage1-inline-hbs.d.ts +0 -9
- package/src/babel-plugin-stage1-inline-hbs.js +0 -96
- package/src/babel-plugin-stage1-inline-hbs.js.map +0 -1
- package/src/browser-index.d.ts +0 -1
- package/src/browser-index.js +0 -6
- package/src/browser-index.js.map +0 -1
- package/src/ember-template-compiler-types.d.ts +0 -41
- package/src/ember-template-compiler-types.js +0 -3
- package/src/ember-template-compiler-types.js.map +0 -1
- package/src/load-ember-template-compiler.d.ts +0 -6
- package/src/load-ember-template-compiler.js +0 -57
- package/src/load-ember-template-compiler.js.map +0 -1
- package/src/mini-modules-polyfill.d.ts +0 -12
- package/src/mini-modules-polyfill.js +0 -80
- package/src/mini-modules-polyfill.js.map +0 -1
- package/src/patch-template-compiler.d.ts +0 -1
- package/src/patch-template-compiler.js +0 -176
- package/src/patch-template-compiler.js.map +0 -1
- package/src/resolver-plugin.d.ts +0 -3
- package/src/resolver-plugin.js +0 -53
- package/src/resolver-plugin.js.map +0 -1
- package/src/resolver.d.ts +0 -14
- package/src/resolver.js +0 -3
- package/src/resolver.js.map +0 -1
- package/src/template-compiler-common.d.ts +0 -70
- package/src/template-compiler-common.js +0 -176
- package/src/template-compiler-common.js.map +0 -1
- package/src/template-compiler-node.d.ts +0 -17
- package/src/template-compiler-node.js +0 -32
- package/src/template-compiler-node.js.map +0 -1
@@ -1,176 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.patch = void 0;
|
4
|
-
const core_1 = require("@babel/core");
|
5
|
-
function parseVersion(templateCompilerPath, source) {
|
6
|
-
// ember-template-compiler.js contains a comment that indicates what version it is for
|
7
|
-
// that looks like:
|
8
|
-
/*!
|
9
|
-
* @overview Ember - JavaScript Application Framework
|
10
|
-
* @copyright Copyright 2011-2020 Tilde Inc. and contributors
|
11
|
-
* Portions Copyright 2006-2011 Strobe Inc.
|
12
|
-
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
13
|
-
* @license Licensed under MIT license
|
14
|
-
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
15
|
-
* @version 3.25.1
|
16
|
-
*/
|
17
|
-
let version = source.match(/@version\s+([\d\.]+)/);
|
18
|
-
if (!version || !version[1]) {
|
19
|
-
throw new Error(`Could not find version string in \`${templateCompilerPath}\`. Maybe we don't support your ember-source version?`);
|
20
|
-
}
|
21
|
-
let numbers = version[1].split('.');
|
22
|
-
let major = parseInt(numbers[0], 10);
|
23
|
-
let minor = parseInt(numbers[1], 10);
|
24
|
-
let patch = parseInt(numbers[2], 10);
|
25
|
-
return { major, minor, patch };
|
26
|
-
}
|
27
|
-
function emberVersionGte(templateCompilerPath, source, major, minor) {
|
28
|
-
let actual = parseVersion(templateCompilerPath, source);
|
29
|
-
return actual.major > major || (actual.major === major && actual.minor >= minor);
|
30
|
-
}
|
31
|
-
function patch(source, templateCompilerPath) {
|
32
|
-
let version = parseVersion(templateCompilerPath, source);
|
33
|
-
if (emberVersionGte(templateCompilerPath, source, 3, 26) ||
|
34
|
-
(version.major === 3 && version.minor === 25 && version.patch >= 2) ||
|
35
|
-
(version.major === 3 && version.minor === 24 && version.patch >= 3)) {
|
36
|
-
// no modifications are needed after
|
37
|
-
// https://github.com/emberjs/ember.js/pull/19426 and backported to
|
38
|
-
// 3.26.0-beta.3, 3.25.2, 3.24.3
|
39
|
-
return source;
|
40
|
-
}
|
41
|
-
let replacedVar = false;
|
42
|
-
let patchedSource;
|
43
|
-
let needsAngleBracketPrinterFix = emberVersionGte(templateCompilerPath, source, 3, 12) && !emberVersionGte(templateCompilerPath, source, 3, 17);
|
44
|
-
if (needsAngleBracketPrinterFix) {
|
45
|
-
// here we are stripping off the first `var Ember;`. That one small change
|
46
|
-
// lets us crack open the file and get access to its internal loader, because
|
47
|
-
// we can give it our own predefined `Ember` variable instead, which it will
|
48
|
-
// use and put `Ember.__loader` onto.
|
49
|
-
//
|
50
|
-
// on ember 3.12 through 3.16 (which use variants of glimmer-vm 0.38.5) we
|
51
|
-
// also apply a patch to the printer in @glimmer/syntax to fix
|
52
|
-
// https://github.com/glimmerjs/glimmer-vm/pull/941/files because it can
|
53
|
-
// really bork apps under embroider, and we'd like to support at least all
|
54
|
-
// active LTS versions of ember.
|
55
|
-
patchedSource = (0, core_1.transform)(source, {
|
56
|
-
plugins: [
|
57
|
-
function () {
|
58
|
-
return {
|
59
|
-
visitor: {
|
60
|
-
VariableDeclarator(path) {
|
61
|
-
let id = path.node.id;
|
62
|
-
if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {
|
63
|
-
replacedVar = true;
|
64
|
-
path.remove();
|
65
|
-
}
|
66
|
-
},
|
67
|
-
CallExpression: {
|
68
|
-
enter(path, state) {
|
69
|
-
let callee = path.get('callee');
|
70
|
-
if (!callee.isIdentifier() || callee.node.name !== 'define') {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
let firstArg = path.get('arguments')[0];
|
74
|
-
if (!firstArg.isStringLiteral() || firstArg.node.value !== '@glimmer/syntax') {
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
state.definingGlimmerSyntax = path;
|
78
|
-
},
|
79
|
-
exit(path, state) {
|
80
|
-
if (state.definingGlimmerSyntax === path) {
|
81
|
-
state.definingGlimmerSyntax = false;
|
82
|
-
}
|
83
|
-
},
|
84
|
-
},
|
85
|
-
FunctionDeclaration: {
|
86
|
-
enter(path, state) {
|
87
|
-
if (!state.definingGlimmerSyntax) {
|
88
|
-
return;
|
89
|
-
}
|
90
|
-
let id = path.get('id');
|
91
|
-
if (id.isIdentifier() && id.node.name === 'build') {
|
92
|
-
state.declaringBuildFunction = path;
|
93
|
-
}
|
94
|
-
},
|
95
|
-
exit(path, state) {
|
96
|
-
if (state.declaringBuildFunction === path) {
|
97
|
-
state.declaringBuildFunction = false;
|
98
|
-
}
|
99
|
-
},
|
100
|
-
},
|
101
|
-
SwitchCase: {
|
102
|
-
enter(path, state) {
|
103
|
-
if (!state.definingGlimmerSyntax) {
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
let test = path.get('test');
|
107
|
-
if (test.isStringLiteral() && test.node.value === 'ElementNode') {
|
108
|
-
state.caseElementNode = path;
|
109
|
-
}
|
110
|
-
},
|
111
|
-
exit(path, state) {
|
112
|
-
if (state.caseElementNode === path) {
|
113
|
-
state.caseElementNode = false;
|
114
|
-
}
|
115
|
-
},
|
116
|
-
},
|
117
|
-
IfStatement(path, state) {
|
118
|
-
if (!state.caseElementNode) {
|
119
|
-
return;
|
120
|
-
}
|
121
|
-
let test = path.get('test');
|
122
|
-
// the place we want is the only if with a computed member
|
123
|
-
// expression predicate.
|
124
|
-
if (test.isMemberExpression() && test.node.computed) {
|
125
|
-
path.node.alternate = core_1.types.ifStatement(core_1.types.memberExpression(core_1.types.identifier('ast'), core_1.types.identifier('selfClosing')), core_1.types.blockStatement([
|
126
|
-
core_1.types.expressionStatement(core_1.types.callExpression(core_1.types.memberExpression(core_1.types.identifier('output'), core_1.types.identifier('push')), [
|
127
|
-
core_1.types.stringLiteral(' />'),
|
128
|
-
])),
|
129
|
-
]), path.node.alternate);
|
130
|
-
}
|
131
|
-
},
|
132
|
-
},
|
133
|
-
};
|
134
|
-
},
|
135
|
-
],
|
136
|
-
}).code;
|
137
|
-
}
|
138
|
-
else {
|
139
|
-
// applies to < 3.12 and >= 3.17
|
140
|
-
//
|
141
|
-
// here we are stripping off the first `var Ember;`. That one small change
|
142
|
-
// lets us crack open the file and get access to its internal loader, because
|
143
|
-
// we can give it our own predefined `Ember` variable instead, which it will
|
144
|
-
// use and put `Ember.__loader` onto.
|
145
|
-
patchedSource = (0, core_1.transform)(source, {
|
146
|
-
generatorOpts: {
|
147
|
-
compact: true,
|
148
|
-
},
|
149
|
-
plugins: [
|
150
|
-
function () {
|
151
|
-
return {
|
152
|
-
visitor: {
|
153
|
-
VariableDeclarator(path) {
|
154
|
-
let id = path.node.id;
|
155
|
-
if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {
|
156
|
-
replacedVar = true;
|
157
|
-
path.remove();
|
158
|
-
}
|
159
|
-
},
|
160
|
-
},
|
161
|
-
};
|
162
|
-
},
|
163
|
-
],
|
164
|
-
}).code;
|
165
|
-
}
|
166
|
-
if (!replacedVar) {
|
167
|
-
throw new Error(`didn't find expected source in ${templateCompilerPath}. Maybe we don't support your ember-source version?`);
|
168
|
-
}
|
169
|
-
return `
|
170
|
-
let Ember = {};
|
171
|
-
${patchedSource};
|
172
|
-
module.exports.Ember = Ember;
|
173
|
-
`;
|
174
|
-
}
|
175
|
-
exports.patch = patch;
|
176
|
-
//# sourceMappingURL=patch-template-compiler.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"patch-template-compiler.js","sourceRoot":"","sources":["patch-template-compiler.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAEpD,SAAS,YAAY,CAAC,oBAA4B,EAAE,MAAc;IAChE,sFAAsF;IACtF,mBAAmB;IAEnB;;;;;;;;OAQG;IAEH,IAAI,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,sCAAsC,oBAAoB,uDAAuD,CAClH,CAAC;KACH;IAED,IAAI,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAErC,OAA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ACJ,CAAC;AA/JD,sBA+JC","sourcesContent":["import { NodePath } from '@babel/traverse';\nimport { transform, types as t } from '@babel/core';\n\nfunction parseVersion(templateCompilerPath: string, source: string): { major: number; minor: number; patch: number } {\n // ember-template-compiler.js contains a comment that indicates what version it is for\n // that looks like:\n\n /*!\n * @overview Ember - JavaScript Application Framework\n * @copyright Copyright 2011-2020 Tilde Inc. and contributors\n * Portions Copyright 2006-2011 Strobe Inc.\n * Portions Copyright 2008-2011 Apple Inc. All rights reserved.\n * @license Licensed under MIT license\n * See https://raw.github.com/emberjs/ember.js/master/LICENSE\n * @version 3.25.1\n */\n\n let version = source.match(/@version\\s+([\\d\\.]+)/);\n if (!version || !version[1]) {\n throw new Error(\n `Could not find version string in \\`${templateCompilerPath}\\`. Maybe we don't support your ember-source version?`\n );\n }\n\n let numbers = version[1].split('.');\n let major = parseInt(numbers[0], 10);\n let minor = parseInt(numbers[1], 10);\n let patch = parseInt(numbers[2], 10);\n\n return { major, minor, patch };\n}\n\nfunction emberVersionGte(templateCompilerPath: string, source: string, major: number, minor: number): boolean {\n let actual = parseVersion(templateCompilerPath, source);\n\n return actual.major > major || (actual.major === major && actual.minor >= minor);\n}\n\nexport function patch(source: string, templateCompilerPath: string): string {\n let version = parseVersion(templateCompilerPath, source);\n\n if (\n emberVersionGte(templateCompilerPath, source, 3, 26) ||\n (version.major === 3 && version.minor === 25 && version.patch >= 2) ||\n (version.major === 3 && version.minor === 24 && version.patch >= 3)\n ) {\n // no modifications are needed after\n // https://github.com/emberjs/ember.js/pull/19426 and backported to\n // 3.26.0-beta.3, 3.25.2, 3.24.3\n return source;\n }\n\n let replacedVar = false;\n let patchedSource;\n\n let needsAngleBracketPrinterFix =\n emberVersionGte(templateCompilerPath, source, 3, 12) && !emberVersionGte(templateCompilerPath, source, 3, 17);\n\n if (needsAngleBracketPrinterFix) {\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n //\n // on ember 3.12 through 3.16 (which use variants of glimmer-vm 0.38.5) we\n // also apply a patch to the printer in @glimmer/syntax to fix\n // https://github.com/glimmerjs/glimmer-vm/pull/941/files because it can\n // really bork apps under embroider, and we'd like to support at least all\n // active LTS versions of ember.\n patchedSource = transform(source, {\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<t.VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n CallExpression: {\n enter(path: NodePath<t.CallExpression>, state: BabelState) {\n let callee = path.get('callee');\n if (!callee.isIdentifier() || callee.node.name !== 'define') {\n return;\n }\n let firstArg = path.get('arguments')[0];\n if (!firstArg.isStringLiteral() || firstArg.node.value !== '@glimmer/syntax') {\n return;\n }\n state.definingGlimmerSyntax = path;\n },\n exit(path: NodePath<t.CallExpression>, state: BabelState) {\n if (state.definingGlimmerSyntax === path) {\n state.definingGlimmerSyntax = false;\n }\n },\n },\n FunctionDeclaration: {\n enter(path: NodePath<t.FunctionDeclaration>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let id = path.get('id');\n if (id.isIdentifier() && id.node.name === 'build') {\n state.declaringBuildFunction = path;\n }\n },\n exit(path: NodePath<t.FunctionDeclaration>, state: BabelState) {\n if (state.declaringBuildFunction === path) {\n state.declaringBuildFunction = false;\n }\n },\n },\n SwitchCase: {\n enter(path: NodePath<t.SwitchCase>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let test = path.get('test');\n if (test.isStringLiteral() && test.node.value === 'ElementNode') {\n state.caseElementNode = path;\n }\n },\n exit(path: NodePath<t.SwitchCase>, state: BabelState) {\n if (state.caseElementNode === path) {\n state.caseElementNode = false;\n }\n },\n },\n IfStatement(path: NodePath<t.IfStatement>, state: BabelState) {\n if (!state.caseElementNode) {\n return;\n }\n let test = path.get('test');\n // the place we want is the only if with a computed member\n // expression predicate.\n if (test.isMemberExpression() && test.node.computed) {\n path.node.alternate = t.ifStatement(\n t.memberExpression(t.identifier('ast'), t.identifier('selfClosing')),\n t.blockStatement([\n t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('output'), t.identifier('push')), [\n t.stringLiteral(' />'),\n ])\n ),\n ]),\n path.node.alternate\n );\n }\n },\n },\n };\n },\n ],\n })!.code!;\n } else {\n // applies to < 3.12 and >= 3.17\n //\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n patchedSource = transform(source, {\n generatorOpts: {\n compact: true,\n },\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<t.VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n },\n };\n },\n ],\n })!.code!;\n }\n\n if (!replacedVar) {\n throw new Error(\n `didn't find expected source in ${templateCompilerPath}. Maybe we don't support your ember-source version?`\n );\n }\n\n return `\n let Ember = {};\n ${patchedSource};\n module.exports.Ember = Ember;\n `;\n}\n\ninterface BabelState {\n definingGlimmerSyntax: NodePath | false;\n declaringBuildFunction: NodePath | false;\n caseElementNode: NodePath | false;\n}\n"]}
|
package/src/resolver-plugin.d.ts
DELETED
package/src/resolver-plugin.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.resolverPlugin = void 0;
|
7
|
-
const unplugin_1 = require("unplugin");
|
8
|
-
const module_resolver_1 = require("./module-resolver");
|
9
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
10
|
-
exports.resolverPlugin = (0, unplugin_1.createUnplugin)((resolverOptions) => {
|
11
|
-
return {
|
12
|
-
name: 'unplugin-embroider-resolver',
|
13
|
-
async resolveId(id, importer, _options) {
|
14
|
-
if (!importer) {
|
15
|
-
return null;
|
16
|
-
}
|
17
|
-
let resolution = resolverFor(importer, resolverOptions).resolve(id);
|
18
|
-
switch (resolution.result) {
|
19
|
-
case 'external':
|
20
|
-
// according to the docs we should be allowed to return `{ external:
|
21
|
-
// true, id: resolution.specifier }` here and that would take care of
|
22
|
-
// externalizing. But due to https://github.com/unjs/unplugin/issues/238
|
23
|
-
// that doesn't work, so we will generate our own runtime stubs via the
|
24
|
-
// load hook below.
|
25
|
-
return `@embroider/externals/${resolution.specifier}`;
|
26
|
-
case 'continue':
|
27
|
-
// null is the "defer to other plugins and default resolution" outcome
|
28
|
-
return null;
|
29
|
-
case 'redirect-to':
|
30
|
-
return null;
|
31
|
-
default:
|
32
|
-
throw (0, assert_never_1.default)(resolution);
|
33
|
-
}
|
34
|
-
},
|
35
|
-
async load(id) {
|
36
|
-
if (id.startsWith('@embroider/externals/')) {
|
37
|
-
let moduleName = id.slice('@embroider/externals/'.length);
|
38
|
-
return (0, module_resolver_1.externalShim)({ moduleName });
|
39
|
-
}
|
40
|
-
},
|
41
|
-
};
|
42
|
-
});
|
43
|
-
let prev;
|
44
|
-
function resolverFor(importer, resolverOptions) {
|
45
|
-
// as a very simple cache, reuse the same Resolver if we're still working
|
46
|
-
// from the same importer as the last call. We'd expect that is a common
|
47
|
-
// case, and we can avoid re-discovering things like the owning package of
|
48
|
-
// the importer.
|
49
|
-
let resolver = (prev === null || prev === void 0 ? void 0 : prev.importer) === importer ? prev.resolver : new module_resolver_1.Resolver(importer, resolverOptions);
|
50
|
-
prev = { importer, resolver };
|
51
|
-
return resolver;
|
52
|
-
}
|
53
|
-
//# sourceMappingURL=resolver-plugin.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"resolver-plugin.js","sourceRoot":"","sources":["resolver-plugin.ts"],"names":[],"m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AQ,MAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,0BAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACrG,IAAI,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC9B,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { createUnplugin } from 'unplugin';\nimport { externalShim, Options as ResolverPluginOptions, Resolver } from './module-resolver';\nimport assertNever from 'assert-never';\n\nexport { ResolverPluginOptions };\n\nexport const resolverPlugin = createUnplugin((resolverOptions: ResolverPluginOptions) => {\n return {\n name: 'unplugin-embroider-resolver',\n async resolveId(\n id: string,\n importer: string | undefined,\n _options: {\n isEntry: boolean;\n }\n ) {\n if (!importer) {\n return null;\n }\n\n let resolution = resolverFor(importer, resolverOptions).resolve(id);\n\n switch (resolution.result) {\n case 'external':\n // according to the docs we should be allowed to return `{ external:\n // true, id: resolution.specifier }` here and that would take care of\n // externalizing. But due to https://github.com/unjs/unplugin/issues/238\n // that doesn't work, so we will generate our own runtime stubs via the\n // load hook below.\n return `@embroider/externals/${resolution.specifier}`;\n case 'continue':\n // null is the \"defer to other plugins and default resolution\" outcome\n return null;\n case 'redirect-to':\n return null;\n default:\n throw assertNever(resolution);\n }\n },\n async load(id: string) {\n if (id.startsWith('@embroider/externals/')) {\n let moduleName = id.slice('@embroider/externals/'.length);\n return externalShim({ moduleName });\n }\n },\n };\n});\n\nlet prev:\n | {\n importer: string;\n resolver: Resolver;\n }\n | undefined;\n\nfunction resolverFor(importer: string, resolverOptions: ResolverPluginOptions): Resolver {\n // as a very simple cache, reuse the same Resolver if we're still working\n // from the same importer as the last call. We'd expect that is a common\n // case, and we can avoid re-discovering things like the owning package of\n // the importer.\n let resolver = prev?.importer === importer ? prev.resolver : new Resolver(importer, resolverOptions);\n prev = { importer, resolver };\n return resolver;\n}\n"]}
|
package/src/resolver.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { TemplateCompiler } from './template-compiler-common';
|
2
|
-
import { Options } from './babel-plugin-adjust-imports';
|
3
|
-
export interface ResolvedDep {
|
4
|
-
runtimeName: string;
|
5
|
-
path: string;
|
6
|
-
absPath: string;
|
7
|
-
}
|
8
|
-
export interface Resolver {
|
9
|
-
astTransformer(templateCompiler: TemplateCompiler): unknown;
|
10
|
-
dependenciesOf(moduleName: string): ResolvedDep[];
|
11
|
-
absPathToRuntimePath(absPath: string): string;
|
12
|
-
absPathToRuntimeName(absPath: string): string;
|
13
|
-
adjustImportsOptions: Options;
|
14
|
-
}
|
package/src/resolver.js
DELETED
package/src/resolver.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["resolver.ts"],"names":[],"mappings":"","sourcesContent":["import type { TemplateCompiler } from './template-compiler-common';\nimport { Options } from './babel-plugin-adjust-imports';\n\nexport interface ResolvedDep {\n runtimeName: string;\n path: string;\n absPath: string;\n}\n\nexport interface Resolver {\n astTransformer(templateCompiler: TemplateCompiler): unknown;\n dependenciesOf(moduleName: string): ResolvedDep[];\n\n // this takes an absolute path to a file and gives back a path like\n // \"the-package-name/path/to/the-file.js\", while taking into account any\n // backward-compatible runtime name of the package. It's used by the template\n // compiler, because this is the kind of path AST plugins expect to see.\n absPathToRuntimePath(absPath: string): string;\n\n // this takes an absolute path to a file and gives back the runtime name of\n // that module, as it would tradtionally be named within loader.js.\n absPathToRuntimeName(absPath: string): string;\n\n adjustImportsOptions: Options;\n}\n"]}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
import { Resolver, ResolvedDep } from './resolver';
|
2
|
-
export interface Plugins {
|
3
|
-
ast?: unknown[];
|
4
|
-
}
|
5
|
-
export interface AST {
|
6
|
-
_deliberatelyOpaque: 'AST';
|
7
|
-
}
|
8
|
-
export interface PreprocessOptions {
|
9
|
-
contents: string;
|
10
|
-
moduleName: string;
|
11
|
-
plugins?: Plugins;
|
12
|
-
filename?: string;
|
13
|
-
parseOptions?: {
|
14
|
-
srcName?: string;
|
15
|
-
ignoreStandalone?: boolean;
|
16
|
-
};
|
17
|
-
mode?: 'codemod' | 'precompile';
|
18
|
-
strictMode?: boolean;
|
19
|
-
locals?: string[];
|
20
|
-
}
|
21
|
-
export interface PrinterOptions {
|
22
|
-
entityEncoding?: 'transformed' | 'raw';
|
23
|
-
}
|
24
|
-
export interface GlimmerSyntax {
|
25
|
-
preprocess(html: string, options?: PreprocessOptions): AST;
|
26
|
-
print(ast: AST, options?: PrinterOptions): string;
|
27
|
-
defaultOptions(options: PreprocessOptions): PreprocessOptions;
|
28
|
-
precompile(templateContents: string, options: {
|
29
|
-
contents: string;
|
30
|
-
moduleName: string;
|
31
|
-
filename: string;
|
32
|
-
plugins?: any;
|
33
|
-
parseOptions?: {
|
34
|
-
srcName?: string;
|
35
|
-
};
|
36
|
-
}): string;
|
37
|
-
_Ember: {
|
38
|
-
FEATURES: any;
|
39
|
-
ENV: any;
|
40
|
-
};
|
41
|
-
}
|
42
|
-
export interface TemplateCompilerParams {
|
43
|
-
loadEmberTemplateCompiler: () => {
|
44
|
-
theExports: unknown;
|
45
|
-
cacheKey: string;
|
46
|
-
};
|
47
|
-
resolver?: Resolver;
|
48
|
-
EmberENV: unknown;
|
49
|
-
plugins: Plugins;
|
50
|
-
}
|
51
|
-
export declare class TemplateCompiler {
|
52
|
-
private loadEmberTemplateCompiler;
|
53
|
-
private resolver?;
|
54
|
-
private EmberENV;
|
55
|
-
private plugins;
|
56
|
-
constructor(params: TemplateCompilerParams);
|
57
|
-
private get syntax();
|
58
|
-
get cacheKey(): string;
|
59
|
-
private setup;
|
60
|
-
private getReversedASTPlugins;
|
61
|
-
precompile(templateSource: string, options: Record<string, unknown> & {
|
62
|
-
filename: string;
|
63
|
-
}): {
|
64
|
-
compiled: string;
|
65
|
-
dependencies: ResolvedDep[];
|
66
|
-
};
|
67
|
-
applyTransforms(moduleName: string, contents: string): string;
|
68
|
-
parse(moduleName: string, contents: string): AST;
|
69
|
-
baseDir(): string;
|
70
|
-
}
|
@@ -1,176 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.TemplateCompiler = void 0;
|
13
|
-
const strip_bom_1 = __importDefault(require("strip-bom"));
|
14
|
-
const path_1 = require("path");
|
15
|
-
const typescript_memoize_1 = require("typescript-memoize");
|
16
|
-
const wrap_legacy_hbs_plugin_if_needed_1 = __importDefault(require("wrap-legacy-hbs-plugin-if-needed"));
|
17
|
-
class TemplateCompiler {
|
18
|
-
constructor(params) {
|
19
|
-
this.loadEmberTemplateCompiler = params.loadEmberTemplateCompiler;
|
20
|
-
this.resolver = params.resolver;
|
21
|
-
this.EmberENV = params.EmberENV;
|
22
|
-
this.plugins = params.plugins;
|
23
|
-
}
|
24
|
-
get syntax() {
|
25
|
-
return this.setup().syntax;
|
26
|
-
}
|
27
|
-
get cacheKey() {
|
28
|
-
return this.setup().cacheKey;
|
29
|
-
}
|
30
|
-
setup() {
|
31
|
-
let { theExports, cacheKey } = this.loadEmberTemplateCompiler();
|
32
|
-
let syntax = loadGlimmerSyntax(theExports);
|
33
|
-
initializeEmberENV(syntax, this.EmberENV);
|
34
|
-
// todo: get resolver reflected in cacheKey
|
35
|
-
return { syntax, cacheKey };
|
36
|
-
}
|
37
|
-
getReversedASTPlugins(ast) {
|
38
|
-
return ast.slice().reverse();
|
39
|
-
}
|
40
|
-
// Compiles to the wire format plus dependency list.
|
41
|
-
precompile(templateSource, options) {
|
42
|
-
var _a, _b;
|
43
|
-
let dependencies;
|
44
|
-
let runtimeName;
|
45
|
-
let filename = options.filename;
|
46
|
-
if (this.resolver) {
|
47
|
-
runtimeName = this.resolver.absPathToRuntimePath(filename);
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
runtimeName = filename;
|
51
|
-
}
|
52
|
-
let opts = this.syntax.defaultOptions({ contents: templateSource, moduleName: filename });
|
53
|
-
let plugins = {
|
54
|
-
...opts === null || opts === void 0 ? void 0 : opts.plugins,
|
55
|
-
ast: [
|
56
|
-
...this.getReversedASTPlugins(this.plugins.ast),
|
57
|
-
this.resolver && this.resolver.astTransformer(this),
|
58
|
-
// Ember 3.27+ uses _buildCompileOptions will not add AST plugins to its result
|
59
|
-
...((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.plugins) === null || _a === void 0 ? void 0 : _a.ast) !== null && _b !== void 0 ? _b : []),
|
60
|
-
].filter(Boolean),
|
61
|
-
};
|
62
|
-
let compiled = this.syntax.precompile((0, strip_bom_1.default)(templateSource), {
|
63
|
-
contents: templateSource,
|
64
|
-
moduleName: runtimeName,
|
65
|
-
plugins,
|
66
|
-
...options,
|
67
|
-
});
|
68
|
-
if (this.resolver) {
|
69
|
-
dependencies = this.resolver.dependenciesOf(filename);
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
dependencies = [];
|
73
|
-
}
|
74
|
-
return { compiled, dependencies };
|
75
|
-
}
|
76
|
-
// Applies all custom AST transforms and emits the results still as
|
77
|
-
// handlebars.
|
78
|
-
applyTransforms(moduleName, contents) {
|
79
|
-
let opts = this.syntax.defaultOptions({ contents, moduleName });
|
80
|
-
// the user-provided plugins come first in the list, and those are the
|
81
|
-
// only ones we want to run. The built-in plugins don't need to run here
|
82
|
-
// in stage1, it's better that they run in stage3 when the appropriate
|
83
|
-
// ember version is in charge.
|
84
|
-
//
|
85
|
-
// rather than slicing them off, we could choose instead to not call
|
86
|
-
// syntax.defaultOptions, but then we lose some of the compatibility
|
87
|
-
// normalization that it does on the user-provided plugins.
|
88
|
-
opts.plugins = opts.plugins || {}; // Ember 3.27+ won't add opts.plugins
|
89
|
-
opts.plugins.ast = this.getReversedASTPlugins(this.plugins.ast).map(plugin => {
|
90
|
-
// Although the precompile API does, this direct glimmer syntax api
|
91
|
-
// does not support these legacy plugins, so we must wrap them.
|
92
|
-
return (0, wrap_legacy_hbs_plugin_if_needed_1.default)(plugin);
|
93
|
-
});
|
94
|
-
// instructs glimmer-vm to preserve entity encodings (e.g. don't parse -> ' ')
|
95
|
-
opts.mode = 'codemod';
|
96
|
-
opts.filename = moduleName;
|
97
|
-
opts.moduleName = this.resolver ? this.resolver.absPathToRuntimePath(moduleName) || moduleName : moduleName;
|
98
|
-
let ast = this.syntax.preprocess(contents, opts);
|
99
|
-
return this.syntax.print(ast, { entityEncoding: 'raw' });
|
100
|
-
}
|
101
|
-
parse(moduleName, contents) {
|
102
|
-
// this is just a parse, so we deliberately don't run any plugins.
|
103
|
-
let opts = { contents, moduleName, plugins: {} };
|
104
|
-
return this.syntax.preprocess(contents, opts);
|
105
|
-
}
|
106
|
-
baseDir() {
|
107
|
-
return (0, path_1.join)(__dirname, '..');
|
108
|
-
}
|
109
|
-
}
|
110
|
-
__decorate([
|
111
|
-
(0, typescript_memoize_1.Memoize)()
|
112
|
-
], TemplateCompiler.prototype, "setup", null);
|
113
|
-
__decorate([
|
114
|
-
(0, typescript_memoize_1.Memoize)()
|
115
|
-
], TemplateCompiler.prototype, "getReversedASTPlugins", null);
|
116
|
-
exports.TemplateCompiler = TemplateCompiler;
|
117
|
-
// this matches the setup done by ember-cli-htmlbars: https://git.io/JtbN6
|
118
|
-
function initializeEmberENV(syntax, EmberENV) {
|
119
|
-
if (!EmberENV) {
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
let props;
|
123
|
-
if (EmberENV.FEATURES) {
|
124
|
-
props = Object.keys(EmberENV.FEATURES);
|
125
|
-
props.forEach(prop => {
|
126
|
-
syntax._Ember.FEATURES[prop] = EmberENV.FEATURES[prop];
|
127
|
-
});
|
128
|
-
}
|
129
|
-
if (EmberENV) {
|
130
|
-
props = Object.keys(EmberENV);
|
131
|
-
props.forEach(prop => {
|
132
|
-
if (prop === 'FEATURES') {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
syntax._Ember.ENV[prop] = EmberENV[prop];
|
136
|
-
});
|
137
|
-
}
|
138
|
-
}
|
139
|
-
// we could directly depend on @glimmer/syntax and have nice types and
|
140
|
-
// everything. But the problem is, we really want to use the exact version that
|
141
|
-
// the app itself is using, and its copy is bundled away inside
|
142
|
-
// ember-template-compiler.js.
|
143
|
-
function loadGlimmerSyntax(emberTemplateCompilerExports) {
|
144
|
-
var _a, _b;
|
145
|
-
// detect if we are using an Ember version with the exports we need
|
146
|
-
// (from https://github.com/emberjs/ember.js/pull/19426)
|
147
|
-
if (emberTemplateCompilerExports._preprocess !== undefined) {
|
148
|
-
return {
|
149
|
-
print: emberTemplateCompilerExports._print,
|
150
|
-
preprocess: emberTemplateCompilerExports._preprocess,
|
151
|
-
defaultOptions: emberTemplateCompilerExports._buildCompileOptions,
|
152
|
-
precompile: emberTemplateCompilerExports.precompile,
|
153
|
-
_Ember: emberTemplateCompilerExports._Ember,
|
154
|
-
};
|
155
|
-
}
|
156
|
-
else {
|
157
|
-
// Older Ember versions (prior to 3.27) do not expose a public way to to source 2 source compilation of templates.
|
158
|
-
// because of this, we must resort to some hackery.
|
159
|
-
//
|
160
|
-
// We use the following API's (that we grab from Ember.__loader):
|
161
|
-
//
|
162
|
-
// * glimmer/syntax's preprocess
|
163
|
-
// * glimmer/syntax's print
|
164
|
-
// * ember-template-compiler/lib/system/compile-options's defaultOptions
|
165
|
-
let syntax = ((_a = emberTemplateCompilerExports.Ember) !== null && _a !== void 0 ? _a : emberTemplateCompilerExports._Ember).__loader.require('@glimmer/syntax');
|
166
|
-
let compilerOptions = ((_b = emberTemplateCompilerExports.Ember) !== null && _b !== void 0 ? _b : emberTemplateCompilerExports._Ember).__loader.require('ember-template-compiler/lib/system/compile-options');
|
167
|
-
return {
|
168
|
-
print: syntax.print,
|
169
|
-
preprocess: syntax.preprocess,
|
170
|
-
defaultOptions: compilerOptions.default,
|
171
|
-
precompile: emberTemplateCompilerExports.precompile,
|
172
|
-
_Ember: emberTemplateCompilerExports._Ember,
|
173
|
-
};
|
174
|
-
}
|
175
|
-
}
|
176
|
-
//# sourceMappingURL=template-compiler-common.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"template-compiler-common.js","sourceRoot":"","sources":["template-compiler-common.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAiC;AAEjC,+BAA4B;AAC5B,2DAA6C;AAC7C,wGAA2E;AAiE3E,MAAa,gBAAgB;IAM3B,YAAY,MAA8B;QACxC,IAAI,CAAC,yBAAyB,GAAG,MAAM,CAAC,yBAAyB,CAAC;QAClE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAGO,KAAK;QACX,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChE,IAAI,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC3C,kBAAkB,CAAC,MAAM,EAAE,IA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CAAC;QAC3C,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAED,sEAAsE;AACtE,+EAA+E;AAC/E,+DAA+D;AAC/D,8BAA8B;AAC9B,SAAS,iBAAiB,CAAC,4BAAiC;;IAC1D,mEAAmE;IACnE,wDAAwD;IACxD,IAAI,4BAA4B,CAAC,WAAW,KAAK,SAAS,EAAE;QAC1D,OAAO;YACL,KAAK,EAAE,4BAA4B,CAAC,MAAM;YAC1C,UAAU,EAAE,4BAA4B,CAAC,WAAW;YACpD,cAAc,EAAE,4BAA4B,CAAC,oBAAoB;YACjE,UAAU,EAAE,4BAA4B,CAAC,UAAU;YACnD,MAAM,EAAE,4BAA4B,CAAC,MAAM;SAC5C,CAAC;KACH;SAAM;QACL,kHAAkH;QAClH,mDAAmD;QACnD,EAAE;QACF,iEAAiE;QACjE,EAAE;QACF,gCAAgC;QAChC,2BAA2B;QAC3B,wEAAwE;QACxE,IAAI,MAAM,GAAG,CAAC,MAAA,4BAA4B,CAAC,KAAK,mCAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CACvG,iBAAiB,CAClB,CAAC;QACF,IAAI,eAAe,GAAG,CAAC,MAAA,4BAA4B,CAAC,KAAK,mCAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAChH,oDAAoD,CACrD,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,cAAc,EAAE,eAAe,CAAC,OAAO;YACvC,UAAU,EAAE,4BAA4B,CAAC,UAAU;YACnD,MAAM,EAAE,4BAA4B,CAAC,MAAM;SAC5C,CAAC;KACH;AACH,CAAC","sourcesContent":["import stripBom from 'strip-bom';\nimport { Resolver, ResolvedDep } from './resolver';\nimport { join } from 'path';\nimport { Memoize } from 'typescript-memoize';\nimport wrapLegacyHbsPluginIfNeeded from 'wrap-legacy-hbs-plugin-if-needed';\n\nexport interface Plugins {\n ast?: unknown[];\n}\n\nexport interface AST {\n _deliberatelyOpaque: 'AST';\n}\n\nexport interface PreprocessOptions {\n contents: string;\n moduleName: string;\n plugins?: Plugins;\n filename?: string;\n\n parseOptions?: {\n srcName?: string;\n ignoreStandalone?: boolean;\n };\n\n // added in Ember 3.17 (@glimmer/syntax@0.40.2)\n mode?: 'codemod' | 'precompile';\n\n // added in Ember 3.25\n strictMode?: boolean;\n locals?: string[];\n}\n\nexport interface PrinterOptions {\n entityEncoding?: 'transformed' | 'raw';\n}\n\n// This just reflects the API we're extracting from ember-template-compiler.js,\n// plus a cache key that lets us know when the underlying source has remained\n// stable.\nexport interface GlimmerSyntax {\n preprocess(html: string, options?: PreprocessOptions): AST;\n print(ast: AST, options?: PrinterOptions): string;\n defaultOptions(options: PreprocessOptions): PreprocessOptions;\n precompile(\n templateContents: string,\n options: {\n contents: string;\n moduleName: string;\n filename: string;\n plugins?: any;\n parseOptions?: {\n srcName?: string;\n };\n }\n ): string;\n _Ember: { FEATURES: any; ENV: any };\n}\n\nexport interface TemplateCompilerParams {\n // this should be the exports object from ember-template-compiler.js. It's\n // \"unknown\" here because it changes shape in different ember versions, we\n // will do our best to consume it.\n loadEmberTemplateCompiler: () => { theExports: unknown; cacheKey: string };\n resolver?: Resolver;\n EmberENV: unknown;\n plugins: Plugins;\n}\n\nexport class TemplateCompiler {\n private loadEmberTemplateCompiler: () => { theExports: unknown; cacheKey: string };\n private resolver?: Resolver;\n private EmberENV: unknown;\n private plugins: Plugins;\n\n constructor(params: TemplateCompilerParams) {\n this.loadEmberTemplateCompiler = params.loadEmberTemplateCompiler;\n this.resolver = params.resolver;\n this.EmberENV = params.EmberENV;\n this.plugins = params.plugins;\n }\n\n private get syntax(): GlimmerSyntax {\n return this.setup().syntax;\n }\n\n get cacheKey(): string {\n return this.setup().cacheKey;\n }\n\n @Memoize()\n private setup() {\n let { theExports, cacheKey } = this.loadEmberTemplateCompiler();\n let syntax = loadGlimmerSyntax(theExports);\n initializeEmberENV(syntax, this.EmberENV);\n // todo: get resolver reflected in cacheKey\n return { syntax, cacheKey };\n }\n\n @Memoize()\n private getReversedASTPlugins(ast: unknown[]): unknown[] {\n return ast.slice().reverse();\n }\n\n // Compiles to the wire format plus dependency list.\n precompile(\n templateSource: string,\n options: Record<string, unknown> & { filename: string }\n ): { compiled: string; dependencies: ResolvedDep[] } {\n let dependencies: ResolvedDep[];\n let runtimeName: string;\n let filename: string = options.filename;\n\n if (this.resolver) {\n runtimeName = this.resolver.absPathToRuntimePath(filename);\n } else {\n runtimeName = filename;\n }\n\n let opts = this.syntax.defaultOptions({ contents: templateSource, moduleName: filename });\n let plugins: Plugins = {\n ...opts?.plugins,\n\n ast: [\n ...this.getReversedASTPlugins(this.plugins.ast!),\n this.resolver && this.resolver.astTransformer(this),\n\n // Ember 3.27+ uses _buildCompileOptions will not add AST plugins to its result\n ...(opts?.plugins?.ast ?? []),\n ].filter(Boolean),\n };\n\n let compiled = this.syntax.precompile(stripBom(templateSource), {\n contents: templateSource,\n moduleName: runtimeName,\n plugins,\n ...options,\n });\n\n if (this.resolver) {\n dependencies = this.resolver.dependenciesOf(filename);\n } else {\n dependencies = [];\n }\n\n return { compiled, dependencies };\n }\n\n // Applies all custom AST transforms and emits the results still as\n // handlebars.\n applyTransforms(moduleName: string, contents: string): string {\n let opts = this.syntax.defaultOptions({ contents, moduleName });\n\n // the user-provided plugins come first in the list, and those are the\n // only ones we want to run. The built-in plugins don't need to run here\n // in stage1, it's better that they run in stage3 when the appropriate\n // ember version is in charge.\n //\n // rather than slicing them off, we could choose instead to not call\n // syntax.defaultOptions, but then we lose some of the compatibility\n // normalization that it does on the user-provided plugins.\n opts.plugins = opts.plugins || {}; // Ember 3.27+ won't add opts.plugins\n opts.plugins.ast = this.getReversedASTPlugins(this.plugins.ast!).map(plugin => {\n // Although the precompile API does, this direct glimmer syntax api\n // does not support these legacy plugins, so we must wrap them.\n return wrapLegacyHbsPluginIfNeeded(plugin as any);\n });\n\n // instructs glimmer-vm to preserve entity encodings (e.g. don't parse -> ' ')\n opts.mode = 'codemod';\n\n opts.filename = moduleName;\n opts.moduleName = this.resolver ? this.resolver.absPathToRuntimePath(moduleName) || moduleName : moduleName;\n let ast = this.syntax.preprocess(contents, opts);\n\n return this.syntax.print(ast, { entityEncoding: 'raw' });\n }\n\n parse(moduleName: string, contents: string): AST {\n // this is just a parse, so we deliberately don't run any plugins.\n let opts = { contents, moduleName, plugins: {} };\n return this.syntax.preprocess(contents, opts);\n }\n\n baseDir() {\n return join(__dirname, '..');\n }\n}\n\n// this matches the setup done by ember-cli-htmlbars: https://git.io/JtbN6\nfunction initializeEmberENV(syntax: GlimmerSyntax, EmberENV: any) {\n if (!EmberENV) {\n return;\n }\n\n let props;\n\n if (EmberENV.FEATURES) {\n props = Object.keys(EmberENV.FEATURES);\n props.forEach(prop => {\n syntax._Ember.FEATURES[prop] = EmberENV.FEATURES[prop];\n });\n }\n\n if (EmberENV) {\n props = Object.keys(EmberENV);\n props.forEach(prop => {\n if (prop === 'FEATURES') {\n return;\n }\n syntax._Ember.ENV[prop] = EmberENV[prop];\n });\n }\n}\n\n// we could directly depend on @glimmer/syntax and have nice types and\n// everything. But the problem is, we really want to use the exact version that\n// the app itself is using, and its copy is bundled away inside\n// ember-template-compiler.js.\nfunction loadGlimmerSyntax(emberTemplateCompilerExports: any): GlimmerSyntax {\n // detect if we are using an Ember version with the exports we need\n // (from https://github.com/emberjs/ember.js/pull/19426)\n if (emberTemplateCompilerExports._preprocess !== undefined) {\n return {\n print: emberTemplateCompilerExports._print,\n preprocess: emberTemplateCompilerExports._preprocess,\n defaultOptions: emberTemplateCompilerExports._buildCompileOptions,\n precompile: emberTemplateCompilerExports.precompile,\n _Ember: emberTemplateCompilerExports._Ember,\n };\n } else {\n // Older Ember versions (prior to 3.27) do not expose a public way to to source 2 source compilation of templates.\n // because of this, we must resort to some hackery.\n //\n // We use the following API's (that we grab from Ember.__loader):\n //\n // * glimmer/syntax's preprocess\n // * glimmer/syntax's print\n // * ember-template-compiler/lib/system/compile-options's defaultOptions\n let syntax = (emberTemplateCompilerExports.Ember ?? emberTemplateCompilerExports._Ember).__loader.require(\n '@glimmer/syntax'\n );\n let compilerOptions = (emberTemplateCompilerExports.Ember ?? emberTemplateCompilerExports._Ember).__loader.require(\n 'ember-template-compiler/lib/system/compile-options'\n );\n\n return {\n print: syntax.print,\n preprocess: syntax.preprocess,\n defaultOptions: compilerOptions.default,\n precompile: emberTemplateCompilerExports.precompile,\n _Ember: emberTemplateCompilerExports._Ember,\n };\n }\n}\n"]}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Resolver } from './resolver';
|
2
|
-
import { PluginItem } from '@babel/core';
|
3
|
-
import { Plugins } from './ember-template-compiler-types';
|
4
|
-
import { TemplateCompiler } from './template-compiler-common';
|
5
|
-
export interface NodeTemplateCompilerParams {
|
6
|
-
compilerPath: string;
|
7
|
-
compilerChecksum: string;
|
8
|
-
resolver?: Resolver;
|
9
|
-
EmberENV: unknown;
|
10
|
-
plugins: Plugins;
|
11
|
-
}
|
12
|
-
export declare class NodeTemplateCompiler extends TemplateCompiler {
|
13
|
-
params: NodeTemplateCompilerParams;
|
14
|
-
constructor(params: NodeTemplateCompilerParams);
|
15
|
-
inlineTransformsBabelPlugin(): PluginItem;
|
16
|
-
baseDir(): string;
|
17
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.NodeTemplateCompiler = void 0;
|
4
|
-
const path_1 = require("path");
|
5
|
-
const load_ember_template_compiler_1 = require("./load-ember-template-compiler");
|
6
|
-
const template_compiler_common_1 = require("./template-compiler-common");
|
7
|
-
class NodeTemplateCompiler extends template_compiler_common_1.TemplateCompiler {
|
8
|
-
constructor(params) {
|
9
|
-
super({
|
10
|
-
loadEmberTemplateCompiler: () => (0, load_ember_template_compiler_1.getEmberExports)(params.compilerPath),
|
11
|
-
resolver: params.resolver,
|
12
|
-
EmberENV: params.EmberENV,
|
13
|
-
plugins: params.plugins,
|
14
|
-
});
|
15
|
-
this.params = params;
|
16
|
-
}
|
17
|
-
// Use applyTransforms on the contents of inline hbs template strings inside
|
18
|
-
// Javascript.
|
19
|
-
inlineTransformsBabelPlugin() {
|
20
|
-
return [
|
21
|
-
(0, path_1.join)(__dirname, 'babel-plugin-stage1-inline-hbs-node.js'),
|
22
|
-
{
|
23
|
-
templateCompiler: this.params,
|
24
|
-
},
|
25
|
-
];
|
26
|
-
}
|
27
|
-
baseDir() {
|
28
|
-
return (0, path_1.join)(__dirname, '..');
|
29
|
-
}
|
30
|
-
}
|
31
|
-
exports.NodeTemplateCompiler = NodeTemplateCompiler;
|
32
|
-
//# sourceMappingURL=template-compiler-node.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"template-compiler-node.js","sourceRoot":"","sources":["template-compiler-node.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAI5B,iFAAiE;AACjE,yEAA8D;AAU9D,MAAa,oBAAqB,SAAQ,2CAAgB;IACxD,YAAmB,MAAkC;QACnD,KAAK,CAAC;YACJ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,MAAM,CAAC,YAAY,CAAC;YACrE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;QANc,WAAM,GAAN,MAAM,CAA4B;IAOrD,CAAC;IAED,4EAA4E;IAC5E,cAAc;IACd,2BAA2B;QACzB,OAAO;YACL,IAAA,WAAI,EAAC,SAAS,EAAE,wCAAwC,CAAC;YACzD;gBACE,gBAAgB,EAAE,IAAI,CAAC,MAAM;aACT;SACvB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAxBD,oDAwBC","sourcesContent":["import { Resolver } from './resolver';\nimport { join } from 'path';\nimport { PluginItem } from '@babel/core';\nimport type { Params as InlineBabelParams } from './babel-plugin-stage1-inline-hbs-node';\nimport { Plugins } from './ember-template-compiler-types';\nimport { getEmberExports } from './load-ember-template-compiler';\nimport { TemplateCompiler } from './template-compiler-common';\n\nexport interface NodeTemplateCompilerParams {\n compilerPath: string;\n compilerChecksum: string;\n resolver?: Resolver;\n EmberENV: unknown;\n plugins: Plugins;\n}\n\nexport class NodeTemplateCompiler extends TemplateCompiler {\n constructor(public params: NodeTemplateCompilerParams) {\n super({\n loadEmberTemplateCompiler: () => getEmberExports(params.compilerPath),\n resolver: params.resolver,\n EmberENV: params.EmberENV,\n plugins: params.plugins,\n });\n }\n\n // Use applyTransforms on the contents of inline hbs template strings inside\n // Javascript.\n inlineTransformsBabelPlugin(): PluginItem {\n return [\n join(__dirname, 'babel-plugin-stage1-inline-hbs-node.js'),\n {\n templateCompiler: this.params,\n } as InlineBabelParams,\n ];\n }\n\n baseDir() {\n return join(__dirname, '..');\n }\n}\n"]}
|