@embroider/compat 2.1.1-unstable.21eae41 → 2.1.1-unstable.936fd63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/audit/babel-visitor.d.ts +1 -0
- package/src/audit/babel-visitor.js +2 -2
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit.d.ts +1 -1
- package/src/audit.js +6 -3
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +93 -26
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/compat-app.js +3 -10
- package/src/compat-app.js.map +1 -1
- package/src/dependency-rules.d.ts +7 -2
- package/src/dependency-rules.js +17 -1
- package/src/dependency-rules.js.map +1 -1
- package/src/resolver-transform.js +13 -1
- 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": "2.1.1-unstable.
|
|
3
|
+
"version": "2.1.1-unstable.936fd63",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
29
29
|
"@babel/preset-env": "^7.14.5",
|
|
30
30
|
"@babel/traverse": "^7.14.5",
|
|
31
|
-
"@embroider/macros": "1.10.0-unstable.
|
|
31
|
+
"@embroider/macros": "1.10.0-unstable.936fd63",
|
|
32
32
|
"@types/babel__code-frame": "^7.0.2",
|
|
33
33
|
"@types/yargs": "^17.0.3",
|
|
34
34
|
"assert-never": "^1.1.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"typescript": "*"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@embroider/core": "2.1.1-unstable.
|
|
86
|
+
"@embroider/core": "2.1.1-unstable.936fd63"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": "12.* || 14.* || >= 16"
|
|
@@ -27,7 +27,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
|
|
|
27
27
|
let sawExports = false;
|
|
28
28
|
let sawDefine = false;
|
|
29
29
|
/* eslint-enable @typescript-eslint/no-inferrable-types */
|
|
30
|
-
let ast = (0, core_1.transformSync)(rawSource, Object.assign({ filename: filename }, babelConfig))
|
|
30
|
+
let { ast, code } = (0, core_1.transformSync)(rawSource, Object.assign({ filename: filename }, babelConfig));
|
|
31
31
|
let saveCodeFrame = frames.forSource(rawSource);
|
|
32
32
|
(0, traverse_1.default)(ast, {
|
|
33
33
|
Identifier(path) {
|
|
@@ -141,7 +141,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
|
|
|
141
141
|
});
|
|
142
142
|
let isCJS = imports.length === 0 && exports.size === 0 && (sawModule || sawExports);
|
|
143
143
|
let isAMD = imports.length === 0 && exports.size === 0 && sawDefine;
|
|
144
|
-
return { imports, exports, isCJS, isAMD, problems };
|
|
144
|
+
return { imports, exports, isCJS, isAMD, problems, transpiledContent: code };
|
|
145
145
|
}
|
|
146
146
|
exports.auditJS = auditJS;
|
|
147
147
|
class CodeFrameStorage {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA2D;AAC3D,sCAA0E;AAC1E,kDAAqE;AAErE,MAAa,YAAY;CAAG;AAA5B,oCAA4B;AAgB5B,SAAgB,iBAAiB,CAAC,KAA+B;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,8CAEC;AAMD,yCAAyC;AACzC,SAAgB,OAAO,CAAC,SAAiB,EAAE,QAAgB,EAAE,WAA6B,EAAE,MAAwB;IAClH,IAAI,OAAO,GAAG,EAAsB,CAAC;IACrC,IAAI,OAAO,GAAG,IAAI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,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF,KAAK,mBAAmB;YACtB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClF,KAAK,qBAAqB,CAAC;QAC3B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChF;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC","sourcesContent":["import traverse, { NodePath, Node } from '@babel/traverse';\nimport { TransformOptions, transformSync, types as t } from '@babel/core';\nimport { codeFrameColumns, SourceLocation } from '@babel/code-frame';\n\nexport class VisitorState {}\n\nexport interface InternalImport {\n source: string;\n codeFrameIndex: number | undefined;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n codeFrameIndex: number | undefined;\n }[];\n}\n\nexport interface NamespaceMarker {\n isNamespace: true;\n}\n\nexport function isNamespaceMarker(value: string | NamespaceMarker): value is NamespaceMarker {\n return typeof value !== 'string';\n}\n\nexport interface ExportAll {\n all: string;\n}\n\n// babelConfig must include { ast: true }\nexport function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage) {\n let imports = [] as InternalImport[];\n let exports = new Set<string | ExportAll>();\n let problems = [] as { message: string; detail: string; codeFrameIndex: number | undefined }[];\n\n /* eslint-disable @typescript-eslint/no-inferrable-types */\n // These are not really inferrable. Without explicit declarations, TS thinks\n // they're always false because it doesn't know the handler methods run\n // synchronously\n let sawModule: boolean = false;\n let sawExports: boolean = false;\n let sawDefine: boolean = false;\n /* eslint-enable @typescript-eslint/no-inferrable-types */\n\n let ast = transformSync(rawSource, Object.assign({ filename: filename }, babelConfig))!.ast!;\n let saveCodeFrame = frames.forSource(rawSource);\n\n traverse(ast, {\n Identifier(path: NodePath<t.Identifier>) {\n if (path.node.name === 'module' && isFreeVariable(path)) {\n sawModule = true;\n } else if (path.node.name === 'exports' && isFreeVariable(path)) {\n sawExports = true;\n } else if (path.node.name === 'define' && isFreeVariable(path)) {\n sawDefine = true;\n }\n if (inExportDeclarationContext(path)) {\n exports.add(path.node.name);\n }\n },\n CallExpression(path: NodePath<t.CallExpression>) {\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'importSync') || t.isImport(callee)) {\n let arg = path.node.arguments[0];\n if (arg.type === 'StringLiteral') {\n imports.push({\n source: arg.value,\n codeFrameIndex: saveCodeFrame(arg),\n specifiers: [],\n });\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${t.isImport(callee) ? 'import' : 'importSync'}`,\n detail: arg.type,\n codeFrameIndex: saveCodeFrame(arg),\n });\n }\n }\n },\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n },\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: 'default',\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportNamespaceSpecifier(path: NodePath<t.ImportNamespaceSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportSpecifier(path: NodePath<t.ImportSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.imported),\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n exports.add('default');\n },\n ExportSpecifier(path: NodePath<t.ExportSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.local),\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportNamespaceSpecifier(path: NodePath<t.ExportNamespaceSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>) {\n exports.add({ all: path.node.source.value });\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [\n {\n name: { isNamespace: true },\n local: null,\n codeFrameIndex: saveCodeFrame(path.node),\n },\n ],\n });\n },\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n if (path.node.source) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n }\n },\n });\n\n let isCJS = imports.length === 0 && exports.size === 0 && (sawModule || sawExports);\n let isAMD = imports.length === 0 && exports.size === 0 && sawDefine;\n return { imports, exports, isCJS, isAMD, problems };\n}\n\nexport class CodeFrameStorage {\n private codeFrames = [] as { rawSourceIndex: number; loc: SourceLocation }[];\n private rawSources = [] as string[];\n\n forSource(rawSource: string): (node: { loc?: SourceLocation | null }) => number | undefined {\n let rawSourceIndex: number | undefined;\n return (node: { loc?: SourceLocation | null | undefined }) => {\n let loc = node.loc;\n if (!loc) {\n return;\n }\n if (rawSourceIndex == null) {\n rawSourceIndex = this.rawSources.length;\n this.rawSources.push(rawSource);\n }\n let codeFrameIndex = this.codeFrames.length;\n this.codeFrames.push({\n rawSourceIndex,\n loc,\n });\n return codeFrameIndex;\n };\n }\n\n render(codeFrameIndex: number | undefined): string | undefined {\n if (codeFrameIndex != null) {\n let { loc, rawSourceIndex } = this.codeFrames[codeFrameIndex];\n return codeFrameColumns(this.rawSources[rawSourceIndex], loc, { highlightCode: true });\n }\n }\n}\n\nfunction name(node: t.StringLiteral | t.Identifier): string {\n if (t.isStringLiteral(node)) {\n return node.value;\n } else {\n return node.name;\n }\n}\n\nfunction isFreeVariable(path: NodePath<t.Identifier>) {\n return !path.scope.hasBinding(path.node.name);\n}\n\nconst contextCache: WeakMap<Node, boolean> = new WeakMap();\n\nfunction inExportDeclarationContext(path: NodePath): boolean {\n if (contextCache.has(path.node)) {\n return contextCache.get(path.node)!;\n } else {\n let answer = _inExportDeclarationContext(path);\n contextCache.set(path.node, answer);\n return answer;\n }\n}\n\nfunction _inExportDeclarationContext(path: NodePath): boolean {\n let parent = path.parent;\n switch (parent.type) {\n case 'ExportNamedDeclaration':\n return parent.declaration === path.node;\n case 'VariableDeclaration':\n case 'ObjectPattern':\n case 'ArrayPattern':\n case 'RestElement':\n return inExportDeclarationContext(path.parentPath);\n case 'VariableDeclarator':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath);\n case 'ObjectProperty':\n return parent.value === path.node && inExportDeclarationContext(path.parentPath);\n case 'AssignmentPattern':\n return parent.left === path.node && inExportDeclarationContext(path.parentPath);\n case 'FunctionDeclaration':\n case 'ClassDeclaration':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath);\n default:\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA2D;AAC3D,sCAA0E;AAC1E,kDAAqE;AAErE,MAAa,YAAY;CAAG;AAA5B,oCAA4B;AAgB5B,SAAgB,iBAAiB,CAAC,KAA+B;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,8CAEC;AAMD,yCAAyC;AACzC,SAAgB,OAAO,CAAC,SAAiB,EAAE,QAAgB,EAAE,WAA6B,EAAE,MAAwB;IAClH,IAAI,OAAO,GAAG,EAAsB,CAAC;IACr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CAAC,UAAU,CAAC,CAAC;QAChF,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnF,KAAK,mBAAmB;YACtB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClF,KAAK,qBAAqB,CAAC;QAC3B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChF;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC","sourcesContent":["import traverse, { NodePath, Node } from '@babel/traverse';\nimport { TransformOptions, transformSync, types as t } from '@babel/core';\nimport { codeFrameColumns, SourceLocation } from '@babel/code-frame';\n\nexport class VisitorState {}\n\nexport interface InternalImport {\n source: string;\n codeFrameIndex: number | undefined;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n codeFrameIndex: number | undefined;\n }[];\n}\n\nexport interface NamespaceMarker {\n isNamespace: true;\n}\n\nexport function isNamespaceMarker(value: string | NamespaceMarker): value is NamespaceMarker {\n return typeof value !== 'string';\n}\n\nexport interface ExportAll {\n all: string;\n}\n\n// babelConfig must include { ast: true }\nexport function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage) {\n let imports = [] as InternalImport[];\n let exports = new Set<string | ExportAll>();\n let problems = [] as { message: string; detail: string; codeFrameIndex: number | undefined }[];\n\n /* eslint-disable @typescript-eslint/no-inferrable-types */\n // These are not really inferrable. Without explicit declarations, TS thinks\n // they're always false because it doesn't know the handler methods run\n // synchronously\n let sawModule: boolean = false;\n let sawExports: boolean = false;\n let sawDefine: boolean = false;\n /* eslint-enable @typescript-eslint/no-inferrable-types */\n\n let { ast, code } = transformSync(rawSource, Object.assign({ filename: filename }, babelConfig))!;\n let saveCodeFrame = frames.forSource(rawSource);\n\n traverse(ast!, {\n Identifier(path: NodePath<t.Identifier>) {\n if (path.node.name === 'module' && isFreeVariable(path)) {\n sawModule = true;\n } else if (path.node.name === 'exports' && isFreeVariable(path)) {\n sawExports = true;\n } else if (path.node.name === 'define' && isFreeVariable(path)) {\n sawDefine = true;\n }\n if (inExportDeclarationContext(path)) {\n exports.add(path.node.name);\n }\n },\n CallExpression(path: NodePath<t.CallExpression>) {\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'importSync') || t.isImport(callee)) {\n let arg = path.node.arguments[0];\n if (arg.type === 'StringLiteral') {\n imports.push({\n source: arg.value,\n codeFrameIndex: saveCodeFrame(arg),\n specifiers: [],\n });\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${t.isImport(callee) ? 'import' : 'importSync'}`,\n detail: arg.type,\n codeFrameIndex: saveCodeFrame(arg),\n });\n }\n }\n },\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n },\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: 'default',\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportNamespaceSpecifier(path: NodePath<t.ImportNamespaceSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportSpecifier(path: NodePath<t.ImportSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.imported),\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n exports.add('default');\n },\n ExportSpecifier(path: NodePath<t.ExportSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.local),\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportNamespaceSpecifier(path: NodePath<t.ExportNamespaceSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>) {\n exports.add({ all: path.node.source.value });\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [\n {\n name: { isNamespace: true },\n local: null,\n codeFrameIndex: saveCodeFrame(path.node),\n },\n ],\n });\n },\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n if (path.node.source) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n }\n },\n });\n\n let isCJS = imports.length === 0 && exports.size === 0 && (sawModule || sawExports);\n let isAMD = imports.length === 0 && exports.size === 0 && sawDefine;\n return { imports, exports, isCJS, isAMD, problems, transpiledContent: code! };\n}\n\nexport class CodeFrameStorage {\n private codeFrames = [] as { rawSourceIndex: number; loc: SourceLocation }[];\n private rawSources = [] as string[];\n\n forSource(rawSource: string): (node: { loc?: SourceLocation | null }) => number | undefined {\n let rawSourceIndex: number | undefined;\n return (node: { loc?: SourceLocation | null | undefined }) => {\n let loc = node.loc;\n if (!loc) {\n return;\n }\n if (rawSourceIndex == null) {\n rawSourceIndex = this.rawSources.length;\n this.rawSources.push(rawSource);\n }\n let codeFrameIndex = this.codeFrames.length;\n this.codeFrames.push({\n rawSourceIndex,\n loc,\n });\n return codeFrameIndex;\n };\n }\n\n render(codeFrameIndex: number | undefined): string | undefined {\n if (codeFrameIndex != null) {\n let { loc, rawSourceIndex } = this.codeFrames[codeFrameIndex];\n return codeFrameColumns(this.rawSources[rawSourceIndex], loc, { highlightCode: true });\n }\n }\n}\n\nfunction name(node: t.StringLiteral | t.Identifier): string {\n if (t.isStringLiteral(node)) {\n return node.value;\n } else {\n return node.name;\n }\n}\n\nfunction isFreeVariable(path: NodePath<t.Identifier>) {\n return !path.scope.hasBinding(path.node.name);\n}\n\nconst contextCache: WeakMap<Node, boolean> = new WeakMap();\n\nfunction inExportDeclarationContext(path: NodePath): boolean {\n if (contextCache.has(path.node)) {\n return contextCache.get(path.node)!;\n } else {\n let answer = _inExportDeclarationContext(path);\n contextCache.set(path.node, answer);\n return answer;\n }\n}\n\nfunction _inExportDeclarationContext(path: NodePath): boolean {\n let parent = path.parent;\n switch (parent.type) {\n case 'ExportNamedDeclaration':\n return parent.declaration === path.node;\n case 'VariableDeclaration':\n case 'ObjectPattern':\n case 'ArrayPattern':\n case 'RestElement':\n return inExportDeclarationContext(path.parentPath);\n case 'VariableDeclarator':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath);\n case 'ObjectProperty':\n return parent.value === path.node && inExportDeclarationContext(path.parentPath);\n case 'AssignmentPattern':\n return parent.left === path.node && inExportDeclarationContext(path.parentPath);\n case 'FunctionDeclaration':\n case 'ClassDeclaration':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath);\n default:\n return false;\n }\n}\n"]}
|
package/src/audit.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ interface InternalModule {
|
|
|
47
47
|
isCJS: boolean;
|
|
48
48
|
isAMD: boolean;
|
|
49
49
|
dependencies: string[];
|
|
50
|
+
transpiledContent: string | Buffer;
|
|
50
51
|
};
|
|
51
52
|
resolved?: Map<string, string | ResolutionFailure>;
|
|
52
|
-
content?: string | Buffer;
|
|
53
53
|
linked?: {
|
|
54
54
|
exports: Set<string>;
|
|
55
55
|
};
|
package/src/audit.js
CHANGED
|
@@ -38,7 +38,7 @@ class AuditResults {
|
|
|
38
38
|
this.findings = [];
|
|
39
39
|
}
|
|
40
40
|
static create(baseDir, findings, modules) {
|
|
41
|
-
var _a, _b;
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
42
|
let results = new this();
|
|
43
43
|
for (let [filename, module] of modules) {
|
|
44
44
|
let publicModule = {
|
|
@@ -67,7 +67,9 @@ class AuditResults {
|
|
|
67
67
|
}))
|
|
68
68
|
: [],
|
|
69
69
|
exports: ((_b = module.linked) === null || _b === void 0 ? void 0 : _b.exports) ? [...module.linked.exports] : [],
|
|
70
|
-
content:
|
|
70
|
+
content: ((_c = module.parsed) === null || _c === void 0 ? void 0 : _c.transpiledContent)
|
|
71
|
+
? (_d = module.parsed) === null || _d === void 0 ? void 0 : _d.transpiledContent.toString()
|
|
72
|
+
: 'module failed to transpile',
|
|
71
73
|
};
|
|
72
74
|
results.modules[(0, core_1.explicitRelative)(baseDir, filename)] = publicModule;
|
|
73
75
|
}
|
|
@@ -234,7 +236,6 @@ class Audit {
|
|
|
234
236
|
else {
|
|
235
237
|
module.parsed = visitResult;
|
|
236
238
|
module.resolved = await this.resolveDeps(visitResult.dependencies, filename);
|
|
237
|
-
module.content = content;
|
|
238
239
|
}
|
|
239
240
|
}
|
|
240
241
|
}
|
|
@@ -376,6 +377,7 @@ class Audit {
|
|
|
376
377
|
isCJS: false,
|
|
377
378
|
isAMD: false,
|
|
378
379
|
dependencies,
|
|
380
|
+
transpiledContent: content,
|
|
379
381
|
};
|
|
380
382
|
}
|
|
381
383
|
async visitJS(filename, content) {
|
|
@@ -396,6 +398,7 @@ class Audit {
|
|
|
396
398
|
isCJS: result.isCJS,
|
|
397
399
|
isAMD: result.isAMD,
|
|
398
400
|
dependencies: result.imports.map(i => i.source),
|
|
401
|
+
transpiledContent: result.transpiledContent,
|
|
399
402
|
};
|
|
400
403
|
}
|
|
401
404
|
catch (err) {
|
package/src/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{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AAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,CAAC;KACf;IAED,OAAO,GAAG;SACP,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,oCAEC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { dirname, join, resolve as resolvePath } from 'path';\nimport { AppMeta, explicitRelative, hbsToJS, Resolver, ResolverOptions } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport jsdom from 'jsdom';\nimport groupBy from 'lodash/groupBy';\nimport fromPairs from 'lodash/fromPairs';\nimport {\n auditJS,\n CodeFrameStorage,\n ExportAll,\n InternalImport,\n isNamespaceMarker,\n NamespaceMarker,\n} from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\n\nconst { JSDOM } = jsdom;\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport interface Module {\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n imports: Import[];\n exports: string[];\n resolutions: { [source: string]: string | null };\n content: string;\n}\n\ninterface ResolutionFailure {\n isResolutionFailure: true;\n}\n\nfunction isResolutionFailure(result: string | ResolutionFailure | undefined): result is ResolutionFailure {\n return typeof result === 'object' && 'isResolutionFailure' in result;\n}\n\ninterface InternalModule {\n consumedFrom: (string | RootMarker)[];\n\n parsed?: {\n imports: InternalImport[];\n exports: Set<string | ExportAll>;\n isCJS: boolean;\n isAMD: boolean;\n dependencies: string[];\n };\n\n resolved?: Map<string, string | ResolutionFailure>;\n\n content?: string | Buffer;\n\n linked?: {\n exports: Set<string>;\n };\n}\n\ntype ParsedInternalModule = Omit<InternalModule, 'parsed'> & {\n parsed: NonNullable<InternalModule['parsed']>;\n};\n\ntype ResolvedInternalModule = Omit<ParsedInternalModule, 'resolved'> & {\n resolved: NonNullable<ParsedInternalModule['resolved']>;\n};\n\nfunction isResolved(module: InternalModule | undefined): module is ResolvedInternalModule {\n return Boolean(module?.parsed && module.resolved);\n}\n\ntype LinkedInternalModule = Omit<ResolvedInternalModule, 'linked'> & {\n linked: NonNullable<ResolvedInternalModule['linked']>;\n};\n\nfunction isLinked(module: InternalModule | undefined): module is LinkedInternalModule {\n return Boolean(module?.parsed && module.resolved && module.linked);\n}\n\nexport interface Import {\n source: string;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n }[];\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>) {\n let results = new this();\n for (let [filename, module] of modules) {\n let publicModule: Module = {\n appRelativePath: explicitRelative(baseDir, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(baseDir, entry);\n }\n }),\n resolutions: module.resolved\n ? fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(baseDir, target),\n ])\n )\n : {},\n imports: module.parsed?.imports\n ? module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n })),\n }))\n : [],\n exports: module.linked?.exports ? [...module.linked.exports] : [],\n content: module.content ? module.content.toString() : '',\n };\n results.modules[explicitRelative(baseDir, filename)] = publicModule;\n }\n for (let finding of findings) {\n let relFinding = Object.assign({}, finding, { filename: explicitRelative(baseDir, finding.filename) });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private modules: Map<string, InternalModule> = new Map();\n private virtualModules: Map<string, string> = new Map();\n private moduleQueue = new Set<string>();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n let dir: string;\n\n if (options.outputDir) {\n dir = options.outputDir;\n } else {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n dir = await this.findStage2Output(options);\n }\n\n let audit = new this(dir, options);\n if (options['reuse-build']) {\n if (!audit.meta.babel.isParallelSafe) {\n throw new BuildError(\n `You can't use the ${chalk.red(\n '--reuse-build'\n )} option because some of your babel or HBS plugins are non-serializable`\n );\n }\n }\n return audit.run();\n }\n\n private static async findStage2Output(options: AuditBuildOptions): Promise<string> {\n try {\n if (!options.app) {\n throw new Error(`AuditBuildOptions needs \"app\" directory`);\n }\n return readFileSync(join(options.app, 'dist/.stage2-output'), 'utf8');\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new BuildError(\n `${chalk.yellow(\n 'Your build'\n )} did not produce expected Embroider stage2 output.\\nMake sure you actually have Embroider configured.`\n );\n }\n throw err;\n }\n }\n\n constructor(private appDir: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.appDir, 'package.json'));\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.appDir, this.meta.babel.filename));\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(this.appDir, '.embroider', 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n private visitorFor(\n filename: string\n ): (\n this: Audit,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed']> | Finding[]> {\n if (filename.endsWith('.html')) {\n return this.visitHTML;\n } else if (filename.endsWith('.hbs')) {\n return this.visitHBS;\n } else if (filename.endsWith('.json')) {\n return this.visitJSON;\n } else {\n return this.visitJS;\n }\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let filename = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(filename);\n this.debug('visit', filename);\n let visitor = this.visitorFor(filename);\n let content: string | Buffer;\n if (this.virtualModules.has(filename)) {\n content = this.virtualModules.get(filename)!;\n } else {\n content = readFileSync(filename);\n }\n // cast is safe because the only way to get into the queue is to go\n // through scheduleVisit, and scheduleVisit creates the entry in\n // this.modules.\n let module: InternalModule = this.modules.get(filename)!;\n let visitResult = await visitor.call(this, filename, content);\n if (Array.isArray(visitResult)) {\n // the visitor was unable to figure out the ParseFields and returned\n // some number of Findings to us to explain why.\n for (let finding of visitResult) {\n this.pushFinding(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, filename);\n module.content = content;\n }\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n for (let asset of this.meta.assets) {\n if (asset.endsWith('.html')) {\n this.scheduleVisit(resolvePath(this.appDir, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n return AuditResults.create(this.appDir, this.findings, this.modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private linkModules() {\n for (let module of this.modules.values()) {\n if (isResolved(module)) {\n this.linkModule(module);\n }\n }\n }\n\n private linkModule(module: ResolvedInternalModule) {\n let exports = new Set<string>();\n for (let exp of module.parsed.exports) {\n if (typeof exp === 'string') {\n exports.add(exp);\n } else {\n let moduleName = module.resolved.get(exp.all)!;\n if (!isResolutionFailure(moduleName)) {\n let target = this.modules.get(moduleName)!;\n if (!isLinked(target) && isResolved(target)) {\n this.linkModule(target);\n }\n if (isLinked(target)) {\n for (let innerExp of target.linked.exports) {\n exports.add(innerExp);\n }\n } else {\n // our module doesn't successfully enter linked state because it\n // depends on stuff that also couldn't\n return;\n }\n }\n }\n }\n module.linked = {\n exports,\n };\n }\n\n private inspectModules() {\n for (let [filename, module] of this.modules) {\n if (isLinked(module)) {\n this.inspectImports(filename, module);\n }\n }\n }\n\n private inspectImports(filename: string, module: LinkedInternalModule) {\n for (let imp of module.parsed.imports) {\n let resolved = module.resolved.get(imp.source);\n if (isResolutionFailure(resolved)) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = this.modules.get(resolved)!;\n for (let specifier of imp.specifiers) {\n if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: LinkedInternalModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);\n }\n\n private async visitHTML(filename: string, content: Buffer | string): Promise<ParsedInternalModule['parsed']> {\n let dom = new JSDOM(content);\n let scripts = dom.window.document.querySelectorAll('script[type=\"module\"]') as NodeListOf<HTMLScriptElement>;\n let dependencies = [] as string[];\n for (let script of scripts) {\n let src = script.src;\n if (!src) {\n continue;\n }\n if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {\n // src was absolute, we don't handle it\n continue;\n }\n if (src.startsWith(this.meta['root-url'])) {\n // root-relative URLs are actually relative to the appDir\n src = explicitRelative(dirname(filename), resolvePath(this.appDir, src.replace(this.meta['root-url'], '')));\n }\n dependencies.push(src);\n }\n\n return {\n imports: [],\n exports: new Set(),\n isCJS: false,\n isAMD: false,\n dependencies,\n };\n }\n\n private async visitJS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n try {\n let result = auditJS(rawSource, filename, this.babelConfig, this.frames);\n\n for (let problem of result.problems) {\n this.pushFinding({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.frames.render(problem.codeFrameIndex),\n });\n }\n return {\n exports: result.exports,\n imports: result.imports,\n isCJS: result.isCJS,\n isAMD: result.isAMD,\n dependencies: result.imports.map(i => i.source),\n };\n } catch (err) {\n if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {\n return [\n {\n filename,\n message: `failed to parse`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private async visitHBS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n let js = hbsToJS(rawSource);\n return this.visitJS(filename, js);\n }\n\n private async visitJSON(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n return [\n {\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n }\n return this.visitJS(filename, js);\n }\n\n private async resolveDeps(deps: string[], fromFile: string): Promise<InternalModule['resolved']> {\n let resolved = new Map() as NonNullable<InternalModule['resolved']>;\n for (let dep of deps) {\n let resolution = await this.resolver.nodeResolve(dep, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n case 'not_found':\n if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n resolved.set(dep, { isResolutionFailure: true as true });\n break;\n case 'real':\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n }\n }\n return resolved;\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n\n private scheduleVisit(filename: string, parent: string | RootMarker) {\n let record = this.modules.get(filename);\n if (!record) {\n this.debug(`discovered`, filename);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(filename, record);\n this.moduleQueue.add(filename);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport interface RootMarker {\n isRoot: true;\n}\n\nexport function isRootMarker(value: string | RootMarker | undefined): value is RootMarker {\n return Boolean(value && typeof value !== 'string' && value.isRoot);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsD;AACtD,+BAA6D;AAC7D,0CAAgG;AAChG,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AACzC,yDAO+B;AAE/B,yCAAmE;AAiBzB,2FAjBvB,kBAAU,OAiBuB;AAAE,6FAjBvB,oBAAY,OAiBuB;AAflE,MAAM,EAAE,KAAK,EA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AAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,oCAEC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { dirname, join, resolve as resolvePath } from 'path';\nimport { AppMeta, explicitRelative, hbsToJS, Resolver, ResolverOptions } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport jsdom from 'jsdom';\nimport groupBy from 'lodash/groupBy';\nimport fromPairs from 'lodash/fromPairs';\nimport {\n auditJS,\n CodeFrameStorage,\n ExportAll,\n InternalImport,\n isNamespaceMarker,\n NamespaceMarker,\n} from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\n\nconst { JSDOM } = jsdom;\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport interface Module {\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n imports: Import[];\n exports: string[];\n resolutions: { [source: string]: string | null };\n content: string;\n}\n\ninterface ResolutionFailure {\n isResolutionFailure: true;\n}\n\nfunction isResolutionFailure(result: string | ResolutionFailure | undefined): result is ResolutionFailure {\n return typeof result === 'object' && 'isResolutionFailure' in result;\n}\n\ninterface InternalModule {\n consumedFrom: (string | RootMarker)[];\n\n parsed?: {\n imports: InternalImport[];\n exports: Set<string | ExportAll>;\n isCJS: boolean;\n isAMD: boolean;\n dependencies: string[];\n transpiledContent: string | Buffer;\n };\n\n resolved?: Map<string, string | ResolutionFailure>;\n\n linked?: {\n exports: Set<string>;\n };\n}\n\ntype ParsedInternalModule = Omit<InternalModule, 'parsed'> & {\n parsed: NonNullable<InternalModule['parsed']>;\n};\n\ntype ResolvedInternalModule = Omit<ParsedInternalModule, 'resolved'> & {\n resolved: NonNullable<ParsedInternalModule['resolved']>;\n};\n\nfunction isResolved(module: InternalModule | undefined): module is ResolvedInternalModule {\n return Boolean(module?.parsed && module.resolved);\n}\n\ntype LinkedInternalModule = Omit<ResolvedInternalModule, 'linked'> & {\n linked: NonNullable<ResolvedInternalModule['linked']>;\n};\n\nfunction isLinked(module: InternalModule | undefined): module is LinkedInternalModule {\n return Boolean(module?.parsed && module.resolved && module.linked);\n}\n\nexport interface Import {\n source: string;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n }[];\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>) {\n let results = new this();\n for (let [filename, module] of modules) {\n let publicModule: Module = {\n appRelativePath: explicitRelative(baseDir, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(baseDir, entry);\n }\n }),\n resolutions: module.resolved\n ? fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(baseDir, target),\n ])\n )\n : {},\n imports: module.parsed?.imports\n ? module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n })),\n }))\n : [],\n exports: module.linked?.exports ? [...module.linked.exports] : [],\n content: module.parsed?.transpiledContent\n ? module.parsed?.transpiledContent.toString()\n : 'module failed to transpile',\n };\n results.modules[explicitRelative(baseDir, filename)] = publicModule;\n }\n for (let finding of findings) {\n let relFinding = Object.assign({}, finding, { filename: explicitRelative(baseDir, finding.filename) });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private modules: Map<string, InternalModule> = new Map();\n private virtualModules: Map<string, string> = new Map();\n private moduleQueue = new Set<string>();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n let dir: string;\n\n if (options.outputDir) {\n dir = options.outputDir;\n } else {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n dir = await this.findStage2Output(options);\n }\n\n let audit = new this(dir, options);\n if (options['reuse-build']) {\n if (!audit.meta.babel.isParallelSafe) {\n throw new BuildError(\n `You can't use the ${chalk.red(\n '--reuse-build'\n )} option because some of your babel or HBS plugins are non-serializable`\n );\n }\n }\n return audit.run();\n }\n\n private static async findStage2Output(options: AuditBuildOptions): Promise<string> {\n try {\n if (!options.app) {\n throw new Error(`AuditBuildOptions needs \"app\" directory`);\n }\n return readFileSync(join(options.app, 'dist/.stage2-output'), 'utf8');\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new BuildError(\n `${chalk.yellow(\n 'Your build'\n )} did not produce expected Embroider stage2 output.\\nMake sure you actually have Embroider configured.`\n );\n }\n throw err;\n }\n }\n\n constructor(private appDir: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.appDir, 'package.json'));\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.appDir, this.meta.babel.filename));\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(this.appDir, '.embroider', 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n private visitorFor(\n filename: string\n ): (\n this: Audit,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed']> | Finding[]> {\n if (filename.endsWith('.html')) {\n return this.visitHTML;\n } else if (filename.endsWith('.hbs')) {\n return this.visitHBS;\n } else if (filename.endsWith('.json')) {\n return this.visitJSON;\n } else {\n return this.visitJS;\n }\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let filename = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(filename);\n this.debug('visit', filename);\n let visitor = this.visitorFor(filename);\n let content: string | Buffer;\n if (this.virtualModules.has(filename)) {\n content = this.virtualModules.get(filename)!;\n } else {\n content = readFileSync(filename);\n }\n // cast is safe because the only way to get into the queue is to go\n // through scheduleVisit, and scheduleVisit creates the entry in\n // this.modules.\n let module: InternalModule = this.modules.get(filename)!;\n let visitResult = await visitor.call(this, filename, content);\n if (Array.isArray(visitResult)) {\n // the visitor was unable to figure out the ParseFields and returned\n // some number of Findings to us to explain why.\n for (let finding of visitResult) {\n this.pushFinding(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, filename);\n }\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n for (let asset of this.meta.assets) {\n if (asset.endsWith('.html')) {\n this.scheduleVisit(resolvePath(this.appDir, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n return AuditResults.create(this.appDir, this.findings, this.modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private linkModules() {\n for (let module of this.modules.values()) {\n if (isResolved(module)) {\n this.linkModule(module);\n }\n }\n }\n\n private linkModule(module: ResolvedInternalModule) {\n let exports = new Set<string>();\n for (let exp of module.parsed.exports) {\n if (typeof exp === 'string') {\n exports.add(exp);\n } else {\n let moduleName = module.resolved.get(exp.all)!;\n if (!isResolutionFailure(moduleName)) {\n let target = this.modules.get(moduleName)!;\n if (!isLinked(target) && isResolved(target)) {\n this.linkModule(target);\n }\n if (isLinked(target)) {\n for (let innerExp of target.linked.exports) {\n exports.add(innerExp);\n }\n } else {\n // our module doesn't successfully enter linked state because it\n // depends on stuff that also couldn't\n return;\n }\n }\n }\n }\n module.linked = {\n exports,\n };\n }\n\n private inspectModules() {\n for (let [filename, module] of this.modules) {\n if (isLinked(module)) {\n this.inspectImports(filename, module);\n }\n }\n }\n\n private inspectImports(filename: string, module: LinkedInternalModule) {\n for (let imp of module.parsed.imports) {\n let resolved = module.resolved.get(imp.source);\n if (isResolutionFailure(resolved)) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = this.modules.get(resolved)!;\n for (let specifier of imp.specifiers) {\n if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: LinkedInternalModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);\n }\n\n private async visitHTML(filename: string, content: Buffer | string): Promise<ParsedInternalModule['parsed']> {\n let dom = new JSDOM(content);\n let scripts = dom.window.document.querySelectorAll('script[type=\"module\"]') as NodeListOf<HTMLScriptElement>;\n let dependencies = [] as string[];\n for (let script of scripts) {\n let src = script.src;\n if (!src) {\n continue;\n }\n if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {\n // src was absolute, we don't handle it\n continue;\n }\n if (src.startsWith(this.meta['root-url'])) {\n // root-relative URLs are actually relative to the appDir\n src = explicitRelative(dirname(filename), resolvePath(this.appDir, src.replace(this.meta['root-url'], '')));\n }\n dependencies.push(src);\n }\n\n return {\n imports: [],\n exports: new Set(),\n isCJS: false,\n isAMD: false,\n dependencies,\n transpiledContent: content,\n };\n }\n\n private async visitJS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n try {\n let result = auditJS(rawSource, filename, this.babelConfig, this.frames);\n\n for (let problem of result.problems) {\n this.pushFinding({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.frames.render(problem.codeFrameIndex),\n });\n }\n return {\n exports: result.exports,\n imports: result.imports,\n isCJS: result.isCJS,\n isAMD: result.isAMD,\n dependencies: result.imports.map(i => i.source),\n transpiledContent: result.transpiledContent,\n };\n } catch (err) {\n if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {\n return [\n {\n filename,\n message: `failed to parse`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private async visitHBS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n let js = hbsToJS(rawSource);\n return this.visitJS(filename, js);\n }\n\n private async visitJSON(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n return [\n {\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n }\n return this.visitJS(filename, js);\n }\n\n private async resolveDeps(deps: string[], fromFile: string): Promise<InternalModule['resolved']> {\n let resolved = new Map() as NonNullable<InternalModule['resolved']>;\n for (let dep of deps) {\n let resolution = await this.resolver.nodeResolve(dep, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n case 'not_found':\n if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n resolved.set(dep, { isResolutionFailure: true as true });\n break;\n case 'real':\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n }\n }\n return resolved;\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n\n private scheduleVisit(filename: string, parent: string | RootMarker) {\n let record = this.modules.get(filename);\n if (!record) {\n this.debug(`discovered`, filename);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(filename, record);\n this.moduleQueue.add(filename);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport interface RootMarker {\n isRoot: true;\n}\n\nexport function isRootMarker(value: string | RootMarker | undefined): value is RootMarker {\n return Boolean(value && typeof value !== 'string' && value.isRoot);\n}\n"]}
|
|
@@ -5,6 +5,7 @@ const babel_import_util_1 = require("babel-import-util");
|
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const core_1 = require("@embroider/core");
|
|
7
7
|
const dasherize_component_name_1 = require("./dasherize-component-name");
|
|
8
|
+
const dependency_rules_1 = require("./dependency-rules");
|
|
8
9
|
function main(babel) {
|
|
9
10
|
let t = babel.types;
|
|
10
11
|
let cached;
|
|
@@ -13,10 +14,12 @@ function main(babel) {
|
|
|
13
14
|
return cached;
|
|
14
15
|
}
|
|
15
16
|
let resolverOptions = (0, fs_extra_1.readJSONSync)((0, path_1.join)(appRoot, '.embroider', 'resolver.json'));
|
|
17
|
+
let resolver = new core_1.Resolver(resolverOptions);
|
|
16
18
|
cached = {
|
|
17
19
|
resolverOptions,
|
|
18
|
-
resolver
|
|
19
|
-
extraImports: preprocessExtraImports(resolverOptions),
|
|
20
|
+
resolver,
|
|
21
|
+
extraImports: preprocessExtraImports(resolverOptions, resolver),
|
|
22
|
+
componentExtraImports: preprocessComponentExtraImports(resolverOptions),
|
|
20
23
|
};
|
|
21
24
|
return cached;
|
|
22
25
|
}
|
|
@@ -37,26 +40,41 @@ main.baseDir = function () {
|
|
|
37
40
|
function addExtraImports(t, path, config) {
|
|
38
41
|
let filename = path.hub.file.opts.filename;
|
|
39
42
|
let entry = config.extraImports[filename];
|
|
43
|
+
let adder = new babel_import_util_1.ImportUtil(t, path);
|
|
40
44
|
if (entry) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
applyRules(t, path, entry, adder, config, filename);
|
|
46
|
+
}
|
|
47
|
+
let componentName = config.resolver.reverseComponentLookup(filename);
|
|
48
|
+
if (componentName) {
|
|
49
|
+
let rules = config.componentExtraImports[componentName];
|
|
50
|
+
if (rules) {
|
|
51
|
+
applyRules(t, path, rules, adder, config, filename);
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function applyRules(t, path, rules, adder, config, filename) {
|
|
56
|
+
let lookup = lazyPackageLookup(config, filename);
|
|
57
|
+
if (rules.dependsOnModules) {
|
|
58
|
+
for (let target of rules.dependsOnModules) {
|
|
59
|
+
if (lookup.owningPackage) {
|
|
60
|
+
let runtimeName;
|
|
61
|
+
if ((0, core_1.packageName)(target)) {
|
|
62
|
+
runtimeName = target;
|
|
55
63
|
}
|
|
64
|
+
else {
|
|
65
|
+
runtimeName = (0, core_1.unrelativize)(lookup.owningPackage, target, filename);
|
|
66
|
+
}
|
|
67
|
+
path.node.body.unshift(amdDefine(t, adder, path, target, runtimeName));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (rules.dependsOnComponents) {
|
|
72
|
+
for (let dasherizedName of rules.dependsOnComponents) {
|
|
73
|
+
if (lookup.owningEngine) {
|
|
74
|
+
path.node.body.unshift(amdDefine(t, adder, path, `#embroider_compat/components/${dasherizedName}`, `${lookup.owningEngine.packageName}/components/${dasherizedName}`));
|
|
56
75
|
}
|
|
57
76
|
}
|
|
58
77
|
}
|
|
59
|
-
//let componentName = config.resolver.reverseComponentLookup(filename);
|
|
60
78
|
}
|
|
61
79
|
function amdDefine(t, adder, path, target, runtimeName) {
|
|
62
80
|
let value = t.callExpression(adder.import(path, '@embroider/macros', 'importSync'), [t.stringLiteral(target)]);
|
|
@@ -65,7 +83,7 @@ function amdDefine(t, adder, path, target, runtimeName) {
|
|
|
65
83
|
t.functionExpression(null, [], t.blockStatement([t.returnStatement(value)])),
|
|
66
84
|
]));
|
|
67
85
|
}
|
|
68
|
-
function preprocessExtraImports(config) {
|
|
86
|
+
function preprocessExtraImports(config, resolver) {
|
|
69
87
|
let extraImports = {};
|
|
70
88
|
for (let rule of config.activePackageRules) {
|
|
71
89
|
if (rule.addonModules) {
|
|
@@ -77,7 +95,14 @@ function preprocessExtraImports(config) {
|
|
|
77
95
|
}
|
|
78
96
|
if (rule.appModules) {
|
|
79
97
|
for (let [filename, moduleRules] of Object.entries(rule.appModules)) {
|
|
80
|
-
|
|
98
|
+
for (let root of rule.roots) {
|
|
99
|
+
// in general v2 addons can keep their app tree stuff in other places
|
|
100
|
+
// than "_app_" and we would need to check their package.json to see.
|
|
101
|
+
// But this code is only for applying packageRules to auto-upgraded v1
|
|
102
|
+
// addons, and those we always organize with their treeForApp output
|
|
103
|
+
// in _app_.
|
|
104
|
+
expandDependsOnRules((0, dependency_rules_1.appTreeRulesDir)(root, resolver), filename, moduleRules, extraImports);
|
|
105
|
+
}
|
|
81
106
|
}
|
|
82
107
|
}
|
|
83
108
|
if (rule.addonTemplates) {
|
|
@@ -89,12 +114,60 @@ function preprocessExtraImports(config) {
|
|
|
89
114
|
}
|
|
90
115
|
if (rule.appTemplates) {
|
|
91
116
|
for (let [filename, moduleRules] of Object.entries(rule.appTemplates)) {
|
|
92
|
-
|
|
117
|
+
for (let root of rule.roots) {
|
|
118
|
+
expandInvokesRules((0, dependency_rules_1.appTreeRulesDir)(root, resolver), filename, moduleRules, extraImports);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return extraImports;
|
|
124
|
+
}
|
|
125
|
+
function lazyPackageLookup(config, filename) {
|
|
126
|
+
let owningPackage;
|
|
127
|
+
let owningEngine;
|
|
128
|
+
return {
|
|
129
|
+
get owningPackage() {
|
|
130
|
+
if (!owningPackage) {
|
|
131
|
+
owningPackage = { result: config.resolver.owningPackage(filename) };
|
|
132
|
+
}
|
|
133
|
+
return owningPackage.result;
|
|
134
|
+
},
|
|
135
|
+
get owningEngine() {
|
|
136
|
+
if (!owningEngine) {
|
|
137
|
+
owningEngine = { result: undefined };
|
|
138
|
+
let p = this.owningPackage;
|
|
139
|
+
if (p) {
|
|
140
|
+
owningEngine.result = config.resolver.owningEngine(p);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return owningEngine.result;
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function preprocessComponentExtraImports(config) {
|
|
148
|
+
let extraImports = {};
|
|
149
|
+
for (let rule of config.activePackageRules) {
|
|
150
|
+
if (rule.components) {
|
|
151
|
+
for (let [componentName, rules] of Object.entries(rule.components)) {
|
|
152
|
+
if (rules.invokes) {
|
|
153
|
+
extraImports[dasherizeComponent(componentName, rule)] = {
|
|
154
|
+
dependsOnComponents: Object.values(rules.invokes)
|
|
155
|
+
.flat()
|
|
156
|
+
.map(c => dasherizeComponent(c, rules)),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
93
159
|
}
|
|
94
160
|
}
|
|
95
161
|
}
|
|
96
162
|
return extraImports;
|
|
97
163
|
}
|
|
164
|
+
function dasherizeComponent(componentSnippet, rules) {
|
|
165
|
+
let d = (0, dasherize_component_name_1.snippetToDasherizedName)(componentSnippet);
|
|
166
|
+
if (!d) {
|
|
167
|
+
throw new Error(`unable to parse component snippet "${componentSnippet}" from rule ${JSON.stringify(rules, null, 2)}`);
|
|
168
|
+
}
|
|
169
|
+
return d;
|
|
170
|
+
}
|
|
98
171
|
function expandDependsOnRules(root, filename, rules, extraImports) {
|
|
99
172
|
if (rules.dependsOnModules || rules.dependsOnComponents) {
|
|
100
173
|
let entry = {};
|
|
@@ -102,13 +175,7 @@ function expandDependsOnRules(root, filename, rules, extraImports) {
|
|
|
102
175
|
entry.dependsOnModules = rules.dependsOnModules;
|
|
103
176
|
}
|
|
104
177
|
if (rules.dependsOnComponents) {
|
|
105
|
-
entry.dependsOnComponents = rules.dependsOnComponents.map(c =>
|
|
106
|
-
let d = (0, dasherize_component_name_1.snippetToDasherizedName)(c);
|
|
107
|
-
if (!d) {
|
|
108
|
-
throw new Error(`unable to parse component snippet "${c}" from rule ${JSON.stringify(rules, null, 2)}`);
|
|
109
|
-
}
|
|
110
|
-
return d;
|
|
111
|
-
});
|
|
178
|
+
entry.dependsOnComponents = rules.dependsOnComponents.map(c => dasherizeComponent(c, rules));
|
|
112
179
|
}
|
|
113
180
|
extraImports[(0, path_1.join)(root, filename)] = entry;
|
|
114
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-adjust-imports.js","sourceRoot":"","sources":["babel-plugin-adjust-imports.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAI5B,yDAA+C;AAC/C,uCAAwC;AAExC,0CAA2C;AAC3C,yEAAqE;AAqBrE,SAAwB,IAAI,CAAC,KAAmB;IAC9C,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IACpB,IAAI,MAAkC,CAAC;IACvC,SAAS,SAAS,CAAC,OAAe;QAChC,IAAI,MAAM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EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAC/F,CAAC;iBACH;gBACD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC7B;SACF;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;KAC9D;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 { CompatResolverOptions } from './resolver-transform';\nimport { Resolver } from '@embroider/core';\nimport { snippetToDasherizedName } from './dasherize-component-name';\nimport { ModuleRules, TemplateRules } from './dependency-rules';\n\nexport type Options = { appRoot: string };\n\ninterface State {\n opts: Options;\n}\n\ntype BabelTypes = typeof t;\ntype InternalConfig = {\n resolverOptions: CompatResolverOptions;\n resolver: Resolver;\n extraImports: {\n [absPath: string]: {\n dependsOnComponents?: string[]; // these are already standardized in dasherized form\n dependsOnModules?: string[];\n };\n };\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(join(appRoot, '.embroider', 'resolver.json'));\n cached = {\n resolverOptions,\n resolver: new Resolver(resolverOptions),\n extraImports: preprocessExtraImports(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 = path.hub.file.opts.filename;\n let entry = config.extraImports[filename];\n if (entry) {\n let adder = new ImportUtil(t, path);\n if (entry.dependsOnModules) {\n for (let target of entry.dependsOnModules) {\n path.node.body.unshift(amdDefine(t, adder, path, target, target));\n }\n }\n if (entry.dependsOnComponents) {\n for (let dasherizedName of entry.dependsOnComponents) {\n let pkg = config.resolver.owningPackage(filename);\n if (pkg) {\n let owningEngine = config.resolver.owningEngine(pkg);\n if (owningEngine) {\n path.node.body.unshift(\n amdDefine(\n t,\n adder,\n path,\n `#embroider_compat/components/${dasherizedName}`,\n `${owningEngine.packageName}/components/${dasherizedName}`\n )\n );\n }\n }\n }\n }\n }\n\n //let componentName = config.resolver.reverseComponentLookup(filename);\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): InternalConfig['extraImports'] {\n let extraImports: InternalConfig['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 expandDependsOnRules(config.appRoot, filename, moduleRules, extraImports);\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 expandInvokesRules(config.appRoot, filename, moduleRules, extraImports);\n }\n }\n }\n return extraImports;\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 => {\n let d = snippetToDasherizedName(c);\n if (!d) {\n throw new Error(`unable to parse component snippet \"${c}\" from rule ${JSON.stringify(rules, null, 2)}`);\n }\n return d;\n });\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":";;AAAA,+BAA4B;AAI5B,yDAA+C;AAC/C,uCAAwC;AAExC,0CAA+E;AAC/E,yEAAqE;AACrE,yDAAqH;AA4BrH,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;YACV,OAAO,MAAM,CAAC;SACf;QACD,IAAI,eAAe,GAA0B,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;QACxG,IAAI,QAAQ,GAAG,IAAI,eAAQ,CAAC,eAAe,CAAC,CAAC;QAC7C,MAAM,GAAG;YACP,eAAe;YAC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AAK,CAAC,mBAAmB,EAAE;QACvD,IAAI,KAAK,GAA2C,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,gBAAgB,EAAE;YAC1B,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;SACjD;QACD,IAAI,KAAK,CAAC,mBAAmB,EAAE;YAC7B,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;SAC9F;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC;KAC5C;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,IAAY,EACZ,QAAgB,EAChB,KAAoB,EACpB,YAA4C;IAE5C,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,IAAI,mBAAmB,GAAa,EAAE,CAAC;QACvC,KAAK,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YACtD,KAAK,IAAI,SAAS,IAAI,aAAa,EAAE;gBACnC,IAAI,CAAC,GAAG,IAAA,kDAAuB,EAAC,SAAS,CAAC,CAAC;gBAC3C,IAAI,CAAC,CAAC,EAAE;oBACN,MAAM,IAAI,KAAK,CACb,sCAAsC,SAAS,eAAe,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAC/F,CAAC;iBACH;gBACD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC7B;SACF;QACD,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;KAC9D;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 { CompatResolverOptions } from './resolver-transform';\nimport { Package, packageName, Resolver, unrelativize } from '@embroider/core';\nimport { snippetToDasherizedName } from './dasherize-component-name';\nimport { ActivePackageRules, appTreeRulesDir, ComponentRules, ModuleRules, TemplateRules } 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(join(appRoot, '.embroider', 'resolver.json'));\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 = path.hub.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_compat/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.owningPackage(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"]}
|
package/src/compat-app.js
CHANGED
|
@@ -239,7 +239,7 @@ class CompatAppAdapter {
|
|
|
239
239
|
}
|
|
240
240
|
activeRules() {
|
|
241
241
|
return (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
|
|
242
|
-
this.appPackage,
|
|
242
|
+
{ name: this.appPackage.name, version: this.appPackage.version, root: this.root },
|
|
243
243
|
...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
244
244
|
]);
|
|
245
245
|
}
|
|
@@ -270,23 +270,16 @@ class CompatAppAdapter {
|
|
|
270
270
|
for (let addon of this.allActiveAddons) {
|
|
271
271
|
activeAddons[addon.name] = addon.root;
|
|
272
272
|
}
|
|
273
|
-
let relocatedFiles = {};
|
|
274
|
-
for (let { destPath, appFiles } of engines) {
|
|
275
|
-
for (let [relativePath, originalPath] of appFiles.relocatedFiles) {
|
|
276
|
-
relocatedFiles[(0, path_1.join)(destPath, relativePath)] = originalPath;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
273
|
let config = {
|
|
280
274
|
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
281
275
|
activeAddons,
|
|
282
276
|
renameModules,
|
|
283
277
|
renamePackages,
|
|
284
|
-
relocatedFiles,
|
|
285
278
|
resolvableExtensions: this.resolvableExtensions(),
|
|
286
279
|
appRoot: this.root,
|
|
287
|
-
engines: engines.map(engine => ({
|
|
280
|
+
engines: engines.map((engine, index) => ({
|
|
288
281
|
packageName: engine.package.name,
|
|
289
|
-
root: this.root,
|
|
282
|
+
root: index === 0 ? this.root : engine.package.root,
|
|
290
283
|
activeAddons: [...engine.addons]
|
|
291
284
|
.map(a => ({
|
|
292
285
|
name: a.name,
|
package/src/compat-app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-app.js","sourceRoot":"","sources":["compat-app.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,gFAA8C;AAC9C,0CAayB;AACzB,4EAAkD;AAElD,0DAAiC;AACjC,+BAA4B;AAG5B,2BAA2C;AAC3C,uCAAyD;AAEzD,yDAAsE;AACtE,6DAAqC;AACrC,2DAA6C;AAC7C,qCAA8C;AAC9C,qDAA0D;AAC1D,oEAAkC;AAClC,uCAA0C;AAa1C,uEAAuE;AACvE,wEAAwE;AACxE,QAAQ;AACR,SAAS,KAAK,CAAC,sBAA8B,EAAE,OAA0B;IACvE,IAAI,UAAU,GAAG,2BAAe,CAAC,MAAM,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC;IAE7E,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;IAC1C,IAAI,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IACnC,IAAI,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IACvC,IAAI,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;IACnC,IAAI,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC;IAErC,IAAI,OAAO,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;QACvC,UAAU,GAAG,IAAA,8BAAU,EAAC,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC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AE,WAAW,CAAC,CAAC;IAC/D,CAAC;CACF;AALD,4BAKC;AAED,SAAS,YAAY,CAAC,GAAU,EAAE,OAA4B;IAC5D,IAAI,OAAO,EAAE;QACX,OAAO,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;KACxC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAU,EAAE,OAAgB;IACrD,IAAI,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACjC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,IAAA,gBAAW,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;SAC1D,GAAG,CAAC,QAAQ,CAAC,EAAE;QACd,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC5B,iEAAiE;YACjE,OAAO,OAAO,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;SAC7E;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 { Node as BroccoliNode } from 'broccoli-node-api';\nimport mergeTrees from 'broccoli-merge-trees';\nimport {\n Stage,\n PackageCache,\n OutputPaths,\n BuildStage,\n Asset,\n EmberAsset,\n AppAdapter,\n AppBuilder,\n EmberENV,\n Package,\n AddonPackage,\n Engine,\n} from '@embroider/core';\nimport V1InstanceCache from './v1-instance-cache';\nimport V1App from './v1-app';\nimport walkSync from 'walk-sync';\nimport { join } from 'path';\nimport { JSDOM } from 'jsdom';\nimport { V1Config } from './v1-config';\nimport { statSync, readdirSync } from 'fs';\nimport Options, { optionsWithDefaults } from './options';\nimport { CompatResolverOptions } from './resolver-transform';\nimport { activePackageRules, PackageRules } from './dependency-rules';\nimport flatMap from 'lodash/flatMap';\nimport { Memoize } from 'typescript-memoize';\nimport { sync as resolveSync } from 'resolve';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport bind from 'bind-decorator';\nimport { pathExistsSync } from 'fs-extra';\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 type { PluginItem } from '@babel/core';\n\ninterface TreeNames {\n appJS: BroccoliNode;\n htmlTree: BroccoliNode;\n publicTree: BroccoliNode | undefined;\n configTree: BroccoliNode;\n}\n\n// This runs at broccoli-pipeline-construction time, whereas our actual\n// CompatAppAdapter instance only becomes available during tree-building\n// time.\nfunction setup(legacyEmberAppInstance: object, options: Required<Options>) {\n let oldPackage = V1InstanceCache.forApp(legacyEmberAppInstance, options).app;\n\n let { appJS } = oldPackage.processAppJS();\n let htmlTree = oldPackage.htmlTree;\n let publicTree = oldPackage.publicTree;\n let configTree = oldPackage.config;\n let appBootTree = oldPackage.appBoot;\n\n if (options.extraPublicTrees.length > 0) {\n publicTree = mergeTrees([publicTree, ...options.extraPublicTrees].filter(Boolean) as BroccoliNode[]);\n }\n\n let inTrees = {\n appJS,\n htmlTree,\n publicTree,\n configTree,\n appBootTree,\n };\n\n let instantiate = async (root: string, appSrcDir: string, packageCache: PackageCache) => {\n let appPackage = packageCache.get(appSrcDir);\n let adapter = new CompatAppAdapter(\n root,\n appPackage,\n options,\n oldPackage,\n configTree,\n packageCache.get(join(root, 'node_modules', '@embroider', 'synthesized-vendor')),\n packageCache.get(join(root, 'node_modules', '@embroider', 'synthesized-styles'))\n );\n\n return new AppBuilder<TreeNames>(\n root,\n appPackage,\n adapter,\n options,\n MacrosConfig.for(legacyEmberAppInstance, appSrcDir)\n );\n };\n\n return { inTrees, instantiate };\n}\n\nclass CompatAppAdapter implements AppAdapter<TreeNames, CompatResolverOptions> {\n constructor(\n private root: string,\n private appPackage: Package,\n private options: Required<Options>,\n private oldPackage: V1App,\n private configTree: V1Config,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n appJSSrcDir(treePaths: OutputPaths<TreeNames>) {\n return treePaths.appJS;\n }\n\n @Memoize()\n fastbootJSSrcDir(_treePaths: OutputPaths<TreeNames>) {\n let target = join(this.oldPackage.root, 'fastboot');\n if (pathExistsSync(target)) {\n return target;\n }\n }\n\n get env() {\n return this.oldPackage.env;\n }\n\n assets(treePaths: OutputPaths<TreeNames>): Asset[] {\n let assets: Asset[] = [];\n\n // Everything in our traditional public tree is an on-disk asset\n if (treePaths.publicTree) {\n walkSync\n .entries(treePaths.publicTree, {\n directories: false,\n })\n .forEach(entry => {\n assets.push({\n kind: 'on-disk',\n relativePath: entry.relativePath,\n sourcePath: entry.fullPath,\n mtime: entry.mtime as unknown as number, // https://github.com/joliss/node-walk-sync/pull/38\n size: entry.size,\n });\n });\n }\n\n // ember-cli traditionally outputs a dummy testem.js file to prevent\n // spurious errors when running tests under \"ember s\".\n if (this.oldPackage.shouldBuildTests) {\n let testemAsset = this.findTestemAsset();\n if (testemAsset) {\n assets.push(testemAsset);\n }\n }\n\n for (let asset of this.emberEntrypoints(treePaths.htmlTree)) {\n assets.push(asset);\n }\n\n return assets;\n }\n\n @Memoize()\n findTestemAsset(): Asset | undefined {\n let sourcePath;\n try {\n sourcePath = resolveSync('ember-cli/lib/broccoli/testem.js', { basedir: this.root });\n } catch (err) {}\n if (sourcePath) {\n let stat = statSync(sourcePath);\n return {\n kind: 'on-disk',\n relativePath: 'testem.js',\n sourcePath,\n mtime: stat.mtime.getTime(),\n size: stat.size,\n };\n }\n }\n\n developingAddons(): string[] {\n if (this.oldPackage.owningAddon) {\n return [this.oldPackage.owningAddon.root];\n }\n return [];\n }\n\n @Memoize()\n activeAddonChildren(pkg: Package = this.appPackage): 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 definitely appear in one of the other\n // sections.\n addon => pkg.packageJSON.dependencies?.[addon.name] || pkg.packageJSON.devDependencies?.[addon.name]\n );\n if (pkg === this.appPackage) {\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 get allActiveAddons(): AddonPackage[] {\n let result = this.appPackage.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 // todo: filter by addon-provided hook\n return pkg.isEmberPackage();\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 @Memoize()\n resolvableExtensions(): string[] {\n // webpack's default is ['.wasm', '.mjs', '.js', '.json']. Keeping that\n // subset in that order is sensible, since many third-party libraries will\n // expect it to work that way.\n //\n // For TS, we defer to ember-cli-babel, and the setting for\n // \"enableTypescriptTransform\" can be set with and without\n // ember-cli-typescript\n return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];\n }\n\n private *emberEntrypoints(htmlTreePath: string): IterableIterator<Asset> {\n let classicEntrypoints = [\n { entrypoint: 'index.html', includeTests: false },\n { entrypoint: 'tests/index.html', includeTests: true },\n ];\n if (!this.oldPackage.shouldBuildTests) {\n classicEntrypoints.pop();\n }\n for (let { entrypoint, includeTests } of classicEntrypoints) {\n let sourcePath = join(htmlTreePath, entrypoint);\n let stats = statSync(sourcePath);\n let asset: EmberAsset = {\n kind: 'ember',\n relativePath: entrypoint,\n includeTests,\n sourcePath,\n mtime: stats.mtime.getTime(),\n size: stats.size,\n rootURL: this.rootURL(),\n prepare: (dom: JSDOM) => {\n let scripts = [...dom.window.document.querySelectorAll('script')];\n let styles = [...dom.window.document.querySelectorAll('link[rel=\"stylesheet\"]')] as HTMLLinkElement[];\n\n return {\n javascript: definitelyReplace(dom, this.oldPackage.findAppScript(scripts, entrypoint)),\n styles: definitelyReplace(dom, this.oldPackage.findAppStyles(styles, entrypoint)),\n implicitScripts: definitelyReplace(dom, this.oldPackage.findVendorScript(scripts, entrypoint)),\n implicitStyles: definitelyReplace(dom, this.oldPackage.findVendorStyles(styles, entrypoint)),\n testJavascript: maybeReplace(dom, this.oldPackage.findTestScript(scripts)),\n implicitTestScripts: maybeReplace(dom, this.oldPackage.findTestSupportScript(scripts)),\n implicitTestStyles: maybeReplace(dom, this.oldPackage.findTestSupportStyles(styles)),\n };\n },\n };\n yield asset;\n }\n }\n\n autoRun(): boolean {\n return this.oldPackage.autoRun;\n }\n\n appBoot(): string | undefined {\n return this.oldPackage.appBoot.readAppBoot();\n }\n\n mainModule(): string {\n return 'app';\n }\n\n mainModuleConfig(): unknown {\n return this.configTree.readConfig().APP;\n }\n\n emberENV(): EmberENV {\n return this.configTree.readConfig().EmberENV;\n }\n\n modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n rootURL(): string {\n return this.configTree.readConfig().rootURL;\n }\n\n templateCompilerPath(): string {\n return 'ember-source/vendor/ember/ember-template-compiler';\n }\n\n strictV2Format() {\n return false;\n }\n\n @Memoize()\n private activeRules() {\n return activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n this.appPackage,\n ...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n }\n\n hbsTransforms(resolverConfig: CompatResolverOptions): Transform[] {\n if (\n this.options.staticComponents ||\n this.options.staticHelpers ||\n this.options.staticModifiers ||\n (globalThis as any).embroider_audit\n ) {\n let opts: ResolverTransformOptions = {\n appRoot: resolverConfig.appRoot,\n };\n return [[require.resolve('./resolver-transform'), opts]];\n } else {\n return [];\n }\n }\n\n jsPlugins(resolverConfig: CompatResolverOptions): PluginItem[] {\n let pluginConfig: AdjustImportsOptions = {\n appRoot: resolverConfig.appRoot,\n };\n return [[require.resolve('./babel-plugin-adjust-imports'), pluginConfig]];\n }\n\n 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 activeAddons: CompatResolverOptions['activeAddons'] = {};\n for (let addon of this.allActiveAddons) {\n activeAddons[addon.name] = addon.root;\n }\n\n let relocatedFiles: CompatResolverOptions['relocatedFiles'] = {};\n for (let { destPath, appFiles } of engines) {\n for (let [relativePath, originalPath] of appFiles.relocatedFiles) {\n relocatedFiles[join(destPath, relativePath)] = originalPath;\n }\n }\n\n let config: CompatResolverOptions = {\n // this part is the base ModuleResolverOptions as required by @embroider/core\n activeAddons,\n renameModules,\n renamePackages,\n relocatedFiles,\n resolvableExtensions: this.resolvableExtensions(),\n appRoot: this.root,\n engines: engines.map(engine => ({\n packageName: engine.package.name,\n root: this.root,\n activeAddons: [...engine.addons]\n .map(a => ({\n name: a.name,\n root: a.root,\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 })),\n\n // this is the additional stufff that @embroider/compat adds on top to do\n // global template resolving\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n options: this.options,\n activePackageRules: this.activeRules(),\n };\n\n return config;\n }\n\n htmlbarsPlugins(): Transform[] {\n return this.oldPackage.htmlbarsPlugins;\n }\n\n babelMajorVersion() {\n return this.oldPackage.babelMajorVersion();\n }\n\n babelConfig() {\n return this.oldPackage.babelConfig();\n }\n}\n\nexport default class CompatApp extends BuildStage<TreeNames> {\n constructor(legacyEmberAppInstance: object, addons: Stage, options?: Options) {\n let { inTrees, instantiate } = setup(legacyEmberAppInstance, optionsWithDefaults(options));\n super(addons, inTrees, '@embroider/compat/app', instantiate);\n }\n}\n\nfunction maybeReplace(dom: JSDOM, element: Element | undefined): Node | undefined {\n if (element) {\n return definitelyReplace(dom, element);\n }\n}\n\nfunction definitelyReplace(dom: JSDOM, element: Element): Node {\n let placeholder = dom.window.document.createTextNode('');\n element.replaceWith(placeholder);\n return placeholder;\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.js","sourceRoot":"","sources":["compat-app.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,gFAA8C;AAC9C,0CAayB;AACzB,4EAAkD;AAElD,0DAAiC;AACjC,+BAA4B;AAG5B,2BAA2C;AAC3C,uCAAyD;AAEzD,yDAAsE;AACtE,6DAAqC;AACrC,2DAA6C;AAC7C,qCAA8C;AAC9C,qDAA0D;AAC1D,oEAAkC;AAClC,uCAA0C;AAa1C,uEAAuE;AACvE,wEAAwE;AACxE,QAAQ;AACR,SAAS,KAAK,CAAC,sBAA8B,EAAE,OAA0B;IACvE,IAAI,UAAU,GAAG,2BAAe,CAAC,MAAM,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC,GAAG,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AAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { Node as BroccoliNode } from 'broccoli-node-api';\nimport mergeTrees from 'broccoli-merge-trees';\nimport {\n Stage,\n PackageCache,\n OutputPaths,\n BuildStage,\n Asset,\n EmberAsset,\n AppAdapter,\n AppBuilder,\n EmberENV,\n Package,\n AddonPackage,\n Engine,\n} from '@embroider/core';\nimport V1InstanceCache from './v1-instance-cache';\nimport V1App from './v1-app';\nimport walkSync from 'walk-sync';\nimport { join } from 'path';\nimport { JSDOM } from 'jsdom';\nimport { V1Config } from './v1-config';\nimport { statSync, readdirSync } from 'fs';\nimport Options, { optionsWithDefaults } from './options';\nimport { CompatResolverOptions } from './resolver-transform';\nimport { activePackageRules, PackageRules } from './dependency-rules';\nimport flatMap from 'lodash/flatMap';\nimport { Memoize } from 'typescript-memoize';\nimport { sync as resolveSync } from 'resolve';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport bind from 'bind-decorator';\nimport { pathExistsSync } from 'fs-extra';\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 type { PluginItem } from '@babel/core';\n\ninterface TreeNames {\n appJS: BroccoliNode;\n htmlTree: BroccoliNode;\n publicTree: BroccoliNode | undefined;\n configTree: BroccoliNode;\n}\n\n// This runs at broccoli-pipeline-construction time, whereas our actual\n// CompatAppAdapter instance only becomes available during tree-building\n// time.\nfunction setup(legacyEmberAppInstance: object, options: Required<Options>) {\n let oldPackage = V1InstanceCache.forApp(legacyEmberAppInstance, options).app;\n\n let { appJS } = oldPackage.processAppJS();\n let htmlTree = oldPackage.htmlTree;\n let publicTree = oldPackage.publicTree;\n let configTree = oldPackage.config;\n let appBootTree = oldPackage.appBoot;\n\n if (options.extraPublicTrees.length > 0) {\n publicTree = mergeTrees([publicTree, ...options.extraPublicTrees].filter(Boolean) as BroccoliNode[]);\n }\n\n let inTrees = {\n appJS,\n htmlTree,\n publicTree,\n configTree,\n appBootTree,\n };\n\n let instantiate = async (root: string, appSrcDir: string, packageCache: PackageCache) => {\n let appPackage = packageCache.get(appSrcDir);\n let adapter = new CompatAppAdapter(\n root,\n appPackage,\n options,\n oldPackage,\n configTree,\n packageCache.get(join(root, 'node_modules', '@embroider', 'synthesized-vendor')),\n packageCache.get(join(root, 'node_modules', '@embroider', 'synthesized-styles'))\n );\n\n return new AppBuilder<TreeNames>(\n root,\n appPackage,\n adapter,\n options,\n MacrosConfig.for(legacyEmberAppInstance, appSrcDir)\n );\n };\n\n return { inTrees, instantiate };\n}\n\nclass CompatAppAdapter implements AppAdapter<TreeNames, CompatResolverOptions> {\n constructor(\n private root: string,\n private appPackage: Package,\n private options: Required<Options>,\n private oldPackage: V1App,\n private configTree: V1Config,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n appJSSrcDir(treePaths: OutputPaths<TreeNames>) {\n return treePaths.appJS;\n }\n\n @Memoize()\n fastbootJSSrcDir(_treePaths: OutputPaths<TreeNames>) {\n let target = join(this.oldPackage.root, 'fastboot');\n if (pathExistsSync(target)) {\n return target;\n }\n }\n\n get env() {\n return this.oldPackage.env;\n }\n\n assets(treePaths: OutputPaths<TreeNames>): Asset[] {\n let assets: Asset[] = [];\n\n // Everything in our traditional public tree is an on-disk asset\n if (treePaths.publicTree) {\n walkSync\n .entries(treePaths.publicTree, {\n directories: false,\n })\n .forEach(entry => {\n assets.push({\n kind: 'on-disk',\n relativePath: entry.relativePath,\n sourcePath: entry.fullPath,\n mtime: entry.mtime as unknown as number, // https://github.com/joliss/node-walk-sync/pull/38\n size: entry.size,\n });\n });\n }\n\n // ember-cli traditionally outputs a dummy testem.js file to prevent\n // spurious errors when running tests under \"ember s\".\n if (this.oldPackage.shouldBuildTests) {\n let testemAsset = this.findTestemAsset();\n if (testemAsset) {\n assets.push(testemAsset);\n }\n }\n\n for (let asset of this.emberEntrypoints(treePaths.htmlTree)) {\n assets.push(asset);\n }\n\n return assets;\n }\n\n @Memoize()\n findTestemAsset(): Asset | undefined {\n let sourcePath;\n try {\n sourcePath = resolveSync('ember-cli/lib/broccoli/testem.js', { basedir: this.root });\n } catch (err) {}\n if (sourcePath) {\n let stat = statSync(sourcePath);\n return {\n kind: 'on-disk',\n relativePath: 'testem.js',\n sourcePath,\n mtime: stat.mtime.getTime(),\n size: stat.size,\n };\n }\n }\n\n developingAddons(): string[] {\n if (this.oldPackage.owningAddon) {\n return [this.oldPackage.owningAddon.root];\n }\n return [];\n }\n\n @Memoize()\n activeAddonChildren(pkg: Package = this.appPackage): 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 definitely appear in one of the other\n // sections.\n addon => pkg.packageJSON.dependencies?.[addon.name] || pkg.packageJSON.devDependencies?.[addon.name]\n );\n if (pkg === this.appPackage) {\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 get allActiveAddons(): AddonPackage[] {\n let result = this.appPackage.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 // todo: filter by addon-provided hook\n return pkg.isEmberPackage();\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 @Memoize()\n resolvableExtensions(): string[] {\n // webpack's default is ['.wasm', '.mjs', '.js', '.json']. Keeping that\n // subset in that order is sensible, since many third-party libraries will\n // expect it to work that way.\n //\n // For TS, we defer to ember-cli-babel, and the setting for\n // \"enableTypescriptTransform\" can be set with and without\n // ember-cli-typescript\n return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];\n }\n\n private *emberEntrypoints(htmlTreePath: string): IterableIterator<Asset> {\n let classicEntrypoints = [\n { entrypoint: 'index.html', includeTests: false },\n { entrypoint: 'tests/index.html', includeTests: true },\n ];\n if (!this.oldPackage.shouldBuildTests) {\n classicEntrypoints.pop();\n }\n for (let { entrypoint, includeTests } of classicEntrypoints) {\n let sourcePath = join(htmlTreePath, entrypoint);\n let stats = statSync(sourcePath);\n let asset: EmberAsset = {\n kind: 'ember',\n relativePath: entrypoint,\n includeTests,\n sourcePath,\n mtime: stats.mtime.getTime(),\n size: stats.size,\n rootURL: this.rootURL(),\n prepare: (dom: JSDOM) => {\n let scripts = [...dom.window.document.querySelectorAll('script')];\n let styles = [...dom.window.document.querySelectorAll('link[rel=\"stylesheet\"]')] as HTMLLinkElement[];\n\n return {\n javascript: definitelyReplace(dom, this.oldPackage.findAppScript(scripts, entrypoint)),\n styles: definitelyReplace(dom, this.oldPackage.findAppStyles(styles, entrypoint)),\n implicitScripts: definitelyReplace(dom, this.oldPackage.findVendorScript(scripts, entrypoint)),\n implicitStyles: definitelyReplace(dom, this.oldPackage.findVendorStyles(styles, entrypoint)),\n testJavascript: maybeReplace(dom, this.oldPackage.findTestScript(scripts)),\n implicitTestScripts: maybeReplace(dom, this.oldPackage.findTestSupportScript(scripts)),\n implicitTestStyles: maybeReplace(dom, this.oldPackage.findTestSupportStyles(styles)),\n };\n },\n };\n yield asset;\n }\n }\n\n autoRun(): boolean {\n return this.oldPackage.autoRun;\n }\n\n appBoot(): string | undefined {\n return this.oldPackage.appBoot.readAppBoot();\n }\n\n mainModule(): string {\n return 'app';\n }\n\n mainModuleConfig(): unknown {\n return this.configTree.readConfig().APP;\n }\n\n emberENV(): EmberENV {\n return this.configTree.readConfig().EmberENV;\n }\n\n modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n rootURL(): string {\n return this.configTree.readConfig().rootURL;\n }\n\n templateCompilerPath(): string {\n return 'ember-source/vendor/ember/ember-template-compiler';\n }\n\n strictV2Format() {\n return false;\n }\n\n @Memoize()\n private activeRules() {\n return activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.appPackage.name, version: this.appPackage.version, root: this.root },\n ...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n }\n\n hbsTransforms(resolverConfig: CompatResolverOptions): Transform[] {\n if (\n this.options.staticComponents ||\n this.options.staticHelpers ||\n this.options.staticModifiers ||\n (globalThis as any).embroider_audit\n ) {\n let opts: ResolverTransformOptions = {\n appRoot: resolverConfig.appRoot,\n };\n return [[require.resolve('./resolver-transform'), opts]];\n } else {\n return [];\n }\n }\n\n jsPlugins(resolverConfig: CompatResolverOptions): PluginItem[] {\n let pluginConfig: AdjustImportsOptions = {\n appRoot: resolverConfig.appRoot,\n };\n return [[require.resolve('./babel-plugin-adjust-imports'), pluginConfig]];\n }\n\n 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 activeAddons: CompatResolverOptions['activeAddons'] = {};\n for (let addon of this.allActiveAddons) {\n activeAddons[addon.name] = addon.root;\n }\n\n let config: CompatResolverOptions = {\n // this part is the base ModuleResolverOptions as required by @embroider/core\n activeAddons,\n renameModules,\n renamePackages,\n resolvableExtensions: this.resolvableExtensions(),\n appRoot: this.root,\n engines: engines.map((engine, index) => ({\n packageName: engine.package.name,\n root: index === 0 ? this.root : engine.package.root, // first engine is the app, which has been relocated to this.roto\n activeAddons: [...engine.addons]\n .map(a => ({\n name: a.name,\n root: a.root,\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 })),\n\n // this is the additional stufff that @embroider/compat adds on top to do\n // global template resolving\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n options: this.options,\n activePackageRules: this.activeRules(),\n };\n\n return config;\n }\n\n htmlbarsPlugins(): Transform[] {\n return this.oldPackage.htmlbarsPlugins;\n }\n\n babelMajorVersion() {\n return this.oldPackage.babelMajorVersion();\n }\n\n babelConfig() {\n return this.oldPackage.babelConfig();\n }\n}\n\nexport default class CompatApp extends BuildStage<TreeNames> {\n constructor(legacyEmberAppInstance: object, addons: Stage, options?: Options) {\n let { inTrees, instantiate } = setup(legacyEmberAppInstance, optionsWithDefaults(options));\n super(addons, inTrees, '@embroider/compat/app', instantiate);\n }\n}\n\nfunction maybeReplace(dom: JSDOM, element: Element | undefined): Node | undefined {\n if (element) {\n return definitelyReplace(dom, element);\n }\n}\n\nfunction definitelyReplace(dom: JSDOM, element: Element): Node {\n let placeholder = dom.window.document.createTextNode('');\n element.replaceWith(placeholder);\n return placeholder;\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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Resolver } from '@embroider/core';
|
|
2
2
|
export interface PackageRules {
|
|
3
3
|
package: string;
|
|
4
4
|
semverRange?: string;
|
|
@@ -61,5 +61,10 @@ export interface PreprocessedComponentRule {
|
|
|
61
61
|
disambiguate: Record<string, 'component' | 'helper' | 'data'>;
|
|
62
62
|
}
|
|
63
63
|
export declare function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule;
|
|
64
|
-
export declare function activePackageRules(packageRules: PackageRules[], activePackages:
|
|
64
|
+
export declare function activePackageRules(packageRules: PackageRules[], activePackages: {
|
|
65
|
+
name: string;
|
|
66
|
+
root: string;
|
|
67
|
+
version: string;
|
|
68
|
+
}[]): ActivePackageRules[];
|
|
69
|
+
export declare function appTreeRulesDir(root: string, resolver: Resolver): string;
|
|
65
70
|
export {};
|
package/src/dependency-rules.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.activePackageRules = exports.preprocessComponentRule = void 0;
|
|
3
|
+
exports.appTreeRulesDir = exports.activePackageRules = exports.preprocessComponentRule = void 0;
|
|
4
4
|
const core_1 = require("@embroider/core");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const semver_1 = require("semver");
|
|
6
7
|
// take a component rule from the authoring format to a format more optimized
|
|
7
8
|
// for consumption in the resolver
|
|
@@ -63,4 +64,19 @@ function activePackageRules(packageRules, activePackages) {
|
|
|
63
64
|
return output;
|
|
64
65
|
}
|
|
65
66
|
exports.activePackageRules = activePackageRules;
|
|
67
|
+
function appTreeRulesDir(root, resolver) {
|
|
68
|
+
let pkg = resolver.owningPackage(root);
|
|
69
|
+
if (pkg === null || pkg === void 0 ? void 0 : pkg.isV2Addon()) {
|
|
70
|
+
// in general v2 addons can keep their app tree stuff in other places than
|
|
71
|
+
// "_app_" and we would need to check their package.json to see. But this code
|
|
72
|
+
// is only for applying packageRules to auto-upgraded v1 addons and apps, and
|
|
73
|
+
// those we always organize predictably.
|
|
74
|
+
return (0, path_1.resolve)(root, '_app_');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// auto-upgraded apps don't get an exist _app_ dir.
|
|
78
|
+
return root;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.appTreeRulesDir = appTreeRulesDir;
|
|
66
82
|
//# sourceMappingURL=dependency-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAuD;AACvD,mCAAmC;AAwKnC,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE;QAC5C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE;YAC1D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;YAC3C,iBAAiB,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;SACpC;KACF;IACD,IAAI,cAAc,CAAC,OAAO,EAAE;QAC1B,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YACzD,iBAAiB,C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@embroider/core';\nimport { satisfies } from 'semver';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAwD;AACxD,+BAA+B;AAC/B,mCAAmC;AAwKnC,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE;QAC5C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE;YAC1D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;YAC3C,iBAAiB,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;SACpC;KACF;IACD,IAAI,cAAc,CAAC,OAAO,EAAE;QAC1B,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO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BC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,QAAkB;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,EAAE,EAAE;QACpB,0EAA0E;QAC1E,8EAA8E;QAC9E,6EAA6E;QAC7E,wCAAwC;QACxC,OAAO,IAAA,cAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KAC/B;SAAM;QACL,mDAAmD;QACnD,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAZD,0CAYC","sourcesContent":["import { getOrCreate, Resolver } from '@embroider/core';\nimport { resolve } from 'path';\nimport { satisfies } from 'semver';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(\n packageRules: PackageRules[],\n activePackages: { name: string; root: string; version: string }[]\n): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function appTreeRulesDir(root: string, resolver: Resolver) {\n let pkg = resolver.owningPackage(root);\n if (pkg?.isV2Addon()) {\n // in general v2 addons can keep their app tree stuff in other places than\n // \"_app_\" and we would need to check their package.json to see. But this code\n // is only for applying packageRules to auto-upgraded v1 addons and apps, and\n // those we always organize predictably.\n return resolve(root, '_app_');\n } else {\n // auto-upgraded apps don't get an exist _app_ dir.\n return root;\n }\n}\n"]}
|
|
@@ -418,12 +418,24 @@ class TemplateResolver {
|
|
|
418
418
|
let processedRules = (0, dependency_rules_1.preprocessComponentRule)(rules);
|
|
419
419
|
let dasherizedName = this.standardDasherize(snippet, rule);
|
|
420
420
|
components.set(dasherizedName, processedRules);
|
|
421
|
+
if (rules.layout) {
|
|
422
|
+
for (let root of rule.roots) {
|
|
423
|
+
if (rules.layout.addonPath) {
|
|
424
|
+
files.set((0, path_1.join)(root, rules.layout.addonPath), processedRules);
|
|
425
|
+
}
|
|
426
|
+
if (rules.layout.appPath) {
|
|
427
|
+
files.set((0, path_1.join)(root, rules.layout.appPath), processedRules);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
421
431
|
}
|
|
422
432
|
}
|
|
423
433
|
if (rule.appTemplates) {
|
|
424
434
|
for (let [path, templateRules] of Object.entries(rule.appTemplates)) {
|
|
425
435
|
let processedRules = (0, dependency_rules_1.preprocessComponentRule)(templateRules);
|
|
426
|
-
|
|
436
|
+
for (let root of rule.roots) {
|
|
437
|
+
files.set((0, path_1.join)((0, dependency_rules_1.appTreeRulesDir)(root, this.moduleResolver), path), processedRules);
|
|
438
|
+
}
|
|
427
439
|
}
|
|
428
440
|
}
|
|
429
441
|
if (rule.addonTemplates) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,yDAO4B;AAC5B,2DAA6C;AAE7C,gEAAuC;AACvC,+BAAiC;AACjC,uCAAwC;AACxC,yEAAgF;AAChF,0CAAmF;AAGnF,mCAA8C;AA0BjC,QAAA,eAAe,GAAG;IAC7B,kBAAkB;IAClB,aAAa;IACb,oBAAoB;IACpB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,QAAQ;IACR,UAAU;IACV,SAAS;IACT,MAAM;IACN,IAAI;IACJ,KAAK;IACL,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,OAAO;IACP,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,UAAU;IACV,OAAO;IACP,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,SAAS;IACT,cAAc;IACd,UAAU;IACV,UAAU;IACV,SAAS;IACT,WAAW;IACX,QAAQ;IACR,MAAM;IACN,OAAO;CACR,CAAC;AA+CF,MAAM,gBAAgB;IAQpB,YAAoB,GAAQ,EAAU,MAA6B;QAA/C,QAAG,GAAH,GAAG,CAAK;QAAU,WAAM,GAAN,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AC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,gFAAgF;AAChF,gBAAgB;AAChB,SAAS,kBAAkB,CAAC,SAAiC,EAAE,YAA+B;IAC5F,IAAI,MAAM,GAAkC,SAAS,CAAC;IACtD,OAAO,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE;QAC7C,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAuB,CAAC,EAAE;YAClE,OAAO,IAAI,CAAC;SACb;QACD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;KACxB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AACD,SAAS,YAAY,CAAC,QAAa,EAAE,QAAa;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAClC;AACH,CAAC","sourcesContent":["import type { ASTv1, ASTPlugin, ASTPluginBuilder, ASTPluginEnvironment, WalkerPath } from '@glimmer/syntax';\nimport {\n PreprocessedComponentRule,\n preprocessComponentRule,\n ActivePackageRules,\n ComponentRules,\n PackageRules,\n ModuleRules,\n} 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 { ResolverOptions as CoreResolverOptions, Resolver } from '@embroider/core';\nimport CompatOptions from './options';\nimport { AuditMessage, Loc } from './audit';\nimport { camelCase, mergeWith } from 'lodash';\n\ntype Env = WithJSUtils<ASTPluginEnvironment> & {\n filename: string;\n contents: string;\n strict?: 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}\n\nexport const builtInKeywords = [\n '-get-dynamic-var',\n '-in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each-in',\n 'each',\n 'fn',\n 'get',\n 'has-block-params',\n 'has-block',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'helper',\n 'if',\n 'in-element',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'modifier',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unique-id',\n 'unless',\n 'with',\n 'yield',\n];\n\ninterface ComponentResolution {\n type: 'component';\n specifier: 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};\n\ntype ModifierResolution = {\n type: 'modifier';\n specifier: 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(private env: Env, private config: CompatResolverOptions) {\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, 'default', 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 }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n files.set(join(this.config.appRoot, path), processedRules);\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 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 if (builtInKeywords.includes(name)) {\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_compat/components/${name}`,\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 if (builtInKeywords.includes(path)) {\n return null;\n }\n\n return {\n type: 'helper',\n specifier: `#embroider_compat/helpers/${path}`,\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 (\n (!this.staticHelpersEnabled && !this.staticComponentsEnabled) ||\n builtInKeywords.includes(path) ||\n this.isIgnoredComponent(path)\n ) {\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_compat/ambiguous/${path}`,\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 if (builtInKeywords.includes(path)) {\n return null;\n }\n\n return {\n type: 'modifier',\n specifier: `#embroider_compat/modifiers/${path}`,\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 = node.path.parts[0];\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = 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 (node.path.this === true) {\n return;\n }\n if (this.scopeStack.inScope(node.path.parts[0], 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 let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n MustacheStatement: {\n enter: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = node.path.parts[0];\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original.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(node.path.parts[0], path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n let resolution = 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 }: Options) {\n let config: CompatResolverOptions = readJSONSync(join(appRoot, '.embroider', 'resolver.json'));\n const resolverTransform: ASTPluginBuilder<Env> = env => {\n if (env.strict) {\n return {\n name: 'embroider-build-time-resolver-strict-noop',\n visitor: {},\n };\n }\n return new TemplateResolver(env, config);\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"]}
|
|
1
|
+
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,yDAQ4B;AAC5B,2DAA6C;AAE7C,gEAAuC;AACvC,+BAAiC;AACjC,uCAAwC;AACxC,yEAAgF;AAChF,0CAAmF;AAGnF,mCAA8C;AA0BjC,QAAA,eAAe,GAAG;IAC7B,kBAAkB;IAClB,aAAa;IACb,oBAAoB;IACpB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,QAAQ;IACR,UAAU;IACV,SAAS;IACT,MAAM;IACN,IAAI;IACJ,KAAK;IACL,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,OAAO;IACP,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,UAAU;IACV,OAAO;IACP,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,SAAS;IACT,cAAc;IACd,UAAU;IACV,UAAU;IACV,SAAS;IACT,WAAW;IACX,QAAQ;IACR,MAAM;IACN,OAAO;CACR,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CAAC,CAAC;KAClC;AACH,CAAC","sourcesContent":["import type { ASTv1, ASTPlugin, ASTPluginBuilder, ASTPluginEnvironment, WalkerPath } from '@glimmer/syntax';\nimport {\n PreprocessedComponentRule,\n preprocessComponentRule,\n ActivePackageRules,\n ComponentRules,\n PackageRules,\n ModuleRules,\n appTreeRulesDir,\n} 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 { ResolverOptions as CoreResolverOptions, Resolver } from '@embroider/core';\nimport CompatOptions from './options';\nimport { AuditMessage, Loc } from './audit';\nimport { camelCase, mergeWith } from 'lodash';\n\ntype Env = WithJSUtils<ASTPluginEnvironment> & {\n filename: string;\n contents: string;\n strict?: 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}\n\nexport const builtInKeywords = [\n '-get-dynamic-var',\n '-in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each-in',\n 'each',\n 'fn',\n 'get',\n 'has-block-params',\n 'has-block',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'helper',\n 'if',\n 'in-element',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'modifier',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unique-id',\n 'unless',\n 'with',\n 'yield',\n];\n\ninterface ComponentResolution {\n type: 'component';\n specifier: 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};\n\ntype ModifierResolution = {\n type: 'modifier';\n specifier: 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(private env: Env, private config: CompatResolverOptions) {\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, 'default', 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 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 if (builtInKeywords.includes(name)) {\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_compat/components/${name}`,\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 if (builtInKeywords.includes(path)) {\n return null;\n }\n\n return {\n type: 'helper',\n specifier: `#embroider_compat/helpers/${path}`,\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 (\n (!this.staticHelpersEnabled && !this.staticComponentsEnabled) ||\n builtInKeywords.includes(path) ||\n this.isIgnoredComponent(path)\n ) {\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_compat/ambiguous/${path}`,\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 if (builtInKeywords.includes(path)) {\n return null;\n }\n\n return {\n type: 'modifier',\n specifier: `#embroider_compat/modifiers/${path}`,\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 = node.path.parts[0];\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n let resolution = 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 (node.path.this === true) {\n return;\n }\n if (this.scopeStack.inScope(node.path.parts[0], 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 let resolution = this.targetHelper(node.path.original);\n this.emit(path, resolution, (node, newId) => {\n node.path = newId;\n });\n },\n MustacheStatement: {\n enter: (node, path) => {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n let rootName = node.path.parts[0];\n if (this.scopeStack.inScope(rootName, path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original.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(node.path.parts[0], path)) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n let resolution = 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 }: Options) {\n let config: CompatResolverOptions = readJSONSync(join(appRoot, '.embroider', 'resolver.json'));\n const resolverTransform: ASTPluginBuilder<Env> = env => {\n if (env.strict) {\n return {\n name: 'embroider-build-time-resolver-strict-noop',\n visitor: {},\n };\n }\n return new TemplateResolver(env, config);\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"]}
|