@embroider/compat 0.46.2 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -5
- package/src/audit/babel-visitor.js +3 -4
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/compat-adapters/ember-cli-babel.d.ts +5 -0
- package/src/compat-adapters/ember-cli-babel.js +27 -0
- package/src/compat-adapters/ember-cli-babel.js.map +1 -0
- package/src/compat-adapters/ember-get-config.js +5 -1
- package/src/compat-adapters/ember-get-config.js.map +1 -1
- package/src/dependency-rules.js.map +1 -1
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/resolver-transform.d.ts +1 -0
- package/src/resolver-transform.js +30 -1
- package/src/resolver-transform.js.map +1 -1
- package/src/resolver.d.ts +11 -2
- package/src/resolver.js +79 -5
- package/src/resolver.js.map +1 -1
- package/src/v1-addon.js +4 -1
- package/src/v1-addon.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -29,9 +29,8 @@
|
|
|
29
29
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
30
30
|
"@babel/preset-env": "^7.14.5",
|
|
31
31
|
"@babel/traverse": "^7.14.5",
|
|
32
|
-
"@
|
|
33
|
-
"@embroider/
|
|
34
|
-
"@embroider/shared-internals": "0.46.2",
|
|
32
|
+
"@embroider/macros": "0.48.0",
|
|
33
|
+
"@embroider/shared-internals": "0.48.0",
|
|
35
34
|
"@types/babel__code-frame": "^7.0.2",
|
|
36
35
|
"@types/yargs": "^17.0.3",
|
|
37
36
|
"assert-never": "^1.1.0",
|
|
@@ -86,7 +85,7 @@
|
|
|
86
85
|
"typescript": "*"
|
|
87
86
|
},
|
|
88
87
|
"peerDependencies": {
|
|
89
|
-
"@embroider/core": "0.
|
|
88
|
+
"@embroider/core": "0.48.0"
|
|
90
89
|
},
|
|
91
90
|
"engines": {
|
|
92
91
|
"node": "12.* || 14.* || >= 16"
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CodeFrameStorage = exports.auditJS = exports.isNamespaceMarker = exports.VisitorState = void 0;
|
|
7
7
|
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
8
|
-
const types_1 = require("@babel/types");
|
|
9
8
|
const core_1 = require("@babel/core");
|
|
10
9
|
const code_frame_1 = require("@babel/code-frame");
|
|
11
10
|
class VisitorState {
|
|
@@ -47,7 +46,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
|
|
|
47
46
|
},
|
|
48
47
|
CallExpression(path) {
|
|
49
48
|
let callee = path.get('callee');
|
|
50
|
-
if (callee.referencesImport('@embroider/macros', 'importSync') ||
|
|
49
|
+
if (callee.referencesImport('@embroider/macros', 'importSync') || core_1.types.isImport(callee)) {
|
|
51
50
|
let arg = path.node.arguments[0];
|
|
52
51
|
if (arg.type === 'StringLiteral') {
|
|
53
52
|
imports.push({
|
|
@@ -58,7 +57,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
|
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
60
59
|
problems.push({
|
|
61
|
-
message: `audit tool is unable to understand this usage of ${
|
|
60
|
+
message: `audit tool is unable to understand this usage of ${core_1.types.isImport(callee) ? 'import' : 'importSync'}`,
|
|
62
61
|
detail: arg.type,
|
|
63
62
|
codeFrameIndex: saveCodeFrame(arg),
|
|
64
63
|
});
|
|
@@ -178,7 +177,7 @@ class CodeFrameStorage {
|
|
|
178
177
|
}
|
|
179
178
|
exports.CodeFrameStorage = CodeFrameStorage;
|
|
180
179
|
function name(node) {
|
|
181
|
-
if (
|
|
180
|
+
if (core_1.types.isStringLiteral(node)) {
|
|
182
181
|
return node.value;
|
|
183
182
|
}
|
|
184
183
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA2D;AAC3D,wCAesB;AACtB,sCAA8D;AAC9D,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,GAAG,EAAsB,CAAC;IAC5C,IAAI,QAAQ,GAAG,EAA+E,CAAC;IAE/F,2DAA2D;IAC3D,4EAA4E;IAC5E,uEAAuE;IACvE,gBAAgB;IAChB,IAAI,SAAS,GAAY,KAAK,CAAC;IAC/B,IAAI,UAAU,GAAY,KAAK,CAAC;IAChC,IAAI,SAAS,GAAY,KAAK,CAAC;IAC/B,0DAA0D;IAE1D,IAAI,GAAG,GAAG,IAAA,oBAAa,EAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAE,CAAC,GAAI,CAAC;IAC7F,IAAI,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAEhD,IAAA,kBAAQ,EAAC,GAAG,EAAE;QACZ,UAAU,CAAC,IAA0B;YACnC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE;gBACvD,SAAS,GAAG,IAAI,CAAC;aAClB;iBAAM,IAAI,IAAI,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M,CAAC;KACf;AACH,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAc;IACjD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,wBAAwB;YAC3B,OAAO,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,CAAC;QAC1C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,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 {\n CallExpression,\n ExportAllDeclaration,\n ExportDefaultDeclaration,\n ExportNamedDeclaration,\n ExportNamespaceSpecifier,\n ExportSpecifier,\n Identifier,\n ImportDeclaration,\n ImportDefaultSpecifier,\n ImportNamespaceSpecifier,\n ImportSpecifier,\n isImport,\n isStringLiteral,\n StringLiteral,\n} from '@babel/types';\nimport { TransformOptions, transformSync } 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<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<CallExpression>) {\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'importSync') || 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 ${isImport(callee) ? 'import' : 'importSync'}`,\n detail: arg.type,\n codeFrameIndex: saveCodeFrame(arg),\n });\n }\n }\n },\n ImportDeclaration(path: NodePath<ImportDeclaration>) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n },\n ImportDefaultSpecifier(path: NodePath<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<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<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<ExportDefaultDeclaration>) {\n exports.add('default');\n },\n ExportSpecifier(path: NodePath<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<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<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<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 }) => {\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: StringLiteral | Identifier): string {\n if (isStringLiteral(node)) {\n return node.value;\n } else {\n return node.name;\n }\n}\n\nfunction isFreeVariable(path: NodePath<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;IACrC,IAAI,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,IAAI,QAAQ,GAAG,EAA+E,CAAC;IAE/F,2DAA2D;IAC3D,4EAA4E;IAC5E,uEAAuE;IACvE,gBAAgB;IAChB,IAAI,SAAS,GAAY,KAAK,CAAC;IAC/B,IAAI,UAAU,GAAY,KAAK,CAAC;IAChC,IAAI,SAAS,GAAY,KAAK,CAAC;IAC/B,0DAA0D;IAE1D,IAAI,GAAG,GAAG,IAAA,oBAAa,EAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAE,CAAC,GAAI,CAAC;IAC7F,IAAI,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAEhD,IAAA,kBAAQ,EAAC,GAAG,EAAE;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IAAI,CAAC,IAAI,CAAE,CAAC;KACrC;SAAM;QACL,IAAI,MAAM,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAC/C,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAc;IACjD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,wBAAwB;YAC3B,OAAO,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,CAAC;QAC1C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,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 = 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 }) => {\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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const broccoli_file_creator_1 = __importDefault(require("broccoli-file-creator"));
|
|
7
|
+
const v1_addon_1 = __importDefault(require("../v1-addon"));
|
|
8
|
+
// Because almost every addon depends on ember-cli-babel, and because ember-cli
|
|
9
|
+
// instantiates a separate instance of Addon per consumer, approximately *half*
|
|
10
|
+
// of all Addon instances in a typical app will be copies of ember-cli-babel.
|
|
11
|
+
//
|
|
12
|
+
// Under embroider, *all* of them should be contributing no files to the build.
|
|
13
|
+
class EmberCliBabel extends v1_addon_1.default {
|
|
14
|
+
// this ensures we don't bother smooshing together a large number of useless
|
|
15
|
+
// copies of the addon.
|
|
16
|
+
hasAnyTrees() {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
// and the one copy that we do emit should just be an empty valid package. We
|
|
20
|
+
// don't want the babel helpers it emits, they're not even used under
|
|
21
|
+
// Embroider anyway.
|
|
22
|
+
get v2Tree() {
|
|
23
|
+
return (0, broccoli_file_creator_1.default)('package.json', JSON.stringify(this.newPackageJSON, null, 2));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = EmberCliBabel;
|
|
27
|
+
//# sourceMappingURL=ember-cli-babel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ember-cli-babel.js","sourceRoot":"","sources":["ember-cli-babel.ts"],"names":[],"mappings":";;;;;AAAA,kFAA8C;AAC9C,2DAAkC;AAElC,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,EAAE;AACF,+EAA+E;AAC/E,MAAqB,aAAc,SAAQ,kBAAO;IAChD,4EAA4E;IAC5E,uBAAuB;IACvB,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6EAA6E;IAC7E,qEAAqE;IACrE,oBAAoB;IACpB,IAAI,MAAM;QACR,OAAO,IAAA,+BAAS,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;CACF;AAbD,gCAaC","sourcesContent":["import writeFile from 'broccoli-file-creator';\nimport V1Addon from '../v1-addon';\n\n// Because almost every addon depends on ember-cli-babel, and because ember-cli\n// instantiates a separate instance of Addon per consumer, approximately *half*\n// of all Addon instances in a typical app will be copies of ember-cli-babel.\n//\n// Under embroider, *all* of them should be contributing no files to the build.\nexport default class EmberCliBabel extends V1Addon {\n // this ensures we don't bother smooshing together a large number of useless\n // copies of the addon.\n hasAnyTrees() {\n return false;\n }\n\n // and the one copy that we do emit should just be an empty valid package. We\n // don't want the babel helpers it emits, they're not even used under\n // Embroider anyway.\n get v2Tree() {\n return writeFile('package.json', JSON.stringify(this.newPackageJSON, null, 2));\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const v1_addon_1 = __importDefault(require("../v1-addon"));
|
|
7
7
|
const broccoli_file_creator_1 = __importDefault(require("broccoli-file-creator"));
|
|
8
|
+
const broccoli_merge_trees_1 = __importDefault(require("broccoli-merge-trees"));
|
|
8
9
|
function createIndexContents(config) {
|
|
9
10
|
return `export default ${JSON.stringify(config)};`;
|
|
10
11
|
}
|
|
@@ -24,7 +25,10 @@ class default_1 extends v1_addon_1.default {
|
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
26
|
const configModule = require(this.app.configPath());
|
|
26
27
|
const appEnvironmentConfig = configModule(this.app.env);
|
|
27
|
-
return (0,
|
|
28
|
+
return (0, broccoli_merge_trees_1.default)([
|
|
29
|
+
(0, broccoli_file_creator_1.default)('index.js', createIndexContents(appEnvironmentConfig)),
|
|
30
|
+
(0, broccoli_file_creator_1.default)('package.json', JSON.stringify(this.newPackageJSON, null, 2)),
|
|
31
|
+
]);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ember-get-config.js","sourceRoot":"","sources":["ember-get-config.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAClC,kFAA8C;AAE9C,SAAS,mBAAmB,CAAC,MAAW;IACtC,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,iEAAiE;QACjE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExD,OAAO,IAAA,+BAAS,EAAC,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ember-get-config.js","sourceRoot":"","sources":["ember-get-config.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAClC,kFAA8C;AAC9C,gFAA8C;AAE9C,SAAS,mBAAmB,CAAC,MAAW;IACtC,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,iEAAiE;QACjE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExD,OAAO,IAAA,8BAAU,EAAC;YAChB,IAAA,+BAAS,EAAC,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YAChE,IAAA,+BAAS,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;CACF;AAXD,4BAWC","sourcesContent":["import V1Addon from '../v1-addon';\nimport writeFile from 'broccoli-file-creator';\nimport mergeTrees from 'broccoli-merge-trees';\n\nfunction createIndexContents(config: any): string {\n return `export default ${JSON.stringify(config)};`;\n}\n\n/**\n * The `ember-get-config` addon conceptually does just one thing: re-exports the `config/environment` runtime module\n * from the host app so that addons can import it themseles. It handles the \"hard part\" of knowing what the host app's\n * module name is, since that's not something an addon can normally know ahead of time.\n *\n * From a dependency graph perspective though, declaring all of the dependencies correctly would require a circular\n * dependency from the addon back to the host app itself, which we don't want to introduce.\n *\n * We need to basically re-implement the entire addon's behavior so that it still exports the app's\n * `config/environment` runtime value, but without needing it to actually export from the host app's module.\n */\nexport default class extends V1Addon {\n get v2Tree() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const configModule = require(this.app.configPath());\n const appEnvironmentConfig = configModule(this.app.env);\n\n return mergeTrees([\n writeFile('index.js', createIndexContents(appEnvironmentConfig)),\n writeFile('package.json', JSON.stringify(this.newPackageJSON, null, 2)),\n ]);\n }\n}\n"]}
|
|
@@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aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,gCAAgC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;aAC7G;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,OAAO;gBACP,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;gBACzD,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC,CAAC;SACJ;KACF;IACD,IAAI,WAAW,CAAC,mBAAmB,EAAE;QACnC,KAAK,IAAI,OAAO,IAAI,WAAW,CAAC,mBAAmB,EAAE;YACnD,IAAI,KAAK,GAAG,QAAQ,CAAC,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACnE,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE;gBAC1D,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;aAC3F;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAxBD,8CAwBC","sourcesContent":["import { Package, explicitRelative, getOrCreate } from '@embroider/core';\nimport { satisfies } from 'semver';\nimport CompatResolver from './resolver';\nimport { dirname } from 'path';\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 temlate 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\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 dependsOnComponents: ComponentSnippet[];\n argumentsAreComponents: string[];\n safeInteriorPaths: string[];\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 let dependsOnComponents = [];\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 }\n }\n if (componentRules.invokes) {\n for (let [path, snippets] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n for (let snippet of snippets) {\n dependsOnComponents.push(snippet);\n }\n }\n }\n return {\n argumentsAreComponents,\n safeInteriorPaths,\n dependsOnComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\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\nexport function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {\n let output: { absPath: string; target: string; runtimeName: string }[] = [];\n if (moduleRules.dependsOnModules) {\n for (let path of moduleRules.dependsOnModules) {\n let found = resolver.resolveImport(path, absPath);\n if (!found) {\n throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);\n }\n output.push({\n absPath,\n target: explicitRelative(dirname(absPath), found.absPath),\n runtimeName: found.runtimeName,\n });\n }\n }\n if (moduleRules.dependsOnComponents) {\n for (let snippet of moduleRules.dependsOnComponents) {\n let found = resolver.resolveComponentSnippet(snippet, moduleRules);\n for (let { absPath: target, runtimeName } of found.modules) {\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n }\n }\n return output;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAyE;AACzE,mCAAmC;AAEnC,+BAA+B;AA8J/B,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,mBAAmB,GAAG,EAAE,CAAC;IAC7B,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;SAClC;KACF;IACD,IAAI,cAAc,CAAC,OAAO,EAAE;QAC1B,KAAK,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YACnE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,IAAI,OAAO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AAI,WAAW,CAAC,gBAAgB,EAAE;QAChC,KAAK,IAAI,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE;YAC7C,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAClD,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,gCAAgC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;aAC7G;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,OAAO;gBACP,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;gBACzD,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC,CAAC;SACJ;KACF;IACD,IAAI,WAAW,CAAC,mBAAmB,EAAE;QACnC,KAAK,IAAI,OAAO,IAAI,WAAW,CAAC,mBAAmB,EAAE;YACnD,IAAI,KAAK,GAAG,QAAQ,CAAC,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACnE,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE;gBAC1D,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;aAC3F;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAxBD,8CAwBC","sourcesContent":["import { Package, explicitRelative, getOrCreate } from '@embroider/core';\nimport { satisfies } from 'semver';\nimport CompatResolver from './resolver';\nimport { dirname } from 'path';\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\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 dependsOnComponents: ComponentSnippet[];\n argumentsAreComponents: string[];\n safeInteriorPaths: string[];\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 let dependsOnComponents = [];\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 }\n }\n if (componentRules.invokes) {\n for (let [path, snippets] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n for (let snippet of snippets) {\n dependsOnComponents.push(snippet);\n }\n }\n }\n return {\n argumentsAreComponents,\n safeInteriorPaths,\n dependsOnComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\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\nexport function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {\n let output: { absPath: string; target: string; runtimeName: string }[] = [];\n if (moduleRules.dependsOnModules) {\n for (let path of moduleRules.dependsOnModules) {\n let found = resolver.resolveImport(path, absPath);\n if (!found) {\n throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);\n }\n output.push({\n absPath,\n target: explicitRelative(dirname(absPath), found.absPath),\n runtimeName: found.runtimeName,\n });\n }\n }\n if (moduleRules.dependsOnComponents) {\n for (let snippet of moduleRules.dependsOnComponents) {\n let found = resolver.resolveComponentSnippet(snippet, moduleRules);\n for (let { absPath: target, runtimeName } of found.modules) {\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n }\n }\n return output;\n}\n"]}
|
package/src/options.js
CHANGED
package/src/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAEA,0CAAkG;AA0FlG,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,kBAAkB,EAAE,EAAE;IACtB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { V1AddonConstructor } from './v1-addon';\nimport { Node } from 'broccoli-node-api';\nimport { Options as CoreOptions, optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // temporary directory where we will work when we're rewriting your addons\n // and/or app to v2-compatible formats.\n workspaceDir?: string | null;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n optionalComponents: [],\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticComponents: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAEA,0CAAkG;AA0FlG,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,kBAAkB,EAAE,EAAE;IACtB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,IAAI;QACtB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { V1AddonConstructor } from './v1-addon';\nimport { Node } from 'broccoli-node-api';\nimport { Options as CoreOptions, optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // temporary directory where we will work when we're rewriting your addons\n // and/or app to v2-compatible formats.\n workspaceDir?: string | null;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n optionalComponents: [],\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticModifiers: true,\n staticComponents: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
|
|
@@ -13,6 +13,7 @@ export declare function makeResolverTransform(resolver: Resolver): {
|
|
|
13
13
|
BlockStatement(node: ASTv1.BlockStatement): void;
|
|
14
14
|
SubExpression(node: ASTv1.SubExpression): void;
|
|
15
15
|
MustacheStatement(node: ASTv1.MustacheStatement): void;
|
|
16
|
+
ElementModifierStatement(node: ASTv1.ElementModifierStatement): void;
|
|
16
17
|
ElementNode: {
|
|
17
18
|
enter(node: ASTv1.ElementNode): void;
|
|
18
19
|
exit(): void;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeResolverTransform = void 0;
|
|
7
7
|
const resolver_1 = __importDefault(require("./resolver"));
|
|
8
|
-
// This is the AST transform that resolves components and
|
|
8
|
+
// This is the AST transform that resolves components, helpers and modifiers at build time
|
|
9
9
|
// and puts them into `dependencies`.
|
|
10
10
|
function makeResolverTransform(resolver) {
|
|
11
11
|
function resolverTransform({ filename }) {
|
|
@@ -29,6 +29,9 @@ function makeResolverTransform(resolver) {
|
|
|
29
29
|
if (scopeStack.inScope(node.path.parts[0])) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
if (node.path.this === true) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
32
35
|
if (node.path.parts.length > 1) {
|
|
33
36
|
// paths with a dot in them (which therefore split into more than
|
|
34
37
|
// one "part") are classically understood by ember to be contextual
|
|
@@ -81,6 +84,9 @@ function makeResolverTransform(resolver) {
|
|
|
81
84
|
if (scopeStack.inScope(node.path.parts[0])) {
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
87
|
+
if (node.path.this === true) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
84
90
|
if (node.path.parts.length > 1) {
|
|
85
91
|
// paths with a dot in them (which therefore split into more than
|
|
86
92
|
// one "part") are classically understood by ember to be contextual
|
|
@@ -106,6 +112,29 @@ function makeResolverTransform(resolver) {
|
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
},
|
|
115
|
+
ElementModifierStatement(node) {
|
|
116
|
+
if (node.path.type !== 'PathExpression') {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (scopeStack.inScope(node.path.parts[0])) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (node.path.this === true) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (node.path.data === true) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (node.path.parts.length > 1) {
|
|
129
|
+
// paths with a dot in them (which therefore split into more than
|
|
130
|
+
// one "part") are classically understood by ember to be contextual
|
|
131
|
+
// components. With the introduction of `Template strict mode` in Ember 3.25
|
|
132
|
+
// it is also possible to pass modifiers this way which means there's nothing
|
|
133
|
+
// to resolve at this location.
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);
|
|
137
|
+
},
|
|
109
138
|
ElementNode: {
|
|
110
139
|
enter(node) {
|
|
111
140
|
if (!scopeStack.inScope(node.tag.split('.')[0])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAwF;AAGxF,+EAA+E;AAC/E,qCAAqC;AACrC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAwB;QAC3D,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,+BAA+B;YAErC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAmB;wBACvB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,CAAC;oBACD,IAAI;wBACF,UAAU,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC;iBACF;gBACD,cAAc,CAAC,IAA0B;oBACvC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;wBACvC,OAAO;qBACR;oBACD,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBAC1C,OAAO;qBACR;oBACD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;wBAC9B,iEAAiE;wBACjE,mEAAmE;wBACnE,6DAA6D;wBAC7D,YAAY;wBACZ,OAAO;qBACR;oBACD,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,M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,CAAC,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5E,OAAO;KACR;IAED,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEhF,OAAO;IACP,0CAA0C;IAC1C,qCAAqC;IACrC,iCAAiC;IACjC,wEAAwE;IACxE,MAAM;IACN,YAAY;IACZ,IAAI;IAEJ,OAAO;IACP,0CAA0C;IAC1C,4CAA4C;IAC5C,wCAAwC;IACxC,MAAM;IACN,sFAAsF;IACtF,YAAY;IACZ,IAAI;IAEJ,mCAAmC;IACnC,oGAAoG;IACpG,YAAY;IACZ,IAAI;IAEJ,uHAAuH;IACvH,yFAAyF;IACzF,YAAY;IACZ,IAAI;IAEJ,8FAA8F;AAChG,CAAC","sourcesContent":["import { default as Resolver, ComponentResolution, ComponentLocator } from './resolver';\nimport type { ASTv1 } from '@glimmer/syntax';\n\n// This is the AST transform that resolves components and helpers at build time\n// and puts them into `dependencies`.\nexport function makeResolverTransform(resolver: Resolver) {\n function resolverTransform({ filename }: { filename: string }) {\n resolver.enter(filename);\n\n let scopeStack = new ScopeStack();\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node: ASTv1.Program) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node: ASTv1.BlockStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n const resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n }\n }\n });\n }\n },\n SubExpression(node: ASTv1.SubExpression) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n },\n MustacheStatement(node: ASTv1.MustacheStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n for (let name of resolution.argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n }\n }\n }\n },\n ElementNode: {\n enter(node: ASTv1.ElementNode) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let attr = node.attributes.find((attr: ASTv1.AttrNode) => attr.name === '@' + name);\n if (attr) {\n handleComponentHelper(attr.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n }\n resolverTransform.parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): void {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n return;\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return;\n }\n\n resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.hash.pairs.length === 0 &&\n // param.params.length === 0 &&\n // handleComponentHelper(param.path, resolver, moduleName, scopeStack)\n // ) {\n // return;\n // }\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.path.type === 'PathExpression' &&\n // param.path.original === 'component'\n // ) {\n // // safe because we will handle this inner `{{component ...}}` mustache on its own\n // return;\n // }\n\n // if (param.type === 'TextNode') {\n // resolver.resolveComponentHelper({ type: 'literal', path: param.chars }, moduleName, param.loc);\n // return;\n // }\n\n // if (param.type === 'SubExpression' && param.path.type === 'PathExpression' && param.path.original === 'component') {\n // // safe because we will handle this inner `(component ...)` subexpression on its own\n // return;\n // }\n\n // resolver.unresolvableComponentArgument(componentName, argumentName, moduleName, param.loc);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAwF;AAGxF,0FAA0F;AAC1F,qCAAqC;AACrC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAwB;QAC3D,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,+BAA+B;YAErC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAmB;wBACvB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,CAAC;oBACD,IAAI;wBACF,UAAU,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC;iBACF;gBACD,cAAc,CAAC,IAA0B;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E,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC/B;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5E,OAAO;KACR;IAED,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEhF,OAAO;IACP,0CAA0C;IAC1C,qCAAqC;IACrC,iCAAiC;IACjC,wEAAwE;IACxE,MAAM;IACN,YAAY;IACZ,IAAI;IAEJ,OAAO;IACP,0CAA0C;IAC1C,4CAA4C;IAC5C,wCAAwC;IACxC,MAAM;IACN,sFAAsF;IACtF,YAAY;IACZ,IAAI;IAEJ,mCAAmC;IACnC,oGAAoG;IACpG,YAAY;IACZ,IAAI;IAEJ,uHAAuH;IACvH,yFAAyF;IACzF,YAAY;IACZ,IAAI;IAEJ,8FAA8F;AAChG,CAAC","sourcesContent":["import { default as Resolver, ComponentResolution, ComponentLocator } from './resolver';\nimport type { ASTv1 } from '@glimmer/syntax';\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\n// and puts them into `dependencies`.\nexport function makeResolverTransform(resolver: Resolver) {\n function resolverTransform({ filename }: { filename: string }) {\n resolver.enter(filename);\n\n let scopeStack = new ScopeStack();\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node: ASTv1.Program) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node: ASTv1.BlockStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n const resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n }\n }\n });\n }\n },\n SubExpression(node: ASTv1.SubExpression) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n },\n MustacheStatement(node: ASTv1.MustacheStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n for (let name of resolution.argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n }\n }\n }\n },\n ElementModifierStatement(node: ASTv1.ElementModifierStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);\n },\n ElementNode: {\n enter(node: ASTv1.ElementNode) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let attr = node.attributes.find((attr: ASTv1.AttrNode) => attr.name === '@' + name);\n if (attr) {\n handleComponentHelper(attr.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n }\n resolverTransform.parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): void {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n return;\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return;\n }\n\n resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.hash.pairs.length === 0 &&\n // param.params.length === 0 &&\n // handleComponentHelper(param.path, resolver, moduleName, scopeStack)\n // ) {\n // return;\n // }\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.path.type === 'PathExpression' &&\n // param.path.original === 'component'\n // ) {\n // // safe because we will handle this inner `{{component ...}}` mustache on its own\n // return;\n // }\n\n // if (param.type === 'TextNode') {\n // resolver.resolveComponentHelper({ type: 'literal', path: param.chars }, moduleName, param.loc);\n // return;\n // }\n\n // if (param.type === 'SubExpression' && param.path.type === 'PathExpression' && param.path.original === 'component') {\n // // safe because we will handle this inner `(component ...)` subexpression on its own\n // return;\n // }\n\n // resolver.unresolvableComponentArgument(componentName, argumentName, moduleName, param.loc);\n}\n"]}
|
package/src/resolver.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ export interface HelperResolution {
|
|
|
14
14
|
type: 'helper';
|
|
15
15
|
modules: ResolvedDep[];
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export interface ModifierResolution {
|
|
18
|
+
type: 'modifier';
|
|
19
|
+
modules: ResolvedDep[];
|
|
20
|
+
}
|
|
21
|
+
export declare type ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;
|
|
18
22
|
export interface ResolutionFail {
|
|
19
23
|
type: 'error';
|
|
20
24
|
message: string;
|
|
@@ -32,7 +36,7 @@ export interface Loc {
|
|
|
32
36
|
column: number;
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
declare type ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
|
|
39
|
+
declare type ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
|
|
36
40
|
interface RehydrationParamsBase {
|
|
37
41
|
root: string;
|
|
38
42
|
modulePrefix: string;
|
|
@@ -88,12 +92,17 @@ export default class CompatResolver implements Resolver {
|
|
|
88
92
|
}): string;
|
|
89
93
|
private get staticComponentsEnabled();
|
|
90
94
|
private get staticHelpersEnabled();
|
|
95
|
+
private get staticModifiersEnabled();
|
|
91
96
|
private tryHelper;
|
|
97
|
+
private _tryHelper;
|
|
98
|
+
private tryModifier;
|
|
99
|
+
private _tryModifier;
|
|
92
100
|
private get appPackage();
|
|
93
101
|
private tryComponent;
|
|
94
102
|
private _tryComponent;
|
|
95
103
|
resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null;
|
|
96
104
|
resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null;
|
|
105
|
+
resolveElementModifierStatement(path: string, from: string, loc: Loc): Resolution | null;
|
|
97
106
|
resolveElement(tagName: string, from: string, loc: Loc): Resolution | null;
|
|
98
107
|
resolveComponentHelper(component: ComponentLocator, from: string, loc: Loc, impliedBecause?: {
|
|
99
108
|
componentName: string;
|