@embroider/compat 4.0.5-unstable.f9bcc6f → 4.1.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/dist/src/audit/babel-visitor.d.ts +2 -2
- package/dist/src/audit/babel-visitor.js +2 -2
- package/dist/src/audit/babel-visitor.js.map +1 -1
- package/dist/src/module-visitor.js +1 -1
- package/dist/src/module-visitor.js.map +1 -1
- package/dist/src/v1-addon.js +8 -1
- package/dist/src/v1-addon.js.map +1 -1
- package/package.json +8 -7
|
@@ -18,7 +18,7 @@ export declare function isNamespaceMarker(value: string | NamespaceMarker): valu
|
|
|
18
18
|
export interface ExportAll {
|
|
19
19
|
all: string;
|
|
20
20
|
}
|
|
21
|
-
export declare function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage): {
|
|
21
|
+
export declare function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage): Promise<{
|
|
22
22
|
imports: InternalImport[];
|
|
23
23
|
exports: Set<string | ExportAll>;
|
|
24
24
|
isCJS: false;
|
|
@@ -29,7 +29,7 @@ export declare function auditJS(rawSource: string, filename: string, babelConfig
|
|
|
29
29
|
codeFrameIndex: number | undefined;
|
|
30
30
|
}[];
|
|
31
31
|
transpiledContent: string;
|
|
32
|
-
}
|
|
32
|
+
}>;
|
|
33
33
|
export declare class CodeFrameStorage {
|
|
34
34
|
private codeFrames;
|
|
35
35
|
private rawSources;
|
|
@@ -15,7 +15,7 @@ exports.VisitorState = VisitorState;
|
|
|
15
15
|
function isNamespaceMarker(value) {
|
|
16
16
|
return typeof value !== 'string';
|
|
17
17
|
}
|
|
18
|
-
function auditJS(rawSource, filename, babelConfig, frames) {
|
|
18
|
+
async function auditJS(rawSource, filename, babelConfig, frames) {
|
|
19
19
|
if (!babelConfig.ast) {
|
|
20
20
|
throw new Error(`module auditing requires a babel config with ast: true`);
|
|
21
21
|
}
|
|
@@ -30,7 +30,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
|
|
|
30
30
|
let sawExports = false;
|
|
31
31
|
let sawDefine = false;
|
|
32
32
|
/* eslint-enable @typescript-eslint/no-inferrable-types */
|
|
33
|
-
let { ast, code } = (0, core_1.
|
|
33
|
+
let { ast, code } = (await (0, core_1.transformAsync)(rawSource, Object.assign({ filename: filename }, babelConfig)));
|
|
34
34
|
let saveCodeFrame = frames.forSource(rawSource);
|
|
35
35
|
(0, traverse_1.default)(ast, {
|
|
36
36
|
Identifier(path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["../../../src/audit/babel-visitor.ts"],"names":[],"mappings":";;;;;;AAuBA,8CAEC;AAMD,0BAwIC;AAtKD,+DAAuC;AAEvC,sCAAwD;AAExD,kDAAqD;AAErD,MAAa,YAAY;CAAG;AAA5B,oCAA4B;AAgB5B,SAAgB,iBAAiB,CAAC,KAA+B;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAMD,SAAgB,OAAO,CAAC,SAAiB,EAAE,QAAgB,EAAE,WAA6B,EAAE,MAAwB;IAClH,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,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,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAA,oBAAa,EAAC,SAAS,EAAE,MAAM,CAAC,MA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KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACpF,KAAK,mBAAmB;YACtB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACnF,KAAK,qBAAqB,CAAC;QAC3B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport type { TransformOptions } from '@babel/core';\nimport { transformSync, types as t } from '@babel/core';\nimport type { SourceLocation } from '@babel/code-frame';\nimport { codeFrameColumns } 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\nexport function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage) {\n if (!babelConfig.ast) {\n throw new Error(`module auditing requires a babel config with ast: true`);\n }\n\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.node)) {\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 if (arg.leadingComments?.find(c => /@vite-ignore/.test(c.value))) {\n // this is vite internals that we should ignore too\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${\n t.isImport(callee.node) ? 'import' : 'importSync'\n }`,\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"]}
|
|
1
|
+
{"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["../../../src/audit/babel-visitor.ts"],"names":[],"mappings":";;;;;;AAuBA,8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,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport type { TransformOptions } from '@babel/core';\nimport { transformAsync, types as t } from '@babel/core';\nimport type { SourceLocation } from '@babel/code-frame';\nimport { codeFrameColumns } 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\nexport async function auditJS(\n rawSource: string,\n filename: string,\n babelConfig: TransformOptions,\n frames: CodeFrameStorage\n) {\n if (!babelConfig.ast) {\n throw new Error(`module auditing requires a babel config with ast: true`);\n }\n\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 } = (await transformAsync(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.node)) {\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 if (arg.leadingComments?.find(c => /@vite-ignore/.test(c.value))) {\n // this is vite internals that we should ignore too\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${\n t.isImport(callee.node) ? 'import' : 'importSync'\n }`,\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"]}
|
|
@@ -184,7 +184,7 @@ class ModuleVisitor {
|
|
|
184
184
|
async visitJS(filename, content) {
|
|
185
185
|
let rawSource = content.toString('utf8');
|
|
186
186
|
try {
|
|
187
|
-
let result = (0, babel_visitor_1.auditJS)(rawSource, filename, this.params.babelConfig, this.params.frames);
|
|
187
|
+
let result = await (0, babel_visitor_1.auditJS)(rawSource, filename, this.params.babelConfig, this.params.frames);
|
|
188
188
|
for (let problem of result.problems) {
|
|
189
189
|
this.params.findings.push({
|
|
190
190
|
filename,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-visitor.js","sourceRoot":"","sources":["../../src/module-visitor.ts"],"names":[],"mappings":";;;;;AAkGA,oCAGC;AAuSD,oCAEC;AA9YD,0CAAmD;AACnD,yDAM+B;AAC/B,iE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,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAMD,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC","sourcesContent":["import { explicitRelative } from '@embroider/core';\nimport {\n type CodeFrameStorage,\n auditJS,\n type ExportAll,\n type InternalImport,\n type NamespaceMarker,\n} from './audit/babel-visitor';\nimport fromPairs from 'lodash/fromPairs';\nimport assertNever from 'assert-never';\nimport { JSDOM } from 'jsdom';\n\nimport type { Finding } from './audit';\nimport type { TransformOptions } from '@babel/core';\n\nexport type Module = CompleteModule | ParsedModule | UnparseableModule;\n\nexport interface UnparseableModule {\n type: 'unparseable';\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n}\n\nexport interface ParsedModule extends Omit<UnparseableModule, 'type'> {\n type: 'parsed';\n imports: Import[];\n resolutions: { [source: string]: string | null };\n content: string;\n isCJS: boolean;\n isAMD: boolean;\n}\n\nexport interface CompleteModule extends Omit<ParsedModule, 'type'> {\n type: 'complete';\n exports: string[];\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 codeFrameIndex: number | undefined;\n }[];\n codeFrameIndex: number | undefined;\n}\n\ninterface VisitorParams {\n base: string;\n resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n entrypoints: string[];\n debug?: boolean;\n\n findings: Finding[];\n frames: CodeFrameStorage;\n babelConfig: TransformOptions;\n}\n\nexport async function visitModules(params: VisitorParams): Promise<Record<string, Module>> {\n let visitor = new ModuleVisitor(params);\n return await visitor.run();\n}\n\nexport type ContentType = 'javascript' | 'html';\n\nclass ModuleVisitor {\n private modules: Map<string, InternalModule> = new Map();\n\n private moduleQueue = new Set<string>();\n private base: string;\n private debugEnabled: boolean;\n private resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n private load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n private entrypoints: string[];\n\n constructor(private params: VisitorParams) {\n this.base = params.base;\n this.debugEnabled = Boolean(params.debug);\n this.resolveId = params.resolveId;\n this.load = params.load;\n this.entrypoints = params.entrypoints;\n }\n\n async run(): Promise<Record<string, Module>> {\n for (let entry of this.entrypoints) {\n this.scheduleVisit(entry, { isRoot: true });\n }\n await this.drainQueue();\n this.linkModules();\n return this.buildResults();\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let id = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(id);\n this.debug('visit', id);\n let loaded = await this.load(id);\n if (Array.isArray(loaded)) {\n for (let finding of loaded) {\n this.params.findings.push(finding);\n }\n continue;\n }\n // if the load hook returned undefined we need to just skip it\n if (loaded === undefined) {\n continue;\n }\n let { content, type } = loaded;\n\n let visitor = this.visitorFor(type);\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(id)!;\n let visitResult = await visitor.call(this, id, 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.params.findings.push(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, id);\n }\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 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 if (['@embroider/macros'].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\n let resolution = await this.resolveId(dep, fromFile);\n if (resolution) {\n resolved.set(dep, resolution);\n this.scheduleVisit(resolution, fromFile);\n continue;\n } else {\n resolved.set(dep, { isResolutionFailure: true as true });\n continue;\n }\n }\n return resolved;\n }\n\n private scheduleVisit(id: string, parent: string | RootMarker) {\n let record = this.modules.get(id);\n if (!record) {\n this.debug(`discovered`, id);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(id, record);\n this.moduleQueue.add(id);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n\n private visitorFor(\n type: ContentType\n ): (\n this: ModuleVisitor,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed'] | Finding[]>> {\n switch (type) {\n case 'html':\n return this.visitHTML;\n case 'javascript':\n return this.visitJS;\n default:\n throw assertNever(type);\n }\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 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.params.babelConfig, this.params.frames);\n\n for (let problem of result.problems) {\n this.params.findings.push({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.params.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.base, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private debug(message: string, ...args: any[]) {\n if (this.debugEnabled) {\n console.log(message, ...args);\n }\n }\n\n private toPublicModule(filename: string, module: InternalModule): Module {\n let result: UnparseableModule = {\n type: 'unparseable',\n appRelativePath: explicitRelative(this.base, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(this.base, entry);\n }\n }),\n };\n\n if (!module.parsed || !module.resolved) {\n return result;\n }\n\n let parsedResult: ParsedModule = {\n ...result,\n type: 'parsed',\n resolutions: fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(this.base, target),\n ])\n ),\n imports: module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n codeFrameIndex: s.codeFrameIndex,\n })),\n codeFrameIndex: i.codeFrameIndex,\n })),\n content: module.parsed.transpiledContent.toString(),\n isAMD: Boolean(module.parsed.isAMD),\n isCJS: Boolean(module.parsed.isCJS),\n };\n\n if (!module.linked) {\n return parsedResult;\n }\n\n return {\n ...parsedResult,\n type: 'complete',\n exports: [...module.linked.exports],\n };\n }\n\n private buildResults() {\n let publicModules: Record<string, Module> = {};\n for (let [filename, module] of this.modules) {\n let publicModule = this.toPublicModule(filename, module);\n publicModules[explicitRelative(this.base, filename)] = publicModule;\n }\n return publicModules;\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\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"]}
|
|
1
|
+
{"version":3,"file":"module-visitor.js","sourceRoot":"","sources":["../../src/module-visitor.ts"],"names":[],"m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AC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACzD,aAAa,CAAC,IAAA,uBAAgB,EAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAMD,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC","sourcesContent":["import { explicitRelative } from '@embroider/core';\nimport {\n type CodeFrameStorage,\n auditJS,\n type ExportAll,\n type InternalImport,\n type NamespaceMarker,\n} from './audit/babel-visitor';\nimport fromPairs from 'lodash/fromPairs';\nimport assertNever from 'assert-never';\nimport { JSDOM } from 'jsdom';\n\nimport type { Finding } from './audit';\nimport type { TransformOptions } from '@babel/core';\n\nexport type Module = CompleteModule | ParsedModule | UnparseableModule;\n\nexport interface UnparseableModule {\n type: 'unparseable';\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n}\n\nexport interface ParsedModule extends Omit<UnparseableModule, 'type'> {\n type: 'parsed';\n imports: Import[];\n resolutions: { [source: string]: string | null };\n content: string;\n isCJS: boolean;\n isAMD: boolean;\n}\n\nexport interface CompleteModule extends Omit<ParsedModule, 'type'> {\n type: 'complete';\n exports: string[];\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 codeFrameIndex: number | undefined;\n }[];\n codeFrameIndex: number | undefined;\n}\n\ninterface VisitorParams {\n base: string;\n resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n entrypoints: string[];\n debug?: boolean;\n\n findings: Finding[];\n frames: CodeFrameStorage;\n babelConfig: TransformOptions;\n}\n\nexport async function visitModules(params: VisitorParams): Promise<Record<string, Module>> {\n let visitor = new ModuleVisitor(params);\n return await visitor.run();\n}\n\nexport type ContentType = 'javascript' | 'html';\n\nclass ModuleVisitor {\n private modules: Map<string, InternalModule> = new Map();\n\n private moduleQueue = new Set<string>();\n private base: string;\n private debugEnabled: boolean;\n private resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n private load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n private entrypoints: string[];\n\n constructor(private params: VisitorParams) {\n this.base = params.base;\n this.debugEnabled = Boolean(params.debug);\n this.resolveId = params.resolveId;\n this.load = params.load;\n this.entrypoints = params.entrypoints;\n }\n\n async run(): Promise<Record<string, Module>> {\n for (let entry of this.entrypoints) {\n this.scheduleVisit(entry, { isRoot: true });\n }\n await this.drainQueue();\n this.linkModules();\n return this.buildResults();\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let id = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(id);\n this.debug('visit', id);\n let loaded = await this.load(id);\n if (Array.isArray(loaded)) {\n for (let finding of loaded) {\n this.params.findings.push(finding);\n }\n continue;\n }\n // if the load hook returned undefined we need to just skip it\n if (loaded === undefined) {\n continue;\n }\n let { content, type } = loaded;\n\n let visitor = this.visitorFor(type);\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(id)!;\n let visitResult = await visitor.call(this, id, 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.params.findings.push(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, id);\n }\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 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 if (['@embroider/macros'].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\n let resolution = await this.resolveId(dep, fromFile);\n if (resolution) {\n resolved.set(dep, resolution);\n this.scheduleVisit(resolution, fromFile);\n continue;\n } else {\n resolved.set(dep, { isResolutionFailure: true as true });\n continue;\n }\n }\n return resolved;\n }\n\n private scheduleVisit(id: string, parent: string | RootMarker) {\n let record = this.modules.get(id);\n if (!record) {\n this.debug(`discovered`, id);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(id, record);\n this.moduleQueue.add(id);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n\n private visitorFor(\n type: ContentType\n ): (\n this: ModuleVisitor,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed'] | Finding[]>> {\n switch (type) {\n case 'html':\n return this.visitHTML;\n case 'javascript':\n return this.visitJS;\n default:\n throw assertNever(type);\n }\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 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 = await auditJS(rawSource, filename, this.params.babelConfig, this.params.frames);\n\n for (let problem of result.problems) {\n this.params.findings.push({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.params.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.base, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private debug(message: string, ...args: any[]) {\n if (this.debugEnabled) {\n console.log(message, ...args);\n }\n }\n\n private toPublicModule(filename: string, module: InternalModule): Module {\n let result: UnparseableModule = {\n type: 'unparseable',\n appRelativePath: explicitRelative(this.base, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(this.base, entry);\n }\n }),\n };\n\n if (!module.parsed || !module.resolved) {\n return result;\n }\n\n let parsedResult: ParsedModule = {\n ...result,\n type: 'parsed',\n resolutions: fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(this.base, target),\n ])\n ),\n imports: module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n codeFrameIndex: s.codeFrameIndex,\n })),\n codeFrameIndex: i.codeFrameIndex,\n })),\n content: module.parsed.transpiledContent.toString(),\n isAMD: Boolean(module.parsed.isAMD),\n isCJS: Boolean(module.parsed.isCJS),\n };\n\n if (!module.linked) {\n return parsedResult;\n }\n\n return {\n ...parsedResult,\n type: 'complete',\n exports: [...module.linked.exports],\n };\n }\n\n private buildResults() {\n let publicModules: Record<string, Module> = {};\n for (let [filename, module] of this.modules) {\n let publicModule = this.toPublicModule(filename, module);\n publicModules[explicitRelative(this.base, filename)] = publicModule;\n }\n return publicModules;\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\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"]}
|
package/dist/src/v1-addon.js
CHANGED
|
@@ -105,6 +105,7 @@ class V1Addon {
|
|
|
105
105
|
}
|
|
106
106
|
// this is only defined when there are custom AST transforms that need it
|
|
107
107
|
get templateCompilerBabelPlugin() {
|
|
108
|
+
var _a;
|
|
108
109
|
let plugins = (0, prepare_htmlbars_ast_plugins_1.default)(this.addonInstance.registry);
|
|
109
110
|
let hasTemplateTag = this.addonInstance.addons.find((a) => a.name === 'ember-template-imports');
|
|
110
111
|
// our macros don't run here in stage1
|
|
@@ -123,7 +124,13 @@ class V1Addon {
|
|
|
123
124
|
],
|
|
124
125
|
transforms: plugins,
|
|
125
126
|
};
|
|
126
|
-
|
|
127
|
+
let babelVersion = (_a = this.addonInstance.addons.find(a => a.name === 'ember-cli-babel')) === null || _a === void 0 ? void 0 : _a.pkg.version;
|
|
128
|
+
if (babelVersion && semver_1.default.satisfies(babelVersion, '< 8.0.0')) {
|
|
129
|
+
return [require.resolve('babel-plugin-ember-template-compilation-2'), opts];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return [require.resolve('babel-plugin-ember-template-compilation'), opts];
|
|
133
|
+
}
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
136
|
updateRegistry(registry) {
|
package/dist/src/v1-addon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-addon.js","sourceRoot":"","sources":["../../src/v1-addon.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAA6C;AAC7C,+BAAwD;AACxD,mCAA2C;AAC3C,uCAAsD;AAEtD,sEAA0C;AAC1C,qDAA2D;AAC3D,kFAAwD;AACxD,2DAAiE;AAEjE,gFAA8C;AAC9C,oDAA4B;AAC5B,8EAAoD;AACpD,qCAA2C;AAE3C,0CAA0D;AAC1D,0DAAiC;AACjC,kEAAyC;AACzC,qDAAqE;AAErE,sEAA6C;AAC7C,kFAA8C;AAC9C,gHAAqF;AACrF,iEAKgC;AAChC,4FAAgE;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C;QAC/B,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,eAAe,GAAG,IAAI,8BAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAExD,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,YAAY,CAAC,OAAO,GAAG,GAAG,EAAE;IAC1B,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport { dirname, join, relative, resolve } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { existsSync, pathExistsSync } from 'fs-extra';\nimport type { Options as FunnelOptions } from 'broccoli-funnel';\nimport buildFunnel from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport RewritePackageJSON from './rewrite-package-json';\nimport { todo, unsupported } from '@embroider/core/src/messages';\nimport type { Node } from 'broccoli-node-api';\nimport mergeTrees from 'broccoli-merge-trees';\nimport semver from 'semver';\nimport rewriteAddonTree from './rewrite-addon-tree';\nimport { mergeWithAppend } from './merges';\nimport type { AddonMeta, PackageCache, AddonInstance, AddonTreePath } from '@embroider/core';\nimport { debug, findTopmostAddon } from '@embroider/core';\nimport walkSync from 'walk-sync';\nimport ObserveTree from './observe-tree';\nimport { isEmbroiderMacrosPlugin } from '@embroider/macros/src/node';\nimport type { TransformOptions, PluginItem } from '@babel/core';\nimport modulesCompat from './modules-compat';\nimport writeFile from 'broccoli-file-creator';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport {\n isEmberAutoImportDynamic,\n isCompactReexports,\n isColocationPlugin,\n isInlinePrecompilePlugin,\n} from './detect-babel-plugins';\nimport HbsToJSBroccoliPlugin from './hbs-to-js-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport loadAstPlugins from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\nimport type { Options as EtcOptions } from 'babel-plugin-ember-template-compilation';\nimport type CompatApp from './compat-app';\nimport type { CompatOptionsType } from './options';\n\nconst stockTreeNames: AddonTreePath[] = Object.freeze([\n 'addon',\n 'addon-styles',\n 'styles',\n 'addon-test-support',\n 'test-support',\n 'app',\n 'public',\n 'vendor',\n // 'addon-templates' and 'templates are trees too, but they live inside\n // 'addon' and 'app' and we handle them there.\n]) as AddonTreePath[];\n\nconst dynamicTreeHooks = Object.freeze([\n 'treeFor',\n 'treeForAddon',\n 'treeForAddonTemplates',\n 'treeForAddonTestSupport',\n 'treeForApp',\n 'treeForPublic',\n 'treeForStyles',\n 'treeForTemplates',\n 'treeForTestSupport',\n 'treeForVendor',\n]);\n\nconst defaultMethods = {\n app: 'treeForApp',\n addon: 'treeForAddon',\n 'addon-styles': 'treeForAddonStyles',\n 'addon-templates': 'treeForAddonTemplates',\n 'addon-test-support': 'treeForAddonTestSupport',\n public: 'treeForPublic',\n styles: 'treeForStyles',\n templates: 'treeForTemplates',\n 'test-support': 'treeForTestSupport',\n vendor: 'treeForVendor',\n};\n\nconst appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n// This controls and types the interface between our new world and the classic\n// v1 addon instance.\nexport default class V1Addon {\n constructor(\n protected addonInstance: AddonInstance,\n protected addonOptions: CompatOptionsType,\n protected app: CompatApp,\n private packageCache: PackageCache,\n private orderIdx: number\n ) {\n if (addonInstance.registry) {\n this.updateRegistry(addonInstance.registry);\n }\n }\n\n // Optional extensible hook for pruning down the list of redundant addon\n // instances produced by the classic ember-cli architecture. ember-cli\n // instantiates each addon *per consumer*, not per package. So a given package\n // will have many addon instances, and Embroider dutifully produces a V1Addon\n // instance for each one, and then needs to mimic the classic smooshing\n // behavior between them.\n //\n // But some packages (and ember-cli-babel is the motivating example) produce a\n // huge number of instances that do nothing useful and incur significant cost.\n // This hook allows their compat adapter to prune down the set, using\n // addon-specific knowledge of which instance(s) are actually important.\n //\n // The order of the instances is significant. The first one is the one with\n // the highest precedence, meaning its files would win under classic\n // smooshing.\n reduceInstances(instances: V1Addon[]): V1Addon[] {\n // the default beahvior is that all copies matter\n return instances;\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompilerBabelPlugin(): PluginItem | undefined {\n let plugins = loadAstPlugins(this.addonInstance.registry);\n let hasTemplateTag = this.addonInstance.addons.find((a: any) => a.name === 'ember-template-imports');\n // our macros don't run here in stage1\n plugins = plugins.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n if (plugins.length > 0 || hasTemplateTag) {\n let compilerPath = require.resolve('ember-source/dist/ember-template-compiler.js', {\n paths: [findTopmostAddon(this.addonInstance).parent.root],\n });\n let opts: EtcOptions = {\n compilerPath,\n targetFormat: 'hbs',\n enableLegacyModules: [\n 'ember-cli-htmlbars',\n 'ember-cli-htmlbars-inline-precompile',\n 'htmlbars-inline-precompile',\n ],\n transforms: plugins,\n };\n return [require.resolve('babel-plugin-ember-template-compilation'), opts];\n }\n }\n\n private updateRegistry(registry: any) {\n // auto-import gets disabled because we support it natively\n registry.remove('js', 'ember-auto-import-analyzer');\n\n // here we're replacing the stock template compiler with our own. Ours\n // doesn't compile all the way to wire format -- it does source-to-source\n // transformation just to process custom AST transforms, while leaving the\n // template as a template. It does turn HBS files into equivalent JS files\n // (because in the general case, AST transforms may need to emit values in\n // Javascript scope), but those JS files will contain HBS strings, not wire\n // format.\n //\n // Even when no AST transforms are registered, we'll still need to register\n // a no-op transform here to avoid an exception coming out of ember-cli like\n // \"Addon templates were detected, but there are no template compilers\n // registered\".\n registry.remove('template', 'ember-cli-htmlbars');\n registry.add('template', {\n name: 'embroider-addon-templates',\n ext: 'hbs',\n _addon: this,\n toTree(this: { _addon: V1Addon }, tree: Node): Node {\n if (this._addon.templateCompilerBabelPlugin) {\n return new HbsToJSBroccoliPlugin(tree);\n } else {\n // when there are no custom AST transforms, we don't need to do\n // anything at all.\n return tree;\n }\n },\n });\n\n // first, look into the babel config and related packages to decide whether\n // we need to run babel at all in this stage.\n let needsCustomBabel = this.needsCustomBabel();\n\n // regardless of the answer, we modify the babel config, because even if\n // we're unregistering ember-cli-babel, some addons manually invoke\n // ember-cli-babel in their custom hooks, and in that case we want to be\n // sure we've taken out the babel plugins that really shouldn't run at this\n // stage.\n this.updateBabelConfig();\n\n if (!needsCustomBabel) {\n // no custom babel behavior, so we don't run the ember-cli-babel\n // preprocessor at all. We still need to register a no-op preprocessor to\n // prevent ember-cli from emitting a deprecation warning.\n registry.remove('js', 'ember-cli-babel');\n registry.add('js', {\n name: 'embroider-babel-noop',\n ext: 'js',\n toTree(tree: Node) {\n return tree;\n },\n });\n }\n }\n\n // we need to run custom inline hbs preprocessing if there are custom hbs\n // plugins and there are inline hbs templates\n private needsInlineHBS(): boolean {\n if (!this.templateCompilerBabelPlugin) {\n // no custom transforms\n return false;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-htmlbars-inline-precompile')) {\n // the older inline template compiler is present\n return true;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-template-imports')) {\n /**\n * Stage1 will always run custom broccoli preprocessors. So that's enough to convert:\n *\n * import Thing from './thing';\n * <template><Thing/></template>\n * to\n *\n * import Thing from './thing';\n * import { template } from '@ember/template-compiler';\n * export default template(\"Thing\", {\n * eval: function() { return eval(arguments[0]) } })\n * });\n * This is really all we need to do at stage1, since this is now valid Javascript that could appear in a v2 addon.\n *\n * But if the addon is also using TS, we also need to run the typescript transform before it will be valid JS. And if the typescript transform was being truly correct it would not try to delete the import because the eval can see the imported binding. That's why we have an eval. It's a standards-compliant want of gaining access to everything in scope.\n *\n * Normally we only use babel-plugin-ember-template-compilation in stage1 to run custom AST transforms. Since there are none in the addon, we don't add it. The fix here is helping because there is a new reason to add it. It will further convert the above example to:\n *\n * import Thing from './thing';\n * import { template } from '@ember/template-compiler';\n * export default template(\"Thing\", {\n * scope: () => ({ Thing })\n * });\n * which typescript then respects.\n */\n return true;\n }\n\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-htmlbars' && semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>4.0.0')\n )\n ) {\n // a version of ember-cli-htmlbars that natively supports inline hbs is present\n return true;\n }\n\n return false;\n }\n\n private needsCustomBabel() {\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-typescript' &&\n semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>=4.0.0-alpha.1')\n )\n ) {\n // This addon is using ember-cli-typescript 4, which relies on\n // ember-cli-babel to add the TypeScript transform Babel plugin.\n return true;\n }\n\n if (\n this.addonInstance.options &&\n this.addonInstance.options['ember-cli-babel'] &&\n this.addonInstance.options['ember-cli-babel'].enableTypeScriptTransform\n ) {\n // This addon has explicitly configured ember-cli-babel to add the\n // TypeScript transform Babel plugin.\n return true;\n }\n\n if ((this.options.babel?.plugins?.filter(babelPluginAllowedInStage1)?.length ?? 0) > 0) {\n // this addon has custom babel plugins, so we need to run them here in\n // stage1\n return true;\n }\n\n // even if there are no custom babel plugins, if we need to do any\n // preprocessing of inline handlebars templates we still need to run the\n // custom babel.\n return this.needsInlineHBS();\n }\n\n get name(): string {\n return this.packageJSON.name;\n }\n\n // you can override this to change the *input* packageJSON that the rest of\n // stage1 will see. If you want to see and change the *output* packageJSON see\n // `newPackageJSON`.\n protected get packageJSON() {\n return this.packageCache.get(this.root).packageJSON;\n }\n\n protected get newPackageJSON() {\n // shallow copy only! This is OK as long as we're only changing top-level\n // keys in this method\n let pkg = Object.assign({}, this.packageJSON);\n let meta: AddonMeta = Object.assign({}, this.packageCache.get(this.root).meta, this.packageMeta);\n pkg['ember-addon'] = meta;\n\n // classic addons don't get to customize their entrypoints like this. We\n // always rewrite them so their entrypoint is index.js, so whatever was here\n // is just misleading to stage3 packagers that might look (rollup does).\n delete pkg.main;\n delete pkg.module;\n delete pkg.exports;\n\n return pkg;\n }\n\n @Memoize()\n get root(): string {\n // addonInstance.root gets modified by a customized \"main\" or\n // \"ember-addon.main\" in package.json. We want the real package root here\n // (the place where package.json lives).\n return dirname(pkgUpSync({ cwd: this.addonInstance.root })!);\n }\n\n @Memoize()\n private get mainModule() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require((this.addonInstance as unknown as any).constructor._meta_.modulePath);\n\n if (typeof mod === 'function') {\n return mod.prototype;\n } else {\n return mod;\n }\n }\n\n protected get options() {\n if (!this.addonInstance.options) {\n this.addonInstance.options = {};\n return this.addonInstance.options;\n }\n // some addons (like ember-cli-inline-content) assign the *app's* options\n // onto their own this.options. Which means they (accidentally or on\n // purpose), always get the app's babel config, and it means when we try\n // to modify the addon's babel config we're accidentally modifying the\n // app's too.\n //\n // So here we do copying to ensure that we can modify the babel config\n // without altering anybody else. We're not doing cloneDeep because that\n // pulls on our lazy MacrosConfig if it appears in any babel configs here,\n // whereas we want to leave it unevaluated until babel actually uses it.\n let addonOptions =\n typeof this.addonInstance.options == 'function' ? this.addonInstance.options() : this.addonInstance.options;\n let options = Object.assign({}, addonOptions);\n if (options.babel) {\n options.babel = Object.assign({}, options.babel);\n if (options.babel.plugins) {\n options.babel.plugins = options.babel.plugins.slice();\n }\n }\n if (options['ember-cli-babel']) {\n options['ember-cli-babel'] = Object.assign({}, options['ember-cli-babel']);\n }\n\n if (typeof this.addonInstance.options == 'function') {\n this.addonInstance.options = () => options;\n } else {\n this.addonInstance.options = options;\n }\n\n return options;\n }\n\n protected customizes(...treeNames: string[]) {\n // get the real addon as we're going to compare with __proto__\n const realAddon = getRealAddon(this.addonInstance);\n return Boolean(\n treeNames.find(treeName => {\n return (\n // customized hook exists in actual code exported from their index.js\n this.mainModule[treeName] ||\n // addon instance doesn't match its own prototype\n (realAddon.__proto__ && realAddon[treeName] !== realAddon.__proto__[treeName]) ||\n this.customizesHookName(treeName)\n );\n })\n );\n }\n\n private customizesHookName(treeName: string): boolean {\n if (!this.addonInstance.treeForMethods) {\n // weird old addons don't even extend ember-cli's Addon base class and\n // might not have this.\n return false;\n }\n for (let [name, methodName] of Object.entries(defaultMethods)) {\n if (methodName === treeName) {\n return this.addonInstance.treeForMethods[name] !== methodName;\n }\n }\n return false;\n }\n\n @Memoize()\n private hasStockTree(treeName: AddonTreePath): boolean {\n if (this.suppressesTree(treeName)) {\n return false;\n }\n\n // we need to use this.addonInstance.root instead of this.root here because\n // we're looking for the classic location of the stock tree, and that\n // location is influenced by a customized ember-addon.main in package.json,\n // which is reflected in addonInstance.root.\n return (\n this.addonInstance.treePaths && existsSync(join(this.addonInstance.root, this.addonInstance.treePaths[treeName]))\n );\n }\n\n hasAnyTrees(): boolean {\n return Boolean(stockTreeNames.find(name => this.hasStockTree(name))) || this.customizes(...dynamicTreeHooks);\n }\n\n // we keep all these here to ensure that we always apply the same options to\n // the same tree, so that our cache doesn't need to worry about varying\n // options.\n private stockTreeFunnelOptions(treeName: string): FunnelOptions | undefined {\n switch (treeName) {\n case 'addon':\n return {\n exclude: ['styles/**'],\n };\n case 'styles':\n return {\n destDir: '_app_styles_',\n };\n case 'addon-test-support':\n return {\n destDir: 'test-support',\n };\n case 'app':\n return {\n exclude: ['styles/**'],\n destDir: appPublicationDir,\n };\n case 'public':\n return {\n destDir: `public/${this.moduleName}`,\n };\n case 'vendor':\n return {\n destDir: 'vendor',\n };\n }\n }\n\n protected stockTree(treeName: AddonTreePath): Node {\n return this.throughTreeCache(treeName, 'stock', () => {\n // adjust from the legacy \"root\" to our real root, because our rootTree\n // uses our real root but the stock trees are defined in terms of the\n // legacy root\n let srcDir = relative(this.root, join(this.addonInstance.root, this.addonInstance.treePaths[treeName]));\n let opts = Object.assign({ srcDir }, this.stockTreeFunnelOptions(treeName));\n return buildFunnel(this.rootTree, opts);\n })!;\n }\n\n @Memoize()\n protected get rootTree(): Node {\n if (this.packageCache.get(this.root).mayRebuild) {\n return new WatchedDir(this.root);\n } else {\n return new UnwatchedDir(this.root);\n }\n }\n\n @Memoize()\n private get moduleName(): string {\n if (typeof this.addonInstance.moduleName === 'function') {\n return this.addonInstance.moduleName();\n }\n return this.addonInstance.name;\n }\n\n // applies preprocessors to JS and HBS\n private transpile(tree: Node) {\n // Namespace the tree being passed to preprocessJs with the moduleName\n // to mimic classic build\n tree = buildFunnel(tree, { destDir: this.moduleName });\n\n if (this.addonInstance.shouldCompileTemplates() && this.addonInstance.registry.load('template')?.length > 0) {\n tree = this.app.preprocessRegistry.preprocessTemplates(tree, {\n registry: this.addonInstance.registry,\n });\n }\n\n tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\n });\n\n // Remove namespacing so that it gets written out to the node_modules\n // directory correctly.\n tree = buildFunnel(tree, {\n srcDir: this.moduleName,\n });\n\n return tree;\n }\n\n @Memoize()\n protected updateBabelConfig() {\n let packageOptions = this.options;\n let emberCLIBabelInstance = this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-babel');\n let version;\n\n if (emberCLIBabelInstance) {\n version = emberCLIBabelInstance.pkg.version;\n }\n\n if (!packageOptions['ember-cli-babel']) {\n packageOptions['ember-cli-babel'] = {};\n }\n\n if (!packageOptions.babel) {\n packageOptions.babel = {};\n }\n let babelConfig = packageOptions.babel as TransformOptions;\n\n Object.assign(packageOptions['ember-cli-babel'], {\n compileModules: false,\n disablePresetEnv: true,\n disableDebugTooling: true,\n disableEmberModulesAPIPolyfill: true,\n });\n\n if (version && semver.satisfies(semver.coerce(version) || version, '^5')) {\n unsupported(`${this.name} is using babel 5. Not installing our custom plugin.`);\n return;\n }\n\n if (!babelConfig.plugins) {\n babelConfig.plugins = [];\n } else {\n let hadAutoImport = Boolean(babelConfig.plugins.find(isEmberAutoImportDynamic));\n babelConfig.plugins = babelConfig.plugins.filter(babelPluginAllowedInStage1);\n if (hadAutoImport) {\n // if we removed ember-auto-import's dynamic import() plugin, the code\n // may use import() syntax and we need to re-add it to the parser.\n if (version && semver.satisfies(semver.coerce(version) || version, '^6')) {\n babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import'));\n } else {\n babelConfig.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));\n }\n }\n }\n\n if (this.templateCompilerBabelPlugin) {\n babelConfig.plugins.push(this.templateCompilerBabelPlugin);\n }\n }\n\n get v2Tree(): Node {\n return this.throughTreeCache(\n // these are all the kinds of trees that ember-cli's tree cache\n // understands. We need them all here because if *any* of these are\n // uncacheable, we want our whole v2 tree to be treated as uncacheable.\n [\n 'app',\n 'addon',\n 'addon-styles',\n 'addon-templates',\n 'addon-test-support',\n 'public',\n 'styles',\n 'templates',\n 'test-support',\n 'vendor',\n ],\n 'v2Tree',\n () => mergeTrees(this.v2Trees, { overwrite: true })\n );\n }\n\n // this is split out so that compatibility shims can override it to add more\n // things to the package metadata.\n protected get packageMeta(): Partial<AddonMeta> {\n let built = this.build();\n return mergeWithAppend(\n {\n version: 2,\n 'auto-upgraded': true,\n type: 'addon',\n },\n built.staticMeta,\n ...built.dynamicMeta.map(d => d())\n );\n }\n\n @Memoize()\n protected get v2Trees() {\n let { trees } = this.build();\n return trees;\n }\n\n protected throughTreeCache(nameOrNames: string | string[], category: string, fn: () => Node): Node;\n protected throughTreeCache(\n nameOrNames: string | string[],\n category: string,\n fn: () => Node | undefined\n ): Node | undefined {\n let cacheKey: string | undefined;\n if (typeof this.addonInstance.cacheKeyForTree === 'function') {\n let names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames];\n cacheKey = names.reduce((accum: string | undefined, name) => {\n if (accum == null) {\n // a previous name was uncacheable, so we're entirely uncacheable\n return undefined;\n }\n let key = this.addonInstance.cacheKeyForTree?.(name);\n if (key) {\n return accum + key;\n } else {\n return undefined;\n }\n }, '');\n if (cacheKey) {\n cacheKey = cacheKey + category;\n let cachedTree = this.app.addonTreeCache.get(cacheKey);\n if (cachedTree) {\n debug('cache hit %s %s %s', this.name, nameOrNames, category);\n return cachedTree;\n }\n }\n }\n debug('cache miss %s %s %s', this.name, nameOrNames, category);\n let tree = fn();\n if (tree && cacheKey) {\n this.app.addonTreeCache.set(cacheKey, tree);\n }\n return tree;\n }\n\n // In general, we can't reliably run addons' custom `treeFor()` methods,\n // because they recurse in a way that we absolutely don't want.\n //\n // But there is a very common use case that we *can* handle opportunisticaly,\n // which is a treeFor() that's used purely to guard whether `_super` will be\n // called or not.\n protected suppressesTree(name: string): boolean {\n if (!this.customizes('treeFor')) {\n return false;\n }\n // get the real addon as we're going to patch and restore `_super`\n const realAddon = getRealAddon(this.addonInstance);\n let origSuper = this.addonInstance._super;\n try {\n realAddon._super = stubbedSuper;\n let result = this.mainModule.treeFor?.call(this.addonInstance, name);\n if (result === markedEmptyTree) {\n // the method returns _super unchanged, so tree is not suppressed and we\n // understand what's going on\n return false;\n }\n if (result == null) {\n // the method nulled out the tree, so we are definitely suppressing\n return true;\n }\n // we can't tell what's really going on, don't suppress and hope for the\n // best\n unsupported(`${this.name} has a custom treeFor() method that is doing some arbitrary broccoli processing.`);\n return false;\n } finally {\n if (realAddon._super === stubbedSuper) {\n realAddon._super = origSuper;\n }\n }\n }\n\n protected invokeOriginalTreeFor(\n name: string,\n { neuterPreprocessors } = { neuterPreprocessors: false }\n ): Node | undefined {\n // @ts-expect-error have no idea why throughTreeCache overload is not working here..\n return this.throughTreeCache(name, 'original', () => {\n // get the real addon as we're going to patch and restore `preprocessJs`\n const realAddon = getRealAddon(this.addonInstance);\n let original;\n try {\n if (neuterPreprocessors) {\n original = realAddon.preprocessJs;\n realAddon.preprocessJs = function (tree: Node) {\n return tree;\n };\n }\n if (this.suppressesTree(name)) {\n return undefined;\n }\n return this.addonInstance._treeFor(name);\n } finally {\n if (neuterPreprocessors) {\n realAddon.preprocessJs = original;\n }\n }\n });\n }\n\n protected treeForAddon(built: IntermediateBuild): Node | undefined {\n // the extra isEngine condition is because ember-engines injects a\n // treeForAddon method into each engine addon that we really don't need or\n // want to run. Unfortunately there's not a more localized place to patch it\n // out, partly because ember-engines also uses a bogus inheritance strategy\n // (instead of providing a prototype that engine addons can extend it\n // patches things into their instance directly).\n if (this.customizes('treeForAddon', 'treeForAddonTemplates') && !this.isEngine()) {\n let tree = this.invokeOriginalTreeFor('addon', { neuterPreprocessors: true });\n if (tree) {\n tree = modulesCompat(tree);\n\n // this captures addons that are trying to escape their own package's\n // namespace\n let result = rewriteAddonTree(this.transpile(tree), this.name, this.moduleName);\n built.dynamicMeta.push(result.getMeta);\n return result.tree;\n }\n } else if (this.hasStockTree('addon')) {\n return this.transpile(this.stockTree('addon'));\n }\n }\n\n protected addonStylesTree(): Node | undefined {\n if (this.customizes('treeForAddonStyles')) {\n let custom = this.invokeOriginalTreeFor('addon-styles');\n if (custom) {\n return this.addonInstance.compileStyles(custom);\n }\n } else if (this.hasStockTree('addon-styles')) {\n return this.addonInstance.compileStyles(this.stockTree('addon-styles'));\n }\n }\n\n protected treeForTestSupport(): Node | undefined {\n if (this.customizes('treeForTestSupport')) {\n todo(`${this.name} has customized the test support tree`);\n } else if (this.hasStockTree('test-support')) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app. For example, imports should be relative to\n // the consuming app, not our own package.\n return buildFunnel(this.stockTree('test-support'), {\n destDir: `${appPublicationDir}/tests`,\n });\n }\n }\n\n private buildTreeForAddon(built: IntermediateBuild) {\n let tree = this.treeForAddon(built);\n if (!tree) {\n return;\n }\n let templateOnlyComponents: Node = new SynthesizeTemplateOnlyComponents(tree, {\n allowedPaths: ['components'],\n\n // if an addon has custom AST transforms, stage1 can rewrite .hbs to\n // .hbs.js\n templateExtensions: ['.hbs', '.hbs.js'],\n });\n\n if (this.isEngine()) {\n // even when staticAddonTrees is enabled, engines may have a router map\n // that needs to be dynamically resolved.\n let hasRoutesModule = false;\n\n tree = new ObserveTree(tree, outputDir => {\n hasRoutesModule = existsSync(resolve(outputDir, 'routes.js'));\n });\n built.dynamicMeta.push(() => ({\n 'implicit-modules': hasRoutesModule ? ['./routes.js'] : [],\n }));\n }\n\n built.trees.push(tree);\n built.trees.push(templateOnlyComponents);\n }\n\n private buildAddonStyles(built: IntermediateBuild) {\n let addonStylesTree = this.addonStylesTree();\n if (addonStylesTree) {\n if (this.app.hasCompiledStyles) {\n // >= ember-cli@3.18 store css files in <addon-name/__COMPILED_STYLES__\n // and for embroider to work correctly need to be moved back to `/`\n //\n // speaking with @rwjblue the ember-cli build is now frozen, and it is\n // ok to assume that after the above version no changes will occur\n // makings this work-around safe.\n //\n // additional context: https://github.com/embroider-build/embroider/pull/934/files#r695269976\n addonStylesTree = buildFunnel(addonStylesTree, {\n srcDir: `${this.name}/__COMPILED_STYLES__`,\n destDir: '/',\n allowEmpty: true,\n });\n }\n\n let discoveredFiles: string[] = [];\n let tree = new ObserveTree(addonStylesTree, outputPath => {\n discoveredFiles = walkSync(outputPath, { globs: ['**/*.css'], directories: false });\n });\n built.trees.push(tree);\n built.dynamicMeta.push(() => {\n return {\n 'implicit-styles': discoveredFiles.map(f => `./${f}`),\n };\n });\n }\n }\n\n private buildTreeForStyles(built: IntermediateBuild) {\n let tree;\n if (this.customizes('treeForStyles')) {\n // the user's tree returns their own styles with no \"app/styles\" wrapping\n // around, which is actually what we want\n tree = this.invokeOriginalTreeFor('styles');\n if (tree) {\n tree = buildFunnel(tree, {\n destDir: '_app_styles_',\n getDestinationPath(path) {\n return path.replace(/^app\\/styles\\//, '');\n },\n });\n }\n } else if (this.hasStockTree('styles')) {\n tree = this.stockTree('styles');\n }\n if (tree) {\n built.trees.push(tree);\n }\n }\n\n private buildAddonTestSupport(built: IntermediateBuild) {\n let addonTestSupportTree;\n if (this.customizes('treeForAddonTestSupport')) {\n let original = this.invokeOriginalTreeFor('addon-test-support', { neuterPreprocessors: true });\n if (original) {\n let { tree, getMeta } = rewriteAddonTree(original, this.name, this.moduleName);\n addonTestSupportTree = this.transpile(tree);\n built.dynamicMeta.push(getMeta);\n }\n } else if (this.hasStockTree('addon-test-support')) {\n addonTestSupportTree = this.transpile(this.stockTree('addon-test-support'));\n }\n if (addonTestSupportTree) {\n built.trees.push(addonTestSupportTree);\n }\n }\n\n private maybeSetDirectoryMeta(built: IntermediateBuild, tree: Node, localDir: string, key: keyof AddonMeta): Node {\n let files: AddonMeta['app-js'];\n built.dynamicMeta.push(() => {\n if (files) {\n return { [key]: files };\n } else {\n return {};\n }\n });\n return new ObserveTree(tree, (outputPath: string) => {\n let dir = join(outputPath, localDir);\n if (existsSync(dir)) {\n files = fromPairs(walkSync(dir, { globs: ['**/*.js', '**/*.hbs'] }).map(f => [`./${f}`, `./${localDir}/${f}`]));\n } else {\n files = undefined;\n }\n });\n }\n\n private buildTestSupport(built: IntermediateBuild) {\n let tree = this.treeForTestSupport();\n if (tree) {\n tree = this.maybeSetDirectoryMeta(built, tree, appPublicationDir, 'app-js');\n built.trees.push(tree);\n }\n }\n\n private buildTreeForApp(built: IntermediateBuild) {\n let appTree;\n if (this.customizes('treeForApp', 'treeForTemplates')) {\n let original = this.invokeOriginalTreeFor('app');\n if (original) {\n appTree = buildFunnel(original, {\n destDir: appPublicationDir,\n });\n }\n } else if (this.hasStockTree('app')) {\n appTree = this.stockTree('app');\n }\n\n if (appTree) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app.\n appTree = this.maybeSetDirectoryMeta(built, appTree, appPublicationDir, 'app-js');\n built.trees.push(appTree);\n }\n\n if (\n typeof this.addonInstance.isDevelopingAddon === 'function' &&\n this.addonInstance.isDevelopingAddon() &&\n this.addonInstance.hintingEnabled()\n ) {\n let hintTree = this.addonInstance.jshintAddonTree();\n if (hintTree) {\n hintTree = this.maybeSetDirectoryMeta(\n built,\n buildFunnel(hintTree, { destDir: appPublicationDir }),\n appPublicationDir,\n 'app-js'\n );\n built.trees.push(hintTree);\n }\n }\n }\n\n private buildTreeForFastBoot(built: IntermediateBuild) {\n let tree;\n\n if (this.customizes('treeForFastBoot')) {\n // Arguably, it would be more correct to always create the new Funnel,\n // because the fastboot directory could be created *after* our build starts.\n // But that would result in hundreds of additional trees, even though the\n // vast majority of addons aren't changing and don't have fastboot\n // directories. So I'm pretty comfortable with the optimization. It means\n // that an addon author who creates a brand new fastboot directory in a v1\n // packages will need to restart their build. (Really we hope new addons\n // will be authored in v2 instead soon anyway, and they won't need the\n // concept of \"fastboot directory\" because they can use the macro system to\n // conditionally import some things only in fastboot.)\n if (pathExistsSync(join(this.root, 'fastboot'))) {\n tree = buildFunnel(this.rootTree, { srcDir: 'fastboot' });\n }\n tree = this.addonInstance.treeForFastBoot(tree);\n if (tree) {\n tree = buildFunnel(tree, { destDir: fastbootPublicationDir });\n }\n } else {\n if (pathExistsSync(join(this.root, 'fastboot'))) {\n tree = buildFunnel(this.rootTree, { srcDir: 'fastboot', destDir: fastbootPublicationDir });\n }\n }\n\n if (tree) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app.\n tree = this.maybeSetDirectoryMeta(built, tree, fastbootPublicationDir, 'fastboot-js');\n built.trees.push(tree);\n }\n }\n\n private buildPublicTree(built: IntermediateBuild) {\n let publicTree;\n // the extra isEngine condition is here because ember-engines injects a\n // customized treeForPublic into every engine addon. We don't want or need\n // it to run.\n if (this.customizes('treeForPublic') && !this.isEngine()) {\n let original = this.invokeOriginalTreeFor('public');\n if (original) {\n publicTree = buildFunnel(original, {\n destDir: 'public',\n });\n }\n } else if (this.hasStockTree('public')) {\n publicTree = this.stockTree('public');\n }\n if (publicTree) {\n let publicAssets: { [filename: string]: string } = {};\n publicTree = new ObserveTree(publicTree, (outputPath: string) => {\n publicAssets = {};\n for (let filename of walkSync(join(outputPath, 'public'))) {\n if (!filename.endsWith('/')) {\n publicAssets[`./public/${filename}`] = './' + filename;\n }\n }\n });\n built.trees.push(publicTree);\n built.dynamicMeta.push(() => ({ 'public-assets': publicAssets }));\n }\n }\n\n private buildVendorTree(built: IntermediateBuild) {\n if (this.customizes('treeForVendor')) {\n // We don't have any particular opinions about the structure inside\n // vendor, so even when it's customized we can just use the customized\n // one.\n let tree = this.invokeOriginalTreeFor('vendor');\n if (tree) {\n built.trees.push(\n buildFunnel(tree, {\n destDir: 'vendor',\n })\n );\n }\n } else if (this.hasStockTree('vendor')) {\n built.trees.push(this.stockTree('vendor'));\n }\n }\n\n private isEngine() {\n return typeof this.addonInstance.getEngineConfigContents === 'function';\n }\n\n private buildEngineConfig(built: IntermediateBuild) {\n if (!this.isEngine()) {\n return;\n }\n // this addon is an engine, so it needs its own config/environment.js.\n // ember-engines always emits a separate inline (not-meta-tag) config for\n // fastboot, so we mimic that behavior here.\n //\n // getEngineConfigContents is an arbitrary customizable module, so we can't\n // easily rewrite it to live inside our conditional, so it's safer in a\n // separate module.\n built.trees.push(writeFile('config/_environment_browser_.js', this.addonInstance.getEngineConfigContents?.()));\n built.trees.push(\n writeFile(\n 'config/environment.js',\n `\n import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\n let config;\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n config = ${JSON.stringify(this.addonInstance.engineConfig?.(this.app.env, {}), null, 2)};\n } else {\n config = importSync('./_environment_browser_.js').default;\n }\n export default config;\n `\n )\n );\n }\n\n private buildPackageJSON(built: IntermediateBuild) {\n built.trees.push(new RewritePackageJSON(this.rootTree, () => this.newPackageJSON));\n }\n\n @Memoize()\n private build(): IntermediateBuild {\n let built = new IntermediateBuild();\n built.staticMeta['order-index'] = this.orderIdx;\n\n if (this.options.lazyLoading === true || (this.options.lazyLoading && this.options.lazyLoading.enabled)) {\n built.staticMeta['lazy-engine'] = true;\n }\n\n if (this.moduleName !== this.name) {\n built.staticMeta['renamed-packages'] = {\n [this.moduleName]: this.name,\n };\n }\n\n this.buildTreeForAddon(built);\n this.buildAddonStyles(built);\n this.buildTreeForStyles(built);\n this.buildAddonTestSupport(built);\n this.buildTestSupport(built);\n this.buildTreeForApp(built);\n this.buildTreeForFastBoot(built);\n this.buildPublicTree(built);\n this.buildVendorTree(built);\n this.buildEngineConfig(built);\n this.buildPackageJSON(built);\n return built;\n }\n}\n\nexport interface V1AddonConstructor {\n new (\n addonInstance: any,\n options: CompatOptionsType,\n app: CompatApp,\n packageCache: PackageCache,\n orderIdx: number\n ): V1Addon;\n\n shouldApplyAdapter?(addonInstance: any): boolean;\n}\n\nclass IntermediateBuild {\n trees: Node[] = [];\n staticMeta: { [metaField: string]: any } = {};\n dynamicMeta: (() => Partial<AddonMeta>)[] = [];\n}\n\nfunction babelPluginAllowedInStage1(plugin: PluginItem) {\n if (isEmbroiderMacrosPlugin(plugin)) {\n // the point of @embroider/macros is that it's allowed to stay in v2\n // addon publication format, so it doesn't need to run here in stage1.\n // We always run it in stage3.\n return false;\n }\n\n if (isInlinePrecompilePlugin(plugin)) {\n // Similarly, the inline precompile plugin must not run in stage1. We\n // want all templates uncompiled. Instead, we will be adding our own\n // plugin that only runs custom AST transforms inside inline\n // templates.\n return false;\n }\n\n if (isEmberAutoImportDynamic(plugin)) {\n // We replace ember-auto-import's implementation of dynamic import(), so we\n // need to stop its plugin from rewriting those.\n return false;\n }\n\n if (isCompactReexports(plugin)) {\n // We don't want to replace re-exports at this stage, since that will turn\n // an `export` statement into a `define`, which is handled in Stage 3\n return false;\n }\n\n if (isColocationPlugin(plugin)) {\n // template co-location is a first-class feature we support directly, so\n // whether or not the app brought a plugin for it we're going to do it our\n // way.\n return false;\n }\n\n return true;\n}\n\nconst markedEmptyTree = new UnwatchedDir(process.cwd());\n\nconst stubbedSuper = () => {\n return markedEmptyTree;\n};\n\nstubbedSuper.treeFor = () => {\n return markedEmptyTree;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"v1-addon.js","sourceRoot":"","sources":["../../src/v1-addon.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAA6C;AAC7C,+BAAwD;AACxD,mCAA2C;AAC3C,uCAAsD;AAEtD,sEAA0C;AAC1C,qDAA2D;AAC3D,kFAAwD;AACxD,2DAAiE;AAEjE,gFAA8C;AAC9C,oDAA4B;AAC5B,8EAAoD;AACpD,qCAA2C;AAE3C,0CAA0D;AAC1D,0DAAiC;AACjC,kEAAyC;AACzC,qDAAqE;AAErE,sEAA6C;AAC7C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I,IAAA,+CAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACrC,qEAAqE;QACrE,oEAAoE;QACpE,4DAA4D;QAC5D,aAAa;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,+CAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACrC,2EAA2E;QAC3E,gDAAgD;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,yCAAkB,EAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,0EAA0E;QAC1E,qEAAqE;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,yCAAkB,EAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,eAAe,GAAG,IAAI,8BAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAExD,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,YAAY,CAAC,OAAO,GAAG,GAAG,EAAE;IAC1B,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport { dirname, join, relative, resolve } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { existsSync, pathExistsSync } from 'fs-extra';\nimport type { Options as FunnelOptions } from 'broccoli-funnel';\nimport buildFunnel from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport RewritePackageJSON from './rewrite-package-json';\nimport { todo, unsupported } from '@embroider/core/src/messages';\nimport type { Node } from 'broccoli-node-api';\nimport mergeTrees from 'broccoli-merge-trees';\nimport semver from 'semver';\nimport rewriteAddonTree from './rewrite-addon-tree';\nimport { mergeWithAppend } from './merges';\nimport type { AddonMeta, PackageCache, AddonInstance, AddonTreePath } from '@embroider/core';\nimport { debug, findTopmostAddon } from '@embroider/core';\nimport walkSync from 'walk-sync';\nimport ObserveTree from './observe-tree';\nimport { isEmbroiderMacrosPlugin } from '@embroider/macros/src/node';\nimport type { TransformOptions, PluginItem } from '@babel/core';\nimport modulesCompat from './modules-compat';\nimport writeFile from 'broccoli-file-creator';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport {\n isEmberAutoImportDynamic,\n isCompactReexports,\n isColocationPlugin,\n isInlinePrecompilePlugin,\n} from './detect-babel-plugins';\nimport HbsToJSBroccoliPlugin from './hbs-to-js-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport loadAstPlugins from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\nimport type { Options as EtcOptions } from 'babel-plugin-ember-template-compilation';\nimport type CompatApp from './compat-app';\nimport type { CompatOptionsType } from './options';\n\nconst stockTreeNames: AddonTreePath[] = Object.freeze([\n 'addon',\n 'addon-styles',\n 'styles',\n 'addon-test-support',\n 'test-support',\n 'app',\n 'public',\n 'vendor',\n // 'addon-templates' and 'templates are trees too, but they live inside\n // 'addon' and 'app' and we handle them there.\n]) as AddonTreePath[];\n\nconst dynamicTreeHooks = Object.freeze([\n 'treeFor',\n 'treeForAddon',\n 'treeForAddonTemplates',\n 'treeForAddonTestSupport',\n 'treeForApp',\n 'treeForPublic',\n 'treeForStyles',\n 'treeForTemplates',\n 'treeForTestSupport',\n 'treeForVendor',\n]);\n\nconst defaultMethods = {\n app: 'treeForApp',\n addon: 'treeForAddon',\n 'addon-styles': 'treeForAddonStyles',\n 'addon-templates': 'treeForAddonTemplates',\n 'addon-test-support': 'treeForAddonTestSupport',\n public: 'treeForPublic',\n styles: 'treeForStyles',\n templates: 'treeForTemplates',\n 'test-support': 'treeForTestSupport',\n vendor: 'treeForVendor',\n};\n\nconst appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n// This controls and types the interface between our new world and the classic\n// v1 addon instance.\nexport default class V1Addon {\n constructor(\n protected addonInstance: AddonInstance,\n protected addonOptions: CompatOptionsType,\n protected app: CompatApp,\n private packageCache: PackageCache,\n private orderIdx: number\n ) {\n if (addonInstance.registry) {\n this.updateRegistry(addonInstance.registry);\n }\n }\n\n // Optional extensible hook for pruning down the list of redundant addon\n // instances produced by the classic ember-cli architecture. ember-cli\n // instantiates each addon *per consumer*, not per package. So a given package\n // will have many addon instances, and Embroider dutifully produces a V1Addon\n // instance for each one, and then needs to mimic the classic smooshing\n // behavior between them.\n //\n // But some packages (and ember-cli-babel is the motivating example) produce a\n // huge number of instances that do nothing useful and incur significant cost.\n // This hook allows their compat adapter to prune down the set, using\n // addon-specific knowledge of which instance(s) are actually important.\n //\n // The order of the instances is significant. The first one is the one with\n // the highest precedence, meaning its files would win under classic\n // smooshing.\n reduceInstances(instances: V1Addon[]): V1Addon[] {\n // the default beahvior is that all copies matter\n return instances;\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompilerBabelPlugin(): PluginItem | undefined {\n let plugins = loadAstPlugins(this.addonInstance.registry);\n let hasTemplateTag = this.addonInstance.addons.find((a: any) => a.name === 'ember-template-imports');\n // our macros don't run here in stage1\n plugins = plugins.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n if (plugins.length > 0 || hasTemplateTag) {\n let compilerPath = require.resolve('ember-source/dist/ember-template-compiler.js', {\n paths: [findTopmostAddon(this.addonInstance).parent.root],\n });\n let opts: EtcOptions = {\n compilerPath,\n targetFormat: 'hbs',\n enableLegacyModules: [\n 'ember-cli-htmlbars',\n 'ember-cli-htmlbars-inline-precompile',\n 'htmlbars-inline-precompile',\n ],\n transforms: plugins,\n };\n\n let babelVersion = this.addonInstance.addons.find(a => a.name === 'ember-cli-babel')?.pkg.version;\n if (babelVersion && semver.satisfies(babelVersion, '< 8.0.0')) {\n return [require.resolve('babel-plugin-ember-template-compilation-2'), opts];\n } else {\n return [require.resolve('babel-plugin-ember-template-compilation'), opts];\n }\n }\n }\n\n private updateRegistry(registry: any) {\n // auto-import gets disabled because we support it natively\n registry.remove('js', 'ember-auto-import-analyzer');\n\n // here we're replacing the stock template compiler with our own. Ours\n // doesn't compile all the way to wire format -- it does source-to-source\n // transformation just to process custom AST transforms, while leaving the\n // template as a template. It does turn HBS files into equivalent JS files\n // (because in the general case, AST transforms may need to emit values in\n // Javascript scope), but those JS files will contain HBS strings, not wire\n // format.\n //\n // Even when no AST transforms are registered, we'll still need to register\n // a no-op transform here to avoid an exception coming out of ember-cli like\n // \"Addon templates were detected, but there are no template compilers\n // registered\".\n registry.remove('template', 'ember-cli-htmlbars');\n registry.add('template', {\n name: 'embroider-addon-templates',\n ext: 'hbs',\n _addon: this,\n toTree(this: { _addon: V1Addon }, tree: Node): Node {\n if (this._addon.templateCompilerBabelPlugin) {\n return new HbsToJSBroccoliPlugin(tree);\n } else {\n // when there are no custom AST transforms, we don't need to do\n // anything at all.\n return tree;\n }\n },\n });\n\n // first, look into the babel config and related packages to decide whether\n // we need to run babel at all in this stage.\n let needsCustomBabel = this.needsCustomBabel();\n\n // regardless of the answer, we modify the babel config, because even if\n // we're unregistering ember-cli-babel, some addons manually invoke\n // ember-cli-babel in their custom hooks, and in that case we want to be\n // sure we've taken out the babel plugins that really shouldn't run at this\n // stage.\n this.updateBabelConfig();\n\n if (!needsCustomBabel) {\n // no custom babel behavior, so we don't run the ember-cli-babel\n // preprocessor at all. We still need to register a no-op preprocessor to\n // prevent ember-cli from emitting a deprecation warning.\n registry.remove('js', 'ember-cli-babel');\n registry.add('js', {\n name: 'embroider-babel-noop',\n ext: 'js',\n toTree(tree: Node) {\n return tree;\n },\n });\n }\n }\n\n // we need to run custom inline hbs preprocessing if there are custom hbs\n // plugins and there are inline hbs templates\n private needsInlineHBS(): boolean {\n if (!this.templateCompilerBabelPlugin) {\n // no custom transforms\n return false;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-htmlbars-inline-precompile')) {\n // the older inline template compiler is present\n return true;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-template-imports')) {\n /**\n * Stage1 will always run custom broccoli preprocessors. So that's enough to convert:\n *\n * import Thing from './thing';\n * <template><Thing/></template>\n * to\n *\n * import Thing from './thing';\n * import { template } from '@ember/template-compiler';\n * export default template(\"Thing\", {\n * eval: function() { return eval(arguments[0]) } })\n * });\n * This is really all we need to do at stage1, since this is now valid Javascript that could appear in a v2 addon.\n *\n * But if the addon is also using TS, we also need to run the typescript transform before it will be valid JS. And if the typescript transform was being truly correct it would not try to delete the import because the eval can see the imported binding. That's why we have an eval. It's a standards-compliant want of gaining access to everything in scope.\n *\n * Normally we only use babel-plugin-ember-template-compilation in stage1 to run custom AST transforms. Since there are none in the addon, we don't add it. The fix here is helping because there is a new reason to add it. It will further convert the above example to:\n *\n * import Thing from './thing';\n * import { template } from '@ember/template-compiler';\n * export default template(\"Thing\", {\n * scope: () => ({ Thing })\n * });\n * which typescript then respects.\n */\n return true;\n }\n\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-htmlbars' && semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>4.0.0')\n )\n ) {\n // a version of ember-cli-htmlbars that natively supports inline hbs is present\n return true;\n }\n\n return false;\n }\n\n private needsCustomBabel() {\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-typescript' &&\n semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>=4.0.0-alpha.1')\n )\n ) {\n // This addon is using ember-cli-typescript 4, which relies on\n // ember-cli-babel to add the TypeScript transform Babel plugin.\n return true;\n }\n\n if (\n this.addonInstance.options &&\n this.addonInstance.options['ember-cli-babel'] &&\n this.addonInstance.options['ember-cli-babel'].enableTypeScriptTransform\n ) {\n // This addon has explicitly configured ember-cli-babel to add the\n // TypeScript transform Babel plugin.\n return true;\n }\n\n if ((this.options.babel?.plugins?.filter(babelPluginAllowedInStage1)?.length ?? 0) > 0) {\n // this addon has custom babel plugins, so we need to run them here in\n // stage1\n return true;\n }\n\n // even if there are no custom babel plugins, if we need to do any\n // preprocessing of inline handlebars templates we still need to run the\n // custom babel.\n return this.needsInlineHBS();\n }\n\n get name(): string {\n return this.packageJSON.name;\n }\n\n // you can override this to change the *input* packageJSON that the rest of\n // stage1 will see. If you want to see and change the *output* packageJSON see\n // `newPackageJSON`.\n protected get packageJSON() {\n return this.packageCache.get(this.root).packageJSON;\n }\n\n protected get newPackageJSON() {\n // shallow copy only! This is OK as long as we're only changing top-level\n // keys in this method\n let pkg = Object.assign({}, this.packageJSON);\n let meta: AddonMeta = Object.assign({}, this.packageCache.get(this.root).meta, this.packageMeta);\n pkg['ember-addon'] = meta;\n\n // classic addons don't get to customize their entrypoints like this. We\n // always rewrite them so their entrypoint is index.js, so whatever was here\n // is just misleading to stage3 packagers that might look (rollup does).\n delete pkg.main;\n delete pkg.module;\n delete pkg.exports;\n\n return pkg;\n }\n\n @Memoize()\n get root(): string {\n // addonInstance.root gets modified by a customized \"main\" or\n // \"ember-addon.main\" in package.json. We want the real package root here\n // (the place where package.json lives).\n return dirname(pkgUpSync({ cwd: this.addonInstance.root })!);\n }\n\n @Memoize()\n private get mainModule() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require((this.addonInstance as unknown as any).constructor._meta_.modulePath);\n\n if (typeof mod === 'function') {\n return mod.prototype;\n } else {\n return mod;\n }\n }\n\n protected get options() {\n if (!this.addonInstance.options) {\n this.addonInstance.options = {};\n return this.addonInstance.options;\n }\n // some addons (like ember-cli-inline-content) assign the *app's* options\n // onto their own this.options. Which means they (accidentally or on\n // purpose), always get the app's babel config, and it means when we try\n // to modify the addon's babel config we're accidentally modifying the\n // app's too.\n //\n // So here we do copying to ensure that we can modify the babel config\n // without altering anybody else. We're not doing cloneDeep because that\n // pulls on our lazy MacrosConfig if it appears in any babel configs here,\n // whereas we want to leave it unevaluated until babel actually uses it.\n let addonOptions =\n typeof this.addonInstance.options == 'function' ? this.addonInstance.options() : this.addonInstance.options;\n let options = Object.assign({}, addonOptions);\n if (options.babel) {\n options.babel = Object.assign({}, options.babel);\n if (options.babel.plugins) {\n options.babel.plugins = options.babel.plugins.slice();\n }\n }\n if (options['ember-cli-babel']) {\n options['ember-cli-babel'] = Object.assign({}, options['ember-cli-babel']);\n }\n\n if (typeof this.addonInstance.options == 'function') {\n this.addonInstance.options = () => options;\n } else {\n this.addonInstance.options = options;\n }\n\n return options;\n }\n\n protected customizes(...treeNames: string[]) {\n // get the real addon as we're going to compare with __proto__\n const realAddon = getRealAddon(this.addonInstance);\n return Boolean(\n treeNames.find(treeName => {\n return (\n // customized hook exists in actual code exported from their index.js\n this.mainModule[treeName] ||\n // addon instance doesn't match its own prototype\n (realAddon.__proto__ && realAddon[treeName] !== realAddon.__proto__[treeName]) ||\n this.customizesHookName(treeName)\n );\n })\n );\n }\n\n private customizesHookName(treeName: string): boolean {\n if (!this.addonInstance.treeForMethods) {\n // weird old addons don't even extend ember-cli's Addon base class and\n // might not have this.\n return false;\n }\n for (let [name, methodName] of Object.entries(defaultMethods)) {\n if (methodName === treeName) {\n return this.addonInstance.treeForMethods[name] !== methodName;\n }\n }\n return false;\n }\n\n @Memoize()\n private hasStockTree(treeName: AddonTreePath): boolean {\n if (this.suppressesTree(treeName)) {\n return false;\n }\n\n // we need to use this.addonInstance.root instead of this.root here because\n // we're looking for the classic location of the stock tree, and that\n // location is influenced by a customized ember-addon.main in package.json,\n // which is reflected in addonInstance.root.\n return (\n this.addonInstance.treePaths && existsSync(join(this.addonInstance.root, this.addonInstance.treePaths[treeName]))\n );\n }\n\n hasAnyTrees(): boolean {\n return Boolean(stockTreeNames.find(name => this.hasStockTree(name))) || this.customizes(...dynamicTreeHooks);\n }\n\n // we keep all these here to ensure that we always apply the same options to\n // the same tree, so that our cache doesn't need to worry about varying\n // options.\n private stockTreeFunnelOptions(treeName: string): FunnelOptions | undefined {\n switch (treeName) {\n case 'addon':\n return {\n exclude: ['styles/**'],\n };\n case 'styles':\n return {\n destDir: '_app_styles_',\n };\n case 'addon-test-support':\n return {\n destDir: 'test-support',\n };\n case 'app':\n return {\n exclude: ['styles/**'],\n destDir: appPublicationDir,\n };\n case 'public':\n return {\n destDir: `public/${this.moduleName}`,\n };\n case 'vendor':\n return {\n destDir: 'vendor',\n };\n }\n }\n\n protected stockTree(treeName: AddonTreePath): Node {\n return this.throughTreeCache(treeName, 'stock', () => {\n // adjust from the legacy \"root\" to our real root, because our rootTree\n // uses our real root but the stock trees are defined in terms of the\n // legacy root\n let srcDir = relative(this.root, join(this.addonInstance.root, this.addonInstance.treePaths[treeName]));\n let opts = Object.assign({ srcDir }, this.stockTreeFunnelOptions(treeName));\n return buildFunnel(this.rootTree, opts);\n })!;\n }\n\n @Memoize()\n protected get rootTree(): Node {\n if (this.packageCache.get(this.root).mayRebuild) {\n return new WatchedDir(this.root);\n } else {\n return new UnwatchedDir(this.root);\n }\n }\n\n @Memoize()\n private get moduleName(): string {\n if (typeof this.addonInstance.moduleName === 'function') {\n return this.addonInstance.moduleName();\n }\n return this.addonInstance.name;\n }\n\n // applies preprocessors to JS and HBS\n private transpile(tree: Node) {\n // Namespace the tree being passed to preprocessJs with the moduleName\n // to mimic classic build\n tree = buildFunnel(tree, { destDir: this.moduleName });\n\n if (this.addonInstance.shouldCompileTemplates() && this.addonInstance.registry.load('template')?.length > 0) {\n tree = this.app.preprocessRegistry.preprocessTemplates(tree, {\n registry: this.addonInstance.registry,\n });\n }\n\n tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\n });\n\n // Remove namespacing so that it gets written out to the node_modules\n // directory correctly.\n tree = buildFunnel(tree, {\n srcDir: this.moduleName,\n });\n\n return tree;\n }\n\n @Memoize()\n protected updateBabelConfig() {\n let packageOptions = this.options;\n let emberCLIBabelInstance = this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-babel');\n let version;\n\n if (emberCLIBabelInstance) {\n version = emberCLIBabelInstance.pkg.version;\n }\n\n if (!packageOptions['ember-cli-babel']) {\n packageOptions['ember-cli-babel'] = {};\n }\n\n if (!packageOptions.babel) {\n packageOptions.babel = {};\n }\n let babelConfig = packageOptions.babel as TransformOptions;\n\n Object.assign(packageOptions['ember-cli-babel'], {\n compileModules: false,\n disablePresetEnv: true,\n disableDebugTooling: true,\n disableEmberModulesAPIPolyfill: true,\n });\n\n if (version && semver.satisfies(semver.coerce(version) || version, '^5')) {\n unsupported(`${this.name} is using babel 5. Not installing our custom plugin.`);\n return;\n }\n\n if (!babelConfig.plugins) {\n babelConfig.plugins = [];\n } else {\n let hadAutoImport = Boolean(babelConfig.plugins.find(isEmberAutoImportDynamic));\n babelConfig.plugins = babelConfig.plugins.filter(babelPluginAllowedInStage1);\n if (hadAutoImport) {\n // if we removed ember-auto-import's dynamic import() plugin, the code\n // may use import() syntax and we need to re-add it to the parser.\n if (version && semver.satisfies(semver.coerce(version) || version, '^6')) {\n babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import'));\n } else {\n babelConfig.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));\n }\n }\n }\n\n if (this.templateCompilerBabelPlugin) {\n babelConfig.plugins.push(this.templateCompilerBabelPlugin);\n }\n }\n\n get v2Tree(): Node {\n return this.throughTreeCache(\n // these are all the kinds of trees that ember-cli's tree cache\n // understands. We need them all here because if *any* of these are\n // uncacheable, we want our whole v2 tree to be treated as uncacheable.\n [\n 'app',\n 'addon',\n 'addon-styles',\n 'addon-templates',\n 'addon-test-support',\n 'public',\n 'styles',\n 'templates',\n 'test-support',\n 'vendor',\n ],\n 'v2Tree',\n () => mergeTrees(this.v2Trees, { overwrite: true })\n );\n }\n\n // this is split out so that compatibility shims can override it to add more\n // things to the package metadata.\n protected get packageMeta(): Partial<AddonMeta> {\n let built = this.build();\n return mergeWithAppend(\n {\n version: 2,\n 'auto-upgraded': true,\n type: 'addon',\n },\n built.staticMeta,\n ...built.dynamicMeta.map(d => d())\n );\n }\n\n @Memoize()\n protected get v2Trees() {\n let { trees } = this.build();\n return trees;\n }\n\n protected throughTreeCache(nameOrNames: string | string[], category: string, fn: () => Node): Node;\n protected throughTreeCache(\n nameOrNames: string | string[],\n category: string,\n fn: () => Node | undefined\n ): Node | undefined {\n let cacheKey: string | undefined;\n if (typeof this.addonInstance.cacheKeyForTree === 'function') {\n let names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames];\n cacheKey = names.reduce((accum: string | undefined, name) => {\n if (accum == null) {\n // a previous name was uncacheable, so we're entirely uncacheable\n return undefined;\n }\n let key = this.addonInstance.cacheKeyForTree?.(name);\n if (key) {\n return accum + key;\n } else {\n return undefined;\n }\n }, '');\n if (cacheKey) {\n cacheKey = cacheKey + category;\n let cachedTree = this.app.addonTreeCache.get(cacheKey);\n if (cachedTree) {\n debug('cache hit %s %s %s', this.name, nameOrNames, category);\n return cachedTree;\n }\n }\n }\n debug('cache miss %s %s %s', this.name, nameOrNames, category);\n let tree = fn();\n if (tree && cacheKey) {\n this.app.addonTreeCache.set(cacheKey, tree);\n }\n return tree;\n }\n\n // In general, we can't reliably run addons' custom `treeFor()` methods,\n // because they recurse in a way that we absolutely don't want.\n //\n // But there is a very common use case that we *can* handle opportunisticaly,\n // which is a treeFor() that's used purely to guard whether `_super` will be\n // called or not.\n protected suppressesTree(name: string): boolean {\n if (!this.customizes('treeFor')) {\n return false;\n }\n // get the real addon as we're going to patch and restore `_super`\n const realAddon = getRealAddon(this.addonInstance);\n let origSuper = this.addonInstance._super;\n try {\n realAddon._super = stubbedSuper;\n let result = this.mainModule.treeFor?.call(this.addonInstance, name);\n if (result === markedEmptyTree) {\n // the method returns _super unchanged, so tree is not suppressed and we\n // understand what's going on\n return false;\n }\n if (result == null) {\n // the method nulled out the tree, so we are definitely suppressing\n return true;\n }\n // we can't tell what's really going on, don't suppress and hope for the\n // best\n unsupported(`${this.name} has a custom treeFor() method that is doing some arbitrary broccoli processing.`);\n return false;\n } finally {\n if (realAddon._super === stubbedSuper) {\n realAddon._super = origSuper;\n }\n }\n }\n\n protected invokeOriginalTreeFor(\n name: string,\n { neuterPreprocessors } = { neuterPreprocessors: false }\n ): Node | undefined {\n // @ts-expect-error have no idea why throughTreeCache overload is not working here..\n return this.throughTreeCache(name, 'original', () => {\n // get the real addon as we're going to patch and restore `preprocessJs`\n const realAddon = getRealAddon(this.addonInstance);\n let original;\n try {\n if (neuterPreprocessors) {\n original = realAddon.preprocessJs;\n realAddon.preprocessJs = function (tree: Node) {\n return tree;\n };\n }\n if (this.suppressesTree(name)) {\n return undefined;\n }\n return this.addonInstance._treeFor(name);\n } finally {\n if (neuterPreprocessors) {\n realAddon.preprocessJs = original;\n }\n }\n });\n }\n\n protected treeForAddon(built: IntermediateBuild): Node | undefined {\n // the extra isEngine condition is because ember-engines injects a\n // treeForAddon method into each engine addon that we really don't need or\n // want to run. Unfortunately there's not a more localized place to patch it\n // out, partly because ember-engines also uses a bogus inheritance strategy\n // (instead of providing a prototype that engine addons can extend it\n // patches things into their instance directly).\n if (this.customizes('treeForAddon', 'treeForAddonTemplates') && !this.isEngine()) {\n let tree = this.invokeOriginalTreeFor('addon', { neuterPreprocessors: true });\n if (tree) {\n tree = modulesCompat(tree);\n\n // this captures addons that are trying to escape their own package's\n // namespace\n let result = rewriteAddonTree(this.transpile(tree), this.name, this.moduleName);\n built.dynamicMeta.push(result.getMeta);\n return result.tree;\n }\n } else if (this.hasStockTree('addon')) {\n return this.transpile(this.stockTree('addon'));\n }\n }\n\n protected addonStylesTree(): Node | undefined {\n if (this.customizes('treeForAddonStyles')) {\n let custom = this.invokeOriginalTreeFor('addon-styles');\n if (custom) {\n return this.addonInstance.compileStyles(custom);\n }\n } else if (this.hasStockTree('addon-styles')) {\n return this.addonInstance.compileStyles(this.stockTree('addon-styles'));\n }\n }\n\n protected treeForTestSupport(): Node | undefined {\n if (this.customizes('treeForTestSupport')) {\n todo(`${this.name} has customized the test support tree`);\n } else if (this.hasStockTree('test-support')) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app. For example, imports should be relative to\n // the consuming app, not our own package.\n return buildFunnel(this.stockTree('test-support'), {\n destDir: `${appPublicationDir}/tests`,\n });\n }\n }\n\n private buildTreeForAddon(built: IntermediateBuild) {\n let tree = this.treeForAddon(built);\n if (!tree) {\n return;\n }\n let templateOnlyComponents: Node = new SynthesizeTemplateOnlyComponents(tree, {\n allowedPaths: ['components'],\n\n // if an addon has custom AST transforms, stage1 can rewrite .hbs to\n // .hbs.js\n templateExtensions: ['.hbs', '.hbs.js'],\n });\n\n if (this.isEngine()) {\n // even when staticAddonTrees is enabled, engines may have a router map\n // that needs to be dynamically resolved.\n let hasRoutesModule = false;\n\n tree = new ObserveTree(tree, outputDir => {\n hasRoutesModule = existsSync(resolve(outputDir, 'routes.js'));\n });\n built.dynamicMeta.push(() => ({\n 'implicit-modules': hasRoutesModule ? ['./routes.js'] : [],\n }));\n }\n\n built.trees.push(tree);\n built.trees.push(templateOnlyComponents);\n }\n\n private buildAddonStyles(built: IntermediateBuild) {\n let addonStylesTree = this.addonStylesTree();\n if (addonStylesTree) {\n if (this.app.hasCompiledStyles) {\n // >= ember-cli@3.18 store css files in <addon-name/__COMPILED_STYLES__\n // and for embroider to work correctly need to be moved back to `/`\n //\n // speaking with @rwjblue the ember-cli build is now frozen, and it is\n // ok to assume that after the above version no changes will occur\n // makings this work-around safe.\n //\n // additional context: https://github.com/embroider-build/embroider/pull/934/files#r695269976\n addonStylesTree = buildFunnel(addonStylesTree, {\n srcDir: `${this.name}/__COMPILED_STYLES__`,\n destDir: '/',\n allowEmpty: true,\n });\n }\n\n let discoveredFiles: string[] = [];\n let tree = new ObserveTree(addonStylesTree, outputPath => {\n discoveredFiles = walkSync(outputPath, { globs: ['**/*.css'], directories: false });\n });\n built.trees.push(tree);\n built.dynamicMeta.push(() => {\n return {\n 'implicit-styles': discoveredFiles.map(f => `./${f}`),\n };\n });\n }\n }\n\n private buildTreeForStyles(built: IntermediateBuild) {\n let tree;\n if (this.customizes('treeForStyles')) {\n // the user's tree returns their own styles with no \"app/styles\" wrapping\n // around, which is actually what we want\n tree = this.invokeOriginalTreeFor('styles');\n if (tree) {\n tree = buildFunnel(tree, {\n destDir: '_app_styles_',\n getDestinationPath(path) {\n return path.replace(/^app\\/styles\\//, '');\n },\n });\n }\n } else if (this.hasStockTree('styles')) {\n tree = this.stockTree('styles');\n }\n if (tree) {\n built.trees.push(tree);\n }\n }\n\n private buildAddonTestSupport(built: IntermediateBuild) {\n let addonTestSupportTree;\n if (this.customizes('treeForAddonTestSupport')) {\n let original = this.invokeOriginalTreeFor('addon-test-support', { neuterPreprocessors: true });\n if (original) {\n let { tree, getMeta } = rewriteAddonTree(original, this.name, this.moduleName);\n addonTestSupportTree = this.transpile(tree);\n built.dynamicMeta.push(getMeta);\n }\n } else if (this.hasStockTree('addon-test-support')) {\n addonTestSupportTree = this.transpile(this.stockTree('addon-test-support'));\n }\n if (addonTestSupportTree) {\n built.trees.push(addonTestSupportTree);\n }\n }\n\n private maybeSetDirectoryMeta(built: IntermediateBuild, tree: Node, localDir: string, key: keyof AddonMeta): Node {\n let files: AddonMeta['app-js'];\n built.dynamicMeta.push(() => {\n if (files) {\n return { [key]: files };\n } else {\n return {};\n }\n });\n return new ObserveTree(tree, (outputPath: string) => {\n let dir = join(outputPath, localDir);\n if (existsSync(dir)) {\n files = fromPairs(walkSync(dir, { globs: ['**/*.js', '**/*.hbs'] }).map(f => [`./${f}`, `./${localDir}/${f}`]));\n } else {\n files = undefined;\n }\n });\n }\n\n private buildTestSupport(built: IntermediateBuild) {\n let tree = this.treeForTestSupport();\n if (tree) {\n tree = this.maybeSetDirectoryMeta(built, tree, appPublicationDir, 'app-js');\n built.trees.push(tree);\n }\n }\n\n private buildTreeForApp(built: IntermediateBuild) {\n let appTree;\n if (this.customizes('treeForApp', 'treeForTemplates')) {\n let original = this.invokeOriginalTreeFor('app');\n if (original) {\n appTree = buildFunnel(original, {\n destDir: appPublicationDir,\n });\n }\n } else if (this.hasStockTree('app')) {\n appTree = this.stockTree('app');\n }\n\n if (appTree) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app.\n appTree = this.maybeSetDirectoryMeta(built, appTree, appPublicationDir, 'app-js');\n built.trees.push(appTree);\n }\n\n if (\n typeof this.addonInstance.isDevelopingAddon === 'function' &&\n this.addonInstance.isDevelopingAddon() &&\n this.addonInstance.hintingEnabled()\n ) {\n let hintTree = this.addonInstance.jshintAddonTree();\n if (hintTree) {\n hintTree = this.maybeSetDirectoryMeta(\n built,\n buildFunnel(hintTree, { destDir: appPublicationDir }),\n appPublicationDir,\n 'app-js'\n );\n built.trees.push(hintTree);\n }\n }\n }\n\n private buildTreeForFastBoot(built: IntermediateBuild) {\n let tree;\n\n if (this.customizes('treeForFastBoot')) {\n // Arguably, it would be more correct to always create the new Funnel,\n // because the fastboot directory could be created *after* our build starts.\n // But that would result in hundreds of additional trees, even though the\n // vast majority of addons aren't changing and don't have fastboot\n // directories. So I'm pretty comfortable with the optimization. It means\n // that an addon author who creates a brand new fastboot directory in a v1\n // packages will need to restart their build. (Really we hope new addons\n // will be authored in v2 instead soon anyway, and they won't need the\n // concept of \"fastboot directory\" because they can use the macro system to\n // conditionally import some things only in fastboot.)\n if (pathExistsSync(join(this.root, 'fastboot'))) {\n tree = buildFunnel(this.rootTree, { srcDir: 'fastboot' });\n }\n tree = this.addonInstance.treeForFastBoot(tree);\n if (tree) {\n tree = buildFunnel(tree, { destDir: fastbootPublicationDir });\n }\n } else {\n if (pathExistsSync(join(this.root, 'fastboot'))) {\n tree = buildFunnel(this.rootTree, { srcDir: 'fastboot', destDir: fastbootPublicationDir });\n }\n }\n\n if (tree) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app.\n tree = this.maybeSetDirectoryMeta(built, tree, fastbootPublicationDir, 'fastboot-js');\n built.trees.push(tree);\n }\n }\n\n private buildPublicTree(built: IntermediateBuild) {\n let publicTree;\n // the extra isEngine condition is here because ember-engines injects a\n // customized treeForPublic into every engine addon. We don't want or need\n // it to run.\n if (this.customizes('treeForPublic') && !this.isEngine()) {\n let original = this.invokeOriginalTreeFor('public');\n if (original) {\n publicTree = buildFunnel(original, {\n destDir: 'public',\n });\n }\n } else if (this.hasStockTree('public')) {\n publicTree = this.stockTree('public');\n }\n if (publicTree) {\n let publicAssets: { [filename: string]: string } = {};\n publicTree = new ObserveTree(publicTree, (outputPath: string) => {\n publicAssets = {};\n for (let filename of walkSync(join(outputPath, 'public'))) {\n if (!filename.endsWith('/')) {\n publicAssets[`./public/${filename}`] = './' + filename;\n }\n }\n });\n built.trees.push(publicTree);\n built.dynamicMeta.push(() => ({ 'public-assets': publicAssets }));\n }\n }\n\n private buildVendorTree(built: IntermediateBuild) {\n if (this.customizes('treeForVendor')) {\n // We don't have any particular opinions about the structure inside\n // vendor, so even when it's customized we can just use the customized\n // one.\n let tree = this.invokeOriginalTreeFor('vendor');\n if (tree) {\n built.trees.push(\n buildFunnel(tree, {\n destDir: 'vendor',\n })\n );\n }\n } else if (this.hasStockTree('vendor')) {\n built.trees.push(this.stockTree('vendor'));\n }\n }\n\n private isEngine() {\n return typeof this.addonInstance.getEngineConfigContents === 'function';\n }\n\n private buildEngineConfig(built: IntermediateBuild) {\n if (!this.isEngine()) {\n return;\n }\n // this addon is an engine, so it needs its own config/environment.js.\n // ember-engines always emits a separate inline (not-meta-tag) config for\n // fastboot, so we mimic that behavior here.\n //\n // getEngineConfigContents is an arbitrary customizable module, so we can't\n // easily rewrite it to live inside our conditional, so it's safer in a\n // separate module.\n built.trees.push(writeFile('config/_environment_browser_.js', this.addonInstance.getEngineConfigContents?.()));\n built.trees.push(\n writeFile(\n 'config/environment.js',\n `\n import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\n let config;\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n config = ${JSON.stringify(this.addonInstance.engineConfig?.(this.app.env, {}), null, 2)};\n } else {\n config = importSync('./_environment_browser_.js').default;\n }\n export default config;\n `\n )\n );\n }\n\n private buildPackageJSON(built: IntermediateBuild) {\n built.trees.push(new RewritePackageJSON(this.rootTree, () => this.newPackageJSON));\n }\n\n @Memoize()\n private build(): IntermediateBuild {\n let built = new IntermediateBuild();\n built.staticMeta['order-index'] = this.orderIdx;\n\n if (this.options.lazyLoading === true || (this.options.lazyLoading && this.options.lazyLoading.enabled)) {\n built.staticMeta['lazy-engine'] = true;\n }\n\n if (this.moduleName !== this.name) {\n built.staticMeta['renamed-packages'] = {\n [this.moduleName]: this.name,\n };\n }\n\n this.buildTreeForAddon(built);\n this.buildAddonStyles(built);\n this.buildTreeForStyles(built);\n this.buildAddonTestSupport(built);\n this.buildTestSupport(built);\n this.buildTreeForApp(built);\n this.buildTreeForFastBoot(built);\n this.buildPublicTree(built);\n this.buildVendorTree(built);\n this.buildEngineConfig(built);\n this.buildPackageJSON(built);\n return built;\n }\n}\n\nexport interface V1AddonConstructor {\n new (\n addonInstance: any,\n options: CompatOptionsType,\n app: CompatApp,\n packageCache: PackageCache,\n orderIdx: number\n ): V1Addon;\n\n shouldApplyAdapter?(addonInstance: any): boolean;\n}\n\nclass IntermediateBuild {\n trees: Node[] = [];\n staticMeta: { [metaField: string]: any } = {};\n dynamicMeta: (() => Partial<AddonMeta>)[] = [];\n}\n\nfunction babelPluginAllowedInStage1(plugin: PluginItem) {\n if (isEmbroiderMacrosPlugin(plugin)) {\n // the point of @embroider/macros is that it's allowed to stay in v2\n // addon publication format, so it doesn't need to run here in stage1.\n // We always run it in stage3.\n return false;\n }\n\n if (isInlinePrecompilePlugin(plugin)) {\n // Similarly, the inline precompile plugin must not run in stage1. We\n // want all templates uncompiled. Instead, we will be adding our own\n // plugin that only runs custom AST transforms inside inline\n // templates.\n return false;\n }\n\n if (isEmberAutoImportDynamic(plugin)) {\n // We replace ember-auto-import's implementation of dynamic import(), so we\n // need to stop its plugin from rewriting those.\n return false;\n }\n\n if (isCompactReexports(plugin)) {\n // We don't want to replace re-exports at this stage, since that will turn\n // an `export` statement into a `define`, which is handled in Stage 3\n return false;\n }\n\n if (isColocationPlugin(plugin)) {\n // template co-location is a first-class feature we support directly, so\n // whether or not the app brought a plugin for it we're going to do it our\n // way.\n return false;\n }\n\n return true;\n}\n\nconst markedEmptyTree = new UnwatchedDir(process.cwd());\n\nconst stubbedSuper = () => {\n return markedEmptyTree;\n};\n\nstubbedSuper.treeFor = () => {\n return markedEmptyTree;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"assert-never": "^1.1.0",
|
|
35
35
|
"babel-import-util": "^3.0.1",
|
|
36
36
|
"babel-plugin-debug-macros": "^1.0.2",
|
|
37
|
-
"babel-plugin-ember-template-compilation": "
|
|
37
|
+
"babel-plugin-ember-template-compilation-2": "npm:babel-plugin-ember-template-compilation@^2.4.0",
|
|
38
|
+
"babel-plugin-ember-template-compilation": "^3.0.0",
|
|
38
39
|
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
|
39
40
|
"babylon": "^6.18.0",
|
|
40
41
|
"bind-decorator": "^1.0.11",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"tree-sync": "^2.1.0",
|
|
64
65
|
"typescript-memoize": "^1.0.1",
|
|
65
66
|
"walk-sync": "^3.0.0",
|
|
66
|
-
"@embroider/macros": "1.
|
|
67
|
+
"@embroider/macros": "1.18.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@glimmer/syntax": "^0.94.9",
|
|
@@ -86,12 +87,12 @@
|
|
|
86
87
|
"ember-engines": "^0.8.19",
|
|
87
88
|
"scenario-tester": "^4.0.0",
|
|
88
89
|
"typescript": "^5.4.5",
|
|
89
|
-
"@embroider/core": "^4.0
|
|
90
|
-
"@embroider/
|
|
91
|
-
"@embroider/
|
|
90
|
+
"@embroider/core": "^4.1.0",
|
|
91
|
+
"@embroider/sample-transforms": "0.0.0",
|
|
92
|
+
"@embroider/test-support": "0.36.0"
|
|
92
93
|
},
|
|
93
94
|
"peerDependencies": {
|
|
94
|
-
"@embroider/core": "^4.0
|
|
95
|
+
"@embroider/core": "^4.1.0"
|
|
95
96
|
},
|
|
96
97
|
"engines": {
|
|
97
98
|
"node": "12.* || 14.* || >= 16"
|