@embroider/compat 1.8.3 → 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/package.json +7 -8
- package/src/audit/capture.d.ts +1 -0
- package/src/compat-adapters/ember-cli-fastboot.d.ts +1 -1
- package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
- package/src/compat-addons.js +10 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app.js +12 -38
- package/src/compat-app.js.map +1 -1
- package/src/dasherize-component-name.d.ts +1 -0
- package/src/dasherize-component-name.js +10 -1
- package/src/dasherize-component-name.js.map +1 -1
- package/src/default-pipeline.js +2 -2
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.js +6 -1
- package/src/dependency-rules.js.map +1 -1
- package/src/{template-compiler-broccoli-plugin.d.ts → hbs-to-js-broccoli-plugin.d.ts} +2 -4
- package/src/hbs-to-js-broccoli-plugin.js +39 -0
- package/src/hbs-to-js-broccoli-plugin.js.map +1 -0
- package/src/moved-package-cache.js +5 -1
- package/src/moved-package-cache.js.map +1 -1
- package/src/resolver-transform.d.ts +11 -27
- package/src/resolver-transform.js +163 -65
- package/src/resolver-transform.js.map +1 -1
- package/src/resolver.d.ts +26 -27
- package/src/resolver.js +125 -169
- package/src/resolver.js.map +1 -1
- package/src/synthesize-template-only-components.js +8 -8
- package/src/synthesize-template-only-components.js.map +1 -1
- package/src/v1-addon.d.ts +2 -26
- package/src/v1-addon.js +29 -68
- package/src/v1-addon.js.map +1 -1
- package/src/v1-app.d.ts +3 -2
- package/src/v1-app.js +11 -3
- package/src/v1-app.js.map +1 -1
- package/src/template-compiler-broccoli-plugin.js +0 -28
- package/src/template-compiler-broccoli-plugin.js.map +0 -1
|
@@ -3,14 +3,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeResolverTransform = void 0;
|
|
7
6
|
const resolver_1 = __importDefault(require("./resolver"));
|
|
7
|
+
const assert_never_1 = __importDefault(require("assert-never"));
|
|
8
8
|
// This is the AST transform that resolves components, helpers and modifiers at build time
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function resolverTransform({ filename, contents }) {
|
|
12
|
-
resolver.enter(filename, contents);
|
|
9
|
+
function makeResolverTransform({ resolver, patchHelpersBug }) {
|
|
10
|
+
const resolverTransform = ({ filename, contents, meta: { jsutils }, syntax: { builders }, }) => {
|
|
13
11
|
let scopeStack = new ScopeStack();
|
|
12
|
+
let emittedAMDDeps = new Set();
|
|
13
|
+
function emitAMD(dep) {
|
|
14
|
+
if (dep && !emittedAMDDeps.has(dep.runtimeName)) {
|
|
15
|
+
let parts = dep.runtimeName.split('/');
|
|
16
|
+
let { path, runtimeName } = dep;
|
|
17
|
+
jsutils.emitExpression(context => {
|
|
18
|
+
let identifier = context.import(path, 'default', parts[parts.length - 1]);
|
|
19
|
+
return `window.define("${runtimeName}", () => ${identifier})`;
|
|
20
|
+
});
|
|
21
|
+
emittedAMDDeps.add(dep.runtimeName);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function emit(parentPath, resolution, setter) {
|
|
25
|
+
switch (resolution === null || resolution === void 0 ? void 0 : resolution.type) {
|
|
26
|
+
case 'error':
|
|
27
|
+
resolver.reportError(resolution, filename, contents);
|
|
28
|
+
return;
|
|
29
|
+
case 'helper':
|
|
30
|
+
if (patchHelpersBug) {
|
|
31
|
+
// lexical invocation of helpers was not reliable before Ember 4.2 due to https://github.com/emberjs/ember.js/pull/19878
|
|
32
|
+
emitAMD(resolution.module);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setter(parentPath.node, builders.path(jsutils.bindImport(resolution.module.path, 'default', parentPath, { nameHint: resolution.nameHint })));
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
case 'modifier':
|
|
39
|
+
setter(parentPath.node, builders.path(jsutils.bindImport(resolution.module.path, 'default', parentPath, { nameHint: resolution.nameHint })));
|
|
40
|
+
return;
|
|
41
|
+
case 'component':
|
|
42
|
+
// When people are using octane-style template co-location or
|
|
43
|
+
// polaris-style first-class templates, we see only JS files for their
|
|
44
|
+
// components, because the template association is handled before
|
|
45
|
+
// we're doing any resolving here. In that case, we can safely do
|
|
46
|
+
// component invocation via lexical scope.
|
|
47
|
+
//
|
|
48
|
+
// But when people are using the older non-co-located template style,
|
|
49
|
+
// we can't safely do that -- ember needs to discover both the
|
|
50
|
+
// component and the template in the AMD loader to associate them. In
|
|
51
|
+
// that case, we emit just-in-time AMD definitions for them.
|
|
52
|
+
if (resolution.jsModule && !resolution.hbsModule) {
|
|
53
|
+
setter(parentPath.node, builders.path(jsutils.bindImport(resolution.jsModule.path, 'default', parentPath, { nameHint: resolution.nameHint })));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
emitAMD(resolution.hbsModule);
|
|
57
|
+
emitAMD(resolution.jsModule);
|
|
58
|
+
}
|
|
59
|
+
case undefined:
|
|
60
|
+
return;
|
|
61
|
+
default:
|
|
62
|
+
(0, assert_never_1.default)(resolution);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
14
65
|
return {
|
|
15
66
|
name: 'embroider-build-time-resolver',
|
|
16
67
|
visitor: {
|
|
@@ -22,7 +73,7 @@ function makeResolverTransform(resolver) {
|
|
|
22
73
|
scopeStack.pop();
|
|
23
74
|
},
|
|
24
75
|
},
|
|
25
|
-
BlockStatement(node) {
|
|
76
|
+
BlockStatement(node, path) {
|
|
26
77
|
if (node.path.type !== 'PathExpression') {
|
|
27
78
|
return;
|
|
28
79
|
}
|
|
@@ -40,28 +91,38 @@ function makeResolverTransform(resolver) {
|
|
|
40
91
|
return;
|
|
41
92
|
}
|
|
42
93
|
if (node.path.original === 'component' && node.params.length > 0) {
|
|
43
|
-
handleComponentHelper(node.params[0], resolver, filename, scopeStack);
|
|
94
|
+
let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);
|
|
95
|
+
emit(path, resolution, (node, newIdentifier) => {
|
|
96
|
+
node.params[0] = newIdentifier;
|
|
97
|
+
});
|
|
44
98
|
return;
|
|
45
99
|
}
|
|
46
100
|
// a block counts as args from our perpsective (it's enough to prove
|
|
47
101
|
// this thing must be a component, not content)
|
|
48
102
|
let hasArgs = true;
|
|
49
|
-
|
|
50
|
-
|
|
103
|
+
let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);
|
|
104
|
+
emit(path, resolution, (node, newId) => {
|
|
105
|
+
node.path = newId;
|
|
106
|
+
});
|
|
107
|
+
if ((resolution === null || resolution === void 0 ? void 0 : resolution.type) === 'component') {
|
|
51
108
|
scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {
|
|
109
|
+
let pairs = extendPath(extendPath(path, 'hash'), 'pairs');
|
|
52
110
|
for (let name of argumentsAreComponents) {
|
|
53
|
-
let pair =
|
|
111
|
+
let pair = pairs.find(pair => pair.node.key === name);
|
|
54
112
|
if (pair) {
|
|
55
|
-
handleComponentHelper(pair.value, resolver, filename, scopeStack, {
|
|
113
|
+
let resolution = handleComponentHelper(pair.node.value, resolver, filename, scopeStack, {
|
|
56
114
|
componentName: node.path.original,
|
|
57
115
|
argumentName: name,
|
|
58
116
|
});
|
|
117
|
+
emit(pair, resolution, (node, newId) => {
|
|
118
|
+
node.value = newId;
|
|
119
|
+
});
|
|
59
120
|
}
|
|
60
121
|
}
|
|
61
122
|
});
|
|
62
123
|
}
|
|
63
124
|
},
|
|
64
|
-
SubExpression(node) {
|
|
125
|
+
SubExpression(node, path) {
|
|
65
126
|
if (node.path.type !== 'PathExpression') {
|
|
66
127
|
return;
|
|
67
128
|
}
|
|
@@ -72,7 +133,10 @@ function makeResolverTransform(resolver) {
|
|
|
72
133
|
return;
|
|
73
134
|
}
|
|
74
135
|
if (node.path.original === 'component' && node.params.length > 0) {
|
|
75
|
-
handleComponentHelper(node.params[0], resolver, filename, scopeStack);
|
|
136
|
+
let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);
|
|
137
|
+
emit(path, resolution, (node, newId) => {
|
|
138
|
+
node.params[0] = newId;
|
|
139
|
+
});
|
|
76
140
|
return;
|
|
77
141
|
}
|
|
78
142
|
if (node.path.original === 'helper' && node.params.length > 0) {
|
|
@@ -83,48 +147,63 @@ function makeResolverTransform(resolver) {
|
|
|
83
147
|
handleDynamicModifier(node.params[0], resolver, filename);
|
|
84
148
|
return;
|
|
85
149
|
}
|
|
86
|
-
resolver.resolveSubExpression(node.path.original, filename, node.path.loc);
|
|
150
|
+
let resolution = resolver.resolveSubExpression(node.path.original, filename, node.path.loc);
|
|
151
|
+
emit(path, resolution, (node, newId) => {
|
|
152
|
+
node.path = newId;
|
|
153
|
+
});
|
|
87
154
|
},
|
|
88
|
-
MustacheStatement
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
155
|
+
MustacheStatement: {
|
|
156
|
+
enter(node, path) {
|
|
157
|
+
if (node.path.type !== 'PathExpression') {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (scopeStack.inScope(node.path.parts[0])) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (node.path.this === true) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (node.path.parts.length > 1) {
|
|
167
|
+
// paths with a dot in them (which therefore split into more than
|
|
168
|
+
// one "part") are classically understood by ember to be contextual
|
|
169
|
+
// components, which means there's nothing to resolve at this
|
|
170
|
+
// location.
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (node.path.original === 'component' && node.params.length > 0) {
|
|
174
|
+
let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);
|
|
175
|
+
emit(path, resolution, (node, newId) => {
|
|
176
|
+
node.params[0] = newId;
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (node.path.original === 'helper' && node.params.length > 0) {
|
|
181
|
+
handleDynamicHelper(node.params[0], resolver, filename);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;
|
|
185
|
+
let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);
|
|
186
|
+
emit(path, resolution, (node, newIdentifier) => {
|
|
187
|
+
node.path = newIdentifier;
|
|
188
|
+
});
|
|
189
|
+
if ((resolution === null || resolution === void 0 ? void 0 : resolution.type) === 'component') {
|
|
190
|
+
let pairs = extendPath(extendPath(path, 'hash'), 'pairs');
|
|
191
|
+
for (let name of resolution.argumentsAreComponents) {
|
|
192
|
+
let pair = pairs.find(pair => pair.node.key === name);
|
|
193
|
+
if (pair) {
|
|
194
|
+
let resolution = handleComponentHelper(pair.node.value, resolver, filename, scopeStack, {
|
|
195
|
+
componentName: node.path.original,
|
|
196
|
+
argumentName: name,
|
|
197
|
+
});
|
|
198
|
+
emit(pair, resolution, (node, newId) => {
|
|
199
|
+
node.value = newId;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
123
202
|
}
|
|
124
203
|
}
|
|
125
|
-
}
|
|
204
|
+
},
|
|
126
205
|
},
|
|
127
|
-
ElementModifierStatement(node) {
|
|
206
|
+
ElementModifierStatement(node, path) {
|
|
128
207
|
if (node.path.type !== 'PathExpression') {
|
|
129
208
|
return;
|
|
130
209
|
}
|
|
@@ -145,21 +224,31 @@ function makeResolverTransform(resolver) {
|
|
|
145
224
|
// to resolve at this location.
|
|
146
225
|
return;
|
|
147
226
|
}
|
|
148
|
-
resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);
|
|
227
|
+
let resolution = resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);
|
|
228
|
+
emit(path, resolution, (node, newId) => {
|
|
229
|
+
node.path = newId;
|
|
230
|
+
});
|
|
149
231
|
},
|
|
150
232
|
ElementNode: {
|
|
151
|
-
enter(node) {
|
|
233
|
+
enter(node, path) {
|
|
152
234
|
if (!scopeStack.inScope(node.tag.split('.')[0])) {
|
|
153
235
|
const resolution = resolver.resolveElement(node.tag, filename, node.loc);
|
|
154
|
-
|
|
236
|
+
emit(path, resolution, (node, newId) => {
|
|
237
|
+
node.tag = newId.original;
|
|
238
|
+
});
|
|
239
|
+
if ((resolution === null || resolution === void 0 ? void 0 : resolution.type) === 'component') {
|
|
155
240
|
scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {
|
|
241
|
+
let attributes = extendPath(path, 'attributes');
|
|
156
242
|
for (let name of argumentsAreComponents) {
|
|
157
|
-
let attr =
|
|
243
|
+
let attr = attributes.find(attr => attr.node.name === '@' + name);
|
|
158
244
|
if (attr) {
|
|
159
|
-
handleComponentHelper(attr.value, resolver, filename, scopeStack, {
|
|
245
|
+
let resolution = handleComponentHelper(attr.node.value, resolver, filename, scopeStack, {
|
|
160
246
|
componentName: node.tag,
|
|
161
247
|
argumentName: name,
|
|
162
248
|
});
|
|
249
|
+
emit(attr, resolution, (node, newId) => {
|
|
250
|
+
node.value = builders.mustache(newId);
|
|
251
|
+
});
|
|
163
252
|
}
|
|
164
253
|
}
|
|
165
254
|
});
|
|
@@ -173,7 +262,7 @@ function makeResolverTransform(resolver) {
|
|
|
173
262
|
},
|
|
174
263
|
},
|
|
175
264
|
};
|
|
176
|
-
}
|
|
265
|
+
};
|
|
177
266
|
resolverTransform.parallelBabel = {
|
|
178
267
|
requireFile: __filename,
|
|
179
268
|
buildUsing: 'makeResolverTransform',
|
|
@@ -181,7 +270,7 @@ function makeResolverTransform(resolver) {
|
|
|
181
270
|
};
|
|
182
271
|
return resolverTransform;
|
|
183
272
|
}
|
|
184
|
-
exports.
|
|
273
|
+
exports.default = makeResolverTransform;
|
|
185
274
|
class ScopeStack {
|
|
186
275
|
constructor() {
|
|
187
276
|
this.stack = [];
|
|
@@ -279,12 +368,11 @@ function handleComponentHelper(param, resolver, moduleName, scopeStack, impliedB
|
|
|
279
368
|
break;
|
|
280
369
|
case 'MustacheStatement':
|
|
281
370
|
if (param.hash.pairs.length === 0 && param.params.length === 0) {
|
|
282
|
-
handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);
|
|
283
|
-
return;
|
|
371
|
+
return handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);
|
|
284
372
|
}
|
|
285
373
|
else if (param.path.type === 'PathExpression' && param.path.original === 'component') {
|
|
286
374
|
// safe because we will handle this inner `{{component ...}}` mustache on its own
|
|
287
|
-
return;
|
|
375
|
+
return null;
|
|
288
376
|
}
|
|
289
377
|
else {
|
|
290
378
|
locator = { type: 'other' };
|
|
@@ -296,11 +384,11 @@ function handleComponentHelper(param, resolver, moduleName, scopeStack, impliedB
|
|
|
296
384
|
case 'SubExpression':
|
|
297
385
|
if (param.path.type === 'PathExpression' && param.path.original === 'component') {
|
|
298
386
|
// safe because we will handle this inner `(component ...)` subexpression on its own
|
|
299
|
-
return;
|
|
387
|
+
return null;
|
|
300
388
|
}
|
|
301
389
|
if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {
|
|
302
390
|
// safe because we trust ensure-safe-component
|
|
303
|
-
return;
|
|
391
|
+
return null;
|
|
304
392
|
}
|
|
305
393
|
locator = { type: 'other' };
|
|
306
394
|
break;
|
|
@@ -308,9 +396,9 @@ function handleComponentHelper(param, resolver, moduleName, scopeStack, impliedB
|
|
|
308
396
|
locator = { type: 'other' };
|
|
309
397
|
}
|
|
310
398
|
if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {
|
|
311
|
-
return;
|
|
399
|
+
return null;
|
|
312
400
|
}
|
|
313
|
-
resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);
|
|
401
|
+
return resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);
|
|
314
402
|
}
|
|
315
403
|
function handleDynamicHelper(param, resolver, moduleName) {
|
|
316
404
|
// We only need to handle StringLiterals since Ember already throws an error if unsupported values
|
|
@@ -326,4 +414,14 @@ function handleDynamicModifier(param, resolver, moduleName) {
|
|
|
326
414
|
resolver.resolveDynamicModifier({ type: 'literal', path: param.value }, moduleName, param.loc);
|
|
327
415
|
}
|
|
328
416
|
}
|
|
417
|
+
function extendPath(path, key) {
|
|
418
|
+
const _WalkerPath = path.constructor;
|
|
419
|
+
let child = path.node[key];
|
|
420
|
+
if (Array.isArray(child)) {
|
|
421
|
+
return child.map(c => new _WalkerPath(c, path, key));
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
return new _WalkerPath(child, path, key);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
329
427
|
//# sourceMappingURL=resolver-transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAwF;AAGxF,0FAA0F;AAC1F,qCAAqC;AACrC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAA0C;QACvF,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEnC,IAAI,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,+BAA+B;YAErC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAmB;wBACv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GAA6G;IAC7G,gFAAgF;IAChF,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE;QAClC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;KAC9F;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAuB,EAAE,QAAkB,EAAE,UAAkB;IAC5F,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE;QAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;KAChG;AACH,CAAC","sourcesContent":["import { default as Resolver, ComponentResolution, ComponentLocator } from './resolver';\nimport type { ASTv1 } from '@glimmer/syntax';\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\n// and puts them into `dependencies`.\nexport function makeResolverTransform(resolver: Resolver) {\n function resolverTransform({ filename, contents }: { filename: string; contents: string }) {\n resolver.enter(filename, contents);\n\n let scopeStack = new ScopeStack();\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node: ASTv1.Program) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node: ASTv1.BlockStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n const resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n }\n }\n });\n }\n },\n SubExpression(node: ASTv1.SubExpression) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n if (node.path.original === 'helper' && node.params.length > 0) {\n handleDynamicHelper(node.params[0], resolver, filename);\n return;\n }\n if (node.path.original === 'modifier' && node.params.length > 0) {\n handleDynamicModifier(node.params[0], resolver, filename);\n return;\n }\n resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n },\n MustacheStatement(node: ASTv1.MustacheStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n if (node.path.original === 'helper' && node.params.length > 0) {\n handleDynamicHelper(node.params[0], resolver, filename);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n for (let name of resolution.argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n }\n }\n }\n },\n ElementModifierStatement(node: ASTv1.ElementModifierStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);\n },\n ElementNode: {\n enter(node: ASTv1.ElementNode) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let attr = node.attributes.find((attr: ASTv1.AttrNode) => attr.name === '@' + name);\n if (attr) {\n handleComponentHelper(attr.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n }\n resolverTransform.parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): void {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n return;\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return;\n }\n\n resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n}\n\nfunction handleDynamicHelper(param: ASTv1.Expression, resolver: Resolver, moduleName: string): void {\n // We only need to handle StringLiterals since Ember already throws an error if unsupported values\n // are passed to the helper keyword.\n // If a helper reference is passed in we don't need to do anything since it's either the result of a previous\n // helper keyword invocation, or a helper reference that was imported somewhere.\n if (param.type === 'StringLiteral') {\n resolver.resolveDynamicHelper({ type: 'literal', path: param.value }, moduleName, param.loc);\n }\n}\n\nfunction handleDynamicModifier(param: ASTv1.Expression, resolver: Resolver, moduleName: string): void {\n if (param.type === 'StringLiteral') {\n resolver.resolveDynamicModifier({ type: 'literal', path: param.value }, moduleName, param.loc);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mapp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KAAK,eAAe,EAAE;QAClC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;KAC9F;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAuB,EAAE,QAAkB,EAAE,UAAkB;IAC5F,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE;QAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;KAChG;AACH,CAAC;AAED,SAAS,UAAU,CACjB,IAAmB,EACnB,GAAM;IAEN,MAAM,WAAW,GAAG,IAAI,CAAC,WAMxB,CAAC;IACF,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,GAAa,CAAC,CAAQ,CAAC;KACvE;SAAM;QACL,OAAO,IAAI,WAAW,CAAC,KAAY,EAAE,IAAI,EAAE,GAAa,CAAQ,CAAC;KAClE;AACH,CAAC","sourcesContent":["import {\n default as Resolver,\n ComponentResolution,\n ComponentLocator,\n ResolutionFail,\n Resolution,\n ResolvedDep,\n} from './resolver';\nimport type { ASTv1, ASTPluginBuilder, ASTPluginEnvironment, WalkerPath } from '@glimmer/syntax';\nimport type { WithJSUtils } from 'babel-plugin-ember-template-compilation';\nimport assertNever from 'assert-never';\n\ntype Env = WithJSUtils<ASTPluginEnvironment> & { filename: string; contents: string };\n\nexport interface Options {\n resolver: Resolver;\n patchHelpersBug: boolean;\n}\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\nexport default function makeResolverTransform({ resolver, patchHelpersBug }: Options) {\n const resolverTransform: ASTPluginBuilder<Env> = ({\n filename,\n contents,\n meta: { jsutils },\n syntax: { builders },\n }) => {\n let scopeStack = new ScopeStack();\n let emittedAMDDeps: Set<string> = new Set();\n\n function emitAMD(dep: ResolvedDep | null) {\n if (dep && !emittedAMDDeps.has(dep.runtimeName)) {\n let parts = dep.runtimeName.split('/');\n let { path, runtimeName } = dep;\n jsutils.emitExpression(context => {\n let identifier = context.import(path, 'default', parts[parts.length - 1]);\n return `window.define(\"${runtimeName}\", () => ${identifier})`;\n });\n emittedAMDDeps.add(dep.runtimeName);\n }\n }\n\n function emit<Target extends WalkerPath<ASTv1.Node>>(\n parentPath: Target,\n resolution: Resolution | null,\n setter: (target: Target['node'], newIdentifier: ASTv1.PathExpression) => void\n ) {\n switch (resolution?.type) {\n case 'error':\n resolver.reportError(resolution, filename, contents);\n return;\n case 'helper':\n if (patchHelpersBug) {\n // lexical invocation of helpers was not reliable before Ember 4.2 due to https://github.com/emberjs/ember.js/pull/19878\n emitAMD(resolution.module);\n } else {\n setter(\n parentPath.node,\n builders.path(\n jsutils.bindImport(resolution.module.path, 'default', parentPath, { nameHint: resolution.nameHint })\n )\n );\n }\n return;\n case 'modifier':\n setter(\n parentPath.node,\n builders.path(\n jsutils.bindImport(resolution.module.path, 'default', parentPath, { nameHint: resolution.nameHint })\n )\n );\n return;\n case 'component':\n // When people are using octane-style template co-location or\n // polaris-style first-class templates, we see only JS files for their\n // components, because the template association is handled before\n // we're doing any resolving here. In that case, we can safely do\n // component invocation via lexical scope.\n //\n // But when people are using the older non-co-located template style,\n // we can't safely do that -- ember needs to discover both the\n // component and the template in the AMD loader to associate them. In\n // that case, we emit just-in-time AMD definitions for them.\n if (resolution.jsModule && !resolution.hbsModule) {\n setter(\n parentPath.node,\n builders.path(\n jsutils.bindImport(resolution.jsModule.path, 'default', parentPath, { nameHint: resolution.nameHint })\n )\n );\n } else {\n emitAMD(resolution.hbsModule);\n emitAMD(resolution.jsModule);\n }\n case undefined:\n return;\n default:\n assertNever(resolution);\n }\n }\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node, path) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n emit(path, resolution, (node, newIdentifier) => {\n node.params[0] = newIdentifier;\n });\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n if (resolution?.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n let pairs = extendPath(extendPath(path, 'hash'), 'pairs');\n for (let name of argumentsAreComponents) {\n let pair = pairs.find(pair => pair.node.key === name);\n if (pair) {\n let resolution = handleComponentHelper(pair.node.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n emit(pair, resolution, (node, newId) => {\n node.value = newId;\n });\n }\n }\n });\n }\n },\n SubExpression(node, path) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.original === 'helper' && node.params.length > 0) {\n handleDynamicHelper(node.params[0], resolver, filename);\n return;\n }\n if (node.path.original === 'modifier' && node.params.length > 0) {\n handleDynamicModifier(node.params[0], resolver, filename);\n return;\n }\n let resolution = resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n MustacheStatement: {\n enter(node, path) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.original === 'helper' && node.params.length > 0) {\n handleDynamicHelper(node.params[0], resolver, filename);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n emit(path, resolution, (node, newIdentifier) => {\n node.path = newIdentifier;\n });\n if (resolution?.type === 'component') {\n let pairs = extendPath(extendPath(path, 'hash'), 'pairs');\n for (let name of resolution.argumentsAreComponents) {\n let pair = pairs.find(pair => pair.node.key === name);\n if (pair) {\n let resolution = handleComponentHelper(pair.node.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n emit(pair, resolution, (node, newId) => {\n node.value = newId;\n });\n }\n }\n }\n },\n },\n ElementModifierStatement(node, path) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n let resolution = resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);\n emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n ElementNode: {\n enter(node, path) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n emit(path, resolution, (node, newId) => {\n node.tag = newId.original;\n });\n if (resolution?.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n let attributes = extendPath(path, 'attributes');\n for (let name of argumentsAreComponents) {\n let attr = attributes.find(attr => attr.node.name === '@' + name);\n if (attr) {\n let resolution = handleComponentHelper(attr.node.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n emit(attr, resolution, (node, newId) => {\n node.value = builders.mustache(newId);\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n };\n (resolverTransform as any).parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): ComponentResolution | ResolutionFail | null {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n return handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return null;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return null;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return null;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return null;\n }\n\n return resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n}\n\nfunction handleDynamicHelper(param: ASTv1.Expression, resolver: Resolver, moduleName: string): void {\n // We only need to handle StringLiterals since Ember already throws an error if unsupported values\n // are passed to the helper keyword.\n // If a helper reference is passed in we don't need to do anything since it's either the result of a previous\n // helper keyword invocation, or a helper reference that was imported somewhere.\n if (param.type === 'StringLiteral') {\n resolver.resolveDynamicHelper({ type: 'literal', path: param.value }, moduleName, param.loc);\n }\n}\n\nfunction handleDynamicModifier(param: ASTv1.Expression, resolver: Resolver, moduleName: string): void {\n if (param.type === 'StringLiteral') {\n resolver.resolveDynamicModifier({ type: 'literal', path: param.value }, moduleName, param.loc);\n }\n}\n\nfunction extendPath<N extends ASTv1.Node, K extends keyof N>(\n path: WalkerPath<N>,\n key: K\n): N[K] extends ASTv1.Node ? WalkerPath<N[K]> : N[K] extends ASTv1.Node[] ? WalkerPath<N[K][0]>[] : never {\n const _WalkerPath = path.constructor as {\n new <Child extends ASTv1.Node>(\n node: Child,\n parent?: WalkerPath<ASTv1.Node> | null,\n parentKey?: string | null\n ): WalkerPath<Child>;\n };\n let child = path.node[key];\n if (Array.isArray(child)) {\n return child.map(c => new _WalkerPath(c, path, key as string)) as any;\n } else {\n return new _WalkerPath(child as any, path, key as string) as any;\n }\n}\n"]}
|
package/src/resolver.d.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { ActivePackageRules, ComponentRules, ModuleRules, PackageRules } from './dependency-rules';
|
|
2
|
-
import { Resolver, TemplateCompiler } from '@embroider/core';
|
|
3
2
|
import { Options as AdjustImportsOptions } from '@embroider/core/src/babel-plugin-adjust-imports';
|
|
4
3
|
import Options from './options';
|
|
5
|
-
|
|
4
|
+
export interface ResolvedDep {
|
|
5
|
+
runtimeName: string;
|
|
6
|
+
path: string;
|
|
7
|
+
absPath: string;
|
|
8
|
+
}
|
|
6
9
|
export interface ComponentResolution {
|
|
7
10
|
type: 'component';
|
|
8
|
-
|
|
11
|
+
jsModule: ResolvedDep | null;
|
|
12
|
+
hbsModule: ResolvedDep | null;
|
|
9
13
|
yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];
|
|
10
14
|
yieldsArguments: Required<ComponentRules>['yieldsArguments'];
|
|
11
15
|
argumentsAreComponents: string[];
|
|
16
|
+
nameHint: string;
|
|
12
17
|
}
|
|
13
18
|
export interface HelperResolution {
|
|
14
19
|
type: 'helper';
|
|
15
|
-
|
|
20
|
+
module: ResolvedDep;
|
|
21
|
+
nameHint: string;
|
|
16
22
|
}
|
|
17
23
|
export interface ModifierResolution {
|
|
18
24
|
type: 'modifier';
|
|
19
|
-
|
|
25
|
+
module: ResolvedDep;
|
|
26
|
+
nameHint: string;
|
|
20
27
|
}
|
|
21
28
|
export declare type ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;
|
|
22
29
|
export interface ResolutionFail {
|
|
@@ -42,6 +49,7 @@ interface RehydrationParamsBase {
|
|
|
42
49
|
modulePrefix: string;
|
|
43
50
|
podModulePrefix?: string;
|
|
44
51
|
options: ResolverOptions;
|
|
52
|
+
emberVersion: string;
|
|
45
53
|
activePackageRules: ActivePackageRules[];
|
|
46
54
|
}
|
|
47
55
|
interface RehydrationParamsWithFile extends RehydrationParamsBase {
|
|
@@ -59,39 +67,30 @@ export interface AuditMessage {
|
|
|
59
67
|
source: string;
|
|
60
68
|
filename: string;
|
|
61
69
|
}
|
|
62
|
-
export default class CompatResolver
|
|
70
|
+
export default class CompatResolver {
|
|
63
71
|
private params;
|
|
64
|
-
private dependencies;
|
|
65
|
-
private templateCompiler;
|
|
66
72
|
private auditHandler;
|
|
67
|
-
private currentContents;
|
|
68
73
|
_parallelBabel: {
|
|
69
74
|
requireFile: string;
|
|
70
75
|
buildUsing: string;
|
|
71
76
|
params: RehydrationParams;
|
|
72
77
|
};
|
|
73
78
|
constructor(params: RehydrationParams);
|
|
74
|
-
enter(moduleName: string, contents: string): void;
|
|
75
|
-
private add;
|
|
76
79
|
private findComponentRules;
|
|
77
80
|
private isIgnoredComponent;
|
|
78
81
|
get adjustImportsOptions(): AdjustImportsOptions;
|
|
79
82
|
private get rules();
|
|
80
|
-
resolveComponentSnippet(snippet: string, rule: PackageRules | ModuleRules, from?: string):
|
|
81
|
-
type: 'component';
|
|
82
|
-
};
|
|
83
|
+
resolveComponentSnippet(snippet: string, rule: PackageRules | ModuleRules, from?: string): ComponentResolution;
|
|
83
84
|
private standardDasherize;
|
|
84
|
-
astTransformer(
|
|
85
|
-
|
|
85
|
+
astTransformer(): undefined | string | [string, unknown];
|
|
86
|
+
private humanReadableFile;
|
|
87
|
+
reportError(dep: ResolutionFail, filename: string, source: string): void;
|
|
86
88
|
resolveImport(path: string, from: string): {
|
|
87
89
|
runtimeName: string;
|
|
88
90
|
absPath: string;
|
|
89
91
|
} | undefined;
|
|
90
92
|
private get resolvableExtensionsPattern();
|
|
91
|
-
absPathToRuntimePath
|
|
92
|
-
root: string;
|
|
93
|
-
name: string;
|
|
94
|
-
}): string;
|
|
93
|
+
private absPathToRuntimePath;
|
|
95
94
|
absPathToRuntimeName(absPath: string, owningPackage?: {
|
|
96
95
|
root: string;
|
|
97
96
|
name: string;
|
|
@@ -106,16 +105,16 @@ export default class CompatResolver implements Resolver {
|
|
|
106
105
|
private get appPackage();
|
|
107
106
|
private tryComponent;
|
|
108
107
|
private _tryComponent;
|
|
109
|
-
resolveSubExpression(path: string, from: string, loc: Loc):
|
|
110
|
-
resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc):
|
|
111
|
-
resolveElementModifierStatement(path: string, from: string, loc: Loc):
|
|
112
|
-
resolveElement(tagName: string, from: string, loc: Loc):
|
|
108
|
+
resolveSubExpression(path: string, from: string, loc: Loc): HelperResolution | ResolutionFail | null;
|
|
109
|
+
resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): HelperResolution | ComponentResolution | ResolutionFail | null;
|
|
110
|
+
resolveElementModifierStatement(path: string, from: string, loc: Loc): ModifierResolution | ResolutionFail | null;
|
|
111
|
+
resolveElement(tagName: string, from: string, loc: Loc): ComponentResolution | ResolutionFail | null;
|
|
113
112
|
resolveComponentHelper(component: ComponentLocator, from: string, loc: Loc, impliedBecause?: {
|
|
114
113
|
componentName: string;
|
|
115
114
|
argumentName: string;
|
|
116
|
-
}):
|
|
117
|
-
resolveDynamicHelper(helper: ComponentLocator, from: string, loc: Loc):
|
|
118
|
-
resolveDynamicModifier(modifier: ComponentLocator, from: string, loc: Loc):
|
|
115
|
+
}): ComponentResolution | ResolutionFail | null;
|
|
116
|
+
resolveDynamicHelper(helper: ComponentLocator, from: string, loc: Loc): HelperResolution | ResolutionFail | null;
|
|
117
|
+
resolveDynamicModifier(modifier: ComponentLocator, from: string, loc: Loc): ModifierResolution | ResolutionFail | null;
|
|
119
118
|
}
|
|
120
119
|
export declare type ComponentLocator = {
|
|
121
120
|
type: 'literal';
|