@embroider/compat 3.6.2-unstable.2ff89c0 → 3.6.2-unstable.72d2f54
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 -5
- package/src/babel-plugin-adjust-imports.js +17 -16
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/babel.js +14 -2
- package/src/babel.js.map +1 -1
- package/src/compat-adapters/active-model-adapter.d.ts +1 -1
- package/src/compat-adapters/ember-asset-loader.d.ts +1 -1
- package/src/compat-adapters/ember-cli-addon-docs.d.ts +1 -1
- package/src/compat-adapters/ember-decorators.d.ts +1 -1
- package/src/compat-adapters/ember-macro-helpers.d.ts +1 -1
- package/src/compat-adapters/ember-percy.d.ts +1 -1
- package/src/compat-adapters/ember-resolver.d.ts +1 -1
- package/src/compat-adapters/ember-scroll-modifiers.d.ts +1 -1
- package/src/compat-adapters/ember-source.d.ts +2 -2
- package/src/compat-adapters/ember-test-selectors.d.ts +1 -1
- package/src/compat-app-builder.d.ts +1 -11
- package/src/compat-app-builder.js +31 -183
- package/src/compat-app-builder.js.map +1 -1
- package/src/resolver-transform.js +2 -2
- package/src/resolver-transform.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "3.6.2-unstable.
|
|
3
|
+
"version": "3.6.2-unstable.72d2f54",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"typescript-memoize": "^1.0.1",
|
|
64
64
|
"walk-sync": "^3.0.0",
|
|
65
65
|
"yargs": "^17.0.1",
|
|
66
|
-
"@embroider/macros": "1.16.7-unstable.
|
|
66
|
+
"@embroider/macros": "1.16.7-unstable.72d2f54"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@glimmer/syntax": "^0.84.3",
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
"@types/resolve": "^1.20.0",
|
|
83
83
|
"@types/semver": "^7.3.6",
|
|
84
84
|
"broccoli-node-api": "^1.7.0",
|
|
85
|
-
"code-equality-assertions": "^0.
|
|
85
|
+
"code-equality-assertions": "^1.0.1",
|
|
86
86
|
"ember-engines": "^0.8.19",
|
|
87
87
|
"scenario-tester": "^3.0.1",
|
|
88
88
|
"typescript": "^5.4.5",
|
|
89
|
-
"@embroider/core": "^3.4.16-unstable.
|
|
89
|
+
"@embroider/core": "^3.4.16-unstable.72d2f54",
|
|
90
90
|
"@embroider/sample-transforms": "0.0.0",
|
|
91
91
|
"@embroider/test-support": "0.36.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@embroider/core": "^3.4.16-unstable.
|
|
94
|
+
"@embroider/core": "^3.4.16-unstable.72d2f54"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": "12.* || 14.* || >= 16"
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = main;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const babel_import_util_1 = require("babel-import-util");
|
|
6
|
-
const fs_extra_1 = require("fs-extra");
|
|
7
6
|
const core_1 = require("@embroider/core");
|
|
8
7
|
const dasherize_component_name_1 = require("./dasherize-component-name");
|
|
9
8
|
const dependency_rules_1 = require("./dependency-rules");
|
|
@@ -14,13 +13,11 @@ function main(babel) {
|
|
|
14
13
|
if (cached) {
|
|
15
14
|
return cached;
|
|
16
15
|
}
|
|
17
|
-
let
|
|
18
|
-
let resolver = new core_1.Resolver(resolverOptions);
|
|
16
|
+
let loader = new core_1.ResolverLoader(appRoot);
|
|
19
17
|
cached = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
componentExtraImports: preprocessComponentExtraImports(resolverOptions),
|
|
18
|
+
loader,
|
|
19
|
+
extraImports: preprocessExtraImports(loader),
|
|
20
|
+
componentExtraImports: preprocessComponentExtraImports(loader),
|
|
24
21
|
};
|
|
25
22
|
return cached;
|
|
26
23
|
}
|
|
@@ -44,7 +41,7 @@ function addExtraImports(t, path, config) {
|
|
|
44
41
|
if (entry) {
|
|
45
42
|
applyRules(t, path, entry, adder, config, filename);
|
|
46
43
|
}
|
|
47
|
-
let componentName = config.resolver.reverseComponentLookup(filename);
|
|
44
|
+
let componentName = config.loader.resolver.reverseComponentLookup(filename);
|
|
48
45
|
if (componentName) {
|
|
49
46
|
let rules = config.componentExtraImports[componentName];
|
|
50
47
|
if (rules) {
|
|
@@ -83,9 +80,11 @@ function amdDefine(t, adder, path, target, runtimeName) {
|
|
|
83
80
|
t.functionExpression(null, [], t.blockStatement([t.returnStatement(value)])),
|
|
84
81
|
]));
|
|
85
82
|
}
|
|
86
|
-
function preprocessExtraImports(
|
|
83
|
+
function preprocessExtraImports(loader) {
|
|
84
|
+
var _a;
|
|
87
85
|
let extraImports = {};
|
|
88
|
-
|
|
86
|
+
let config = loader.resolver.options;
|
|
87
|
+
for (let rule of (_a = config.activePackageRules) !== null && _a !== void 0 ? _a : []) {
|
|
89
88
|
if (rule.addonModules) {
|
|
90
89
|
for (let [filename, moduleRules] of Object.entries(rule.addonModules)) {
|
|
91
90
|
for (let root of rule.roots) {
|
|
@@ -101,7 +100,7 @@ function preprocessExtraImports(config, resolver) {
|
|
|
101
100
|
// But this code is only for applying packageRules to auto-upgraded v1
|
|
102
101
|
// addons, and those we always organize with their treeForApp output
|
|
103
102
|
// in _app_.
|
|
104
|
-
expandDependsOnRules((0, dependency_rules_1.appTreeRulesDir)(root, resolver), filename, moduleRules, extraImports);
|
|
103
|
+
expandDependsOnRules((0, dependency_rules_1.appTreeRulesDir)(root, loader.resolver), filename, moduleRules, extraImports);
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
}
|
|
@@ -115,7 +114,7 @@ function preprocessExtraImports(config, resolver) {
|
|
|
115
114
|
if (rule.appTemplates) {
|
|
116
115
|
for (let [filename, moduleRules] of Object.entries(rule.appTemplates)) {
|
|
117
116
|
for (let root of rule.roots) {
|
|
118
|
-
expandInvokesRules((0, dependency_rules_1.appTreeRulesDir)(root, resolver), filename, moduleRules, extraImports);
|
|
117
|
+
expandInvokesRules((0, dependency_rules_1.appTreeRulesDir)(root, loader.resolver), filename, moduleRules, extraImports);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
}
|
|
@@ -128,7 +127,7 @@ function lazyPackageLookup(config, filename) {
|
|
|
128
127
|
return {
|
|
129
128
|
get owningPackage() {
|
|
130
129
|
if (!owningPackage) {
|
|
131
|
-
owningPackage = { result: config.resolver.packageCache.ownerOfFile(filename) };
|
|
130
|
+
owningPackage = { result: config.loader.resolver.packageCache.ownerOfFile(filename) };
|
|
132
131
|
}
|
|
133
132
|
return owningPackage.result;
|
|
134
133
|
},
|
|
@@ -137,16 +136,18 @@ function lazyPackageLookup(config, filename) {
|
|
|
137
136
|
owningEngine = { result: undefined };
|
|
138
137
|
let p = this.owningPackage;
|
|
139
138
|
if (p) {
|
|
140
|
-
owningEngine.result = config.resolver.owningEngine(p);
|
|
139
|
+
owningEngine.result = config.loader.resolver.owningEngine(p);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
return owningEngine.result;
|
|
144
143
|
},
|
|
145
144
|
};
|
|
146
145
|
}
|
|
147
|
-
function preprocessComponentExtraImports(
|
|
146
|
+
function preprocessComponentExtraImports(loader) {
|
|
147
|
+
var _a;
|
|
148
148
|
let extraImports = {};
|
|
149
|
-
|
|
149
|
+
let config = loader.resolver.options;
|
|
150
|
+
for (let rule of (_a = config.activePackageRules) !== null && _a !== void 0 ? _a : []) {
|
|
150
151
|
if (rule.components) {
|
|
151
152
|
for (let [componentName, rules] of Object.entries(rule.components)) {
|
|
152
153
|
if (rules.invokes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-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AC9B,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/F,CAAC;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,IAAY,EACZ,QAAgB,EAChB,KAAoB,EACpB,YAA4C;IAE5C,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,IAAI,mBAAmB,GAAa,EAAE,CAAC;QACvC,KAAK,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,KAAK,IAAI,SAAS,IAAI,aAAa,EAAE,CAAC;gBACpC,IAAI,CAAC,GAAG,IAAA,kDAAuB,EAAC,SAAS,CAAC,CAAC;gBAC3C,IAAI,CAAC,CAAC,EAAE,CAAC;oBACP,MAAM,IAAI,KAAK,CACb,sCAAsC,SAAS,eAAe,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAC/F,CAAC;gBACJ,CAAC;gBACD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import { join } from 'path';\nimport type { NodePath } from '@babel/traverse';\nimport type * as Babel from '@babel/core';\nimport type { types as t } from '@babel/core';\nimport { ImportUtil } from 'babel-import-util';\nimport { readJSONSync } from 'fs-extra';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { Package } from '@embroider/core';\nimport { cleanUrl, locateEmbroiderWorkingDir, packageName, Resolver, unrelativize } from '@embroider/core';\nimport { snippetToDasherizedName } from './dasherize-component-name';\nimport type { ActivePackageRules, ComponentRules, ModuleRules, TemplateRules } from './dependency-rules';\nimport { appTreeRulesDir } from './dependency-rules';\n\nexport type Options = { appRoot: string };\n\ninterface State {\n opts: Options;\n}\n\ntype BabelTypes = typeof t;\n\ninterface ExtraImports {\n [key: string]: {\n dependsOnComponents?: string[]; // these are already standardized in dasherized form\n dependsOnModules?: string[];\n };\n}\n\ntype InternalConfig = {\n resolverOptions: CompatResolverOptions;\n resolver: Resolver;\n\n // rule-based extra dependencies, indexed by filename\n extraImports: ExtraImports;\n\n // rule-based extra dependencies, indexed by classical component name\n componentExtraImports: ExtraImports;\n};\n\nexport default function main(babel: typeof Babel) {\n let t = babel.types;\n let cached: InternalConfig | undefined;\n function getConfig(appRoot: string) {\n if (cached) {\n return cached;\n }\n let resolverOptions: CompatResolverOptions = readJSONSync(\n join(locateEmbroiderWorkingDir(appRoot), 'resolver.json')\n );\n let resolver = new Resolver(resolverOptions);\n cached = {\n resolverOptions,\n resolver,\n extraImports: preprocessExtraImports(resolverOptions, resolver),\n componentExtraImports: preprocessComponentExtraImports(resolverOptions),\n };\n return cached;\n }\n\n return {\n visitor: {\n Program: {\n enter(path: NodePath<t.Program>, state: State) {\n addExtraImports(t, path, getConfig(state.opts.appRoot));\n },\n },\n },\n };\n}\n\n(main as any).baseDir = function () {\n return join(__dirname, '..');\n};\n\nfunction addExtraImports(t: BabelTypes, path: NodePath<t.Program>, config: InternalConfig) {\n let filename: string = cleanUrl((path.hub as any).file.opts.filename);\n let entry = config.extraImports[filename];\n let adder = new ImportUtil(t, path);\n if (entry) {\n applyRules(t, path, entry, adder, config, filename);\n }\n\n let componentName = config.resolver.reverseComponentLookup(filename);\n if (componentName) {\n let rules = config.componentExtraImports[componentName];\n if (rules) {\n applyRules(t, path, rules, adder, config, filename);\n }\n }\n}\n\nfunction applyRules(\n t: BabelTypes,\n path: NodePath<t.Program>,\n rules: ExtraImports[string],\n adder: ImportUtil,\n config: InternalConfig,\n filename: string\n) {\n let lookup = lazyPackageLookup(config, filename);\n if (rules.dependsOnModules) {\n for (let target of rules.dependsOnModules) {\n if (lookup.owningPackage) {\n let runtimeName: string;\n if (packageName(target)) {\n runtimeName = target;\n } else {\n runtimeName = unrelativize(lookup.owningPackage, target, filename);\n }\n path.node.body.unshift(amdDefine(t, adder, path, target, runtimeName));\n }\n }\n }\n if (rules.dependsOnComponents) {\n for (let dasherizedName of rules.dependsOnComponents) {\n if (lookup.owningEngine) {\n path.node.body.unshift(\n amdDefine(\n t,\n adder,\n path,\n `@embroider/virtual/components/${dasherizedName}`,\n `${lookup.owningEngine.packageName}/components/${dasherizedName}`\n )\n );\n }\n }\n }\n}\n\nfunction amdDefine(t: BabelTypes, adder: ImportUtil, path: NodePath<t.Program>, target: string, runtimeName: string) {\n let value = t.callExpression(adder.import(path, '@embroider/macros', 'importSync'), [t.stringLiteral(target)]);\n return t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('window'), t.identifier('define')), [\n t.stringLiteral(runtimeName),\n t.functionExpression(null, [], t.blockStatement([t.returnStatement(value)])),\n ])\n );\n}\n\nfunction preprocessExtraImports(config: CompatResolverOptions, resolver: Resolver): ExtraImports {\n let extraImports: ExtraImports = {};\n for (let rule of config.activePackageRules) {\n if (rule.addonModules) {\n for (let [filename, moduleRules] of Object.entries(rule.addonModules)) {\n for (let root of rule.roots) {\n expandDependsOnRules(root, filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.appModules) {\n for (let [filename, moduleRules] of Object.entries(rule.appModules)) {\n for (let root of rule.roots) {\n // in general v2 addons can keep their app tree stuff in other places\n // than \"_app_\" and we would need to check their package.json to see.\n // But this code is only for applying packageRules to auto-upgraded v1\n // addons, and those we always organize with their treeForApp output\n // in _app_.\n expandDependsOnRules(appTreeRulesDir(root, resolver), filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.addonTemplates) {\n for (let [filename, moduleRules] of Object.entries(rule.addonTemplates)) {\n for (let root of rule.roots) {\n expandInvokesRules(root, filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.appTemplates) {\n for (let [filename, moduleRules] of Object.entries(rule.appTemplates)) {\n for (let root of rule.roots) {\n expandInvokesRules(appTreeRulesDir(root, resolver), filename, moduleRules, extraImports);\n }\n }\n }\n }\n return extraImports;\n}\n\nfunction lazyPackageLookup(config: InternalConfig, filename: string) {\n let owningPackage: { result: Package | undefined } | undefined;\n let owningEngine: { result: ReturnType<Resolver['owningEngine']> | undefined } | undefined;\n return {\n get owningPackage() {\n if (!owningPackage) {\n owningPackage = { result: config.resolver.packageCache.ownerOfFile(filename) };\n }\n return owningPackage.result;\n },\n get owningEngine() {\n if (!owningEngine) {\n owningEngine = { result: undefined };\n let p = this.owningPackage;\n if (p) {\n owningEngine.result = config.resolver.owningEngine(p);\n }\n }\n return owningEngine.result;\n },\n };\n}\n\nfunction preprocessComponentExtraImports(config: CompatResolverOptions): ExtraImports {\n let extraImports: ExtraImports = {};\n for (let rule of config.activePackageRules) {\n if (rule.components) {\n for (let [componentName, rules] of Object.entries(rule.components)) {\n if (rules.invokes) {\n extraImports[dasherizeComponent(componentName, rule)] = {\n dependsOnComponents: Object.values(rules.invokes)\n .flat()\n .map(c => dasherizeComponent(c, rules)),\n };\n }\n }\n }\n }\n return extraImports;\n}\n\nfunction dasherizeComponent(\n componentSnippet: string,\n rules: ModuleRules | ComponentRules | ActivePackageRules\n): string {\n let d = snippetToDasherizedName(componentSnippet);\n if (!d) {\n throw new Error(\n `unable to parse component snippet \"${componentSnippet}\" from rule ${JSON.stringify(rules, null, 2)}`\n );\n }\n return d;\n}\n\nfunction expandDependsOnRules(\n root: string,\n filename: string,\n rules: ModuleRules,\n extraImports: InternalConfig['extraImports']\n) {\n if (rules.dependsOnModules || rules.dependsOnComponents) {\n let entry: InternalConfig['extraImports'][string] = {};\n if (rules.dependsOnModules) {\n entry.dependsOnModules = rules.dependsOnModules;\n }\n if (rules.dependsOnComponents) {\n entry.dependsOnComponents = rules.dependsOnComponents.map(c => dasherizeComponent(c, rules));\n }\n extraImports[join(root, filename)] = entry;\n }\n}\n\nfunction expandInvokesRules(\n root: string,\n filename: string,\n rules: TemplateRules,\n extraImports: InternalConfig['extraImports']\n) {\n if (rules.invokes) {\n let dependsOnComponents: string[] = [];\n for (let componentList of Object.values(rules.invokes)) {\n for (let component of componentList) {\n let d = snippetToDasherizedName(component);\n if (!d) {\n throw new Error(\n `unable to parse component snippet \"${component}\" from rule ${JSON.stringify(rules, null, 2)}`\n );\n }\n dependsOnComponents.push(d);\n }\n }\n extraImports[join(root, filename)] = { dependsOnComponents };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"babel-plugin-adjust-imports.js","sourceRoot":"","sources":["babel-plugin-adjust-imports.ts"],"names":[],"mappings":";;AAqCA,uBA0BC;AA/DD,+BAA4B;AAI5B,yDAA+C;AAG/C,0CAAqG;AACrG,yEAAqE;AAErE,yDAAqD;AA2BrD,SAAwB,IAAI,CAAC,KAAmB;IAC9C,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IACpB,IAAI,MAAkC,CAAC;IACvC,SAAS,SAAS,CAAC,OAAe;QAChC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,MAAM,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,GAAG;YACP,MAAM;YACN,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC;YAC5C,qBAAqB,EAAE,+BAA+B,CAAC,MAAM,CAAC;SAC/D,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,KAAK,CAAC,IAAyB,EAAE,KAAY;oBAC3C,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC1D,CA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K,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAC/F,CAAC;gBACJ,CAAC;gBACD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import { join } from 'path';\nimport type { NodePath } from '@babel/traverse';\nimport type * as Babel from '@babel/core';\nimport type { types as t } from '@babel/core';\nimport { ImportUtil } from 'babel-import-util';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { Package } from '@embroider/core';\nimport { cleanUrl, packageName, type Resolver, ResolverLoader, unrelativize } from '@embroider/core';\nimport { snippetToDasherizedName } from './dasherize-component-name';\nimport type { ActivePackageRules, ComponentRules, ModuleRules, TemplateRules } from './dependency-rules';\nimport { appTreeRulesDir } from './dependency-rules';\n\nexport type Options = { appRoot: string };\n\ninterface State {\n opts: Options;\n}\n\ntype BabelTypes = typeof t;\n\ninterface ExtraImports {\n [key: string]: {\n dependsOnComponents?: string[]; // these are already standardized in dasherized form\n dependsOnModules?: string[];\n };\n}\n\ntype InternalConfig = {\n loader: ResolverLoader;\n\n // rule-based extra dependencies, indexed by filename\n extraImports: ExtraImports;\n\n // rule-based extra dependencies, indexed by classical component name\n componentExtraImports: ExtraImports;\n};\n\nexport default function main(babel: typeof Babel) {\n let t = babel.types;\n let cached: InternalConfig | undefined;\n function getConfig(appRoot: string) {\n if (cached) {\n return cached;\n }\n let loader = new ResolverLoader(appRoot);\n\n cached = {\n loader,\n extraImports: preprocessExtraImports(loader),\n componentExtraImports: preprocessComponentExtraImports(loader),\n };\n return cached;\n }\n\n return {\n visitor: {\n Program: {\n enter(path: NodePath<t.Program>, state: State) {\n addExtraImports(t, path, getConfig(state.opts.appRoot));\n },\n },\n },\n };\n}\n\n(main as any).baseDir = function () {\n return join(__dirname, '..');\n};\n\nfunction addExtraImports(t: BabelTypes, path: NodePath<t.Program>, config: InternalConfig) {\n let filename: string = cleanUrl((path.hub as any).file.opts.filename);\n let entry = config.extraImports[filename];\n let adder = new ImportUtil(t, path);\n if (entry) {\n applyRules(t, path, entry, adder, config, filename);\n }\n\n let componentName = config.loader.resolver.reverseComponentLookup(filename);\n if (componentName) {\n let rules = config.componentExtraImports[componentName];\n if (rules) {\n applyRules(t, path, rules, adder, config, filename);\n }\n }\n}\n\nfunction applyRules(\n t: BabelTypes,\n path: NodePath<t.Program>,\n rules: ExtraImports[string],\n adder: ImportUtil,\n config: InternalConfig,\n filename: string\n) {\n let lookup = lazyPackageLookup(config, filename);\n if (rules.dependsOnModules) {\n for (let target of rules.dependsOnModules) {\n if (lookup.owningPackage) {\n let runtimeName: string;\n if (packageName(target)) {\n runtimeName = target;\n } else {\n runtimeName = unrelativize(lookup.owningPackage, target, filename);\n }\n path.node.body.unshift(amdDefine(t, adder, path, target, runtimeName));\n }\n }\n }\n if (rules.dependsOnComponents) {\n for (let dasherizedName of rules.dependsOnComponents) {\n if (lookup.owningEngine) {\n path.node.body.unshift(\n amdDefine(\n t,\n adder,\n path,\n `@embroider/virtual/components/${dasherizedName}`,\n `${lookup.owningEngine.packageName}/components/${dasherizedName}`\n )\n );\n }\n }\n }\n}\n\nfunction amdDefine(t: BabelTypes, adder: ImportUtil, path: NodePath<t.Program>, target: string, runtimeName: string) {\n let value = t.callExpression(adder.import(path, '@embroider/macros', 'importSync'), [t.stringLiteral(target)]);\n return t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('window'), t.identifier('define')), [\n t.stringLiteral(runtimeName),\n t.functionExpression(null, [], t.blockStatement([t.returnStatement(value)])),\n ])\n );\n}\n\nfunction preprocessExtraImports(loader: ResolverLoader): ExtraImports {\n let extraImports: ExtraImports = {};\n let config = loader.resolver.options as CompatResolverOptions;\n for (let rule of config.activePackageRules ?? []) {\n if (rule.addonModules) {\n for (let [filename, moduleRules] of Object.entries(rule.addonModules)) {\n for (let root of rule.roots) {\n expandDependsOnRules(root, filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.appModules) {\n for (let [filename, moduleRules] of Object.entries(rule.appModules)) {\n for (let root of rule.roots) {\n // in general v2 addons can keep their app tree stuff in other places\n // than \"_app_\" and we would need to check their package.json to see.\n // But this code is only for applying packageRules to auto-upgraded v1\n // addons, and those we always organize with their treeForApp output\n // in _app_.\n expandDependsOnRules(appTreeRulesDir(root, loader.resolver), filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.addonTemplates) {\n for (let [filename, moduleRules] of Object.entries(rule.addonTemplates)) {\n for (let root of rule.roots) {\n expandInvokesRules(root, filename, moduleRules, extraImports);\n }\n }\n }\n if (rule.appTemplates) {\n for (let [filename, moduleRules] of Object.entries(rule.appTemplates)) {\n for (let root of rule.roots) {\n expandInvokesRules(appTreeRulesDir(root, loader.resolver), filename, moduleRules, extraImports);\n }\n }\n }\n }\n return extraImports;\n}\n\nfunction lazyPackageLookup(config: InternalConfig, filename: string) {\n let owningPackage: { result: Package | undefined } | undefined;\n let owningEngine: { result: ReturnType<Resolver['owningEngine']> | undefined } | undefined;\n return {\n get owningPackage() {\n if (!owningPackage) {\n owningPackage = { result: config.loader.resolver.packageCache.ownerOfFile(filename) };\n }\n return owningPackage.result;\n },\n get owningEngine() {\n if (!owningEngine) {\n owningEngine = { result: undefined };\n let p = this.owningPackage;\n if (p) {\n owningEngine.result = config.loader.resolver.owningEngine(p);\n }\n }\n return owningEngine.result;\n },\n };\n}\n\nfunction preprocessComponentExtraImports(loader: ResolverLoader): ExtraImports {\n let extraImports: ExtraImports = {};\n let config = loader.resolver.options as CompatResolverOptions;\n for (let rule of config.activePackageRules ?? []) {\n if (rule.components) {\n for (let [componentName, rules] of Object.entries(rule.components)) {\n if (rules.invokes) {\n extraImports[dasherizeComponent(componentName, rule)] = {\n dependsOnComponents: Object.values(rules.invokes)\n .flat()\n .map(c => dasherizeComponent(c, rules)),\n };\n }\n }\n }\n }\n return extraImports;\n}\n\nfunction dasherizeComponent(\n componentSnippet: string,\n rules: ModuleRules | ComponentRules | ActivePackageRules\n): string {\n let d = snippetToDasherizedName(componentSnippet);\n if (!d) {\n throw new Error(\n `unable to parse component snippet \"${componentSnippet}\" from rule ${JSON.stringify(rules, null, 2)}`\n );\n }\n return d;\n}\n\nfunction expandDependsOnRules(\n root: string,\n filename: string,\n rules: ModuleRules,\n extraImports: InternalConfig['extraImports']\n) {\n if (rules.dependsOnModules || rules.dependsOnComponents) {\n let entry: InternalConfig['extraImports'][string] = {};\n if (rules.dependsOnModules) {\n entry.dependsOnModules = rules.dependsOnModules;\n }\n if (rules.dependsOnComponents) {\n entry.dependsOnComponents = rules.dependsOnComponents.map(c => dasherizeComponent(c, rules));\n }\n extraImports[join(root, filename)] = entry;\n }\n}\n\nfunction expandInvokesRules(\n root: string,\n filename: string,\n rules: TemplateRules,\n extraImports: InternalConfig['extraImports']\n) {\n if (rules.invokes) {\n let dependsOnComponents: string[] = [];\n for (let componentList of Object.values(rules.invokes)) {\n for (let component of componentList) {\n let d = snippetToDasherizedName(component);\n if (!d) {\n throw new Error(\n `unable to parse component snippet \"${component}\" from rule ${JSON.stringify(rules, null, 2)}`\n );\n }\n dependsOnComponents.push(d);\n }\n }\n extraImports[join(root, filename)] = { dependsOnComponents };\n }\n}\n"]}
|
package/src/babel.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.pluginsFromV1Addons = pluginsFromV1Addons;
|
|
4
7
|
exports.transformsFromV1Addons = transformsFromV1Addons;
|
|
@@ -13,17 +16,26 @@ exports.templateCompatSupport = templateCompatSupport;
|
|
|
13
16
|
const fs_1 = require("fs");
|
|
14
17
|
const core_1 = require("@embroider/core");
|
|
15
18
|
const path_1 = require("path");
|
|
19
|
+
const macros_config_1 = __importDefault(require("@embroider/macros/src/macros-config"));
|
|
16
20
|
function loadCompatConfig() {
|
|
17
21
|
let compatFile = (0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(process.cwd()), '_babel_compat_.js');
|
|
18
22
|
if ((0, fs_1.existsSync)(compatFile)) {
|
|
19
23
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
20
24
|
return require(compatFile);
|
|
21
25
|
}
|
|
26
|
+
let macros = macros_config_1.default.for({}, process.cwd());
|
|
27
|
+
let { plugins: templateMacros, setConfig } = macros_config_1.default.transforms();
|
|
28
|
+
setConfig(macros);
|
|
29
|
+
if (process.env.NODE_ENV === 'development') {
|
|
30
|
+
macros.enablePackageDevelopment(process.cwd());
|
|
31
|
+
macros.enableRuntimeMode();
|
|
32
|
+
}
|
|
33
|
+
macros.finalize();
|
|
22
34
|
return {
|
|
23
35
|
plugins: [],
|
|
24
36
|
templateTransforms: [],
|
|
25
|
-
babelMacros:
|
|
26
|
-
templateMacros:
|
|
37
|
+
babelMacros: macros.babelPluginConfig(),
|
|
38
|
+
templateMacros: templateMacros,
|
|
27
39
|
};
|
|
28
40
|
}
|
|
29
41
|
const resolverLoader = new core_1.ResolverLoader(process.cwd());
|
package/src/babel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel.js","sourceRoot":"","sources":["babel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"babel.js","sourceRoot":"","sources":["babel.ts"],"names":[],"mappings":";;;;;AA6CA,kDAGC;AAED,wDAGC;AAED,4CAOC;AAED,wCAGC;AAED,kCAGC;AAED,sCAKC;AAED,wCAyCC;AAED,gDAkCC;AAED,gDAEC;AAED,sDAEC;AArKD,2BAAgC;AAChC,0CAKyB;AACzB,+BAA4B;AAI5B,wFAA+D;AAS/D,SAAS,gBAAgB;IACvB,IAAI,UAAU,GAAG,IAAA,WAAI,EAA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B;aACF;YACD,2CAA2C;SAC5C;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB;IAChC,IAAI,iBAAiB,GAAoC;QACvD,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO;QAEhD,sEAAsE;QACtE,EAAE;QACF,uEAAuE;QACvE,8CAA8C;QAC9C,EAAE;QACF,0EAA0E;QAC1E,wEAAwE;QACxE,qEAAqE;QACrE,2DAA2D;QAC3D,EAAE;QACF,uEAAuE;QACvE,4CAA4C;QAC5C,EAAE;QACF,+DAA+D;QAC/D,6DAA6D;QAC7D,wEAAwE;QACxE,sEAAsE;QACtE,gBAAgB;QAChB,EAAE;QACF,yEAAyE;QACzE,wEAAwE;QACxE,kBAAkB;QAClB,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAEvC,oEAAoE;QACpE,wEAAwE;QACxE,sEAAsE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAC;IACF,OAAO,CAAC,mCAA4B,EAAE,iBAAiB,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,CAAC,GAAG,WAAW,EAAE,EAAE,aAAa,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,mBAAmB,EAAE,CAAC,CAAC;AAClH,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,CAAC,GAAG,sBAAsB,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import type { PluginItem } from '@babel/core';\nimport { existsSync } from 'fs';\nimport {\n locateEmbroiderWorkingDir,\n ResolverLoader,\n templateColocationPluginPath,\n type TemplateColocationPluginOptions,\n} from '@embroider/core';\nimport { join } from 'path';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport type { Options as ResolverTransformOptions } from './resolver-transform';\nimport type { Options as AdjustImportsOptions } from './babel-plugin-adjust-imports';\nimport MacrosConfig from '@embroider/macros/src/macros-config';\n\nexport interface CompatBabelState {\n plugins: PluginItem[];\n templateTransforms: Transform[];\n babelMacros: PluginItem[];\n templateMacros: Transform[];\n}\n\nfunction loadCompatConfig(): CompatBabelState {\n let compatFile = join(locateEmbroiderWorkingDir(process.cwd()), '_babel_compat_.js');\n if (existsSync(compatFile)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(compatFile);\n }\n let macros = MacrosConfig.for({}, process.cwd());\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(macros);\n if (process.env.NODE_ENV === 'development') {\n macros.enablePackageDevelopment(process.cwd());\n macros.enableRuntimeMode();\n }\n macros.finalize();\n return {\n plugins: [],\n templateTransforms: [],\n babelMacros: macros.babelPluginConfig(),\n templateMacros: templateMacros as any,\n };\n}\n\nconst resolverLoader = new ResolverLoader(process.cwd());\n\nexport function pluginsFromV1Addons() {\n let config = loadCompatConfig();\n return config.plugins;\n}\n\nexport function transformsFromV1Addons() {\n let config = loadCompatConfig();\n return config.templateTransforms;\n}\n\nexport function looseModeSupport(): Transform {\n const { resolver } = resolverLoader;\n let opts: ResolverTransformOptions = {\n appRoot: resolver.options.appRoot,\n emberVersion: resolver.options.emberVersion,\n };\n return [require.resolve('./resolver-transform'), opts];\n}\n\nexport function templateMacros() {\n let config = loadCompatConfig();\n return config.templateMacros;\n}\n\nexport function babelMacros() {\n let config = loadCompatConfig();\n return config.babelMacros;\n}\n\nexport function adjustImports() {\n let pluginConfig: AdjustImportsOptions = {\n appRoot: resolverLoader.resolver.options.appRoot,\n };\n return [require.resolve('./babel-plugin-adjust-imports'), pluginConfig];\n}\n\nexport function oldDebugMacros(): PluginItem[] {\n let debugMacros = require.resolve('babel-plugin-debug-macros');\n return [\n [\n debugMacros,\n {\n flags: [\n {\n source: '@glimmer/env',\n flags: {\n DEBUG: true,\n CI: false,\n },\n },\n ],\n debugTools: {\n isDebug: true,\n source: '@ember/debug',\n assertPredicateIndex: 1,\n },\n externalizeHelpers: {\n module: '@ember/debug',\n },\n },\n '@ember/debug stripping',\n ],\n [\n debugMacros,\n {\n externalizeHelpers: {\n module: '@ember/application/deprecations',\n },\n debugTools: {\n isDebug: true,\n source: '@ember/application/deprecations',\n assertPredicateIndex: 1,\n },\n },\n '@ember/application/deprecations stripping',\n ],\n ];\n}\n\nexport function templateColocation(): PluginItem {\n let colocationOptions: TemplateColocationPluginOptions = {\n appRoot: resolverLoader.resolver.options.appRoot,\n\n // This extra weirdness is a compromise in favor of build performance.\n //\n // 1. When auto-upgrading an addon from v1 to v2, we definitely want to\n // run any custom AST transforms in stage1.\n //\n // 2. In general case, AST transforms are allowed to manipulate Javascript\n // scope. This means that running transforms -- even when we're doing\n // source-to-source compilation that emits handlebars and not wire\n // format -- implies changing .hbs files into .js files.\n //\n // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding\n // with an existing co-located .js file).\n //\n // 4. But stage1 doesn't necessarily want to run babel over the\n // corresponding JS file. Most of the time, that's just an\n // unnecessarily expensive second parse. (We only run it in stage1 to\n // eliminate an addon's custom babel plugins, and many addons don't\n // have any.)\n //\n // 5. Therefore, the work of template-colocation gets defered until here,\n // and it may see co-located templates named `.hbs.js` instead of the\n // usual `.hbs.\n templateExtensions: ['.hbs', '.hbs.js'],\n\n // All of the above only applies to auto-upgraded packages that were\n // authored in v1. V2 packages don't get any of this complexity, they're\n // supposed to take care of colocating their own templates explicitly.\n packageGuard: true,\n };\n return [templateColocationPluginPath, colocationOptions];\n}\n\nexport function babelCompatSupport(): PluginItem[] {\n return [...babelMacros(), adjustImports(), ...oldDebugMacros(), templateColocation(), ...pluginsFromV1Addons()];\n}\n\nexport function templateCompatSupport(): Transform[] {\n return [...transformsFromV1Addons(), ...templateMacros(), looseModeSupport()];\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import V1Addon from '../v1-addon';
|
|
2
2
|
export default class extends V1Addon {
|
|
3
3
|
get v2Tree(): import("broccoli-funnel").Funnel;
|
|
4
|
-
get packageMeta(): Partial<import("@embroider/
|
|
4
|
+
get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
|
|
5
5
|
}
|
|
@@ -3,12 +3,12 @@ export default class extends V1Addon {
|
|
|
3
3
|
get v2Tree(): Node;
|
|
4
4
|
private get useStaticEmber();
|
|
5
5
|
private get includedDependencies();
|
|
6
|
-
get newPackageJSON(): import("@embroider/
|
|
6
|
+
get newPackageJSON(): import("@embroider/shared-internals").PackageInfo;
|
|
7
7
|
customizes(treeName: string): boolean;
|
|
8
8
|
invokeOriginalTreeFor(name: string, opts?: {
|
|
9
9
|
neuterPreprocessors: boolean;
|
|
10
10
|
}): any;
|
|
11
11
|
private customAddonTree;
|
|
12
12
|
private customVendorTree;
|
|
13
|
-
get packageMeta(): Partial<import("@embroider/
|
|
13
|
+
get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import V1Addon from '../v1-addon';
|
|
2
2
|
export default class extends V1Addon {
|
|
3
3
|
static shouldApplyAdapter(addonInstance: any): boolean;
|
|
4
|
-
get packageMeta(): Partial<import("@embroider/
|
|
4
|
+
get packageMeta(): Partial<import("@embroider/shared-internals").AddonMeta>;
|
|
5
5
|
}
|
|
@@ -13,19 +13,9 @@ export declare class CompatAppBuilder {
|
|
|
13
13
|
private synthVendor;
|
|
14
14
|
private synthStyles;
|
|
15
15
|
constructor(origAppPackage: Package, appPackageWithMovedDeps: Package, options: Required<Options>, compatApp: CompatApp, configTree: V1Config, contentForTree: ContentForConfig, synthVendor: Package, synthStyles: Package);
|
|
16
|
-
private activeAddonChildren;
|
|
17
|
-
private get allActiveAddons();
|
|
18
|
-
private isActiveAddon;
|
|
19
|
-
private orderAddons;
|
|
20
|
-
private resolvableExtensions;
|
|
21
16
|
private modulePrefix;
|
|
22
17
|
private podModulePrefix;
|
|
23
|
-
private
|
|
24
|
-
private resolverConfig;
|
|
25
|
-
private findActiveAddons;
|
|
26
|
-
private partitionEngines;
|
|
27
|
-
private emberVersion;
|
|
28
|
-
private engines;
|
|
18
|
+
private get resolverConfig();
|
|
29
19
|
build(): Promise<void>;
|
|
30
20
|
private get portableHints();
|
|
31
21
|
private addBabelCompat;
|
|
@@ -11,17 +11,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CompatAppBuilder = void 0;
|
|
13
13
|
const core_1 = require("@embroider/core");
|
|
14
|
-
const path_1 = require("path");
|
|
15
14
|
const dependency_rules_1 = require("./dependency-rules");
|
|
16
|
-
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
17
|
-
const bind_decorator_1 = __importDefault(require("bind-decorator"));
|
|
18
15
|
const fs_extra_1 = require("fs-extra");
|
|
19
16
|
const portable_1 = require("@embroider/core/src/portable");
|
|
20
17
|
const typescript_memoize_1 = require("typescript-memoize");
|
|
21
|
-
const
|
|
18
|
+
const path_1 = require("path");
|
|
22
19
|
const resolve_1 = __importDefault(require("resolve"));
|
|
23
20
|
const fs_extra_2 = require("fs-extra");
|
|
24
21
|
const node_1 = require("@embroider/macros/src/node");
|
|
22
|
+
const module_resolver_options_1 = require("@embroider/core/src/module-resolver-options");
|
|
25
23
|
// This exists during the actual broccoli build step. As opposed to CompatApp,
|
|
26
24
|
// which also exists during pipeline-construction time.
|
|
27
25
|
class CompatAppBuilder {
|
|
@@ -35,181 +33,40 @@ class CompatAppBuilder {
|
|
|
35
33
|
this.synthVendor = synthVendor;
|
|
36
34
|
this.synthStyles = synthStyles;
|
|
37
35
|
}
|
|
38
|
-
activeAddonChildren(pkg) {
|
|
39
|
-
let result = pkg.dependencies.filter(this.isActiveAddon).filter(
|
|
40
|
-
// When looking for child addons, we want to ignore 'peerDependencies' of
|
|
41
|
-
// a given package, to align with how ember-cli resolves addons. So here
|
|
42
|
-
// we only include dependencies that are definitely active due to one of
|
|
43
|
-
// the other sections.
|
|
44
|
-
addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies');
|
|
45
|
-
if (pkg === this.appPackageWithMovedDeps) {
|
|
46
|
-
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
|
|
47
|
-
result = [...result, ...extras];
|
|
48
|
-
}
|
|
49
|
-
return result.sort(this.orderAddons);
|
|
50
|
-
}
|
|
51
|
-
get allActiveAddons() {
|
|
52
|
-
let result = this.appPackageWithMovedDeps.findDescendants(this.isActiveAddon);
|
|
53
|
-
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
|
|
54
|
-
let extraDescendants = (0, flatMap_1.default)(extras, dep => dep.findDescendants(this.isActiveAddon));
|
|
55
|
-
result = [...result, ...extras, ...extraDescendants];
|
|
56
|
-
return result.sort(this.orderAddons);
|
|
57
|
-
}
|
|
58
|
-
isActiveAddon(pkg) {
|
|
59
|
-
// stage1 already took care of converting everything that's actually active
|
|
60
|
-
// into v2 addons. If it's not a v2 addon, we don't want it.
|
|
61
|
-
//
|
|
62
|
-
// We can encounter v1 addons here when there is inactive stuff floating
|
|
63
|
-
// around in the node_modules that accidentally satisfy something like an
|
|
64
|
-
// optional peer dep.
|
|
65
|
-
return pkg.isV2Addon();
|
|
66
|
-
}
|
|
67
|
-
orderAddons(depA, depB) {
|
|
68
|
-
let depAIdx = 0;
|
|
69
|
-
let depBIdx = 0;
|
|
70
|
-
if (depA && depA.meta && depA.isV2Addon()) {
|
|
71
|
-
depAIdx = depA.meta['order-index'] || 0;
|
|
72
|
-
}
|
|
73
|
-
if (depB && depB.meta && depB.isV2Addon()) {
|
|
74
|
-
depBIdx = depB.meta['order-index'] || 0;
|
|
75
|
-
}
|
|
76
|
-
return depAIdx - depBIdx;
|
|
77
|
-
}
|
|
78
|
-
resolvableExtensions() {
|
|
79
|
-
let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;
|
|
80
|
-
if (fromEnv) {
|
|
81
|
-
return fromEnv.split(',');
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
36
|
modulePrefix() {
|
|
88
37
|
return this.configTree.readConfig().modulePrefix;
|
|
89
38
|
}
|
|
90
39
|
podModulePrefix() {
|
|
91
40
|
return this.configTree.readConfig().podModulePrefix;
|
|
92
41
|
}
|
|
93
|
-
|
|
94
|
-
return (0,
|
|
95
|
-
|
|
96
|
-
...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
97
|
-
]);
|
|
98
|
-
}
|
|
99
|
-
resolverConfig(engines) {
|
|
100
|
-
let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
101
|
-
let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
102
|
-
let options = {
|
|
103
|
-
staticHelpers: this.options.staticHelpers,
|
|
104
|
-
staticModifiers: this.options.staticModifiers,
|
|
105
|
-
staticComponents: this.options.staticComponents,
|
|
106
|
-
allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
|
|
107
|
-
};
|
|
108
|
-
let config = {
|
|
109
|
-
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
110
|
-
renameModules,
|
|
111
|
-
renamePackages,
|
|
112
|
-
resolvableExtensions: this.resolvableExtensions(),
|
|
113
|
-
appRoot: this.origAppPackage.root,
|
|
114
|
-
engines: engines.map(engine => ({
|
|
115
|
-
packageName: engine.package.name,
|
|
116
|
-
// we need to use the real path here because webpack requests always use the real path i.e. follow symlinks
|
|
117
|
-
root: (0, fs_extra_1.realpathSync)(engine.package.root),
|
|
118
|
-
fastbootFiles: {},
|
|
119
|
-
activeAddons: [...engine.addons]
|
|
120
|
-
.map(([addon, canResolveFromFile]) => ({
|
|
121
|
-
name: addon.name,
|
|
122
|
-
root: addon.root,
|
|
123
|
-
canResolveFromFile,
|
|
124
|
-
}))
|
|
125
|
-
// the traditional order is the order in which addons will run, such
|
|
126
|
-
// that the last one wins. Our resolver's order is the order to
|
|
127
|
-
// search, so first one wins.
|
|
128
|
-
.reverse(),
|
|
129
|
-
isLazy: engine.package.isLazyEngine(),
|
|
130
|
-
})),
|
|
131
|
-
amdCompatibility: this.options.amdCompatibility,
|
|
132
|
-
// this is the additional stufff that @embroider/compat adds on top to do
|
|
133
|
-
// global template resolving
|
|
42
|
+
get resolverConfig() {
|
|
43
|
+
return (0, module_resolver_options_1.buildResolverOptions)({
|
|
44
|
+
appPackage: this.appPackageWithMovedDeps,
|
|
134
45
|
modulePrefix: this.modulePrefix(),
|
|
135
|
-
splitAtRoutes: this.options.splitAtRoutes,
|
|
136
46
|
podModulePrefix: this.podModulePrefix(),
|
|
137
|
-
|
|
138
|
-
options,
|
|
139
|
-
autoRun: this.compatApp.autoRun,
|
|
47
|
+
splitAtRoutes: this.options.splitAtRoutes,
|
|
140
48
|
staticAppPaths: this.options.staticAppPaths,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
let canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
|
|
155
|
-
engine.addons.set(child, canResolveFrom);
|
|
156
|
-
}
|
|
157
|
-
// ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
|
|
158
|
-
if (!isChild) {
|
|
159
|
-
engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
|
|
160
|
-
return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
partitionEngines() {
|
|
165
|
-
let queue = [
|
|
166
|
-
{
|
|
167
|
-
package: this.appPackageWithMovedDeps,
|
|
168
|
-
addons: new Map(),
|
|
169
|
-
isApp: true,
|
|
170
|
-
modulePrefix: this.modulePrefix(),
|
|
171
|
-
appRelativePath: '.',
|
|
49
|
+
extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles]]]),
|
|
50
|
+
extend: (options, allActiveAddons) => {
|
|
51
|
+
options.activePackageRules = (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
|
|
52
|
+
{ name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },
|
|
53
|
+
...allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
54
|
+
]);
|
|
55
|
+
options.options = {
|
|
56
|
+
staticHelpers: this.options.staticHelpers,
|
|
57
|
+
staticModifiers: this.options.staticModifiers,
|
|
58
|
+
staticComponents: this.options.staticComponents,
|
|
59
|
+
allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
|
|
60
|
+
};
|
|
61
|
+
return options;
|
|
172
62
|
},
|
|
173
|
-
|
|
174
|
-
let done = [];
|
|
175
|
-
let seenEngines = new Set();
|
|
176
|
-
while (true) {
|
|
177
|
-
let current = queue.shift();
|
|
178
|
-
if (!current) {
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
this.findActiveAddons(current.package, current);
|
|
182
|
-
for (let addon of current.addons.keys()) {
|
|
183
|
-
if (addon.isEngine() && !seenEngines.has(addon)) {
|
|
184
|
-
seenEngines.add(addon);
|
|
185
|
-
queue.push({
|
|
186
|
-
package: addon,
|
|
187
|
-
addons: new Map(),
|
|
188
|
-
isApp: !current,
|
|
189
|
-
modulePrefix: addon.name,
|
|
190
|
-
appRelativePath: (0, core_1.explicitRelative)(this.origAppPackage.root, addon.root),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
done.push(current);
|
|
195
|
-
}
|
|
196
|
-
return done;
|
|
197
|
-
}
|
|
198
|
-
emberVersion() {
|
|
199
|
-
let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');
|
|
200
|
-
if (!pkg) {
|
|
201
|
-
throw new Error('no ember version!');
|
|
202
|
-
}
|
|
203
|
-
return pkg.version;
|
|
63
|
+
});
|
|
204
64
|
}
|
|
205
65
|
async build() {
|
|
206
66
|
// on the first build, we lock down the macros config. on subsequent builds,
|
|
207
67
|
// this doesn't do anything anyway because it's idempotent.
|
|
208
68
|
this.compatApp.macrosConfig.finalize();
|
|
209
|
-
|
|
210
|
-
this.engines = this.partitionEngines();
|
|
211
|
-
}
|
|
212
|
-
let resolverConfig = this.resolverConfig(this.engines);
|
|
69
|
+
let resolverConfig = this.resolverConfig;
|
|
213
70
|
let config = this.configTree.readConfig();
|
|
214
71
|
let contentForConfig = this.contentForTree.readContents();
|
|
215
72
|
this.addResolverConfig(resolverConfig);
|
|
@@ -220,13 +77,13 @@ class CompatAppBuilder {
|
|
|
220
77
|
}
|
|
221
78
|
get portableHints() {
|
|
222
79
|
return this.options.pluginHints.map(hint => {
|
|
223
|
-
let cursor = (0,
|
|
80
|
+
let cursor = (0, path_1.join)(this.origAppPackage.root, 'package.json');
|
|
224
81
|
for (let i = 0; i < hint.resolve.length; i++) {
|
|
225
82
|
let target = hint.resolve[i];
|
|
226
83
|
if (i < hint.resolve.length - 1) {
|
|
227
|
-
target = (0,
|
|
84
|
+
target = (0, path_1.join)(target, 'package.json');
|
|
228
85
|
}
|
|
229
|
-
cursor = resolve_1.default.sync(target, { basedir: (0,
|
|
86
|
+
cursor = resolve_1.default.sync(target, { basedir: (0, path_1.dirname)(cursor) });
|
|
230
87
|
}
|
|
231
88
|
return {
|
|
232
89
|
requireFile: cursor,
|
|
@@ -251,16 +108,16 @@ class CompatAppBuilder {
|
|
|
251
108
|
if (!portableConfig.isParallelSafe) {
|
|
252
109
|
throw new Error(`non-serializble babel plugins or AST transforms found in your app`);
|
|
253
110
|
}
|
|
254
|
-
(0, fs_extra_1.writeFileSync)((0,
|
|
111
|
+
(0, fs_extra_1.writeFileSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_compat_.js'), `
|
|
255
112
|
const { Portable } = require('@embroider/core/src/portable');
|
|
256
113
|
module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});
|
|
257
114
|
`, 'utf8');
|
|
258
115
|
}
|
|
259
116
|
addResolverConfig(config) {
|
|
260
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
117
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
|
|
261
118
|
}
|
|
262
119
|
addContentForConfig(contentForConfig) {
|
|
263
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
120
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
264
121
|
spaces: 2,
|
|
265
122
|
});
|
|
266
123
|
// In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.
|
|
@@ -288,7 +145,7 @@ class CompatAppBuilder {
|
|
|
288
145
|
}
|
|
289
146
|
}
|
|
290
147
|
addEmberEnvConfig(emberEnvConfig) {
|
|
291
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
148
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
|
|
292
149
|
spaces: 2,
|
|
293
150
|
});
|
|
294
151
|
}
|
|
@@ -325,25 +182,16 @@ class CompatAppBuilder {
|
|
|
325
182
|
exports.CompatAppBuilder = CompatAppBuilder;
|
|
326
183
|
__decorate([
|
|
327
184
|
(0, typescript_memoize_1.Memoize)()
|
|
328
|
-
], CompatAppBuilder.prototype, "
|
|
329
|
-
__decorate([
|
|
330
|
-
bind_decorator_1.default
|
|
331
|
-
], CompatAppBuilder.prototype, "isActiveAddon", null);
|
|
332
|
-
__decorate([
|
|
333
|
-
bind_decorator_1.default
|
|
334
|
-
], CompatAppBuilder.prototype, "orderAddons", null);
|
|
335
|
-
__decorate([
|
|
336
|
-
(0, typescript_memoize_1.Memoize)()
|
|
337
|
-
], CompatAppBuilder.prototype, "activeRules", null);
|
|
185
|
+
], CompatAppBuilder.prototype, "resolverConfig", null);
|
|
338
186
|
__decorate([
|
|
339
187
|
(0, typescript_memoize_1.Memoize)()
|
|
340
188
|
], CompatAppBuilder.prototype, "portableHints", null);
|
|
341
189
|
function defaultAddonPackageRules() {
|
|
342
|
-
return (0, fs_extra_2.readdirSync)((0,
|
|
190
|
+
return (0, fs_extra_2.readdirSync)((0, path_1.join)(__dirname, 'addon-dependency-rules'))
|
|
343
191
|
.map(filename => {
|
|
344
192
|
if (filename.endsWith('.js')) {
|
|
345
193
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
346
|
-
return require((0,
|
|
194
|
+
return require((0, path_1.join)(__dirname, 'addon-dependency-rules', filename)).default;
|
|
347
195
|
}
|
|
348
196
|
})
|
|
349
197
|
.filter(Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-app-builder.js","sourceRoot":"","sources":["compat-app-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA8E;AAC9E,+BAA8C;AAI9C,yDAAwD;AACxD,6DAAqC;AACrC,oEAAkC;AAClC,uCAAuE;AAEvE,2DAAgF;AAChF,2DAA6C;AAC7C,+BAAqC;AACrC,sDAA8B;AAI9B,uCAAuC;AAIvC,qDAA0D;AAE1D,8EAA8E;AAC9E,uDAAuD;AAEvD,MAAa,gBAAgB;IAC3B,YACU,cAAuB,EACvB,uBAAgC,EAChC,OAA0B,EAC1B,SAAoB,EACpB,UAAoB,EACpB,cAAgC,EAChC,WAAoB,EACpB,WAAoB;QAPpB,mBAAc,GAAd,cAAc,CAAS;QACvB,4BAAuB,GAAvB,uBAAuB,CAAS;QAChC,YAAO,GAAP,OAA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CAAC,CAAC,OAAO,CAAC;QAC9E,CAAC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { AddonPackage, Engine } from '@embroider/core';\nimport { explicitRelative, locateEmbroiderWorkingDir } from '@embroider/core';\nimport { resolve as resolvePath } from 'path';\nimport type Options from './options';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport flatMap from 'lodash/flatMap';\nimport bind from 'bind-decorator';\nimport { outputJSONSync, writeFileSync, realpathSync } from 'fs-extra';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion, Portable } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\n\nimport type CompatApp from './compat-app';\nimport type { CompatBabelState } from './babel';\nimport { MacrosConfig } from '@embroider/macros/src/node';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: Required<Options>,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private activeAddonChildren(pkg: Package): AddonPackage[] {\n let result = (pkg.dependencies.filter(this.isActiveAddon) as AddonPackage[]).filter(\n // When looking for child addons, we want to ignore 'peerDependencies' of\n // a given package, to align with how ember-cli resolves addons. So here\n // we only include dependencies that are definitely active due to one of\n // the other sections.\n addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies'\n );\n if (pkg === this.appPackageWithMovedDeps) {\n let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];\n result = [...result, ...extras];\n }\n return result.sort(this.orderAddons);\n }\n\n @Memoize()\n private get allActiveAddons(): AddonPackage[] {\n let result = this.appPackageWithMovedDeps.findDescendants(this.isActiveAddon) as AddonPackage[];\n let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];\n let extraDescendants = flatMap(extras, dep => dep.findDescendants(this.isActiveAddon)) as AddonPackage[];\n result = [...result, ...extras, ...extraDescendants];\n return result.sort(this.orderAddons);\n }\n\n @bind\n private isActiveAddon(pkg: Package): boolean {\n // stage1 already took care of converting everything that's actually active\n // into v2 addons. If it's not a v2 addon, we don't want it.\n //\n // We can encounter v1 addons here when there is inactive stuff floating\n // around in the node_modules that accidentally satisfy something like an\n // optional peer dep.\n return pkg.isV2Addon();\n }\n\n @bind\n private orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n }\n\n private resolvableExtensions(): string[] {\n let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;\n if (fromEnv) {\n return fromEnv.split(',');\n } else {\n return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];\n }\n }\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private activeRules() {\n return activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n }\n\n private resolverConfig(engines: Engine[]): CompatResolverOptions {\n let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));\n let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));\n\n let options: CompatResolverOptions['options'] = {\n staticHelpers: this.options.staticHelpers,\n staticModifiers: this.options.staticModifiers,\n staticComponents: this.options.staticComponents,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n\n let config: CompatResolverOptions = {\n // this part is the base ModuleResolverOptions as required by @embroider/core\n renameModules,\n renamePackages,\n resolvableExtensions: this.resolvableExtensions(),\n appRoot: this.origAppPackage.root,\n engines: engines.map(engine => ({\n packageName: engine.package.name,\n // we need to use the real path here because webpack requests always use the real path i.e. follow symlinks\n root: realpathSync(engine.package.root),\n fastbootFiles: {},\n activeAddons: [...engine.addons]\n .map(([addon, canResolveFromFile]) => ({\n name: addon.name,\n root: addon.root,\n canResolveFromFile,\n }))\n // the traditional order is the order in which addons will run, such\n // that the last one wins. Our resolver's order is the order to\n // search, so first one wins.\n .reverse(),\n isLazy: engine.package.isLazyEngine(),\n })),\n amdCompatibility: this.options.amdCompatibility,\n\n // this is the additional stufff that @embroider/compat adds on top to do\n // global template resolving\n modulePrefix: this.modulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n podModulePrefix: this.podModulePrefix(),\n activePackageRules: this.activeRules(),\n options,\n autoRun: this.compatApp.autoRun,\n staticAppPaths: this.options.staticAppPaths,\n emberVersion: this.emberVersion(),\n };\n\n return config;\n }\n\n // recurse to find all active addons that don't cross an engine boundary.\n // Inner engines themselves will be returned, but not those engines' children.\n // The output set's insertion order is the proper ember-cli compatible\n // ordering of the addons.\n private findActiveAddons(pkg: Package, engine: Engine, isChild = false): void {\n for (let child of this.activeAddonChildren(pkg)) {\n if (!child.isEngine()) {\n this.findActiveAddons(child, engine, true);\n }\n let canResolveFrom = resolvePath(pkg.root, 'package.json');\n engine.addons.set(child, canResolveFrom);\n }\n // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)\n if (!isChild) {\n engine.addons = new Map(\n [...engine.addons].sort(([a], [b]) => {\n return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);\n })\n );\n }\n }\n\n private partitionEngines(): Engine[] {\n let queue: Engine[] = [\n {\n package: this.appPackageWithMovedDeps,\n addons: new Map(),\n isApp: true,\n modulePrefix: this.modulePrefix(),\n appRelativePath: '.',\n },\n ];\n let done: Engine[] = [];\n let seenEngines: Set<Package> = new Set();\n while (true) {\n let current = queue.shift();\n if (!current) {\n break;\n }\n this.findActiveAddons(current.package, current);\n for (let addon of current.addons.keys()) {\n if (addon.isEngine() && !seenEngines.has(addon)) {\n seenEngines.add(addon);\n queue.push({\n package: addon,\n addons: new Map(),\n isApp: !current,\n modulePrefix: addon.name,\n appRelativePath: explicitRelative(this.origAppPackage.root, addon.root),\n });\n }\n }\n done.push(current);\n }\n return done;\n }\n\n private emberVersion() {\n let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');\n if (!pkg) {\n throw new Error('no ember version!');\n }\n return pkg.version;\n }\n\n private engines: Engine[] | undefined;\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n if (!this.engines) {\n this.engines = this.partitionEngines();\n }\n\n let resolverConfig = this.resolverConfig(this.engines);\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n this.addBabelCompat();\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelCompat() {\n let plugins = this.compatApp.extraBabelPlugins();\n let templateTransforms = this.compatApp.htmlbarsPlugins;\n let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n\n let config: CompatBabelState = {\n plugins,\n templateTransforms,\n babelMacros,\n templateMacros: templateMacros as any,\n };\n\n let portableConfig = new Portable({ hints: this.portableHints }).dehydrate(config);\n if (!portableConfig.isParallelSafe) {\n throw new Error(`non-serializble babel plugins or AST transforms found in your app`);\n }\n\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_compat_.js'),\n `\n const { Portable } = require('@embroider/core/src/portable');\n module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});\n `,\n 'utf8'\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `var prefix = '${modulePrefix}';\\ntry {\\n var metaName = prefix + '/config/environment';\\n var rawConfig = document.querySelector('meta[name=\\\"' + metaName + '\\\"]').getAttribute('content');\\n var config = JSON.parse(decodeURIComponent(rawConfig));\\n\\n var exports = { 'default': config };\\n\\n Object.defineProperty(exports, '__esModule', { value: true });\\n\\n return exports;\\n}\\ncatch(err) {\\n throw new Error('Could not read config from meta tag with name \\\"' + metaName + '\\\".');\\n}\\n`.replace(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compat-app-builder.js","sourceRoot":"","sources":["compat-app-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA4D;AAI5D,yDAAwD;AACxD,uCAAyD;AAEzD,2DAAgF;AAChF,2DAA6C;AAC7C,+BAAqC;AACrC,sDAA8B;AAI9B,uCAAuC;AAIvC,qDAA0D;AAC1D,yFAAmF;AAEnF,8EAA8E;AAC9E,uDAAuD;AAEvD,MAAa,gBAAgB;IAC3B,YACU,cAAuB,EACvB,uBAAgC,EAChC,OAA0B,EAC1B,SAAoB,EACpB,UAAoB,EACpB,cAAgC,EAChC,WAAoB,EACpB,WAAoB;QAPpB,mBAAc,GAAd,cAAc,CAAS;QACvB,4BAAuB,GAAvB,uBAAuB,CAAS;QAChC,YAAO,GAAP,OAAO,CAAmB;QAC1B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAU;QACpB,mBAAc,GAAd,cAAc,CAAkB;QAChC,gBAAW,GAAX,WAAW,CAAS;QACpB,gBAAW,GAAX,WAAW,CAAS;IAC3B,CAAC;IAEI,YAAY;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC;IACnD,CAAC;IAEO,eAAe;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,eAA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C;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { AddonPackage } from '@embroider/core';\nimport { locateEmbroiderWorkingDir } from '@embroider/core';\nimport type Options from './options';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport { outputJSONSync, writeFileSync } from 'fs-extra';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion, Portable } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\n\nimport type CompatApp from './compat-app';\nimport type { CompatBabelState } from './babel';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport { buildResolverOptions } from '@embroider/core/src/module-resolver-options';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: Required<Options>,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private get resolverConfig(): CompatResolverOptions {\n return buildResolverOptions({\n appPackage: this.appPackageWithMovedDeps,\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n staticAppPaths: this.options.staticAppPaths,\n extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles] as AddonPackage[]]]),\n extend: (options: CompatResolverOptions, allActiveAddons) => {\n options.activePackageRules = activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n options.options = {\n staticHelpers: this.options.staticHelpers,\n staticModifiers: this.options.staticModifiers,\n staticComponents: this.options.staticComponents,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n return options;\n },\n });\n }\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n let resolverConfig = this.resolverConfig;\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n this.addBabelCompat();\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelCompat() {\n let plugins = this.compatApp.extraBabelPlugins();\n let templateTransforms = this.compatApp.htmlbarsPlugins;\n let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n\n let config: CompatBabelState = {\n plugins,\n templateTransforms,\n babelMacros,\n templateMacros: templateMacros as any,\n };\n\n let portableConfig = new Portable({ hints: this.portableHints }).dehydrate(config);\n if (!portableConfig.isParallelSafe) {\n throw new Error(`non-serializble babel plugins or AST transforms found in your app`);\n }\n\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_compat_.js'),\n `\n const { Portable } = require('@embroider/core/src/portable');\n module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});\n `,\n 'utf8'\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `var prefix = '${modulePrefix}';\\ntry {\\n var metaName = prefix + '/config/environment';\\n var rawConfig = document.querySelector('meta[name=\\\"' + metaName + '\\\"]').getAttribute('content');\\n var config = JSON.parse(decodeURIComponent(rawConfig));\\n\\n var exports = { 'default': config };\\n\\n Object.defineProperty(exports, '__esModule', { value: true });\\n\\n return exports;\\n}\\ncatch(err) {\\n throw new Error('Could not read config from meta tag with name \\\"' + metaName + '\\\".');\\n}\\n`.replace(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n"]}
|
|
@@ -14,7 +14,6 @@ const dependency_rules_1 = require("./dependency-rules");
|
|
|
14
14
|
const typescript_memoize_1 = require("typescript-memoize");
|
|
15
15
|
const assert_never_1 = __importDefault(require("assert-never"));
|
|
16
16
|
const path_1 = require("path");
|
|
17
|
-
const fs_extra_1 = require("fs-extra");
|
|
18
17
|
const dasherize_component_name_1 = require("./dasherize-component-name");
|
|
19
18
|
const core_1 = require("@embroider/core");
|
|
20
19
|
const lodash_1 = require("lodash");
|
|
@@ -806,7 +805,8 @@ __decorate([
|
|
|
806
805
|
], TemplateResolver.prototype, "rules", null);
|
|
807
806
|
// This is the AST transform that resolves components, helpers and modifiers at build time
|
|
808
807
|
function makeResolverTransform({ appRoot, emberVersion }) {
|
|
809
|
-
let
|
|
808
|
+
let loader = new core_1.ResolverLoader(appRoot);
|
|
809
|
+
let config = loader.resolver.options;
|
|
810
810
|
const resolverTransform = env => {
|
|
811
811
|
if (env.strictMode) {
|
|
812
812
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;;;;;;AAi9BA,wCAiBC;AA19BD,yDAA8E;AAC9E,2DAA6C;AAE7C,gEAAuC;AACvC,+BAAiC;AACjC,uCAAwC;AACxC,yEAAgF;AAEhF,0CAAgF;AAGhF,mCAA8C;AAC9C,mCAAmC;AAiCnC,SAAS,eAAe,CAAC,YAAoB;IAC3C,MAAM,eAAe,GAAwC;QAC3D,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,EAAE;QACjB,oBAAoB,EAAE,EAAE;QACxB,MAAM,EAAE,EAAE;QACV,KAAK,EAAE;YACL,gBAAgB,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC;SAC7C;QACD,SAAS,EAAE,EAAE;QACb,MAAM,EAAE;YACN,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC;SAC9C;QACD,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE;QACR,EAAE,E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AO;IAElB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,SAAS,QAAQ,CAAC,IAAS;IACzB,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,SAAS,KAAK,CAAC,IAAS;IACtB,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,OAAO,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AACpE,CAAC","sourcesContent":["import type { ASTv1, ASTPlugin, ASTPluginBuilder, ASTPluginEnvironment, WalkerPath } from '@glimmer/syntax';\nimport type {\n PreprocessedComponentRule,\n ActivePackageRules,\n ComponentRules,\n PackageRules,\n ModuleRules,\n} from './dependency-rules';\nimport { preprocessComponentRule, appTreeRulesDir } from './dependency-rules';\nimport { Memoize } from 'typescript-memoize';\nimport type { WithJSUtils } from 'babel-plugin-ember-template-compilation';\nimport assertNever from 'assert-never';\nimport { join, sep } from 'path';\nimport { readJSONSync } from 'fs-extra';\nimport { dasherize, snippetToDasherizedName } from './dasherize-component-name';\nimport type { ResolverOptions as CoreResolverOptions } from '@embroider/core';\nimport { Resolver, cleanUrl, locateEmbroiderWorkingDir } from '@embroider/core';\nimport type CompatOptions from './options';\nimport type { AuditMessage, Loc } from './audit';\nimport { camelCase, mergeWith } from 'lodash';\nimport { satisfies } from 'semver';\n\ntype Env = WithJSUtils<ASTPluginEnvironment> & {\n filename: string;\n contents: string;\n strictMode?: boolean;\n locals?: string[];\n};\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype UserConfig = Pick<\n Required<CompatOptions>,\n 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'\n>;\n\nexport interface CompatResolverOptions extends CoreResolverOptions {\n activePackageRules: ActivePackageRules[];\n options: UserConfig;\n}\n\nexport interface Options {\n appRoot: string;\n emberVersion: string;\n}\n\ntype BuiltIn = {\n importableHelper?: [string, string];\n importableComponent?: [string, string];\n importableModifier?: [string, string];\n};\n\nfunction builtInKeywords(emberVersion: string): Record<string, BuiltIn | undefined> {\n const builtInKeywords: Record<string, BuiltIn | undefined> = {\n '-get-dynamic-var': {},\n '-in-element': {},\n '-with-dynamic-vars': {},\n action: {},\n array: {\n importableHelper: ['array', '@ember/helper'],\n },\n component: {},\n concat: {\n importableHelper: ['concat', '@ember/helper'],\n },\n debugger: {},\n 'each-in': {},\n each: {},\n fn: {\n importableHelper: ['fn', '@ember/helper'],\n },\n get: {\n importableHelper: ['get', '@ember/helper'],\n },\n 'has-block-params': {},\n 'has-block': {},\n hasBlock: {},\n hasBlockParams: {},\n hash: {\n importableHelper: ['hash', '@ember/helper'],\n },\n helper: {},\n if: {},\n 'in-element': {},\n input: {\n importableComponent: ['Input', '@ember/component'],\n },\n let: {},\n 'link-to': {\n importableComponent: ['LinkTo', '@ember/routing'],\n },\n loc: {},\n log: {},\n modifier: {},\n mount: {},\n mut: {},\n on: {\n importableModifier: ['on', '@ember/modifier'],\n },\n outlet: {},\n partial: {},\n 'query-params': {},\n readonly: {},\n textarea: {\n importableComponent: ['Textarea', '@ember/component'],\n },\n unbound: {},\n 'unique-id': {},\n unless: {},\n with: {},\n yield: {},\n };\n if (satisfies(emberVersion, '>=5.2')) {\n builtInKeywords['unique-id'] = {\n importableHelper: ['uniqueId', '@ember/helper'],\n };\n }\n return builtInKeywords;\n}\n\ninterface ComponentResolution {\n type: 'component';\n specifier: string;\n importedName: string;\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n nameHint: string;\n}\n\ntype HelperResolution = {\n type: 'helper';\n nameHint: string;\n specifier: string;\n importedName: string;\n};\n\ntype ModifierResolution = {\n type: 'modifier';\n specifier: string;\n importedName: string;\n nameHint: string;\n};\n\ntype ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;\n\ninterface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ntype Resolution = ResolutionResult | ResolutionFail;\n\ntype ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n\nclass TemplateResolver implements ASTPlugin {\n readonly name = 'embroider-build-time-resolver';\n\n private auditHandler: undefined | ((msg: AuditMessage) => void);\n private scopeStack = new ScopeStack();\n\n private moduleResolver: Resolver;\n\n constructor(\n private env: Env,\n private config: CompatResolverOptions,\n private builtInsForEmberVersion: ReturnType<typeof builtInKeywords>\n ) {\n this.moduleResolver = new Resolver(config);\n if ((globalThis as any).embroider_audit) {\n this.auditHandler = (globalThis as any).embroider_audit;\n }\n }\n\n private 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 this.reportError(resolution);\n return;\n case 'component':\n case 'modifier':\n case 'helper': {\n let name = this.env.meta.jsutils.bindImport(resolution.specifier, resolution.importedName, parentPath, {\n nameHint: resolution.nameHint,\n });\n setter(parentPath.node, this.env.syntax.builders.path(name));\n return;\n }\n case undefined:\n return;\n default:\n assertNever(resolution);\n }\n }\n\n private reportError(dep: ResolutionFail) {\n if (!this.auditHandler && !this.config.options.allowUnsafeDynamicComponents) {\n let e: any = new Error(`${dep.message}: ${dep.detail} in ${this.humanReadableFile(this.env.filename)}`);\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = this.env.filename;\n throw e;\n }\n if (this.auditHandler) {\n this.auditHandler({\n message: dep.message,\n filename: this.env.filename,\n detail: dep.detail,\n loc: dep.loc,\n source: this.env.contents,\n });\n }\n }\n\n private humanReadableFile(file: string) {\n let { appRoot } = this.config;\n if (!appRoot.endsWith(sep)) {\n appRoot += sep;\n }\n if (file.startsWith(appRoot)) {\n return file.slice(appRoot.length);\n }\n return file;\n }\n\n private handleComponentHelper(\n param: ASTv1.Node,\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 this.handleComponentHelper(param.path, 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' && this.scopeStack.safeComponentInScope(locator.path)) {\n return null;\n }\n\n return this.targetComponentHelper(locator, param.loc, impliedBecause);\n }\n\n private handleDynamicComponentArguments(\n componentName: string,\n argumentsAreComponents: string[],\n attributes: WalkerPath<ASTv1.AttrNode | ASTv1.HashPair>[]\n ) {\n for (let name of argumentsAreComponents) {\n let attr = attributes.find(attr => {\n if (attr.node.type === 'AttrNode') {\n return attr.node.name === '@' + name;\n } else {\n return attr.node.key === name;\n }\n });\n if (attr) {\n let resolution = this.handleComponentHelper(attr.node.value, {\n componentName,\n argumentName: name,\n });\n this.emit(attr, resolution, (node, newId) => {\n if (node.type === 'AttrNode') {\n node.value = this.env.syntax.builders.mustache(newId);\n } else {\n node.value = newId;\n }\n });\n }\n }\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.config.options.staticComponents || Boolean(this.auditHandler);\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.config.options.staticHelpers || Boolean(this.auditHandler);\n }\n\n private get staticModifiersEnabled(): boolean {\n return this.config.options.staticModifiers || Boolean(this.auditHandler);\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.components.get(dasherizedName)?.safeToIgnore;\n }\n\n @Memoize()\n private get rules() {\n // rules that are keyed by the filename they're talking about\n let files: Map<string, PreprocessedComponentRule> = new Map();\n\n // rules that are keyed by our dasherized interpretation of the component's name\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.config.activePackageRules) {\n if (rule.components) {\n for (let [snippet, rules] of Object.entries(rule.components)) {\n let processedRules = preprocessComponentRule(rules);\n let dasherizedName = this.standardDasherize(snippet, rule);\n components.set(dasherizedName, processedRules);\n if (rules.layout) {\n for (let root of rule.roots) {\n if (rules.layout.addonPath) {\n files.set(join(root, rules.layout.addonPath), processedRules);\n }\n if (rules.layout.appPath) {\n files.set(join(root, rules.layout.appPath), processedRules);\n }\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n files.set(join(appTreeRulesDir(root, this.moduleResolver), path), processedRules);\n }\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n files.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { files, components };\n }\n\n private findRules(absPath: string): PreprocessedComponentRule | undefined {\n // when babel is invoked by vite our filenames can have query params still\n // hanging off them. That would break rule matching.\n absPath = cleanUrl(absPath);\n\n let fileRules = this.rules.files.get(absPath);\n let componentRules: PreprocessedComponentRule | undefined;\n\n let componentName = this.moduleResolver.reverseComponentLookup(absPath);\n if (componentName) {\n componentRules = this.rules.components.get(componentName);\n }\n\n if (fileRules && componentRules) {\n return mergeWith(fileRules, componentRules, appendArrays);\n }\n\n return fileRules ?? componentRules;\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n let name = snippetToDasherizedName(snippet);\n if (name == null) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n return name;\n }\n\n private targetComponent(name: string): ComponentResolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n const builtIn = this.builtInsForEmberVersion[name];\n\n if (builtIn?.importableComponent) {\n let [importedName, specifier] = builtIn.importableComponent;\n return {\n type: 'component',\n specifier,\n importedName,\n yieldsComponents: [],\n yieldsArguments: [],\n argumentsAreComponents: [],\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n if (this.isIgnoredComponent(name)) {\n return null;\n }\n\n let componentRules = this.rules.components.get(name);\n return {\n type: 'component',\n specifier: `@embroider/virtual/components/${name}`,\n importedName: 'default',\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n nameHint: this.nameHint(name),\n };\n }\n\n private targetComponentHelper(\n component: ComponentLocator,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): ComponentResolution | ResolutionFail | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n };\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findRules(this.env.filename);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return {\n type: 'error',\n message,\n detail: component.path,\n loc,\n };\n }\n\n return this.targetComponent(component.path);\n }\n\n private targetHelper(path: string): HelperResolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n\n // people are not allowed to override the built-in helpers with their own\n // globally-named helpers. It throws an error. So it's fine for us to\n // prioritize the builtIns here without bothering to resolve a user helper\n // of the same name.\n const builtIn = this.builtInsForEmberVersion[path];\n\n if (builtIn?.importableHelper) {\n let [importedName, specifier] = builtIn.importableHelper;\n return {\n type: 'helper',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n return {\n type: 'helper',\n specifier: `@embroider/virtual/helpers/${path}`,\n importedName: 'default',\n nameHint: this.nameHint(path),\n };\n }\n\n private targetHelperOrComponent(\n path: string,\n loc: Loc,\n hasArgs: boolean\n ): ComponentResolution | HelperResolution | null {\n /*\n\n In earlier embroider versions we would do a bunch of module resolution right\n here inside the ast transform to try to resolve the ambiguity of this case\n and if we didn't find anything, leave the template unchanged. But that leads\n to both a lot of extra build-time expense (since we are attempting\n resolution for lots of things that may in fact be just some data and not a\n component invocation at all, and also since we are pre-resolving modules\n that will get resolved a second time by the final stage packager).\n\n Now, we're going to be less forgiving, because it streamlines the build for\n everyone who's not still using these *extremely* old patterns.\n\n The problematic case is:\n\n 1. In a non-strict template (because this whole resolver-transform.ts is a\n no-op on strict handlebars).\n\n 2. Have a mustache statement like: `{{something}}`, where `something` is:\n\n a. Not a variable in scope (for example, there's no preceeding line\n like `<Parent as |something|>`)\n b. Does not start with `@` because that must be an argument from outside this template.\n c. Does not contain a dot, like `some.thing` (because that case is classically\n never a global component resolution that we would need to handle)\n d. Does not start with `this` (this rule is mostly redundant with the previous rule,\n but even a standalone `this` is never a component invocation).\n e. Does not have any arguments. If there are argument like `{{something a=b}}`,\n there is still ambiguity between helper vs component, but there is no longer\n the possibility that this was just rendering some data.\n f. Does not take a block, like `{{#something}}{{/something}}` (because that is\n always a component, no ambiguity.)\n\n We can't tell if this problematic case is really:\n\n 1. A helper invocation with no arguments that is being directly rendered.\n Out-of-the-box, ember already generates [a lint\n error](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-curly-component-invocation.md)\n for this, although it tells you to whitelist your helper when IMO it\n should tell you to use an unambiguous syntax like `{{ (something) }}`\n instead.\n\n 2. A component invocation, which you could have written `<Something />`\n instead. Angle-bracket invocation has been available and easy-to-adopt\n for a very long time.\n\n 3. Property-this-fallback for `{{this.something}}`. Property-this-fallback\n is eliminated at Ember 4.0, so people have been heavily pushed to get\n it out of their addons.\n */\n\n // first, bail out on all the stuff we can obviously ignore\n if ((!this.staticHelpersEnabled && !this.staticComponentsEnabled) || this.isIgnoredComponent(path)) {\n return null;\n }\n\n let builtIn = this.builtInsForEmberVersion[path];\n\n if (builtIn?.importableComponent) {\n let [importedName, specifier] = builtIn.importableComponent;\n return {\n type: 'component',\n specifier,\n importedName,\n yieldsComponents: [],\n yieldsArguments: [],\n argumentsAreComponents: [],\n nameHint: importedName,\n };\n }\n\n if (builtIn?.importableHelper) {\n let [importedName, specifier] = builtIn.importableHelper;\n return {\n type: 'helper',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n let ownComponentRules = this.findRules(this.env.filename);\n if (ownComponentRules?.disambiguate[path]) {\n switch (ownComponentRules.disambiguate[path]) {\n case 'component':\n return this.targetComponent(path);\n case 'helper':\n return this.targetHelper(path);\n case 'data':\n return null;\n }\n }\n\n if (!hasArgs && !path.includes('/') && !path.includes('@')) {\n // this is the case that could also be property-this-fallback. We're going\n // to force people to disambiguate, because letting a potential component\n // or helper invocation lurk inside every bit of data you render is not\n // ok.\n this.reportError({\n type: 'error',\n message: 'unsupported ambiguous syntax',\n detail: `\"{{${path}}}\" is ambiguous and could mean \"{{this.${path}}}\" or component \"<${capitalize(\n camelCase(path)\n )} />\" or helper \"{{ (${path}) }}\". Change it to one of those unambigous forms, or use a \"disambiguate\" packageRule to work around the problem if its in third-party code you cannot easily fix.`,\n loc,\n });\n return null;\n }\n\n // Above we already bailed out if both of these were disabled, so we know at\n // least one is turned on. If both aren't turned on, we're stuck, because we\n // can't even tell if this *is* a component vs a helper.\n if (!this.staticHelpersEnabled || !this.staticComponentsEnabled) {\n this.reportError({\n type: 'error',\n message: 'unsupported ambiguity between helper and component',\n detail: `this use of \"{{${path}}}\" could be helper \"{{ (${path}) }}\" or component \"<${capitalize(\n camelCase(path)\n )} />\", and your settings for staticHelpers and staticComponents do not agree. Either switch to one of the unambiguous forms, or make staticHelpers and staticComponents agree, or use a \"disambiguate\" packageRule to work around the problem if its in third-party code you cannot easily fix.`,\n loc,\n });\n return null;\n }\n\n let componentRules = this.rules.components.get(path);\n return {\n type: 'component',\n specifier: `@embroider/virtual/ambiguous/${path}`,\n importedName: 'default',\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n nameHint: this.nameHint(path),\n };\n }\n\n private targetElementModifier(path: string): ModifierResolution | null {\n if (!this.staticModifiersEnabled) {\n return null;\n }\n\n const builtIn = this.builtInsForEmberVersion[path];\n if (builtIn?.importableModifier) {\n let [importedName, specifier] = builtIn.importableModifier;\n return {\n type: 'modifier',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n return {\n type: 'modifier',\n specifier: `@embroider/virtual/modifiers/${path}`,\n importedName: 'default',\n nameHint: this.nameHint(path),\n };\n }\n\n targetDynamicModifier(modifier: ComponentLocator, loc: Loc): ModifierResolution | ResolutionFail | null {\n if (!this.staticModifiersEnabled) {\n return null;\n }\n\n if (modifier.type === 'literal') {\n return this.targetElementModifier(modifier.path);\n } else {\n return {\n type: 'error',\n message: 'Unsafe dynamic modifier',\n detail: `cannot statically analyze this expression`,\n loc,\n };\n }\n }\n\n private targetDynamicHelper(helper: ComponentLocator): HelperResolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n\n if (helper.type === 'literal') {\n return this.targetHelper(helper.path);\n }\n\n // we don't have to manage any errors in this case because ember itself\n // considers it an error to pass anything but a string literal to the\n // `helper` helper.\n return null;\n }\n\n private nameHint(path: string) {\n let parts = path.split('@');\n\n // the extra underscore here guarantees that we will never collide with an\n // HTML element.\n return parts[parts.length - 1] + '_';\n }\n\n private handleDynamicModifier(param: ASTv1.Expression): ModifierResolution | ResolutionFail | null {\n if (param.type === 'StringLiteral') {\n return this.targetDynamicModifier({ type: 'literal', path: param.value }, param.loc);\n }\n // we don't have to manage any errors in this case because ember itself\n // considers it an error to pass anything but a string literal to the\n // modifier helper.\n return null;\n }\n\n private handleDynamicHelper(param: ASTv1.Expression): HelperResolution | ResolutionFail | null {\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 return this.targetDynamicHelper({ type: 'literal', path: param.value });\n }\n return null;\n }\n\n visitor: ASTPlugin['visitor'] = {\n Template: {\n enter: () => {\n if (this.env.locals) {\n this.scopeStack.pushMustacheBlock(this.env.locals);\n }\n },\n exit: () => {\n if (this.env.locals) {\n this.scopeStack.pop();\n }\n },\n },\n Block: {\n enter: node => {\n this.scopeStack.pushMustacheBlock(node.blockParams);\n },\n exit: () => {\n this.scopeStack.pop();\n },\n },\n BlockStatement: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = headOf(node.path);\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (parts(node.path).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 = this.handleComponentHelper(node.params[0]);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.params[0] = newIdentifier;\n });\n return;\n }\n let resolution = this.targetComponent(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n if (resolution?.type === 'component') {\n this.scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n this.handleDynamicComponentArguments(\n rootName,\n argumentsAreComponents,\n extendPath(extendPath(path, 'hash'), 'pairs')\n );\n });\n }\n },\n SubExpression: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (this.scopeStack.inScope(headOf(node.path), path)) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = this.handleComponentHelper(node.params[0]);\n this.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 let resolution = this.handleDynamicHelper(node.params[0]);\n this.emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.original === 'modifier' && node.params.length > 0) {\n let resolution = this.handleDynamicModifier(node.params[0]);\n this.emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.tail.length === 0 && node.path.head.type === 'VarHead') {\n let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n }\n },\n MustacheStatement: {\n enter: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = headOf(node.path);\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (parts(node.path).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.startsWith('@')) {\n // similarly, global resolution of helpers and components never\n // happens with argument paths (it could still be an invocation, but\n // it would be a lexically-scoped invocation, not one we need to\n // adjust)\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = this.handleComponentHelper(node.params[0]);\n this.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 let resolution = this.handleDynamicHelper(node.params[0]);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.params[0] = newIdentifier;\n });\n return;\n }\n if (path.parent?.node.type === 'AttrNode') {\n // this mustache is the value of an attribute. Components aren't\n // allowed here, so we're not ambiguous, so resolve a helper.\n let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.path = newIdentifier;\n });\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = this.targetHelperOrComponent(node.path.original, node.path.loc, hasArgs);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.path = newIdentifier;\n });\n if (resolution?.type === 'component') {\n this.handleDynamicComponentArguments(\n node.path.original,\n resolution.argumentsAreComponents,\n extendPath(extendPath(path, 'hash'), 'pairs')\n );\n }\n },\n },\n ElementModifierStatement: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (this.scopeStack.inScope(headOf(node.path), path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (isAtHead(node.path)) {\n return;\n }\n if (parts(node.path).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 = this.targetElementModifier(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n ElementNode: {\n enter: (node, path) => {\n let rootName = node.tag.split('.')[0];\n if (!this.scopeStack.inScope(rootName, path)) {\n let resolution: ComponentResolution | null = null;\n\n // if it starts with lower case, it can't be a component we need to\n // globally resolve\n if (node.tag[0] !== node.tag[0].toLowerCase()) {\n resolution = this.targetComponent(dasherize(node.tag));\n }\n\n this.emit(path, resolution, (node, newId) => {\n node.tag = newId.original;\n });\n if (resolution?.type === 'component') {\n this.scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n this.handleDynamicComponentArguments(node.tag, argumentsAreComponents, extendPath(path, 'attributes'));\n });\n }\n }\n this.scopeStack.pushElementBlock(node.blockParams, node);\n },\n exit: () => {\n this.scopeStack.pop();\n },\n },\n };\n}\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\nexport default function makeResolverTransform({ appRoot, emberVersion }: Options) {\n let config: CompatResolverOptions = readJSONSync(join(locateEmbroiderWorkingDir(appRoot), 'resolver.json'));\n const resolverTransform: ASTPluginBuilder<Env> = env => {\n if (env.strictMode) {\n return {\n name: 'embroider-build-time-resolver-strict-noop',\n visitor: {},\n };\n }\n return new TemplateResolver(env, config, builtInKeywords(emberVersion));\n };\n (resolverTransform as any).parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: { appRoot: appRoot },\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 =\n | { type: 'mustache'; blockParams: string[] }\n | { type: 'element'; blockParams: string[]; childrenOf: ASTv1.ElementNode }\n | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // mustache blocks like:\n //\n // {{#stuff as |some block vars|}}\n //\n // are relatively simple for us because there's a dedicated `Block` AST node\n // that exactly covers the range in which the variables are in scope.\n pushMustacheBlock(blockParams: string[]) {\n this.stack.unshift({ type: 'mustache', blockParams });\n }\n\n // element blocks like:\n //\n // <Stuff as |some block vars|>\n //\n // are *not* so simple for us because there's no single AST node that exactly\n // covers the range in which the variables are in scope. For example, the\n // *attributes* of the element do not see the variables, but the children of\n // the element do.\n pushElementBlock(blockParams: string[], childrenOf: ASTv1.ElementNode) {\n this.stack.unshift({ type: 'element', blockParams, childrenOf });\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, fromPath: WalkerPath<ASTv1.Node>) {\n for (let scope of this.stack) {\n if (scope.type === 'mustache' && scope.blockParams.includes(name)) {\n return true;\n }\n if (\n scope.type === 'element' &&\n scope.blockParams.includes(name) &&\n withinElementBlock(fromPath, scope.childrenOf)\n ) {\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 === 'mustache' || here.type === 'element') && 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 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\nfunction capitalize(word: string): string {\n return word[0].toUpperCase() + word.slice(1);\n}\n\n// ElementNodes have both children and attributes and both of those are\n// \"children\" in the abstract syntax tree sense, but here we want to distinguish\n// between them.\nfunction withinElementBlock(childPath: WalkerPath<ASTv1.Node>, ancestorNode: ASTv1.ElementNode): Boolean {\n let cursor: WalkerPath<ASTv1.Node> | null = childPath;\n while (cursor && cursor.node !== ancestorNode) {\n if (ancestorNode.children.includes(cursor.node as ASTv1.Statement)) {\n return true;\n }\n cursor = cursor.parent;\n }\n return false;\n}\nfunction appendArrays(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return objValue.concat(srcValue);\n }\n}\n\nfunction headOf(path: any) {\n if (!path) return;\n\n return 'head' in path ? path.head.name : path.parts[0];\n}\n\nfunction isThisHead(path: any) {\n if (!path) return;\n\n if ('head' in path) {\n return path.head.type === 'ThisHead';\n }\n\n return path.this === true;\n}\n\nfunction isAtHead(path: any) {\n if (!path) return;\n\n if ('head' in path) {\n return path.head.type === 'AtHead';\n }\n\n return path.data === true;\n}\n\nfunction parts(path: any) {\n if (!path) return;\n\n return 'original' in path ? path.original.split('.') : path.parts;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;;;;;;AAg9BA,wCAkBC;AA19BD,yDAA8E;AAC9E,2DAA6C;AAE7C,gEAAuC;AACvC,+BAAiC;AACjC,yEAAgF;AAEhF,0CAAqE;AAGrE,mCAA8C;AAC9C,mCAAmC;AAiCnC,SAAS,eAAe,CAAC,YAAoB;IAC3C,MAAM,eAAe,GAAwC;QAC3D,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,EAAE;QACjB,oBAAoB,EAAE,EAAE;QACxB,MAAM,EAAE,EAAE;QACV,KAAK,EAAE;YACL,gBAAgB,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC;SAC7C;QACD,SAAS,EAAE,EAAE;QACb,MAAM,EAAE;YACN,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC;SAC9C;QACD,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE;QACR,EAAE,EAAE;YACF,gBAAgB,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC;SAC1C;QACD,GAAG,EAAE;YACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC;SAC3C;QACD,kBAAkB,EAAE,EAAE;QACtB,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,EAAE;QACZ,cAAc,EAAE,EAAE;QAClB,IAAI,EAAE;YACJ,gBAAgB,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC;SAC5C;QACD,MAAM,EAAE,EAAE;QACV,EAAE,EAAE,EAAE;QACN,YAAY,EA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O,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,SAAS,KAAK,CAAC,IAAS;IACtB,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,OAAO,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AACpE,CAAC","sourcesContent":["import type { ASTv1, ASTPlugin, ASTPluginBuilder, ASTPluginEnvironment, WalkerPath } from '@glimmer/syntax';\nimport type {\n PreprocessedComponentRule,\n ActivePackageRules,\n ComponentRules,\n PackageRules,\n ModuleRules,\n} from './dependency-rules';\nimport { preprocessComponentRule, appTreeRulesDir } from './dependency-rules';\nimport { Memoize } from 'typescript-memoize';\nimport type { WithJSUtils } from 'babel-plugin-ember-template-compilation';\nimport assertNever from 'assert-never';\nimport { join, sep } from 'path';\nimport { dasherize, snippetToDasherizedName } from './dasherize-component-name';\nimport type { ResolverOptions as CoreResolverOptions } from '@embroider/core';\nimport { Resolver, ResolverLoader, cleanUrl } from '@embroider/core';\nimport type CompatOptions from './options';\nimport type { AuditMessage, Loc } from './audit';\nimport { camelCase, mergeWith } from 'lodash';\nimport { satisfies } from 'semver';\n\ntype Env = WithJSUtils<ASTPluginEnvironment> & {\n filename: string;\n contents: string;\n strictMode?: boolean;\n locals?: string[];\n};\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype UserConfig = Pick<\n Required<CompatOptions>,\n 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'\n>;\n\nexport interface CompatResolverOptions extends CoreResolverOptions {\n activePackageRules: ActivePackageRules[];\n options: UserConfig;\n}\n\nexport interface Options {\n appRoot: string;\n emberVersion: string;\n}\n\ntype BuiltIn = {\n importableHelper?: [string, string];\n importableComponent?: [string, string];\n importableModifier?: [string, string];\n};\n\nfunction builtInKeywords(emberVersion: string): Record<string, BuiltIn | undefined> {\n const builtInKeywords: Record<string, BuiltIn | undefined> = {\n '-get-dynamic-var': {},\n '-in-element': {},\n '-with-dynamic-vars': {},\n action: {},\n array: {\n importableHelper: ['array', '@ember/helper'],\n },\n component: {},\n concat: {\n importableHelper: ['concat', '@ember/helper'],\n },\n debugger: {},\n 'each-in': {},\n each: {},\n fn: {\n importableHelper: ['fn', '@ember/helper'],\n },\n get: {\n importableHelper: ['get', '@ember/helper'],\n },\n 'has-block-params': {},\n 'has-block': {},\n hasBlock: {},\n hasBlockParams: {},\n hash: {\n importableHelper: ['hash', '@ember/helper'],\n },\n helper: {},\n if: {},\n 'in-element': {},\n input: {\n importableComponent: ['Input', '@ember/component'],\n },\n let: {},\n 'link-to': {\n importableComponent: ['LinkTo', '@ember/routing'],\n },\n loc: {},\n log: {},\n modifier: {},\n mount: {},\n mut: {},\n on: {\n importableModifier: ['on', '@ember/modifier'],\n },\n outlet: {},\n partial: {},\n 'query-params': {},\n readonly: {},\n textarea: {\n importableComponent: ['Textarea', '@ember/component'],\n },\n unbound: {},\n 'unique-id': {},\n unless: {},\n with: {},\n yield: {},\n };\n if (satisfies(emberVersion, '>=5.2')) {\n builtInKeywords['unique-id'] = {\n importableHelper: ['uniqueId', '@ember/helper'],\n };\n }\n return builtInKeywords;\n}\n\ninterface ComponentResolution {\n type: 'component';\n specifier: string;\n importedName: string;\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n nameHint: string;\n}\n\ntype HelperResolution = {\n type: 'helper';\n nameHint: string;\n specifier: string;\n importedName: string;\n};\n\ntype ModifierResolution = {\n type: 'modifier';\n specifier: string;\n importedName: string;\n nameHint: string;\n};\n\ntype ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;\n\ninterface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ntype Resolution = ResolutionResult | ResolutionFail;\n\ntype ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n\nclass TemplateResolver implements ASTPlugin {\n readonly name = 'embroider-build-time-resolver';\n\n private auditHandler: undefined | ((msg: AuditMessage) => void);\n private scopeStack = new ScopeStack();\n\n private moduleResolver: Resolver;\n\n constructor(\n private env: Env,\n private config: CompatResolverOptions,\n private builtInsForEmberVersion: ReturnType<typeof builtInKeywords>\n ) {\n this.moduleResolver = new Resolver(config);\n if ((globalThis as any).embroider_audit) {\n this.auditHandler = (globalThis as any).embroider_audit;\n }\n }\n\n private 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 this.reportError(resolution);\n return;\n case 'component':\n case 'modifier':\n case 'helper': {\n let name = this.env.meta.jsutils.bindImport(resolution.specifier, resolution.importedName, parentPath, {\n nameHint: resolution.nameHint,\n });\n setter(parentPath.node, this.env.syntax.builders.path(name));\n return;\n }\n case undefined:\n return;\n default:\n assertNever(resolution);\n }\n }\n\n private reportError(dep: ResolutionFail) {\n if (!this.auditHandler && !this.config.options.allowUnsafeDynamicComponents) {\n let e: any = new Error(`${dep.message}: ${dep.detail} in ${this.humanReadableFile(this.env.filename)}`);\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = this.env.filename;\n throw e;\n }\n if (this.auditHandler) {\n this.auditHandler({\n message: dep.message,\n filename: this.env.filename,\n detail: dep.detail,\n loc: dep.loc,\n source: this.env.contents,\n });\n }\n }\n\n private humanReadableFile(file: string) {\n let { appRoot } = this.config;\n if (!appRoot.endsWith(sep)) {\n appRoot += sep;\n }\n if (file.startsWith(appRoot)) {\n return file.slice(appRoot.length);\n }\n return file;\n }\n\n private handleComponentHelper(\n param: ASTv1.Node,\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 this.handleComponentHelper(param.path, 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' && this.scopeStack.safeComponentInScope(locator.path)) {\n return null;\n }\n\n return this.targetComponentHelper(locator, param.loc, impliedBecause);\n }\n\n private handleDynamicComponentArguments(\n componentName: string,\n argumentsAreComponents: string[],\n attributes: WalkerPath<ASTv1.AttrNode | ASTv1.HashPair>[]\n ) {\n for (let name of argumentsAreComponents) {\n let attr = attributes.find(attr => {\n if (attr.node.type === 'AttrNode') {\n return attr.node.name === '@' + name;\n } else {\n return attr.node.key === name;\n }\n });\n if (attr) {\n let resolution = this.handleComponentHelper(attr.node.value, {\n componentName,\n argumentName: name,\n });\n this.emit(attr, resolution, (node, newId) => {\n if (node.type === 'AttrNode') {\n node.value = this.env.syntax.builders.mustache(newId);\n } else {\n node.value = newId;\n }\n });\n }\n }\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.config.options.staticComponents || Boolean(this.auditHandler);\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.config.options.staticHelpers || Boolean(this.auditHandler);\n }\n\n private get staticModifiersEnabled(): boolean {\n return this.config.options.staticModifiers || Boolean(this.auditHandler);\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.components.get(dasherizedName)?.safeToIgnore;\n }\n\n @Memoize()\n private get rules() {\n // rules that are keyed by the filename they're talking about\n let files: Map<string, PreprocessedComponentRule> = new Map();\n\n // rules that are keyed by our dasherized interpretation of the component's name\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.config.activePackageRules) {\n if (rule.components) {\n for (let [snippet, rules] of Object.entries(rule.components)) {\n let processedRules = preprocessComponentRule(rules);\n let dasherizedName = this.standardDasherize(snippet, rule);\n components.set(dasherizedName, processedRules);\n if (rules.layout) {\n for (let root of rule.roots) {\n if (rules.layout.addonPath) {\n files.set(join(root, rules.layout.addonPath), processedRules);\n }\n if (rules.layout.appPath) {\n files.set(join(root, rules.layout.appPath), processedRules);\n }\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n files.set(join(appTreeRulesDir(root, this.moduleResolver), path), processedRules);\n }\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n files.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { files, components };\n }\n\n private findRules(absPath: string): PreprocessedComponentRule | undefined {\n // when babel is invoked by vite our filenames can have query params still\n // hanging off them. That would break rule matching.\n absPath = cleanUrl(absPath);\n\n let fileRules = this.rules.files.get(absPath);\n let componentRules: PreprocessedComponentRule | undefined;\n\n let componentName = this.moduleResolver.reverseComponentLookup(absPath);\n if (componentName) {\n componentRules = this.rules.components.get(componentName);\n }\n\n if (fileRules && componentRules) {\n return mergeWith(fileRules, componentRules, appendArrays);\n }\n\n return fileRules ?? componentRules;\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n let name = snippetToDasherizedName(snippet);\n if (name == null) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n return name;\n }\n\n private targetComponent(name: string): ComponentResolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n const builtIn = this.builtInsForEmberVersion[name];\n\n if (builtIn?.importableComponent) {\n let [importedName, specifier] = builtIn.importableComponent;\n return {\n type: 'component',\n specifier,\n importedName,\n yieldsComponents: [],\n yieldsArguments: [],\n argumentsAreComponents: [],\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n if (this.isIgnoredComponent(name)) {\n return null;\n }\n\n let componentRules = this.rules.components.get(name);\n return {\n type: 'component',\n specifier: `@embroider/virtual/components/${name}`,\n importedName: 'default',\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n nameHint: this.nameHint(name),\n };\n }\n\n private targetComponentHelper(\n component: ComponentLocator,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): ComponentResolution | ResolutionFail | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n };\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findRules(this.env.filename);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return {\n type: 'error',\n message,\n detail: component.path,\n loc,\n };\n }\n\n return this.targetComponent(component.path);\n }\n\n private targetHelper(path: string): HelperResolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n\n // people are not allowed to override the built-in helpers with their own\n // globally-named helpers. It throws an error. So it's fine for us to\n // prioritize the builtIns here without bothering to resolve a user helper\n // of the same name.\n const builtIn = this.builtInsForEmberVersion[path];\n\n if (builtIn?.importableHelper) {\n let [importedName, specifier] = builtIn.importableHelper;\n return {\n type: 'helper',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n return {\n type: 'helper',\n specifier: `@embroider/virtual/helpers/${path}`,\n importedName: 'default',\n nameHint: this.nameHint(path),\n };\n }\n\n private targetHelperOrComponent(\n path: string,\n loc: Loc,\n hasArgs: boolean\n ): ComponentResolution | HelperResolution | null {\n /*\n\n In earlier embroider versions we would do a bunch of module resolution right\n here inside the ast transform to try to resolve the ambiguity of this case\n and if we didn't find anything, leave the template unchanged. But that leads\n to both a lot of extra build-time expense (since we are attempting\n resolution for lots of things that may in fact be just some data and not a\n component invocation at all, and also since we are pre-resolving modules\n that will get resolved a second time by the final stage packager).\n\n Now, we're going to be less forgiving, because it streamlines the build for\n everyone who's not still using these *extremely* old patterns.\n\n The problematic case is:\n\n 1. In a non-strict template (because this whole resolver-transform.ts is a\n no-op on strict handlebars).\n\n 2. Have a mustache statement like: `{{something}}`, where `something` is:\n\n a. Not a variable in scope (for example, there's no preceeding line\n like `<Parent as |something|>`)\n b. Does not start with `@` because that must be an argument from outside this template.\n c. Does not contain a dot, like `some.thing` (because that case is classically\n never a global component resolution that we would need to handle)\n d. Does not start with `this` (this rule is mostly redundant with the previous rule,\n but even a standalone `this` is never a component invocation).\n e. Does not have any arguments. If there are argument like `{{something a=b}}`,\n there is still ambiguity between helper vs component, but there is no longer\n the possibility that this was just rendering some data.\n f. Does not take a block, like `{{#something}}{{/something}}` (because that is\n always a component, no ambiguity.)\n\n We can't tell if this problematic case is really:\n\n 1. A helper invocation with no arguments that is being directly rendered.\n Out-of-the-box, ember already generates [a lint\n error](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-curly-component-invocation.md)\n for this, although it tells you to whitelist your helper when IMO it\n should tell you to use an unambiguous syntax like `{{ (something) }}`\n instead.\n\n 2. A component invocation, which you could have written `<Something />`\n instead. Angle-bracket invocation has been available and easy-to-adopt\n for a very long time.\n\n 3. Property-this-fallback for `{{this.something}}`. Property-this-fallback\n is eliminated at Ember 4.0, so people have been heavily pushed to get\n it out of their addons.\n */\n\n // first, bail out on all the stuff we can obviously ignore\n if ((!this.staticHelpersEnabled && !this.staticComponentsEnabled) || this.isIgnoredComponent(path)) {\n return null;\n }\n\n let builtIn = this.builtInsForEmberVersion[path];\n\n if (builtIn?.importableComponent) {\n let [importedName, specifier] = builtIn.importableComponent;\n return {\n type: 'component',\n specifier,\n importedName,\n yieldsComponents: [],\n yieldsArguments: [],\n argumentsAreComponents: [],\n nameHint: importedName,\n };\n }\n\n if (builtIn?.importableHelper) {\n let [importedName, specifier] = builtIn.importableHelper;\n return {\n type: 'helper',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n let ownComponentRules = this.findRules(this.env.filename);\n if (ownComponentRules?.disambiguate[path]) {\n switch (ownComponentRules.disambiguate[path]) {\n case 'component':\n return this.targetComponent(path);\n case 'helper':\n return this.targetHelper(path);\n case 'data':\n return null;\n }\n }\n\n if (!hasArgs && !path.includes('/') && !path.includes('@')) {\n // this is the case that could also be property-this-fallback. We're going\n // to force people to disambiguate, because letting a potential component\n // or helper invocation lurk inside every bit of data you render is not\n // ok.\n this.reportError({\n type: 'error',\n message: 'unsupported ambiguous syntax',\n detail: `\"{{${path}}}\" is ambiguous and could mean \"{{this.${path}}}\" or component \"<${capitalize(\n camelCase(path)\n )} />\" or helper \"{{ (${path}) }}\". Change it to one of those unambigous forms, or use a \"disambiguate\" packageRule to work around the problem if its in third-party code you cannot easily fix.`,\n loc,\n });\n return null;\n }\n\n // Above we already bailed out if both of these were disabled, so we know at\n // least one is turned on. If both aren't turned on, we're stuck, because we\n // can't even tell if this *is* a component vs a helper.\n if (!this.staticHelpersEnabled || !this.staticComponentsEnabled) {\n this.reportError({\n type: 'error',\n message: 'unsupported ambiguity between helper and component',\n detail: `this use of \"{{${path}}}\" could be helper \"{{ (${path}) }}\" or component \"<${capitalize(\n camelCase(path)\n )} />\", and your settings for staticHelpers and staticComponents do not agree. Either switch to one of the unambiguous forms, or make staticHelpers and staticComponents agree, or use a \"disambiguate\" packageRule to work around the problem if its in third-party code you cannot easily fix.`,\n loc,\n });\n return null;\n }\n\n let componentRules = this.rules.components.get(path);\n return {\n type: 'component',\n specifier: `@embroider/virtual/ambiguous/${path}`,\n importedName: 'default',\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n nameHint: this.nameHint(path),\n };\n }\n\n private targetElementModifier(path: string): ModifierResolution | null {\n if (!this.staticModifiersEnabled) {\n return null;\n }\n\n const builtIn = this.builtInsForEmberVersion[path];\n if (builtIn?.importableModifier) {\n let [importedName, specifier] = builtIn.importableModifier;\n return {\n type: 'modifier',\n specifier,\n importedName,\n nameHint: importedName,\n };\n }\n\n if (builtIn) {\n return null;\n }\n\n return {\n type: 'modifier',\n specifier: `@embroider/virtual/modifiers/${path}`,\n importedName: 'default',\n nameHint: this.nameHint(path),\n };\n }\n\n targetDynamicModifier(modifier: ComponentLocator, loc: Loc): ModifierResolution | ResolutionFail | null {\n if (!this.staticModifiersEnabled) {\n return null;\n }\n\n if (modifier.type === 'literal') {\n return this.targetElementModifier(modifier.path);\n } else {\n return {\n type: 'error',\n message: 'Unsafe dynamic modifier',\n detail: `cannot statically analyze this expression`,\n loc,\n };\n }\n }\n\n private targetDynamicHelper(helper: ComponentLocator): HelperResolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n\n if (helper.type === 'literal') {\n return this.targetHelper(helper.path);\n }\n\n // we don't have to manage any errors in this case because ember itself\n // considers it an error to pass anything but a string literal to the\n // `helper` helper.\n return null;\n }\n\n private nameHint(path: string) {\n let parts = path.split('@');\n\n // the extra underscore here guarantees that we will never collide with an\n // HTML element.\n return parts[parts.length - 1] + '_';\n }\n\n private handleDynamicModifier(param: ASTv1.Expression): ModifierResolution | ResolutionFail | null {\n if (param.type === 'StringLiteral') {\n return this.targetDynamicModifier({ type: 'literal', path: param.value }, param.loc);\n }\n // we don't have to manage any errors in this case because ember itself\n // considers it an error to pass anything but a string literal to the\n // modifier helper.\n return null;\n }\n\n private handleDynamicHelper(param: ASTv1.Expression): HelperResolution | ResolutionFail | null {\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 return this.targetDynamicHelper({ type: 'literal', path: param.value });\n }\n return null;\n }\n\n visitor: ASTPlugin['visitor'] = {\n Template: {\n enter: () => {\n if (this.env.locals) {\n this.scopeStack.pushMustacheBlock(this.env.locals);\n }\n },\n exit: () => {\n if (this.env.locals) {\n this.scopeStack.pop();\n }\n },\n },\n Block: {\n enter: node => {\n this.scopeStack.pushMustacheBlock(node.blockParams);\n },\n exit: () => {\n this.scopeStack.pop();\n },\n },\n BlockStatement: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = headOf(node.path);\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (parts(node.path).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 = this.handleComponentHelper(node.params[0]);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.params[0] = newIdentifier;\n });\n return;\n }\n let resolution = this.targetComponent(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n if (resolution?.type === 'component') {\n this.scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n this.handleDynamicComponentArguments(\n rootName,\n argumentsAreComponents,\n extendPath(extendPath(path, 'hash'), 'pairs')\n );\n });\n }\n },\n SubExpression: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (this.scopeStack.inScope(headOf(node.path), path)) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = this.handleComponentHelper(node.params[0]);\n this.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 let resolution = this.handleDynamicHelper(node.params[0]);\n this.emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.original === 'modifier' && node.params.length > 0) {\n let resolution = this.handleDynamicModifier(node.params[0]);\n this.emit(path, resolution, (node, newId) => {\n node.params[0] = newId;\n });\n return;\n }\n if (node.path.tail.length === 0 && node.path.head.type === 'VarHead') {\n let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n }\n },\n MustacheStatement: {\n enter: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = headOf(node.path);\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (parts(node.path).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.startsWith('@')) {\n // similarly, global resolution of helpers and components never\n // happens with argument paths (it could still be an invocation, but\n // it would be a lexically-scoped invocation, not one we need to\n // adjust)\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = this.handleComponentHelper(node.params[0]);\n this.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 let resolution = this.handleDynamicHelper(node.params[0]);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.params[0] = newIdentifier;\n });\n return;\n }\n if (path.parent?.node.type === 'AttrNode') {\n // this mustache is the value of an attribute. Components aren't\n // allowed here, so we're not ambiguous, so resolve a helper.\n let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.path = newIdentifier;\n });\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = this.targetHelperOrComponent(node.path.original, node.path.loc, hasArgs);\n this.emit(path, resolution, (node, newIdentifier) => {\n node.path = newIdentifier;\n });\n if (resolution?.type === 'component') {\n this.handleDynamicComponentArguments(\n node.path.original,\n resolution.argumentsAreComponents,\n extendPath(extendPath(path, 'hash'), 'pairs')\n );\n }\n },\n },\n ElementModifierStatement: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (this.scopeStack.inScope(headOf(node.path), path)) {\n return;\n }\n if (isThisHead(node.path)) {\n return;\n }\n if (isAtHead(node.path)) {\n return;\n }\n if (parts(node.path).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 = this.targetElementModifier(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n ElementNode: {\n enter: (node, path) => {\n let rootName = node.tag.split('.')[0];\n if (!this.scopeStack.inScope(rootName, path)) {\n let resolution: ComponentResolution | null = null;\n\n // if it starts with lower case, it can't be a component we need to\n // globally resolve\n if (node.tag[0] !== node.tag[0].toLowerCase()) {\n resolution = this.targetComponent(dasherize(node.tag));\n }\n\n this.emit(path, resolution, (node, newId) => {\n node.tag = newId.original;\n });\n if (resolution?.type === 'component') {\n this.scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n this.handleDynamicComponentArguments(node.tag, argumentsAreComponents, extendPath(path, 'attributes'));\n });\n }\n }\n this.scopeStack.pushElementBlock(node.blockParams, node);\n },\n exit: () => {\n this.scopeStack.pop();\n },\n },\n };\n}\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\nexport default function makeResolverTransform({ appRoot, emberVersion }: Options) {\n let loader = new ResolverLoader(appRoot);\n let config = loader.resolver.options as CompatResolverOptions;\n const resolverTransform: ASTPluginBuilder<Env> = env => {\n if (env.strictMode) {\n return {\n name: 'embroider-build-time-resolver-strict-noop',\n visitor: {},\n };\n }\n return new TemplateResolver(env, config, builtInKeywords(emberVersion));\n };\n (resolverTransform as any).parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: { appRoot: appRoot },\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 =\n | { type: 'mustache'; blockParams: string[] }\n | { type: 'element'; blockParams: string[]; childrenOf: ASTv1.ElementNode }\n | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // mustache blocks like:\n //\n // {{#stuff as |some block vars|}}\n //\n // are relatively simple for us because there's a dedicated `Block` AST node\n // that exactly covers the range in which the variables are in scope.\n pushMustacheBlock(blockParams: string[]) {\n this.stack.unshift({ type: 'mustache', blockParams });\n }\n\n // element blocks like:\n //\n // <Stuff as |some block vars|>\n //\n // are *not* so simple for us because there's no single AST node that exactly\n // covers the range in which the variables are in scope. For example, the\n // *attributes* of the element do not see the variables, but the children of\n // the element do.\n pushElementBlock(blockParams: string[], childrenOf: ASTv1.ElementNode) {\n this.stack.unshift({ type: 'element', blockParams, childrenOf });\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, fromPath: WalkerPath<ASTv1.Node>) {\n for (let scope of this.stack) {\n if (scope.type === 'mustache' && scope.blockParams.includes(name)) {\n return true;\n }\n if (\n scope.type === 'element' &&\n scope.blockParams.includes(name) &&\n withinElementBlock(fromPath, scope.childrenOf)\n ) {\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 === 'mustache' || here.type === 'element') && 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 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\nfunction capitalize(word: string): string {\n return word[0].toUpperCase() + word.slice(1);\n}\n\n// ElementNodes have both children and attributes and both of those are\n// \"children\" in the abstract syntax tree sense, but here we want to distinguish\n// between them.\nfunction withinElementBlock(childPath: WalkerPath<ASTv1.Node>, ancestorNode: ASTv1.ElementNode): Boolean {\n let cursor: WalkerPath<ASTv1.Node> | null = childPath;\n while (cursor && cursor.node !== ancestorNode) {\n if (ancestorNode.children.includes(cursor.node as ASTv1.Statement)) {\n return true;\n }\n cursor = cursor.parent;\n }\n return false;\n}\nfunction appendArrays(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return objValue.concat(srcValue);\n }\n}\n\nfunction headOf(path: any) {\n if (!path) return;\n\n return 'head' in path ? path.head.name : path.parts[0];\n}\n\nfunction isThisHead(path: any) {\n if (!path) return;\n\n if ('head' in path) {\n return path.head.type === 'ThisHead';\n }\n\n return path.this === true;\n}\n\nfunction isAtHead(path: any) {\n if (!path) return;\n\n if ('head' in path) {\n return path.head.type === 'AtHead';\n }\n\n return path.data === true;\n}\n\nfunction parts(path: any) {\n if (!path) return;\n\n return 'original' in path ? path.original.split('.') : path.parts;\n}\n"]}
|