@embroider/compat 2.0.2 → 2.1.1-unstable.00ec2e7
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 +5 -4
- package/src/addon-dependency-rules/ember-data.js +1 -0
- package/src/addon-dependency-rules/ember-data.js.map +1 -1
- package/src/audit/babel-visitor.d.ts +1 -0
- package/src/audit/babel-visitor.js +2 -2
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit/build.js +48 -46
- package/src/audit/build.js.map +1 -1
- package/src/audit/options.d.ts +3 -2
- package/src/audit/options.js.map +1 -1
- package/src/audit-cli.js +0 -0
- package/src/audit.d.ts +25 -1
- package/src/audit.js +55 -33
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.d.ts +16 -0
- package/src/babel-plugin-adjust-imports.js +198 -0
- package/src/babel-plugin-adjust-imports.js.map +1 -0
- package/src/compat-adapters/@glimmer/tracking.d.ts +0 -1
- package/src/compat-adapters/@glimmer/tracking.js +8 -15
- package/src/compat-adapters/@glimmer/tracking.js.map +1 -1
- package/src/compat-adapters/ember-data.d.ts +1 -0
- package/src/compat-adapters/ember-data.js +4 -0
- package/src/compat-adapters/ember-data.js.map +1 -1
- package/src/compat-app.js +41 -77
- package/src/compat-app.js.map +1 -1
- package/src/default-pipeline.d.ts +1 -1
- package/src/default-pipeline.js +3 -2
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.d.ts +12 -9
- package/src/dependency-rules.js +21 -37
- package/src/dependency-rules.js.map +1 -1
- package/src/resolver-transform.d.ts +13 -4
- package/src/resolver-transform.js +722 -278
- package/src/resolver-transform.js.map +1 -1
- package/src/v1-app.js +19 -5
- package/src/v1-app.js.map +1 -1
- package/src/audit/capture.d.ts +0 -8
- package/src/audit/capture.js +0 -45
- package/src/audit/capture.js.map +0 -1
- package/src/resolver.d.ts +0 -128
- package/src/resolver.js +0 -677
- package/src/resolver.js.map +0 -1
package/src/resolver.js
DELETED
|
@@ -1,677 +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.rehydrate = void 0;
|
|
13
|
-
const dependency_rules_1 = require("./dependency-rules");
|
|
14
|
-
const core_1 = require("@embroider/core");
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
const typescript_memoize_1 = require("typescript-memoize");
|
|
17
|
-
const dasherize_component_name_1 = require("./dasherize-component-name");
|
|
18
|
-
const fs_extra_1 = require("fs-extra");
|
|
19
|
-
const resolve_1 = __importDefault(require("resolve"));
|
|
20
|
-
const semver_1 = __importDefault(require("semver"));
|
|
21
|
-
// TODO: this depends on the ember version. And it's probably missing some
|
|
22
|
-
// private-but-used values.
|
|
23
|
-
const builtInHelpers = [
|
|
24
|
-
'-get-dynamic-var',
|
|
25
|
-
'-in-element',
|
|
26
|
-
'in-element',
|
|
27
|
-
'-with-dynamic-vars',
|
|
28
|
-
'action',
|
|
29
|
-
'array',
|
|
30
|
-
'component',
|
|
31
|
-
'concat',
|
|
32
|
-
'debugger',
|
|
33
|
-
'each',
|
|
34
|
-
'each-in',
|
|
35
|
-
'fn',
|
|
36
|
-
'get',
|
|
37
|
-
'has-block',
|
|
38
|
-
'has-block-params',
|
|
39
|
-
'hasBlock',
|
|
40
|
-
'hasBlockParams',
|
|
41
|
-
'hash',
|
|
42
|
-
'helper',
|
|
43
|
-
'if',
|
|
44
|
-
'input',
|
|
45
|
-
'let',
|
|
46
|
-
'link-to',
|
|
47
|
-
'loc',
|
|
48
|
-
'log',
|
|
49
|
-
'modifier',
|
|
50
|
-
'mount',
|
|
51
|
-
'mut',
|
|
52
|
-
'on',
|
|
53
|
-
'outlet',
|
|
54
|
-
'partial',
|
|
55
|
-
'query-params',
|
|
56
|
-
'readonly',
|
|
57
|
-
'textarea',
|
|
58
|
-
'unbound',
|
|
59
|
-
'unique-id',
|
|
60
|
-
'unless',
|
|
61
|
-
'with',
|
|
62
|
-
'yield',
|
|
63
|
-
];
|
|
64
|
-
const builtInComponents = ['input', 'link-to', 'textarea'];
|
|
65
|
-
const builtInModifiers = ['action', 'on'];
|
|
66
|
-
function extractOptions(options) {
|
|
67
|
-
return {
|
|
68
|
-
staticHelpers: options.staticHelpers,
|
|
69
|
-
staticModifiers: options.staticModifiers,
|
|
70
|
-
staticComponents: options.staticComponents,
|
|
71
|
-
allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function rehydrate(params) {
|
|
75
|
-
return new CompatResolver(params);
|
|
76
|
-
}
|
|
77
|
-
exports.rehydrate = rehydrate;
|
|
78
|
-
class CompatResolver {
|
|
79
|
-
constructor(params) {
|
|
80
|
-
this.params = params;
|
|
81
|
-
this.params.options = extractOptions(this.params.options);
|
|
82
|
-
this._parallelBabel = {
|
|
83
|
-
requireFile: __filename,
|
|
84
|
-
buildUsing: 'rehydrate',
|
|
85
|
-
params,
|
|
86
|
-
};
|
|
87
|
-
if (globalThis.embroider_audit) {
|
|
88
|
-
this.auditHandler = globalThis.embroider_audit;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
findComponentRules(absPath) {
|
|
92
|
-
let rules = this.rules.components.get(absPath);
|
|
93
|
-
if (rules) {
|
|
94
|
-
return rules;
|
|
95
|
-
}
|
|
96
|
-
// co-located templates aren't visible to the resolver, because they never
|
|
97
|
-
// get resolved from a template (they are always handled directly by the
|
|
98
|
-
// corresponding JS module, which the resolver *does* see). This means their
|
|
99
|
-
// paths won't ever be in `this.rules.components`. But we do want them to
|
|
100
|
-
// "inherit" the rules that are attached to their corresonding JS module.
|
|
101
|
-
if (absPath.endsWith('.hbs')) {
|
|
102
|
-
let stem = absPath.slice(0, -4);
|
|
103
|
-
for (let ext of this.adjustImportsOptions.resolvableExtensions) {
|
|
104
|
-
if (ext !== '.hbs') {
|
|
105
|
-
let rules = this.rules.components.get(stem + ext);
|
|
106
|
-
if (rules) {
|
|
107
|
-
return rules;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
isIgnoredComponent(dasherizedName) {
|
|
115
|
-
return this.rules.ignoredComponents.includes(dasherizedName);
|
|
116
|
-
}
|
|
117
|
-
get adjustImportsOptions() {
|
|
118
|
-
const { params } = this;
|
|
119
|
-
return 'adjustImportsOptionsPath' in params
|
|
120
|
-
? // eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
121
|
-
require(params.adjustImportsOptionsPath)
|
|
122
|
-
: params.adjustImportsOptions;
|
|
123
|
-
}
|
|
124
|
-
get rules() {
|
|
125
|
-
var _a;
|
|
126
|
-
// keyed by their first resolved dependency's runtimeName.
|
|
127
|
-
let components = new Map();
|
|
128
|
-
// keyed by our own dasherized interpretation of the component's name.
|
|
129
|
-
let ignoredComponents = [];
|
|
130
|
-
// we're not responsible for filtering out rules for inactive packages here,
|
|
131
|
-
// that is done before getting to us. So we should assume these are all in
|
|
132
|
-
// force.
|
|
133
|
-
for (let rule of this.params.activePackageRules) {
|
|
134
|
-
if (rule.components) {
|
|
135
|
-
for (let [snippet, componentRules] of Object.entries(rule.components)) {
|
|
136
|
-
if (componentRules.safeToIgnore) {
|
|
137
|
-
ignoredComponents.push(this.standardDasherize(snippet, rule));
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
let resolvedSnippet = this.resolveComponentSnippet(snippet, rule);
|
|
141
|
-
// cast is OK here because a component must have one or the other
|
|
142
|
-
let resolvedDep = ((_a = resolvedSnippet.hbsModule) !== null && _a !== void 0 ? _a : resolvedSnippet.jsModule);
|
|
143
|
-
let processedRules = (0, dependency_rules_1.preprocessComponentRule)(componentRules);
|
|
144
|
-
// we always register our rules on the component's own first resolved
|
|
145
|
-
// module, which must be a module in the app's module namespace.
|
|
146
|
-
components.set(resolvedDep.absPath, processedRules);
|
|
147
|
-
// if there's a custom layout, we also need to register our rules on
|
|
148
|
-
// those templates.
|
|
149
|
-
if (componentRules.layout) {
|
|
150
|
-
if (componentRules.layout.appPath) {
|
|
151
|
-
components.set((0, path_1.join)(this.params.root, componentRules.layout.appPath), processedRules);
|
|
152
|
-
}
|
|
153
|
-
else if (componentRules.layout.addonPath) {
|
|
154
|
-
for (let root of rule.roots) {
|
|
155
|
-
components.set((0, path_1.join)(root, componentRules.layout.addonPath), processedRules);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new Error(`layout property in component rule must contain either appPath or addonPath: ${JSON.stringify(rule, null, 2)}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (rule.appTemplates) {
|
|
165
|
-
for (let [path, templateRules] of Object.entries(rule.appTemplates)) {
|
|
166
|
-
let processedRules = (0, dependency_rules_1.preprocessComponentRule)(templateRules);
|
|
167
|
-
components.set((0, path_1.join)(this.params.root, path), processedRules);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (rule.addonTemplates) {
|
|
171
|
-
for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {
|
|
172
|
-
let processedRules = (0, dependency_rules_1.preprocessComponentRule)(templateRules);
|
|
173
|
-
for (let root of rule.roots) {
|
|
174
|
-
components.set((0, path_1.join)(root, path), processedRules);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return { components, ignoredComponents };
|
|
180
|
-
}
|
|
181
|
-
resolveComponentSnippet(snippet, rule, from = 'rule-snippet.hbs') {
|
|
182
|
-
let name = this.standardDasherize(snippet, rule);
|
|
183
|
-
let found = this.tryComponent(name, from, false);
|
|
184
|
-
if (found && found.type === 'component') {
|
|
185
|
-
return found;
|
|
186
|
-
}
|
|
187
|
-
throw new Error(`unable to locate component ${snippet} referred to in rule ${JSON.stringify(rule, null, 2)}`);
|
|
188
|
-
}
|
|
189
|
-
standardDasherize(snippet, rule) {
|
|
190
|
-
let name = (0, dasherize_component_name_1.snippetToDasherizedName)(snippet);
|
|
191
|
-
if (name == null) {
|
|
192
|
-
throw new Error(`unable to parse component snippet "${snippet}" from rule ${JSON.stringify(rule, null, 2)}`);
|
|
193
|
-
}
|
|
194
|
-
return name;
|
|
195
|
-
}
|
|
196
|
-
astTransformer() {
|
|
197
|
-
if (this.staticComponentsEnabled || this.staticHelpersEnabled || this.staticModifiersEnabled) {
|
|
198
|
-
let opts = {
|
|
199
|
-
resolver: this,
|
|
200
|
-
// lexical invocation of helpers was not reliable before Ember 4.2 due to https://github.com/emberjs/ember.js/pull/19878
|
|
201
|
-
patchHelpersBug: semver_1.default.satisfies(this.params.emberVersion, '<4.2.0-beta.0', {
|
|
202
|
-
includePrerelease: true,
|
|
203
|
-
}),
|
|
204
|
-
};
|
|
205
|
-
return [require.resolve('./resolver-transform'), opts];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
humanReadableFile(file) {
|
|
209
|
-
if (!this.params.root.endsWith('/')) {
|
|
210
|
-
this.params.root += '/';
|
|
211
|
-
}
|
|
212
|
-
if (file.startsWith(this.params.root)) {
|
|
213
|
-
return file.slice(this.params.root.length);
|
|
214
|
-
}
|
|
215
|
-
return file;
|
|
216
|
-
}
|
|
217
|
-
reportError(dep, filename, source) {
|
|
218
|
-
if (!this.auditHandler && !this.params.options.allowUnsafeDynamicComponents) {
|
|
219
|
-
let e = new Error(`${dep.message}: ${dep.detail} in ${this.humanReadableFile(filename)}`);
|
|
220
|
-
e.isTemplateResolverError = true;
|
|
221
|
-
e.loc = dep.loc;
|
|
222
|
-
e.moduleName = filename;
|
|
223
|
-
throw e;
|
|
224
|
-
}
|
|
225
|
-
if (this.auditHandler) {
|
|
226
|
-
this.auditHandler({
|
|
227
|
-
message: dep.message,
|
|
228
|
-
filename,
|
|
229
|
-
detail: dep.detail,
|
|
230
|
-
loc: dep.loc,
|
|
231
|
-
source,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
resolveImport(path, from) {
|
|
236
|
-
let absPath;
|
|
237
|
-
try {
|
|
238
|
-
absPath = resolve_1.default.sync(path, {
|
|
239
|
-
basedir: (0, path_1.dirname)(from),
|
|
240
|
-
extensions: this.adjustImportsOptions.resolvableExtensions,
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
catch (err) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (absPath) {
|
|
247
|
-
let runtimeName = this.absPathToRuntimeName(absPath);
|
|
248
|
-
if (runtimeName) {
|
|
249
|
-
return { runtimeName, absPath };
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
get resolvableExtensionsPattern() {
|
|
254
|
-
return (0, core_1.extensionsPattern)(this.adjustImportsOptions.resolvableExtensions);
|
|
255
|
-
}
|
|
256
|
-
absPathToRuntimePath(absPath, owningPackage) {
|
|
257
|
-
let pkg = owningPackage || core_1.PackageCache.shared('embroider-stage3', this.params.root).ownerOfFile(absPath);
|
|
258
|
-
if (pkg) {
|
|
259
|
-
let packageRuntimeName = pkg.name;
|
|
260
|
-
for (let [runtimeName, realName] of Object.entries(this.adjustImportsOptions.renamePackages)) {
|
|
261
|
-
if (realName === packageRuntimeName) {
|
|
262
|
-
packageRuntimeName = runtimeName;
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return (0, path_1.join)(packageRuntimeName, (0, path_1.relative)(pkg.root, absPath)).split(path_1.sep).join('/');
|
|
267
|
-
}
|
|
268
|
-
else if (absPath.startsWith(this.params.root)) {
|
|
269
|
-
return (0, path_1.join)(this.params.modulePrefix, (0, path_1.relative)(this.params.root, absPath)).split(path_1.sep).join('/');
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
throw new Error(`bug: can't figure out the runtime name for ${absPath}`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
absPathToRuntimeName(absPath, owningPackage) {
|
|
276
|
-
return this.absPathToRuntimePath(absPath, owningPackage)
|
|
277
|
-
.replace(this.resolvableExtensionsPattern, '')
|
|
278
|
-
.replace(/\/index$/, '');
|
|
279
|
-
}
|
|
280
|
-
get staticComponentsEnabled() {
|
|
281
|
-
return this.params.options.staticComponents || Boolean(this.auditHandler);
|
|
282
|
-
}
|
|
283
|
-
get staticHelpersEnabled() {
|
|
284
|
-
return this.params.options.staticHelpers || Boolean(this.auditHandler);
|
|
285
|
-
}
|
|
286
|
-
get staticModifiersEnabled() {
|
|
287
|
-
return this.params.options.staticModifiers || Boolean(this.auditHandler);
|
|
288
|
-
}
|
|
289
|
-
tryHelper(path, from) {
|
|
290
|
-
let parts = path.split('@');
|
|
291
|
-
if (parts.length > 1 && parts[0].length > 0) {
|
|
292
|
-
let cache = core_1.PackageCache.shared('embroider-stage3', this.params.root);
|
|
293
|
-
let packageName = parts[0];
|
|
294
|
-
let renamed = this.adjustImportsOptions.renamePackages[packageName];
|
|
295
|
-
if (renamed) {
|
|
296
|
-
packageName = renamed;
|
|
297
|
-
}
|
|
298
|
-
let owner = cache.ownerOfFile(from);
|
|
299
|
-
let targetPackage = owner.name === packageName ? owner : cache.resolve(packageName, owner);
|
|
300
|
-
return this._tryHelper(parts[1], from, targetPackage);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
return this._tryHelper(path, from, this.appPackage);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
_tryHelper(path, from, targetPackage) {
|
|
307
|
-
for (let extension of this.adjustImportsOptions.resolvableExtensions) {
|
|
308
|
-
let absPath = (0, path_1.join)(targetPackage.root, 'helpers', path) + extension;
|
|
309
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
310
|
-
return {
|
|
311
|
-
type: 'helper',
|
|
312
|
-
module: {
|
|
313
|
-
runtimeName: this.absPathToRuntimeName(absPath, targetPackage),
|
|
314
|
-
path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
|
|
315
|
-
absPath,
|
|
316
|
-
},
|
|
317
|
-
nameHint: path,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
tryModifier(path, from) {
|
|
324
|
-
let parts = path.split('@');
|
|
325
|
-
if (parts.length > 1 && parts[0].length > 0) {
|
|
326
|
-
let cache = core_1.PackageCache.shared('embroider-stage3', this.params.root);
|
|
327
|
-
let packageName = parts[0];
|
|
328
|
-
let renamed = this.adjustImportsOptions.renamePackages[packageName];
|
|
329
|
-
if (renamed) {
|
|
330
|
-
packageName = renamed;
|
|
331
|
-
}
|
|
332
|
-
let owner = cache.ownerOfFile(from);
|
|
333
|
-
let targetPackage = owner.name === packageName ? owner : cache.resolve(packageName, owner);
|
|
334
|
-
return this._tryModifier(parts[1], from, targetPackage);
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
return this._tryModifier(path, from, this.appPackage);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
_tryModifier(path, from, targetPackage) {
|
|
341
|
-
for (let extension of this.adjustImportsOptions.resolvableExtensions) {
|
|
342
|
-
let absPath = (0, path_1.join)(targetPackage.root, 'modifiers', path) + extension;
|
|
343
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
344
|
-
return {
|
|
345
|
-
type: 'modifier',
|
|
346
|
-
module: {
|
|
347
|
-
runtimeName: this.absPathToRuntimeName(absPath, targetPackage),
|
|
348
|
-
path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
|
|
349
|
-
absPath,
|
|
350
|
-
},
|
|
351
|
-
nameHint: path,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
get appPackage() {
|
|
358
|
-
return { root: this.params.root, name: this.params.modulePrefix };
|
|
359
|
-
}
|
|
360
|
-
tryComponent(path, from, withRuleLookup = true) {
|
|
361
|
-
let parts = path.split('@');
|
|
362
|
-
if (parts.length > 1 && parts[0].length > 0) {
|
|
363
|
-
let cache = core_1.PackageCache.shared('embroider-stage3', this.params.root);
|
|
364
|
-
let packageName = parts[0];
|
|
365
|
-
let renamed = this.adjustImportsOptions.renamePackages[packageName];
|
|
366
|
-
if (renamed) {
|
|
367
|
-
packageName = renamed;
|
|
368
|
-
}
|
|
369
|
-
let owner = cache.ownerOfFile(from);
|
|
370
|
-
let targetPackage = owner.name === packageName ? owner : cache.resolve(packageName, owner);
|
|
371
|
-
return this._tryComponent(parts[1], from, withRuleLookup, targetPackage);
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
return this._tryComponent(path, from, withRuleLookup, this.appPackage);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
_tryComponent(path, from, withRuleLookup, targetPackage) {
|
|
378
|
-
let extensions = ['.hbs', ...this.adjustImportsOptions.resolvableExtensions.filter((e) => e !== '.hbs')];
|
|
379
|
-
let hbsModule;
|
|
380
|
-
let jsModule;
|
|
381
|
-
// first, the various places our template might be
|
|
382
|
-
for (let extension of extensions) {
|
|
383
|
-
let absPath = (0, path_1.join)(targetPackage.root, 'templates', 'components', path) + extension;
|
|
384
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
385
|
-
hbsModule = absPath;
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
absPath = (0, path_1.join)(targetPackage.root, 'components', path, 'template') + extension;
|
|
389
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
390
|
-
hbsModule = absPath;
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
if (typeof this.params.podModulePrefix !== 'undefined' &&
|
|
394
|
-
this.params.podModulePrefix !== '' &&
|
|
395
|
-
targetPackage === this.appPackage) {
|
|
396
|
-
let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');
|
|
397
|
-
absPath = (0, path_1.join)(targetPackage.root, podPrefix, 'components', path, 'template') + extension;
|
|
398
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
399
|
-
hbsModule = absPath;
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
// then the various places our javascript might be
|
|
405
|
-
for (let extension of extensions) {
|
|
406
|
-
if (extension === '.hbs') {
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
let absPath = (0, path_1.join)(targetPackage.root, 'components', path, 'index') + extension;
|
|
410
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
411
|
-
jsModule = absPath;
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
absPath = (0, path_1.join)(targetPackage.root, 'components', path) + extension;
|
|
415
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
416
|
-
jsModule = absPath;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
absPath = (0, path_1.join)(targetPackage.root, 'components', path, 'component') + extension;
|
|
420
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
421
|
-
jsModule = absPath;
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
if (typeof this.params.podModulePrefix !== 'undefined' &&
|
|
425
|
-
this.params.podModulePrefix !== '' &&
|
|
426
|
-
targetPackage === this.appPackage) {
|
|
427
|
-
let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');
|
|
428
|
-
absPath = (0, path_1.join)(targetPackage.root, podPrefix, 'components', path, 'component') + extension;
|
|
429
|
-
if ((0, fs_extra_1.pathExistsSync)(absPath)) {
|
|
430
|
-
jsModule = absPath;
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (jsModule == null && hbsModule == null) {
|
|
436
|
-
return null;
|
|
437
|
-
}
|
|
438
|
-
let componentRules;
|
|
439
|
-
if (withRuleLookup) {
|
|
440
|
-
// the order here is important. We follow the convention that any rules
|
|
441
|
-
// get attached to the hbsModule if it exists, and only get attached to
|
|
442
|
-
// the jsModule otherwise
|
|
443
|
-
componentRules = this.findComponentRules((hbsModule !== null && hbsModule !== void 0 ? hbsModule : jsModule));
|
|
444
|
-
}
|
|
445
|
-
return {
|
|
446
|
-
type: 'component',
|
|
447
|
-
jsModule: jsModule
|
|
448
|
-
? {
|
|
449
|
-
path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), jsModule),
|
|
450
|
-
absPath: jsModule,
|
|
451
|
-
runtimeName: this.absPathToRuntimeName(jsModule, targetPackage),
|
|
452
|
-
}
|
|
453
|
-
: null,
|
|
454
|
-
hbsModule: hbsModule
|
|
455
|
-
? {
|
|
456
|
-
path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), hbsModule),
|
|
457
|
-
absPath: hbsModule,
|
|
458
|
-
runtimeName: this.absPathToRuntimeName(hbsModule, targetPackage),
|
|
459
|
-
}
|
|
460
|
-
: null,
|
|
461
|
-
yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],
|
|
462
|
-
yieldsArguments: componentRules ? componentRules.yieldsArguments : [],
|
|
463
|
-
argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],
|
|
464
|
-
nameHint: path,
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
resolveSubExpression(path, from, loc) {
|
|
468
|
-
if (!this.staticHelpersEnabled) {
|
|
469
|
-
return null;
|
|
470
|
-
}
|
|
471
|
-
let found = this.tryHelper(path, from);
|
|
472
|
-
if (found) {
|
|
473
|
-
return found;
|
|
474
|
-
}
|
|
475
|
-
if (builtInHelpers.includes(path)) {
|
|
476
|
-
return null;
|
|
477
|
-
}
|
|
478
|
-
return {
|
|
479
|
-
type: 'error',
|
|
480
|
-
message: `Missing helper`,
|
|
481
|
-
detail: path,
|
|
482
|
-
loc,
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
resolveMustache(path, hasArgs, from, loc) {
|
|
486
|
-
if (this.staticHelpersEnabled) {
|
|
487
|
-
let found = this.tryHelper(path, from);
|
|
488
|
-
if (found) {
|
|
489
|
-
return found;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
if (this.staticComponentsEnabled) {
|
|
493
|
-
let found = this.tryComponent(path, from);
|
|
494
|
-
if (found) {
|
|
495
|
-
return found;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (hasArgs &&
|
|
499
|
-
this.staticComponentsEnabled &&
|
|
500
|
-
this.staticHelpersEnabled &&
|
|
501
|
-
!builtInHelpers.includes(path) &&
|
|
502
|
-
!this.isIgnoredComponent(path)) {
|
|
503
|
-
return {
|
|
504
|
-
type: 'error',
|
|
505
|
-
message: `Missing component or helper`,
|
|
506
|
-
detail: path,
|
|
507
|
-
loc,
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
return null;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
resolveElementModifierStatement(path, from, loc) {
|
|
515
|
-
if (!this.staticModifiersEnabled) {
|
|
516
|
-
return null;
|
|
517
|
-
}
|
|
518
|
-
let found = this.tryModifier(path, from);
|
|
519
|
-
if (found) {
|
|
520
|
-
return found;
|
|
521
|
-
}
|
|
522
|
-
if (builtInModifiers.includes(path)) {
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
return {
|
|
526
|
-
type: 'error',
|
|
527
|
-
message: `Missing modifier`,
|
|
528
|
-
detail: path,
|
|
529
|
-
loc,
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
resolveElement(tagName, from, loc) {
|
|
533
|
-
if (!this.staticComponentsEnabled) {
|
|
534
|
-
return null;
|
|
535
|
-
}
|
|
536
|
-
if (tagName[0] === tagName[0].toLowerCase()) {
|
|
537
|
-
// starts with lower case, so this can't be a component we need to
|
|
538
|
-
// globally resolve
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
let dName = (0, dasherize_component_name_1.dasherize)(tagName);
|
|
542
|
-
if (builtInComponents.includes(dName)) {
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
let found = this.tryComponent(dName, from);
|
|
546
|
-
if (found) {
|
|
547
|
-
found.nameHint = tagName;
|
|
548
|
-
return found;
|
|
549
|
-
}
|
|
550
|
-
if (this.isIgnoredComponent(dName)) {
|
|
551
|
-
return null;
|
|
552
|
-
}
|
|
553
|
-
return {
|
|
554
|
-
type: 'error',
|
|
555
|
-
message: `Missing component`,
|
|
556
|
-
detail: tagName,
|
|
557
|
-
loc,
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
resolveComponentHelper(component, from, loc, impliedBecause) {
|
|
561
|
-
if (!this.staticComponentsEnabled) {
|
|
562
|
-
return null;
|
|
563
|
-
}
|
|
564
|
-
let message;
|
|
565
|
-
if (impliedBecause) {
|
|
566
|
-
message = `argument "${impliedBecause.argumentName}" to component "${impliedBecause.componentName}" is treated as a component, but the value you're passing is dynamic`;
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
message = `Unsafe dynamic component`;
|
|
570
|
-
}
|
|
571
|
-
if (component.type === 'other') {
|
|
572
|
-
return {
|
|
573
|
-
type: 'error',
|
|
574
|
-
message,
|
|
575
|
-
detail: `cannot statically analyze this expression`,
|
|
576
|
-
loc,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
if (component.type === 'path') {
|
|
580
|
-
let ownComponentRules = this.findComponentRules(from);
|
|
581
|
-
if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {
|
|
582
|
-
return null;
|
|
583
|
-
}
|
|
584
|
-
return {
|
|
585
|
-
type: 'error',
|
|
586
|
-
message,
|
|
587
|
-
detail: component.path,
|
|
588
|
-
loc,
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
if (builtInComponents.includes(component.path)) {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
let found = this.tryComponent(component.path, from);
|
|
595
|
-
if (found) {
|
|
596
|
-
return found;
|
|
597
|
-
}
|
|
598
|
-
return {
|
|
599
|
-
type: 'error',
|
|
600
|
-
message: `Missing component`,
|
|
601
|
-
detail: component.path,
|
|
602
|
-
loc,
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
resolveDynamicHelper(helper, from, loc) {
|
|
606
|
-
if (!this.staticHelpersEnabled) {
|
|
607
|
-
return null;
|
|
608
|
-
}
|
|
609
|
-
if (helper.type === 'literal') {
|
|
610
|
-
let helperName = helper.path;
|
|
611
|
-
if (builtInHelpers.includes(helperName)) {
|
|
612
|
-
return null;
|
|
613
|
-
}
|
|
614
|
-
let found = this.tryHelper(helperName, from);
|
|
615
|
-
if (found) {
|
|
616
|
-
return found;
|
|
617
|
-
}
|
|
618
|
-
return {
|
|
619
|
-
type: 'error',
|
|
620
|
-
message: `Missing helper`,
|
|
621
|
-
detail: helperName,
|
|
622
|
-
loc,
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
return {
|
|
627
|
-
type: 'error',
|
|
628
|
-
message: 'Unsafe dynamic helper',
|
|
629
|
-
detail: `cannot statically analyze this expression`,
|
|
630
|
-
loc,
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
resolveDynamicModifier(modifier, from, loc) {
|
|
635
|
-
if (!this.staticModifiersEnabled) {
|
|
636
|
-
return null;
|
|
637
|
-
}
|
|
638
|
-
if (modifier.type === 'literal') {
|
|
639
|
-
let modifierName = modifier.path;
|
|
640
|
-
if (builtInModifiers.includes(modifierName)) {
|
|
641
|
-
return null;
|
|
642
|
-
}
|
|
643
|
-
let found = this.tryModifier(modifierName, from);
|
|
644
|
-
if (found) {
|
|
645
|
-
return found;
|
|
646
|
-
}
|
|
647
|
-
return {
|
|
648
|
-
type: 'error',
|
|
649
|
-
message: `Missing modifier`,
|
|
650
|
-
detail: modifierName,
|
|
651
|
-
loc,
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
return {
|
|
656
|
-
type: 'error',
|
|
657
|
-
message: 'Unsafe dynamic modifier',
|
|
658
|
-
detail: `cannot statically analyze this expression`,
|
|
659
|
-
loc,
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
__decorate([
|
|
665
|
-
(0, typescript_memoize_1.Memoize)()
|
|
666
|
-
], CompatResolver.prototype, "adjustImportsOptions", null);
|
|
667
|
-
__decorate([
|
|
668
|
-
(0, typescript_memoize_1.Memoize)()
|
|
669
|
-
], CompatResolver.prototype, "rules", null);
|
|
670
|
-
__decorate([
|
|
671
|
-
(0, typescript_memoize_1.Memoize)()
|
|
672
|
-
], CompatResolver.prototype, "resolvableExtensionsPattern", null);
|
|
673
|
-
__decorate([
|
|
674
|
-
(0, typescript_memoize_1.Memoize)()
|
|
675
|
-
], CompatResolver.prototype, "appPackage", null);
|
|
676
|
-
exports.default = CompatResolver;
|
|
677
|
-
//# sourceMappingURL=resolver.js.map
|