@embroider/compat 3.5.3-unstable.718cc64 → 3.5.3-unstable.b61ecde

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/compat",
3
- "version": "3.5.3-unstable.718cc64",
3
+ "version": "3.5.3-unstable.b61ecde",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "@babel/preset-env": "^7.14.5",
31
31
  "@babel/runtime": "^7.18.6",
32
32
  "@babel/traverse": "^7.14.5",
33
- "@embroider/macros": "1.16.4-unstable.718cc64",
33
+ "@embroider/macros": "1.16.4-unstable.b61ecde",
34
34
  "@types/babel__code-frame": "^7.0.2",
35
35
  "@types/yargs": "^17.0.3",
36
36
  "assert-never": "^1.1.0",
@@ -66,7 +66,7 @@
66
66
  "yargs": "^17.0.1"
67
67
  },
68
68
  "devDependencies": {
69
- "@embroider/core": "3.4.12-unstable.718cc64",
69
+ "@embroider/core": "3.4.12-unstable.b61ecde",
70
70
  "@embroider/sample-transforms": "workspace:*",
71
71
  "@embroider/test-support": "workspace:*",
72
72
  "@glimmer/syntax": "^0.84.3",
@@ -91,7 +91,7 @@
91
91
  "typescript": "^5.4.5"
92
92
  },
93
93
  "peerDependencies": {
94
- "@embroider/core": "3.4.12-unstable.718cc64"
94
+ "@embroider/core": "3.4.12-unstable.b61ecde"
95
95
  },
96
96
  "engines": {
97
97
  "node": "12.* || 14.* || >= 16"
@@ -47,7 +47,6 @@ function auditJS(rawSource, filename, babelConfig, frames) {
47
47
  }
48
48
  },
49
49
  CallExpression(path) {
50
- var _a;
51
50
  let callee = path.get('callee');
52
51
  if (callee.referencesImport('@embroider/macros', 'importSync') || core_1.types.isImport(callee.node)) {
53
52
  let arg = path.node.arguments[0];
@@ -58,9 +57,6 @@ function auditJS(rawSource, filename, babelConfig, frames) {
58
57
  specifiers: [],
59
58
  });
60
59
  }
61
- else if ((_a = arg.leadingComments) === null || _a === void 0 ? void 0 : _a.find(c => /@vite-ignore/.test(c.value))) {
62
- // this is vite internals that we should ignore too
63
- }
64
60
  else {
65
61
  problems.push({
66
62
  message: `audit tool is unable to understand this usage of ${core_1.types.isImport(callee.node) ? 'import' : 'importSync'}`,
@@ -1 +1 @@
1
- {"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AACA,+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;AAFD,8CAEC;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,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,CAAC,CAAE,CAAC;IAClG,IAAI,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAA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AK,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":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AACA,+DAAuC;AAEvC,sCAAwD;AAExD,kDAAqD;AAErD,MAAa,YAAY;CAAG;AAA5B,oCAA4B;AAgB5B,SAAgB,iBAAiB,CAAC,KAA+B;IAC/D,OAAO,OAAO,KAAK,K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MAAM,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAc;IACjD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,wBAAwB;YAC3B,OAAO,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,CAAC;QAC1C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACtD,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,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 {\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"]}
package/src/compat-app.js CHANGED
@@ -28,6 +28,7 @@ const node_1 = require("@embroider/macros/src/node");
28
28
  const resolve_package_path_1 = __importDefault(require("resolve-package-path"));
29
29
  const broccoli_concat_1 = __importDefault(require("broccoli-concat"));
30
30
  const mapKeys_1 = __importDefault(require("lodash/mapKeys"));
31
+ const synthesize_template_only_components_1 = __importDefault(require("./synthesize-template-only-components"));
31
32
  const detect_babel_plugins_1 = require("./detect-babel-plugins");
32
33
  const prepare_htmlbars_ast_plugins_1 = __importDefault(require("./prepare-htmlbars-ast-plugins"));
33
34
  const fs_1 = require("fs");
@@ -584,6 +585,7 @@ class CompatApp {
584
585
  let lintTree = this.lintTree;
585
586
  let trees = [];
586
587
  trees.push(appTree);
588
+ trees.push(new synthesize_template_only_components_1.default(appTree, { allowedPaths: ['components'], templateExtensions: ['.hbs'] }));
587
589
  if (testsTree) {
588
590
  trees.push(testsTree);
589
591
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compat-app.js","sourceRoot":"","sources":["compat-app.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,0CAA+G;AAE/G,uCAAgD;AAChD,2DAA6C;AAC7C,mCAA2C;AAC3C,+BAAsD;AACtD,sEAA0C;AAC1C,gFAA8C;AAC9C,qDAA6C;AAC7C,sDAA8B;AAC9B,8EAAoD;AACpD,2CAAuC;AACvC,6CAA6D;AAE7D,uCAA6G;AAC7G,gEAAsC;AACtC,oEAA2C;AAE3C,qDAAmF;AACnF,gFAAsD;AACtD,sEAAq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GD;IADC,IAAA,4BAAO,GAAE;2CAWT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAcT;AAOD;IADC,IAAA,4BAAO,GAAE;sDAOT;AAkDD;IADC,IAAA,4BAAO,GAAE;4CA0DT;AAGD;IADC,IAAA,4BAAO,GAAE;kDAyBT;AAGO;IADP,IAAA,4BAAO,GAAE;qDAgBT;AA8UD;IADC,IAAA,4BAAO,GAAE;8CAGT;AA0ED;IADC,IAAA,4BAAO,GAAE;2CAcT","sourcesContent":["import type { Node as BroccoliNode } from 'broccoli-node-api';\nimport type { Stage, Package } from '@embroider/core';\nimport { PackageCache, WaitForTrees, RewrittenPackageCache, locateEmbroiderWorkingDir } from '@embroider/core';\nimport type Options from './options';\nimport { optionsWithDefaults } from './options';\nimport { Memoize } from 'typescript-memoize';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { join, dirname, isAbsolute, sep } from 'path';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { WatchedDir } from 'broccoli-source';\nimport resolve from 'resolve';\nimport ContentForConfig from './content-for-config';\nimport { V1Config } from './v1-config';\nimport { WriteV1AppBoot, ReadV1AppBoot } from './v1-appboot';\nimport type { AddonMeta, EmberAppInstance, OutputFileToInputFileMap, PackageInfo } from '@embroider/core';\nimport { writeJSONSync, ensureDirSync, copySync, pathExistsSync, existsSync, writeFileSync } from 'fs-extra';\nimport AddToTree from './add-to-tree';\nimport DummyPackage from './dummy-package';\nimport type { TransformOptions } from '@babel/core';\nimport { isEmbroiderMacrosPlugin, MacrosConfig } from '@embroider/macros/src/node';\nimport resolvePackagePath from 'resolve-package-path';\nimport Concat from 'broccoli-concat';\nimport mapKeys from 'lodash/mapKeys';\nimport { isEmberAutoImportDynamic, isInlinePrecompilePlugin } from './detect-babel-plugins';\nimport loadAstPlugins from './prepare-htmlbars-ast-plugins';\nimport { readFileSync } from 'fs';\nimport semver from 'semver';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport { CompatAppBuilder } from './compat-app-builder';\nimport walkSync from 'walk-sync';\n\ninterface Group {\n outputFiles: OutputFileToInputFileMap;\n implicitKey: '_implicitStyles' | '_implicitScripts';\n vendorOutputPath: 'string';\n}\n\n// This runs at broccoli-pipeline-construction time, whereas the\n// CompatAppBuilder instance only becomes available during tree-building time.\nexport default class CompatApp {\n private annotation = '@embroider/compat/app';\n private active: CompatAppBuilder | undefined;\n readonly options: Required<Options>;\n\n private _publicAssets: { [filePath: string]: string } = Object.create(null);\n private _implicitScripts: string[] = [];\n private _implicitStyles: string[] = [];\n\n private get isDummy(): boolean {\n return this.legacyEmberAppInstance.project.pkg.keywords?.includes('ember-addon') ?? false;\n }\n\n get name(): string {\n if (this.isDummy) {\n // here we accept the ember-cli behavior\n return this.legacyEmberAppInstance.name;\n } else {\n // always the name from package.json. Not the one that apps may have weirdly\n // customized.\n return this.legacyEmberAppInstance.project.pkg.name;\n }\n }\n\n get env(): string {\n return this.legacyEmberAppInstance.env;\n }\n\n @Memoize()\n get root(): string {\n if (this.isDummy) {\n // this is the Known Hack for finding the true root of the dummy app.\n return join(this.legacyEmberAppInstance.project.configPath(), '..', '..');\n } else {\n return dirname(pkgUpSync({ cwd: this.legacyEmberAppInstance.project.root })!);\n }\n }\n\n @Memoize()\n private get emberCLILocation() {\n const emberCLIPackage = resolvePackagePath('ember-cli', this.root);\n\n if (emberCLIPackage === null) {\n throw new Error(`Embroider: cannot resolve ember-cli's package.json`);\n }\n\n return dirname(emberCLIPackage);\n }\n\n @Memoize()\n get hasCompiledStyles() {\n return semver.gte(JSON.parse(readFileSync(`${this.emberCLILocation}/package.json`, 'utf8')).version, '3.18.0');\n }\n\n private requireFromEmberCLI(specifier: string) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve.sync(specifier, { basedir: this.emberCLILocation }));\n }\n\n private get configReplace() {\n return this.requireFromEmberCLI('broccoli-config-replace');\n }\n\n private get configLoader() {\n return this.requireFromEmberCLI('broccoli-config-loader');\n }\n\n private get appUtils() {\n return this.requireFromEmberCLI('./lib/utilities/ember-app-utils');\n }\n\n @Memoize()\n get addonTreeCache(): Map<string, BroccoliNode> {\n return new Map();\n }\n\n @Memoize()\n get preprocessRegistry() {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get shouldBuildTests(): boolean {\n return this.legacyEmberAppInstance.tests || false;\n }\n\n configPath(): string {\n return this.legacyEmberAppInstance.project.configPath();\n }\n\n private get configTree() {\n return new this.configLoader(dirname(this.configPath()), {\n env: this.legacyEmberAppInstance.env,\n tests: this.legacyEmberAppInstance.tests || false,\n project: this.legacyEmberAppInstance.project,\n });\n }\n\n @Memoize()\n private get config(): V1Config {\n return new V1Config(this.configTree, this.legacyEmberAppInstance.env);\n }\n\n @Memoize()\n get testConfig(): V1Config | undefined {\n if (this.shouldBuildTests) {\n return new V1Config(this.configTree, 'test');\n }\n }\n\n @Memoize()\n private get contentFor(): ContentForConfig {\n const configPaths = [\n { file: '/index.html', path: join('environments', `${this.legacyEmberAppInstance.env}.json`) },\n ];\n if (this.shouldBuildTests) configPaths.push({ file: '/tests/index.html', path: join('environments', `test.json`) });\n return new ContentForConfig(this.configTree, {\n availableContentForTypes: this.options.availableContentForTypes,\n configPaths,\n pattern: this.filteredPatternsByContentFor.contentFor,\n });\n }\n\n get autoRun(): boolean {\n return this.legacyEmberAppInstance.options.autoRun;\n }\n\n @Memoize()\n get appBoot(): ReadV1AppBoot {\n let env = this.legacyEmberAppInstance.env;\n let appBootContentTree = new WriteV1AppBoot();\n\n let patterns = this.configReplacePatterns;\n\n appBootContentTree = new this.configReplace(appBootContentTree, this.configTree, {\n configPath: join('environments', `${env}.json`),\n files: ['config/app-boot.js'],\n patterns,\n });\n\n return new ReadV1AppBoot(appBootContentTree);\n }\n\n private get storeConfigInMeta(): boolean {\n return this.legacyEmberAppInstance.options.storeConfigInMeta;\n }\n\n @Memoize()\n private get configReplacePatterns() {\n return this.appUtils.configReplacePatterns({\n addons: this.legacyEmberAppInstance.project.addons,\n autoRun: this.autoRun,\n storeConfigInMeta: this.storeConfigInMeta,\n });\n }\n\n private get filteredPatternsByContentFor() {\n const filter = '/{{content-for [\\'\"](.+?)[\"\\']}}/g';\n return {\n contentFor: this.configReplacePatterns.find((pattern: any) => filter.includes(pattern.match.toString())),\n others: this.configReplacePatterns.filter((pattern: any) => !filter.includes(pattern.match.toString())),\n };\n }\n\n private get htmlTree() {\n if (this.legacyEmberAppInstance.tests) {\n return mergeTrees([this.indexTree, this.testIndexTree]);\n } else {\n return this.indexTree;\n }\n }\n\n private get indexTree() {\n let indexFilePath = this.legacyEmberAppInstance.options.outputPaths.app.html;\n let index = buildFunnel(this.legacyEmberAppInstance.trees.app, {\n allowEmpty: true,\n include: [`index.html`],\n getDestinationPath: () => indexFilePath,\n annotation: 'app/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `${this.legacyEmberAppInstance.env}.json`),\n files: [indexFilePath],\n patterns: this.filteredPatternsByContentFor.others,\n annotation: 'ConfigReplace/indexTree',\n });\n }\n\n private get testIndexTree() {\n let index = buildFunnel(this.legacyEmberAppInstance.trees.tests, {\n allowEmpty: true,\n include: [`index.html`],\n destDir: 'tests',\n annotation: 'tests/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `test.json`),\n files: ['tests/index.html'],\n patterns: this.filteredPatternsByContentFor.others,\n annotation: 'ConfigReplace/testIndexTree',\n });\n }\n\n @Memoize()\n babelConfig(): TransformOptions {\n // this finds all the built-in babel configuration that comes with ember-cli-babel\n const babelAddon = (this.legacyEmberAppInstance.project as any).findAddonByName('ember-cli-babel');\n const babelConfig = babelAddon.buildBabelOptions({\n 'ember-cli-babel': {\n ...this.legacyEmberAppInstance.options['ember-cli-babel'],\n includeExternalHelpers: true,\n compileModules: false,\n disableDebugTooling: false,\n disablePresetEnv: false,\n disableEmberModulesAPIPolyfill: false,\n },\n });\n\n let plugins = babelConfig.plugins as any[];\n let presets = babelConfig.presets;\n\n // this finds any custom babel configuration that's on the app (either\n // because the app author explicitly added some, or because addons have\n // pushed plugins into it).\n let appBabel = this.legacyEmberAppInstance.options.babel;\n if (appBabel) {\n if (appBabel.plugins) {\n plugins = appBabel.plugins.concat(plugins);\n }\n if (appBabel.presets) {\n presets = appBabel.presets.concat(presets);\n }\n }\n\n plugins = plugins.filter(p => {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n return (\n !isEmbroiderMacrosPlugin(p) &&\n // similarly, if the app was already using an inline template compiler\n // babel plugin, we remove it here because we have our own\n // always-installed version of that (v2 addons are allowed to assume it\n // will be present in the final app build, the app doesn't get to turn\n // that off or configure it.)\n !isInlinePrecompilePlugin(p) &&\n !isEmberAutoImportDynamic(p)\n );\n });\n\n const config: TransformOptions = {\n babelrc: false,\n plugins,\n presets,\n // this is here because broccoli-middleware can't render a codeFrame full\n // of terminal codes. It would be nice to add something like\n // https://github.com/mmalecki/ansispan to broccoli-middleware so we can\n // leave color enabled.\n highlightCode: false,\n };\n\n return config;\n }\n\n @Memoize()\n babelMajorVersion(): 7 {\n let babelAddon = this.legacyEmberAppInstance.project.addons.find((a: any) => a.name === 'ember-cli-babel');\n if (babelAddon) {\n let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]);\n let babelMajor: number | undefined = babelAddonMajor;\n if (babelAddonMajor >= 8) {\n // `ember-cli-babel` v8 breaks lockstep with Babel, because it now\n // defines `@babel/core` as a peer dependency, so we need to check the\n // project's version of `@babel/core`:\n let babelVersion = this.legacyEmberAppInstance.project.pkg.devDependencies?.['@babel/core'];\n if (babelVersion) {\n babelMajor = semver.coerce(babelVersion)?.major;\n } else {\n babelMajor = 7;\n }\n }\n if (babelMajor !== 7) {\n throw new Error('`@embroider/compat` only supports apps and addons that use Babel v7.');\n }\n return babelMajor;\n }\n // if we didn't have our own babel plugin at all, it's safe to parse our\n // code with 7.\n return 7;\n }\n\n @Memoize()\n private transformedNodeFiles(): Map<string, string> {\n // any app.imports from node_modules that need custom transforms will need\n // to get copied into our own synthesized vendor package. app.imports from\n // node_modules that *don't* need custom transforms can just stay where they\n // are.\n let transformed = new Map();\n for (let transformConfig of this.legacyEmberAppInstance._customTransformsMap.values()) {\n for (let filename of transformConfig.files as string[]) {\n let preresolved = this.preresolvedNodeFile(filename);\n if (preresolved) {\n transformed.set(filename, preresolved);\n }\n }\n }\n return transformed;\n }\n\n private preresolvedNodeFile(filename: string) {\n // this regex is an exact copy of how ember-cli does this, so we align.\n let match = filename.match(/^node_modules\\/((@[^/]+\\/)?[^/]+)\\//);\n if (match) {\n // ember-cli has already done its own resolution of\n // `app.import('node_modules/something/...')`, so we go find its answer.\n for (let { name, path } of this.legacyEmberAppInstance._nodeModules.values()) {\n if (match[1] === name) {\n return filename.replace(match[0], path + sep);\n }\n }\n throw new Error(`bug: expected ember-cli to already have a resolved path for asset ${filename}`);\n }\n }\n\n private combinedVendor(addonTrees: BroccoliNode[]): BroccoliNode {\n let trees = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: 'vendor',\n destDir: 'vendor',\n })\n );\n if (this.vendorTree) {\n trees.push(\n buildFunnel(this.vendorTree, {\n destDir: 'vendor',\n })\n );\n }\n\n const tree = mergeTrees(trees, { overwrite: true });\n\n const outputGroups: Group[] = [\n // scripts\n {\n outputFiles: this.legacyEmberAppInstance._scriptOutputFiles,\n implicitKey: '_implicitScripts',\n vendorOutputPath: this.legacyEmberAppInstance.options.outputPaths.vendor.js,\n },\n // styles\n {\n outputFiles: this.legacyEmberAppInstance._styleOutputFiles,\n implicitKey: '_implicitStyles',\n vendorOutputPath: this.legacyEmberAppInstance.options.outputPaths.vendor.css,\n },\n ];\n\n const concatentations = [];\n\n // support: app.import / outputFile / using\n for (let entry of outputGroups) {\n const { outputFiles, implicitKey, vendorOutputPath } = entry;\n for (let importPath of Object.keys(outputFiles)) {\n const headerFiles = outputFiles[importPath];\n\n if (importPath === vendorOutputPath) {\n // these are the default ember-cli output files vendor.js or\n // vendor.css. Let embroider handle these.\n this[implicitKey] = headerFiles;\n } else if (headerFiles.length === 0) {\n // something went really wrong, open an issue\n throw new Error('Embroider: EWUT');\n } else if (headerFiles.length === 1) {\n // app.import(x, { outputFile: y }); where only one app.imports had this outputFile\n //\n // No concat needed. Simply serialize the remapping in the addon's\n // manifest, this ensures it is included in the final output with no extra work.\n this._publicAssets[headerFiles[0]] = importPath;\n } else {\n // app.import(x, { outputFile: y }); where multiple app.imports share one outputFile\n // Concat needed. Perform concat, and include the outputFile in the\n // addon's manifest. This ensures it is included in the final output\n this._publicAssets[importPath] = importPath;\n\n concatentations.push(\n new Concat(tree, {\n headerFiles,\n outputFile: importPath,\n annotation: `Package ${importPath}`,\n separator: '\\n;',\n sourceMapConfig: this.legacyEmberAppInstance.options['sourcemaps'],\n })\n );\n }\n }\n }\n\n this.addOtherAssets();\n return mergeTrees([tree, ...concatentations], { overwrite: true });\n }\n\n private addOtherAssets() {\n for (let asset of this.legacyEmberAppInstance.otherAssetPaths) {\n this._publicAssets[`${asset.src}/${asset.file}`] = `${asset.dest}/${asset.file}`;\n }\n }\n\n private addNodeAssets(inputTree: BroccoliNode): BroccoliNode {\n let transformedNodeFiles = this.transformedNodeFiles();\n\n return new AddToTree(inputTree, outputPath => {\n for (let [localDestPath, sourcePath] of transformedNodeFiles) {\n let destPath = join(outputPath, localDestPath);\n ensureDirSync(dirname(destPath));\n copySync(sourcePath, destPath);\n }\n\n if (this.shouldBuildTests) {\n writeFileSync(\n join(outputPath, 'testem.js'),\n `/*\n * This is dummy file that exists for the sole purpose\n * of allowing tests to run directly in the browser as\n * well as by Testem.\n *\n * Testem is configured to run tests directly against\n * the test build of index.html, which requires a\n * snippet to load the testem.js file:\n * <script src=\"/testem.js\"></script>\n * This has to go before the qunit framework and app\n * tests are loaded.\n *\n * Testem internally supplies this file. However, if you\n * run the tests directly in the browser (localhost:8000/tests),\n * this file does not exist.\n *\n * Hence the purpose of this fake file. This file is served\n * directly from the express server to satisify the script load.\n*/`\n );\n this._publicAssets['/testem.js'] = './testem.js';\n }\n\n let remapAsset = this.remapAsset.bind(this);\n\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'implicit-scripts': this._implicitScripts.map(remapAsset),\n 'implicit-styles': this._implicitStyles.map(remapAsset),\n 'implicit-test-scripts': this.legacyEmberAppInstance.legacyTestFilesToAppend.map(remapAsset),\n 'implicit-test-styles': this.legacyEmberAppInstance.vendorTestStaticStyles.map(remapAsset),\n 'public-assets': mapKeys(this._publicAssets, (_, key) => remapAsset(key)),\n };\n let meta: PackageInfo = {\n name: '@embroider/synthesized-vendor',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n synthesizeVendorPackage(addonTrees: BroccoliNode[]): BroccoliNode {\n return this.applyCustomTransforms(this.addNodeAssets(this.combinedVendor(addonTrees)));\n }\n\n private combinedStyles(addonTrees: BroccoliNode[]): BroccoliNode {\n let trees: BroccoliNode[] = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: '_app_styles_',\n })\n );\n let appStyles = this.legacyEmberAppInstance.trees.styles as BroccoliNode | undefined;\n if (appStyles) {\n // Workaround for https://github.com/ember-cli/ember-cli/issues/9020\n //\n // The default app styles tree is unwatched and relies on side effects\n // elsewhere in ember-cli's build pipeline to actually get rebuilds to\n // work. Here we need it to actually be watched properly if we want to\n // rely on it, particularly when using BROCCOLI_ENABLED_MEMOIZE.\n if ((appStyles as any)._watched === false && (appStyles as any)._directoryPath) {\n appStyles = new WatchedDir((appStyles as any)._directoryPath);\n }\n trees.push(appStyles);\n }\n return mergeTrees(trees, { overwrite: true, annotation: 'embroider-v1-app-combined-styles' });\n }\n\n synthesizeStylesPackage(addonTrees: BroccoliNode[]): BroccoliNode {\n let options = {\n // we're deliberately not allowing this to be customized. It's an\n // internal implementation detail, and respecting outputPaths here is\n // unnecessary complexity. The corresponding code that adjusts the HTML\n // <link> is in updateHTML in app.ts.\n outputPaths: { app: `/assets/${this.name}.css` },\n registry: this.legacyEmberAppInstance.registry,\n minifyCSS: this.legacyEmberAppInstance.options.minifyCSS.options,\n };\n\n let nestedInput = buildFunnel(this.combinedStyles(addonTrees), { destDir: 'app/styles' });\n let styles = this.preprocessors.preprocessCss(nestedInput, '/app/styles', '/assets', options);\n\n return new AddToTree(styles, outputPath => {\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'public-assets': {},\n };\n let assetPath = join(outputPath, 'assets');\n if (pathExistsSync(assetPath)) {\n for (let file of walkSync(assetPath, { directories: false })) {\n addonMeta['public-assets']![`./assets/${file}`] = `/assets/${file}`;\n }\n }\n let meta: PackageInfo = {\n name: '@embroider/synthesized-styles',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n // this is taken nearly verbatim from ember-cli.\n private applyCustomTransforms(externalTree: BroccoliNode) {\n for (let customTransformEntry of this.legacyEmberAppInstance._customTransformsMap) {\n let transformName = customTransformEntry[0];\n let transformConfig = customTransformEntry[1];\n\n let transformTree = buildFunnel(externalTree, {\n files: transformConfig.files,\n annotation: `Funnel (custom transform: ${transformName})`,\n });\n\n externalTree = mergeTrees([externalTree, transformConfig.callback(transformTree, transformConfig.options)], {\n annotation: `TreeMerger (custom transform: ${transformName})`,\n overwrite: true,\n });\n }\n return externalTree;\n }\n\n private remapAsset(asset: string) {\n if (this.transformedNodeFiles().has(asset)) {\n // transformed node assets become local paths, because we have copied\n // those ones into our synthesized vendor package.\n return './' + asset;\n }\n let preresolved = this.preresolvedNodeFile(asset);\n if (preresolved) {\n // non-transformed node assets point directly at their pre-resolved\n // original files (this is an absolute path).\n return preresolved;\n }\n // non node assets are local paths. They need an explicit `/` or `.` at\n // the start.\n if (asset.startsWith('.') || isAbsolute(asset)) {\n return asset;\n }\n return './' + asset;\n }\n\n private preprocessJS(tree: BroccoliNode): BroccoliNode {\n // we're saving all our babel compilation for the final stage packager\n this.legacyEmberAppInstance.registry.remove('js', 'ember-cli-babel');\n\n // auto-import is supported natively so we don't need it here\n this.legacyEmberAppInstance.registry.remove('js', 'ember-auto-import-analyzer');\n\n tree = buildFunnel(tree, { destDir: this.name });\n\n tree = this.preprocessors.preprocessJs(tree, `/`, '/', {\n annotation: 'v1-app-preprocess-js',\n registry: this.legacyEmberAppInstance.registry,\n });\n\n tree = buildFunnel(tree, { srcDir: this.name });\n\n return tree;\n }\n\n get htmlbarsPlugins(): Transform[] {\n let plugins = loadAstPlugins(this.legacyEmberAppInstance.registry);\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n plugins = plugins.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n return plugins;\n }\n\n // our own appTree. Not to be confused with the one that combines the app js\n // from all addons too.\n private get appTree(): BroccoliNode {\n return this.preprocessJS(\n buildFunnel(this.legacyEmberAppInstance.trees.app, {\n exclude: ['styles/**', '*.html'],\n })\n );\n }\n\n private get testsTree(): BroccoliNode | undefined {\n if (this.shouldBuildTests && this.legacyEmberAppInstance.trees.tests) {\n return this.preprocessJS(\n buildFunnel(this.legacyEmberAppInstance.trees.tests, {\n destDir: 'tests',\n })\n );\n }\n }\n\n private get lintTree(): BroccoliNode | undefined {\n if (this.shouldBuildTests) {\n return this.legacyEmberAppInstance.getLintTests();\n }\n }\n\n private get vendorTree(): BroccoliNode | undefined {\n return this.ensureTree(this.legacyEmberAppInstance.trees.vendor);\n }\n\n private ensureTree(maybeTree: string | BroccoliNode | undefined): BroccoliNode | undefined {\n if (typeof maybeTree === 'string') {\n // this is deliberately mimicking how ember-cli does it. We don't use\n // `this.root` on purpose, because that can differ from what ember-cli\n // considers the project.root. And we don't use path.resolve even though\n // that seems possibly more correct, because ember-cli always assumes the\n // input is relative.\n let resolvedPath = join(this.legacyEmberAppInstance.project.root, maybeTree);\n if (existsSync(resolvedPath)) {\n return new WatchedDir(maybeTree);\n } else {\n return undefined;\n }\n }\n return maybeTree;\n }\n\n @Memoize()\n private get preprocessors(): Preprocessors {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n private get publicTree(): BroccoliNode | undefined {\n return this.ensureTree(this.legacyEmberAppInstance.trees.public);\n }\n\n private processAppJS(): { appJS: BroccoliNode } {\n let appTree = this.appTree;\n let testsTree = this.testsTree;\n let lintTree = this.lintTree;\n\n let trees: BroccoliNode[] = [];\n trees.push(appTree);\n\n if (testsTree) {\n trees.push(testsTree);\n }\n if (lintTree) {\n trees.push(lintTree);\n }\n return {\n appJS: mergeTrees(trees, { overwrite: true }),\n };\n }\n\n readonly macrosConfig: MacrosConfig;\n\n constructor(readonly legacyEmberAppInstance: EmberAppInstance, _options?: Options) {\n this.options = optionsWithDefaults(_options);\n\n this.macrosConfig = MacrosConfig.for(legacyEmberAppInstance, this.root);\n if (this.env !== 'production') {\n this.macrosConfig.enablePackageDevelopment(this.root);\n this.macrosConfig.enableRuntimeMode();\n if (this.isDummy) {\n // dummy apps automatically put their owning addon under development too\n this.macrosConfig.enablePackageDevelopment(\n dirname(pkgUpSync({ cwd: this.legacyEmberAppInstance.project.root })!)\n );\n }\n }\n\n // this uses globalConfig because it's a way for packages to ask \"is\n // Embroider doing this build?\". So it's necessarily global, not scoped to\n // any subgraph of dependencies.\n this.macrosConfig.setGlobalConfig(__filename, `@embroider/core`, {\n // this is hard-coded to true because it literally means \"embroider is\n // building this Ember app\". You can see non-true when using the Embroider\n // macros in a classic build.\n active: true,\n });\n }\n\n private inTrees(prevStageTree: BroccoliNode) {\n let publicTree = this.publicTree;\n let configTree = this.config;\n let contentForTree = this.contentFor;\n\n if (this.options.extraPublicTrees.length > 0) {\n publicTree = mergeTrees([publicTree, ...this.options.extraPublicTrees].filter(Boolean) as BroccoliNode[]);\n }\n\n return {\n appJS: this.processAppJS().appJS,\n htmlTree: this.htmlTree,\n publicTree,\n configTree,\n contentForTree,\n appBootTree: this.appBoot,\n prevStageTree,\n };\n }\n\n @Memoize()\n appPackage(): Package {\n // this is deliberately not RewrittenPackageCache, because it's supposed to\n // be the original copy of the app with all the original dependencies.\n let packageCache = PackageCache.shared('embroider', this.root);\n if (this.isDummy) {\n return new DummyPackage(\n this.root,\n this.legacyEmberAppInstance.project.root,\n packageCache as unknown as PackageCache // TODO: cast won't be needed when refactor is complete\n );\n } else {\n return packageCache.get(this.root);\n }\n }\n\n private async instantiate(\n root: string,\n packageCache: RewrittenPackageCache,\n configTree: V1Config,\n contentForTree: ContentForConfig\n ) {\n let origAppPkg = this.appPackage();\n let movedAppPkg = packageCache.withRewrittenDeps(origAppPkg);\n let workingDir = locateEmbroiderWorkingDir(this.root);\n return new CompatAppBuilder(\n root,\n origAppPkg,\n movedAppPkg,\n this.options,\n this,\n configTree,\n contentForTree,\n packageCache.get(join(workingDir, 'rewritten-packages', '@embroider', 'synthesized-vendor')),\n packageCache.get(join(workingDir, 'rewritten-packages', '@embroider', 'synthesized-styles'))\n );\n }\n\n asStage(prevStage: Stage): Stage {\n let resolve: (result: { outputPath: string }) => void;\n let promise: Promise<{ outputPath: string }> = new Promise(r => (resolve = r));\n\n let tree = () => {\n let inTrees = this.inTrees(prevStage.tree);\n return new WaitForTrees(inTrees, this.annotation, async treePaths => {\n if (!this.active) {\n let { outputPath } = await prevStage.ready();\n let packageCache = RewrittenPackageCache.shared('embroider', this.root);\n this.active = await this.instantiate(outputPath, packageCache, inTrees.configTree, inTrees.contentForTree);\n resolve({ outputPath });\n }\n await this.active.build(treePaths);\n });\n };\n\n return {\n get inputPath() {\n return prevStage.inputPath;\n },\n ready: async () => {\n return await promise;\n },\n get tree() {\n return tree();\n },\n };\n }\n}\n\ninterface Preprocessors {\n preprocessJs(tree: BroccoliNode, a: string, b: string, options: object): BroccoliNode;\n preprocessCss(tree: BroccoliNode, a: string, b: string, options: object): BroccoliNode;\n}\n"]}
1
+ {"version":3,"file":"compat-app.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BACX,OAAO,SAAS,CAAC,SAAS,CAAC;YAC7B,CAAC;YACD,KAAK,EAAE,KAAK,IAAI,EAAE;gBAChB,OAAO,MAAM,OAAO,CAAC;YACvB,CAAC;YACD,IAAI,IAAI;gBACN,OAAO,IAAI,EAAE,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAhxBD,4BAgxBC;AAnvBC;IADC,IAAA,4BAAO,GAAE;qCAQT;AAGD;IADC,IAAA,4BAAO,GAAE;iDAST;AAGD;IADC,IAAA,4BAAO,GAAE;kDAGT;AAoBD;IADC,IAAA,4BAAO,GAAE;+CAGT;AAGD;IADC,IAAA,4BAAO,GAAE;mDAGT;AAmBD;IADC,IAAA,4BAAO,GAAE;uCAGT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAKT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAWT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAcT;AAOD;IADC,IAAA,4BAAO,GAAE;sDAOT;AAkDD;IADC,IAAA,4BAAO,GAAE;4CA0DT;AAGD;IADC,IAAA,4BAAO,GAAE;kDAyBT;AAGO;IADP,IAAA,4BAAO,GAAE;qDAgBT;AA8UD;IADC,IAAA,4BAAO,GAAE;8CAGT;AA6ED;IADC,IAAA,4BAAO,GAAE;2CAcT","sourcesContent":["import type { Node as BroccoliNode } from 'broccoli-node-api';\nimport type { Stage, Package } from '@embroider/core';\nimport { PackageCache, WaitForTrees, RewrittenPackageCache, locateEmbroiderWorkingDir } from '@embroider/core';\nimport type Options from './options';\nimport { optionsWithDefaults } from './options';\nimport { Memoize } from 'typescript-memoize';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { join, dirname, isAbsolute, sep } from 'path';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { WatchedDir } from 'broccoli-source';\nimport resolve from 'resolve';\nimport ContentForConfig from './content-for-config';\nimport { V1Config } from './v1-config';\nimport { WriteV1AppBoot, ReadV1AppBoot } from './v1-appboot';\nimport type { AddonMeta, EmberAppInstance, OutputFileToInputFileMap, PackageInfo } from '@embroider/core';\nimport { writeJSONSync, ensureDirSync, copySync, pathExistsSync, existsSync, writeFileSync } from 'fs-extra';\nimport AddToTree from './add-to-tree';\nimport DummyPackage from './dummy-package';\nimport type { TransformOptions } from '@babel/core';\nimport { isEmbroiderMacrosPlugin, MacrosConfig } from '@embroider/macros/src/node';\nimport resolvePackagePath from 'resolve-package-path';\nimport Concat from 'broccoli-concat';\nimport mapKeys from 'lodash/mapKeys';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport { isEmberAutoImportDynamic, isInlinePrecompilePlugin } from './detect-babel-plugins';\nimport loadAstPlugins from './prepare-htmlbars-ast-plugins';\nimport { readFileSync } from 'fs';\nimport semver from 'semver';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport { CompatAppBuilder } from './compat-app-builder';\nimport walkSync from 'walk-sync';\n\ninterface Group {\n outputFiles: OutputFileToInputFileMap;\n implicitKey: '_implicitStyles' | '_implicitScripts';\n vendorOutputPath: 'string';\n}\n\n// This runs at broccoli-pipeline-construction time, whereas the\n// CompatAppBuilder instance only becomes available during tree-building time.\nexport default class CompatApp {\n private annotation = '@embroider/compat/app';\n private active: CompatAppBuilder | undefined;\n readonly options: Required<Options>;\n\n private _publicAssets: { [filePath: string]: string } = Object.create(null);\n private _implicitScripts: string[] = [];\n private _implicitStyles: string[] = [];\n\n private get isDummy(): boolean {\n return this.legacyEmberAppInstance.project.pkg.keywords?.includes('ember-addon') ?? false;\n }\n\n get name(): string {\n if (this.isDummy) {\n // here we accept the ember-cli behavior\n return this.legacyEmberAppInstance.name;\n } else {\n // always the name from package.json. Not the one that apps may have weirdly\n // customized.\n return this.legacyEmberAppInstance.project.pkg.name;\n }\n }\n\n get env(): string {\n return this.legacyEmberAppInstance.env;\n }\n\n @Memoize()\n get root(): string {\n if (this.isDummy) {\n // this is the Known Hack for finding the true root of the dummy app.\n return join(this.legacyEmberAppInstance.project.configPath(), '..', '..');\n } else {\n return dirname(pkgUpSync({ cwd: this.legacyEmberAppInstance.project.root })!);\n }\n }\n\n @Memoize()\n private get emberCLILocation() {\n const emberCLIPackage = resolvePackagePath('ember-cli', this.root);\n\n if (emberCLIPackage === null) {\n throw new Error(`Embroider: cannot resolve ember-cli's package.json`);\n }\n\n return dirname(emberCLIPackage);\n }\n\n @Memoize()\n get hasCompiledStyles() {\n return semver.gte(JSON.parse(readFileSync(`${this.emberCLILocation}/package.json`, 'utf8')).version, '3.18.0');\n }\n\n private requireFromEmberCLI(specifier: string) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve.sync(specifier, { basedir: this.emberCLILocation }));\n }\n\n private get configReplace() {\n return this.requireFromEmberCLI('broccoli-config-replace');\n }\n\n private get configLoader() {\n return this.requireFromEmberCLI('broccoli-config-loader');\n }\n\n private get appUtils() {\n return this.requireFromEmberCLI('./lib/utilities/ember-app-utils');\n }\n\n @Memoize()\n get addonTreeCache(): Map<string, BroccoliNode> {\n return new Map();\n }\n\n @Memoize()\n get preprocessRegistry() {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get shouldBuildTests(): boolean {\n return this.legacyEmberAppInstance.tests || false;\n }\n\n configPath(): string {\n return this.legacyEmberAppInstance.project.configPath();\n }\n\n private get configTree() {\n return new this.configLoader(dirname(this.configPath()), {\n env: this.legacyEmberAppInstance.env,\n tests: this.legacyEmberAppInstance.tests || false,\n project: this.legacyEmberAppInstance.project,\n });\n }\n\n @Memoize()\n private get config(): V1Config {\n return new V1Config(this.configTree, this.legacyEmberAppInstance.env);\n }\n\n @Memoize()\n get testConfig(): V1Config | undefined {\n if (this.shouldBuildTests) {\n return new V1Config(this.configTree, 'test');\n }\n }\n\n @Memoize()\n private get contentFor(): ContentForConfig {\n const configPaths = [\n { file: '/index.html', path: join('environments', `${this.legacyEmberAppInstance.env}.json`) },\n ];\n if (this.shouldBuildTests) configPaths.push({ file: '/tests/index.html', path: join('environments', `test.json`) });\n return new ContentForConfig(this.configTree, {\n availableContentForTypes: this.options.availableContentForTypes,\n configPaths,\n pattern: this.filteredPatternsByContentFor.contentFor,\n });\n }\n\n get autoRun(): boolean {\n return this.legacyEmberAppInstance.options.autoRun;\n }\n\n @Memoize()\n get appBoot(): ReadV1AppBoot {\n let env = this.legacyEmberAppInstance.env;\n let appBootContentTree = new WriteV1AppBoot();\n\n let patterns = this.configReplacePatterns;\n\n appBootContentTree = new this.configReplace(appBootContentTree, this.configTree, {\n configPath: join('environments', `${env}.json`),\n files: ['config/app-boot.js'],\n patterns,\n });\n\n return new ReadV1AppBoot(appBootContentTree);\n }\n\n private get storeConfigInMeta(): boolean {\n return this.legacyEmberAppInstance.options.storeConfigInMeta;\n }\n\n @Memoize()\n private get configReplacePatterns() {\n return this.appUtils.configReplacePatterns({\n addons: this.legacyEmberAppInstance.project.addons,\n autoRun: this.autoRun,\n storeConfigInMeta: this.storeConfigInMeta,\n });\n }\n\n private get filteredPatternsByContentFor() {\n const filter = '/{{content-for [\\'\"](.+?)[\"\\']}}/g';\n return {\n contentFor: this.configReplacePatterns.find((pattern: any) => filter.includes(pattern.match.toString())),\n others: this.configReplacePatterns.filter((pattern: any) => !filter.includes(pattern.match.toString())),\n };\n }\n\n private get htmlTree() {\n if (this.legacyEmberAppInstance.tests) {\n return mergeTrees([this.indexTree, this.testIndexTree]);\n } else {\n return this.indexTree;\n }\n }\n\n private get indexTree() {\n let indexFilePath = this.legacyEmberAppInstance.options.outputPaths.app.html;\n let index = buildFunnel(this.legacyEmberAppInstance.trees.app, {\n allowEmpty: true,\n include: [`index.html`],\n getDestinationPath: () => indexFilePath,\n annotation: 'app/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `${this.legacyEmberAppInstance.env}.json`),\n files: [indexFilePath],\n patterns: this.filteredPatternsByContentFor.others,\n annotation: 'ConfigReplace/indexTree',\n });\n }\n\n private get testIndexTree() {\n let index = buildFunnel(this.legacyEmberAppInstance.trees.tests, {\n allowEmpty: true,\n include: [`index.html`],\n destDir: 'tests',\n annotation: 'tests/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `test.json`),\n files: ['tests/index.html'],\n patterns: this.filteredPatternsByContentFor.others,\n annotation: 'ConfigReplace/testIndexTree',\n });\n }\n\n @Memoize()\n babelConfig(): TransformOptions {\n // this finds all the built-in babel configuration that comes with ember-cli-babel\n const babelAddon = (this.legacyEmberAppInstance.project as any).findAddonByName('ember-cli-babel');\n const babelConfig = babelAddon.buildBabelOptions({\n 'ember-cli-babel': {\n ...this.legacyEmberAppInstance.options['ember-cli-babel'],\n includeExternalHelpers: true,\n compileModules: false,\n disableDebugTooling: false,\n disablePresetEnv: false,\n disableEmberModulesAPIPolyfill: false,\n },\n });\n\n let plugins = babelConfig.plugins as any[];\n let presets = babelConfig.presets;\n\n // this finds any custom babel configuration that's on the app (either\n // because the app author explicitly added some, or because addons have\n // pushed plugins into it).\n let appBabel = this.legacyEmberAppInstance.options.babel;\n if (appBabel) {\n if (appBabel.plugins) {\n plugins = appBabel.plugins.concat(plugins);\n }\n if (appBabel.presets) {\n presets = appBabel.presets.concat(presets);\n }\n }\n\n plugins = plugins.filter(p => {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n return (\n !isEmbroiderMacrosPlugin(p) &&\n // similarly, if the app was already using an inline template compiler\n // babel plugin, we remove it here because we have our own\n // always-installed version of that (v2 addons are allowed to assume it\n // will be present in the final app build, the app doesn't get to turn\n // that off or configure it.)\n !isInlinePrecompilePlugin(p) &&\n !isEmberAutoImportDynamic(p)\n );\n });\n\n const config: TransformOptions = {\n babelrc: false,\n plugins,\n presets,\n // this is here because broccoli-middleware can't render a codeFrame full\n // of terminal codes. It would be nice to add something like\n // https://github.com/mmalecki/ansispan to broccoli-middleware so we can\n // leave color enabled.\n highlightCode: false,\n };\n\n return config;\n }\n\n @Memoize()\n babelMajorVersion(): 7 {\n let babelAddon = this.legacyEmberAppInstance.project.addons.find((a: any) => a.name === 'ember-cli-babel');\n if (babelAddon) {\n let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]);\n let babelMajor: number | undefined = babelAddonMajor;\n if (babelAddonMajor >= 8) {\n // `ember-cli-babel` v8 breaks lockstep with Babel, because it now\n // defines `@babel/core` as a peer dependency, so we need to check the\n // project's version of `@babel/core`:\n let babelVersion = this.legacyEmberAppInstance.project.pkg.devDependencies?.['@babel/core'];\n if (babelVersion) {\n babelMajor = semver.coerce(babelVersion)?.major;\n } else {\n babelMajor = 7;\n }\n }\n if (babelMajor !== 7) {\n throw new Error('`@embroider/compat` only supports apps and addons that use Babel v7.');\n }\n return babelMajor;\n }\n // if we didn't have our own babel plugin at all, it's safe to parse our\n // code with 7.\n return 7;\n }\n\n @Memoize()\n private transformedNodeFiles(): Map<string, string> {\n // any app.imports from node_modules that need custom transforms will need\n // to get copied into our own synthesized vendor package. app.imports from\n // node_modules that *don't* need custom transforms can just stay where they\n // are.\n let transformed = new Map();\n for (let transformConfig of this.legacyEmberAppInstance._customTransformsMap.values()) {\n for (let filename of transformConfig.files as string[]) {\n let preresolved = this.preresolvedNodeFile(filename);\n if (preresolved) {\n transformed.set(filename, preresolved);\n }\n }\n }\n return transformed;\n }\n\n private preresolvedNodeFile(filename: string) {\n // this regex is an exact copy of how ember-cli does this, so we align.\n let match = filename.match(/^node_modules\\/((@[^/]+\\/)?[^/]+)\\//);\n if (match) {\n // ember-cli has already done its own resolution of\n // `app.import('node_modules/something/...')`, so we go find its answer.\n for (let { name, path } of this.legacyEmberAppInstance._nodeModules.values()) {\n if (match[1] === name) {\n return filename.replace(match[0], path + sep);\n }\n }\n throw new Error(`bug: expected ember-cli to already have a resolved path for asset ${filename}`);\n }\n }\n\n private combinedVendor(addonTrees: BroccoliNode[]): BroccoliNode {\n let trees = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: 'vendor',\n destDir: 'vendor',\n })\n );\n if (this.vendorTree) {\n trees.push(\n buildFunnel(this.vendorTree, {\n destDir: 'vendor',\n })\n );\n }\n\n const tree = mergeTrees(trees, { overwrite: true });\n\n const outputGroups: Group[] = [\n // scripts\n {\n outputFiles: this.legacyEmberAppInstance._scriptOutputFiles,\n implicitKey: '_implicitScripts',\n vendorOutputPath: this.legacyEmberAppInstance.options.outputPaths.vendor.js,\n },\n // styles\n {\n outputFiles: this.legacyEmberAppInstance._styleOutputFiles,\n implicitKey: '_implicitStyles',\n vendorOutputPath: this.legacyEmberAppInstance.options.outputPaths.vendor.css,\n },\n ];\n\n const concatentations = [];\n\n // support: app.import / outputFile / using\n for (let entry of outputGroups) {\n const { outputFiles, implicitKey, vendorOutputPath } = entry;\n for (let importPath of Object.keys(outputFiles)) {\n const headerFiles = outputFiles[importPath];\n\n if (importPath === vendorOutputPath) {\n // these are the default ember-cli output files vendor.js or\n // vendor.css. Let embroider handle these.\n this[implicitKey] = headerFiles;\n } else if (headerFiles.length === 0) {\n // something went really wrong, open an issue\n throw new Error('Embroider: EWUT');\n } else if (headerFiles.length === 1) {\n // app.import(x, { outputFile: y }); where only one app.imports had this outputFile\n //\n // No concat needed. Simply serialize the remapping in the addon's\n // manifest, this ensures it is included in the final output with no extra work.\n this._publicAssets[headerFiles[0]] = importPath;\n } else {\n // app.import(x, { outputFile: y }); where multiple app.imports share one outputFile\n // Concat needed. Perform concat, and include the outputFile in the\n // addon's manifest. This ensures it is included in the final output\n this._publicAssets[importPath] = importPath;\n\n concatentations.push(\n new Concat(tree, {\n headerFiles,\n outputFile: importPath,\n annotation: `Package ${importPath}`,\n separator: '\\n;',\n sourceMapConfig: this.legacyEmberAppInstance.options['sourcemaps'],\n })\n );\n }\n }\n }\n\n this.addOtherAssets();\n return mergeTrees([tree, ...concatentations], { overwrite: true });\n }\n\n private addOtherAssets() {\n for (let asset of this.legacyEmberAppInstance.otherAssetPaths) {\n this._publicAssets[`${asset.src}/${asset.file}`] = `${asset.dest}/${asset.file}`;\n }\n }\n\n private addNodeAssets(inputTree: BroccoliNode): BroccoliNode {\n let transformedNodeFiles = this.transformedNodeFiles();\n\n return new AddToTree(inputTree, outputPath => {\n for (let [localDestPath, sourcePath] of transformedNodeFiles) {\n let destPath = join(outputPath, localDestPath);\n ensureDirSync(dirname(destPath));\n copySync(sourcePath, destPath);\n }\n\n if (this.shouldBuildTests) {\n writeFileSync(\n join(outputPath, 'testem.js'),\n `/*\n * This is dummy file that exists for the sole purpose\n * of allowing tests to run directly in the browser as\n * well as by Testem.\n *\n * Testem is configured to run tests directly against\n * the test build of index.html, which requires a\n * snippet to load the testem.js file:\n * <script src=\"/testem.js\"></script>\n * This has to go before the qunit framework and app\n * tests are loaded.\n *\n * Testem internally supplies this file. However, if you\n * run the tests directly in the browser (localhost:8000/tests),\n * this file does not exist.\n *\n * Hence the purpose of this fake file. This file is served\n * directly from the express server to satisify the script load.\n*/`\n );\n this._publicAssets['/testem.js'] = './testem.js';\n }\n\n let remapAsset = this.remapAsset.bind(this);\n\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'implicit-scripts': this._implicitScripts.map(remapAsset),\n 'implicit-styles': this._implicitStyles.map(remapAsset),\n 'implicit-test-scripts': this.legacyEmberAppInstance.legacyTestFilesToAppend.map(remapAsset),\n 'implicit-test-styles': this.legacyEmberAppInstance.vendorTestStaticStyles.map(remapAsset),\n 'public-assets': mapKeys(this._publicAssets, (_, key) => remapAsset(key)),\n };\n let meta: PackageInfo = {\n name: '@embroider/synthesized-vendor',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n synthesizeVendorPackage(addonTrees: BroccoliNode[]): BroccoliNode {\n return this.applyCustomTransforms(this.addNodeAssets(this.combinedVendor(addonTrees)));\n }\n\n private combinedStyles(addonTrees: BroccoliNode[]): BroccoliNode {\n let trees: BroccoliNode[] = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: '_app_styles_',\n })\n );\n let appStyles = this.legacyEmberAppInstance.trees.styles as BroccoliNode | undefined;\n if (appStyles) {\n // Workaround for https://github.com/ember-cli/ember-cli/issues/9020\n //\n // The default app styles tree is unwatched and relies on side effects\n // elsewhere in ember-cli's build pipeline to actually get rebuilds to\n // work. Here we need it to actually be watched properly if we want to\n // rely on it, particularly when using BROCCOLI_ENABLED_MEMOIZE.\n if ((appStyles as any)._watched === false && (appStyles as any)._directoryPath) {\n appStyles = new WatchedDir((appStyles as any)._directoryPath);\n }\n trees.push(appStyles);\n }\n return mergeTrees(trees, { overwrite: true, annotation: 'embroider-v1-app-combined-styles' });\n }\n\n synthesizeStylesPackage(addonTrees: BroccoliNode[]): BroccoliNode {\n let options = {\n // we're deliberately not allowing this to be customized. It's an\n // internal implementation detail, and respecting outputPaths here is\n // unnecessary complexity. The corresponding code that adjusts the HTML\n // <link> is in updateHTML in app.ts.\n outputPaths: { app: `/assets/${this.name}.css` },\n registry: this.legacyEmberAppInstance.registry,\n minifyCSS: this.legacyEmberAppInstance.options.minifyCSS.options,\n };\n\n let nestedInput = buildFunnel(this.combinedStyles(addonTrees), { destDir: 'app/styles' });\n let styles = this.preprocessors.preprocessCss(nestedInput, '/app/styles', '/assets', options);\n\n return new AddToTree(styles, outputPath => {\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'public-assets': {},\n };\n let assetPath = join(outputPath, 'assets');\n if (pathExistsSync(assetPath)) {\n for (let file of walkSync(assetPath, { directories: false })) {\n addonMeta['public-assets']![`./assets/${file}`] = `/assets/${file}`;\n }\n }\n let meta: PackageInfo = {\n name: '@embroider/synthesized-styles',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n // this is taken nearly verbatim from ember-cli.\n private applyCustomTransforms(externalTree: BroccoliNode) {\n for (let customTransformEntry of this.legacyEmberAppInstance._customTransformsMap) {\n let transformName = customTransformEntry[0];\n let transformConfig = customTransformEntry[1];\n\n let transformTree = buildFunnel(externalTree, {\n files: transformConfig.files,\n annotation: `Funnel (custom transform: ${transformName})`,\n });\n\n externalTree = mergeTrees([externalTree, transformConfig.callback(transformTree, transformConfig.options)], {\n annotation: `TreeMerger (custom transform: ${transformName})`,\n overwrite: true,\n });\n }\n return externalTree;\n }\n\n private remapAsset(asset: string) {\n if (this.transformedNodeFiles().has(asset)) {\n // transformed node assets become local paths, because we have copied\n // those ones into our synthesized vendor package.\n return './' + asset;\n }\n let preresolved = this.preresolvedNodeFile(asset);\n if (preresolved) {\n // non-transformed node assets point directly at their pre-resolved\n // original files (this is an absolute path).\n return preresolved;\n }\n // non node assets are local paths. They need an explicit `/` or `.` at\n // the start.\n if (asset.startsWith('.') || isAbsolute(asset)) {\n return asset;\n }\n return './' + asset;\n }\n\n private preprocessJS(tree: BroccoliNode): BroccoliNode {\n // we're saving all our babel compilation for the final stage packager\n this.legacyEmberAppInstance.registry.remove('js', 'ember-cli-babel');\n\n // auto-import is supported natively so we don't need it here\n this.legacyEmberAppInstance.registry.remove('js', 'ember-auto-import-analyzer');\n\n tree = buildFunnel(tree, { destDir: this.name });\n\n tree = this.preprocessors.preprocessJs(tree, `/`, '/', {\n annotation: 'v1-app-preprocess-js',\n registry: this.legacyEmberAppInstance.registry,\n });\n\n tree = buildFunnel(tree, { srcDir: this.name });\n\n return tree;\n }\n\n get htmlbarsPlugins(): Transform[] {\n let plugins = loadAstPlugins(this.legacyEmberAppInstance.registry);\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n plugins = plugins.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n return plugins;\n }\n\n // our own appTree. Not to be confused with the one that combines the app js\n // from all addons too.\n private get appTree(): BroccoliNode {\n return this.preprocessJS(\n buildFunnel(this.legacyEmberAppInstance.trees.app, {\n exclude: ['styles/**', '*.html'],\n })\n );\n }\n\n private get testsTree(): BroccoliNode | undefined {\n if (this.shouldBuildTests && this.legacyEmberAppInstance.trees.tests) {\n return this.preprocessJS(\n buildFunnel(this.legacyEmberAppInstance.trees.tests, {\n destDir: 'tests',\n })\n );\n }\n }\n\n private get lintTree(): BroccoliNode | undefined {\n if (this.shouldBuildTests) {\n return this.legacyEmberAppInstance.getLintTests();\n }\n }\n\n private get vendorTree(): BroccoliNode | undefined {\n return this.ensureTree(this.legacyEmberAppInstance.trees.vendor);\n }\n\n private ensureTree(maybeTree: string | BroccoliNode | undefined): BroccoliNode | undefined {\n if (typeof maybeTree === 'string') {\n // this is deliberately mimicking how ember-cli does it. We don't use\n // `this.root` on purpose, because that can differ from what ember-cli\n // considers the project.root. And we don't use path.resolve even though\n // that seems possibly more correct, because ember-cli always assumes the\n // input is relative.\n let resolvedPath = join(this.legacyEmberAppInstance.project.root, maybeTree);\n if (existsSync(resolvedPath)) {\n return new WatchedDir(maybeTree);\n } else {\n return undefined;\n }\n }\n return maybeTree;\n }\n\n @Memoize()\n private get preprocessors(): Preprocessors {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n private get publicTree(): BroccoliNode | undefined {\n return this.ensureTree(this.legacyEmberAppInstance.trees.public);\n }\n\n private processAppJS(): { appJS: BroccoliNode } {\n let appTree = this.appTree;\n let testsTree = this.testsTree;\n let lintTree = this.lintTree;\n\n let trees: BroccoliNode[] = [];\n trees.push(appTree);\n trees.push(\n new SynthesizeTemplateOnlyComponents(appTree, { allowedPaths: ['components'], templateExtensions: ['.hbs'] })\n );\n\n if (testsTree) {\n trees.push(testsTree);\n }\n if (lintTree) {\n trees.push(lintTree);\n }\n return {\n appJS: mergeTrees(trees, { overwrite: true }),\n };\n }\n\n readonly macrosConfig: MacrosConfig;\n\n constructor(readonly legacyEmberAppInstance: EmberAppInstance, _options?: Options) {\n this.options = optionsWithDefaults(_options);\n\n this.macrosConfig = MacrosConfig.for(legacyEmberAppInstance, this.root);\n if (this.env !== 'production') {\n this.macrosConfig.enablePackageDevelopment(this.root);\n this.macrosConfig.enableRuntimeMode();\n if (this.isDummy) {\n // dummy apps automatically put their owning addon under development too\n this.macrosConfig.enablePackageDevelopment(\n dirname(pkgUpSync({ cwd: this.legacyEmberAppInstance.project.root })!)\n );\n }\n }\n\n // this uses globalConfig because it's a way for packages to ask \"is\n // Embroider doing this build?\". So it's necessarily global, not scoped to\n // any subgraph of dependencies.\n this.macrosConfig.setGlobalConfig(__filename, `@embroider/core`, {\n // this is hard-coded to true because it literally means \"embroider is\n // building this Ember app\". You can see non-true when using the Embroider\n // macros in a classic build.\n active: true,\n });\n }\n\n private inTrees(prevStageTree: BroccoliNode) {\n let publicTree = this.publicTree;\n let configTree = this.config;\n let contentForTree = this.contentFor;\n\n if (this.options.extraPublicTrees.length > 0) {\n publicTree = mergeTrees([publicTree, ...this.options.extraPublicTrees].filter(Boolean) as BroccoliNode[]);\n }\n\n return {\n appJS: this.processAppJS().appJS,\n htmlTree: this.htmlTree,\n publicTree,\n configTree,\n contentForTree,\n appBootTree: this.appBoot,\n prevStageTree,\n };\n }\n\n @Memoize()\n appPackage(): Package {\n // this is deliberately not RewrittenPackageCache, because it's supposed to\n // be the original copy of the app with all the original dependencies.\n let packageCache = PackageCache.shared('embroider', this.root);\n if (this.isDummy) {\n return new DummyPackage(\n this.root,\n this.legacyEmberAppInstance.project.root,\n packageCache as unknown as PackageCache // TODO: cast won't be needed when refactor is complete\n );\n } else {\n return packageCache.get(this.root);\n }\n }\n\n private async instantiate(\n root: string,\n packageCache: RewrittenPackageCache,\n configTree: V1Config,\n contentForTree: ContentForConfig\n ) {\n let origAppPkg = this.appPackage();\n let movedAppPkg = packageCache.withRewrittenDeps(origAppPkg);\n let workingDir = locateEmbroiderWorkingDir(this.root);\n return new CompatAppBuilder(\n root,\n origAppPkg,\n movedAppPkg,\n this.options,\n this,\n configTree,\n contentForTree,\n packageCache.get(join(workingDir, 'rewritten-packages', '@embroider', 'synthesized-vendor')),\n packageCache.get(join(workingDir, 'rewritten-packages', '@embroider', 'synthesized-styles'))\n );\n }\n\n asStage(prevStage: Stage): Stage {\n let resolve: (result: { outputPath: string }) => void;\n let promise: Promise<{ outputPath: string }> = new Promise(r => (resolve = r));\n\n let tree = () => {\n let inTrees = this.inTrees(prevStage.tree);\n return new WaitForTrees(inTrees, this.annotation, async treePaths => {\n if (!this.active) {\n let { outputPath } = await prevStage.ready();\n let packageCache = RewrittenPackageCache.shared('embroider', this.root);\n this.active = await this.instantiate(outputPath, packageCache, inTrees.configTree, inTrees.contentForTree);\n resolve({ outputPath });\n }\n await this.active.build(treePaths);\n });\n };\n\n return {\n get inputPath() {\n return prevStage.inputPath;\n },\n ready: async () => {\n return await promise;\n },\n get tree() {\n return tree();\n },\n };\n }\n}\n\ninterface Preprocessors {\n preprocessJs(tree: BroccoliNode, a: string, b: string, options: object): BroccoliNode;\n preprocessCss(tree: BroccoliNode, a: string, b: string, options: object): BroccoliNode;\n}\n"]}