@embroider/compat 0.47.0 → 0.47.1

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": "0.47.0",
3
+ "version": "0.47.1",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
30
30
  "@babel/preset-env": "^7.14.5",
31
31
  "@babel/traverse": "^7.14.5",
32
- "@embroider/macros": "0.47.0",
33
- "@embroider/shared-internals": "0.47.0",
32
+ "@embroider/macros": "0.47.1",
33
+ "@embroider/shared-internals": "0.47.1",
34
34
  "@types/babel__code-frame": "^7.0.2",
35
35
  "@types/yargs": "^17.0.3",
36
36
  "assert-never": "^1.1.0",
@@ -85,7 +85,7 @@
85
85
  "typescript": "*"
86
86
  },
87
87
  "peerDependencies": {
88
- "@embroider/core": "0.47.0"
88
+ "@embroider/core": "0.47.1"
89
89
  },
90
90
  "engines": {
91
91
  "node": "12.* || 14.* || >= 16"
package/src/audit-cli.js CHANGED
File without changes
package/src/resolver.d.ts CHANGED
@@ -89,6 +89,7 @@ export default class CompatResolver implements Resolver {
89
89
  private get staticComponentsEnabled();
90
90
  private get staticHelpersEnabled();
91
91
  private tryHelper;
92
+ private _tryHelper;
92
93
  private get appPackage();
93
94
  private tryComponent;
94
95
  private _tryComponent;
package/src/resolver.js CHANGED
@@ -326,14 +326,29 @@ class CompatResolver {
326
326
  return this.params.options.staticHelpers || this.auditMode;
327
327
  }
328
328
  tryHelper(path, from) {
329
+ let parts = path.split('@');
330
+ if (parts.length > 1 && parts[0].length > 0) {
331
+ let cache = core_1.PackageCache.shared('embroider-stage3');
332
+ let packageName = parts[0];
333
+ let renamed = this.adjustImportsOptions.renamePackages[packageName];
334
+ if (renamed) {
335
+ packageName = renamed;
336
+ }
337
+ return this._tryHelper(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)));
338
+ }
339
+ else {
340
+ return this._tryHelper(path, from, this.appPackage);
341
+ }
342
+ }
343
+ _tryHelper(path, from, targetPackage) {
329
344
  for (let extension of this.adjustImportsOptions.resolvableExtensions) {
330
- let absPath = (0, path_1.join)(this.params.root, 'helpers', path) + extension;
345
+ let absPath = (0, path_1.join)(targetPackage.root, 'helpers', path) + extension;
331
346
  if ((0, fs_extra_1.pathExistsSync)(absPath)) {
332
347
  return {
333
348
  type: 'helper',
334
349
  modules: [
335
350
  {
336
- runtimeName: `${this.params.modulePrefix}/helpers/${path}`,
351
+ runtimeName: this.absPathToRuntimeName(absPath, targetPackage),
337
352
  path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
338
353
  absPath,
339
354
  },
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAO4B;AAC5B,0CAOyB;AACzB,+BAAoD;AAGpD,2DAA6C;AAG7C,yEAAuD;AACvD,6DAA6D;AAC7D,uCAA0C;AAC1C,sDAA8B;AAsC9B,0EAA0E;AAC1E,2BAA2B;AAC3B,MAAM,cAAc,GAAG;IACrB,kBAAkB;IAClB,aAAa;IACb,YAAY;IACZ,oBAAoB;IACpB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,QAAQ;IACR,UAAU;IACV,MAAM;IACN,SAAS;IACT,IAAI;IACJ,KAAK;IACL,WAAW;IACX,kBAAkB;IAClB,UAAU;IACV,gBAAgB;IAChB,MAAM;IACN,IAAI;IACJ,OAAO;IACP,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,SAAS;IACT,cAAc;IACd,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,MAAM;IACN,OAAO;CACR,CAAC;AAEF,MAAM,iBAAiB,G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C,SAAS,CAAC,IAAI,CAAC,EAAE;gBACrF,OAAO,IAAI,CAAC;aACb;YACD,OAAO,IAAI,CAAC,GAAG,CACb;gBACE,IAAI,EAAE,OAAO;gBACb,OAAO;gBACP,MAAM,EAAE,SAAS,CAAC,IAAI;gBACtB,GAAG;aACJ,EACD,IAAI,CACL,CAAC;SACH;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,GAAG,CACb;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,SAAS,CAAC,IAAI;YACtB,GAAG;SACJ,EACD,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AA5gBC;IADC,IAAA,4BAAO,GAAE;0DAOT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAoET;AAsHD;IADC,IAAA,4BAAO,GAAE;iEAGT;AAsDD;IADC,IAAA,4BAAO,GAAE;gDAGT;AA/TH,iCA+kBC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACvB,IAAI,IAAI,GAAG,CAAC;KACb;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n ActivePackageRules,\n ComponentRules,\n ModuleRules,\n PackageRules,\n PreprocessedComponentRule,\n preprocessComponentRule,\n} from './dependency-rules';\nimport {\n Package,\n PackageCache,\n Resolver,\n TemplateCompiler,\n explicitRelative,\n extensionsPattern,\n} from '@embroider/core';\nimport { dirname, join, relative, sep } from 'path';\n\nimport { Options as AdjustImportsOptions } from '@embroider/core/src/babel-plugin-adjust-imports';\nimport { Memoize } from 'typescript-memoize';\nimport Options from './options';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport { dasherize } from './dasherize-component-name';\nimport { makeResolverTransform } from './resolver-transform';\nimport { pathExistsSync } from 'fs-extra';\nimport resolve from 'resolve';\nimport type { ASTv1 } from '@glimmer/syntax';\n\nexport interface ComponentResolution {\n type: 'component';\n modules: ResolvedDep[];\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n}\n\nexport interface HelperResolution {\n type: 'helper';\n modules: ResolvedDep[];\n}\n\nexport type ResolutionResult = ComponentResolution | HelperResolution;\n\nexport interface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ninterface ResolverDependencyError extends Error {\n isTemplateResolverError?: boolean;\n loc?: Loc;\n moduleName?: string;\n}\n\nexport type Resolution = ResolutionResult | ResolutionFail;\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\n// TODO: this depends on the ember version. And it's probably missing some\n// private-but-used values.\nconst builtInHelpers = [\n '-get-dynamic-var',\n '-in-element',\n 'in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each',\n 'each-in',\n 'fn',\n 'get',\n 'has-block',\n 'has-block-params',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'if',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unless',\n 'with',\n 'yield',\n];\n\nconst builtInComponents = ['input', 'link-to', 'textarea'];\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;\n\nfunction extractOptions(options: Required<Options> | ResolverOptions): ResolverOptions {\n return {\n staticHelpers: options.staticHelpers,\n staticComponents: options.staticComponents,\n allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,\n };\n}\n\ninterface RehydrationParamsBase {\n root: string;\n modulePrefix: string;\n podModulePrefix?: string;\n options: ResolverOptions;\n activePackageRules: ActivePackageRules[];\n}\n\ninterface RehydrationParamsWithFile extends RehydrationParamsBase {\n adjustImportsOptionsPath: string;\n}\n\ninterface RehydrationParamsWithOptions extends RehydrationParamsBase {\n adjustImportsOptions: AdjustImportsOptions;\n}\n\ntype RehydrationParams = RehydrationParamsWithFile | RehydrationParamsWithOptions;\n\nexport function rehydrate(params: RehydrationParams) {\n return new CompatResolver(params);\n}\n\nexport default class CompatResolver implements Resolver {\n private dependencies: Map<string, Resolution[]> = new Map();\n private templateCompiler: TemplateCompiler | undefined;\n private auditMode = false;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: RehydrationParams;\n };\n\n constructor(private params: RehydrationParams) {\n this.params.options = extractOptions(this.params.options);\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'rehydrate',\n params,\n };\n }\n\n enter(moduleName: string) {\n let rules = this.findComponentRules(moduleName);\n let deps: Resolution[];\n if (rules?.dependsOnComponents) {\n deps = rules.dependsOnComponents.map(snippet => this.resolveComponentSnippet(snippet, rules!, moduleName));\n } else {\n deps = [];\n }\n this.dependencies.set(moduleName, deps);\n }\n\n private add(resolution: Resolution, from: string) {\n // this \"!\" is safe because we always `enter()` a module before hitting this\n this.dependencies.get(from)!.push(resolution);\n return resolution;\n }\n\n private findComponentRules(absPath: string): PreprocessedComponentRule | undefined {\n let rules = this.rules.components.get(absPath);\n if (rules) {\n return rules;\n }\n\n // co-located templates aren't visible to the resolver, because they never\n // get resolved from a template (they are always handled directly by the\n // corresponding JS module, which the resolver *does* see). This means their\n // paths won't ever be in `this.rules.components`. But we do want them to\n // \"inherit\" the rules that are attached to their corresonding JS module.\n if (absPath.endsWith('.hbs')) {\n let stem = absPath.slice(0, -4);\n for (let ext of this.adjustImportsOptions.resolvableExtensions) {\n if (ext !== '.hbs') {\n let rules = this.rules.components.get(stem + ext);\n if (rules) {\n return rules;\n }\n }\n }\n }\n return undefined;\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.ignoredComponents.includes(dasherizedName);\n }\n\n @Memoize()\n get adjustImportsOptions(): AdjustImportsOptions {\n const { params } = this;\n return 'adjustImportsOptionsPath' in params\n ? // eslint-disable-next-line @typescript-eslint/no-require-imports\n require(params.adjustImportsOptionsPath)\n : params.adjustImportsOptions;\n }\n\n @Memoize()\n private get rules() {\n if (!this.templateCompiler) {\n throw new Error(\n `Bug: Resolver needs to get linked into a TemplateCompiler before it can understand packageRules`\n );\n }\n\n // keyed by their first resolved dependency's runtimeName.\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // keyed by our own dasherized interpretation of the component's name.\n let ignoredComponents: string[] = [];\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.params.activePackageRules) {\n if (rule.components) {\n for (let [snippet, componentRules] of Object.entries(rule.components)) {\n if (componentRules.safeToIgnore) {\n ignoredComponents.push(this.standardDasherize(snippet, rule));\n continue;\n }\n let resolvedDep = this.resolveComponentSnippet(snippet, rule).modules[0];\n let processedRules = preprocessComponentRule(componentRules);\n\n // we always register our rules on the component's own first resolved\n // module, which must be a module in the app's module namespace.\n components.set(resolvedDep.absPath, processedRules);\n\n // if there's a custom layout, we also need to register our rules on\n // those templates.\n if (componentRules.layout) {\n if (componentRules.layout.appPath) {\n components.set(join(this.params.root, componentRules.layout.appPath), processedRules);\n } else if (componentRules.layout.addonPath) {\n for (let root of rule.roots) {\n components.set(join(root, componentRules.layout.addonPath), processedRules);\n }\n } else {\n throw new Error(\n `layout property in component rule must contain either appPath or addonPath: ${JSON.stringify(\n rule,\n null,\n 2\n )}`\n );\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n components.set(join(this.params.root, path), processedRules);\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n components.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { components, ignoredComponents };\n }\n\n resolveComponentSnippet(\n snippet: string,\n rule: PackageRules | ModuleRules,\n from = 'rule-snippet.hbs'\n ): ResolutionResult & { type: 'component' } {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let name = this.standardDasherize(snippet, rule);\n let found = this.tryComponent(name, from, false);\n if (found && found.type === 'component') {\n return found;\n }\n throw new Error(`unable to locate component ${snippet} referred to in rule ${JSON.stringify(rule, null, 2)}`);\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let ast: ASTv1.Template | ASTv1.Program;\n try {\n ast = this.templateCompiler.parse('snippet.hbs', snippet) as unknown as ASTv1.Template | ASTv1.Program;\n } catch (err) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n if ((ast.type === 'Program' || ast.type === 'Template') && ast.body.length > 0) {\n let first = ast.body[0];\n const isMustachePath = first.type === 'MustacheStatement' && first.path.type === 'PathExpression';\n const isComponent =\n isMustachePath && ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original === 'component';\n const hasStringParam =\n isComponent &&\n Array.isArray((first as ASTv1.MustacheStatement).params) &&\n (first as ASTv1.MustacheStatement).params[0].type === 'StringLiteral';\n if (isMustachePath && isComponent && hasStringParam) {\n return ((first as ASTv1.MustacheStatement).params[0] as ASTv1.StringLiteral).value;\n }\n if (isMustachePath) {\n return ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original;\n }\n if (first.type === 'ElementNode') {\n return dasherize(first.tag);\n }\n }\n throw new Error(`cannot identify a component in rule snippet: \"${snippet}\"`);\n }\n\n astTransformer(templateCompiler: TemplateCompiler): unknown {\n this.templateCompiler = templateCompiler;\n if (this.staticComponentsEnabled || this.staticHelpersEnabled) {\n return makeResolverTransform(this);\n }\n }\n\n // called by our audit tool. Forces staticComponents and staticHelpers to\n // activate so we can audit their behavior, while making their errors silent\n // until we can gather them up at the end of the build for the audit results.\n enableAuditMode() {\n this.auditMode = true;\n }\n\n errorsIn(moduleName: string): ResolutionFail[] {\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n return deps.filter(d => d.type === 'error') as ResolutionFail[];\n } else {\n return [];\n }\n }\n\n dependenciesOf(moduleName: string): ResolvedDep[] {\n let flatDeps: Map<string, ResolvedDep> = new Map();\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n for (let dep of deps) {\n if (dep.type === 'error') {\n if (!this.auditMode && !this.params.options.allowUnsafeDynamicComponents) {\n let e: ResolverDependencyError = new Error(\n `${dep.message}: ${dep.detail} in ${humanReadableFile(this.params.root, moduleName)}`\n );\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = moduleName;\n throw e;\n }\n } else {\n for (let entry of dep.modules) {\n let { runtimeName } = entry;\n flatDeps.set(runtimeName, entry);\n }\n }\n }\n }\n return [...flatDeps.values()];\n }\n\n resolveImport(path: string, from: string): { runtimeName: string; absPath: string } | undefined {\n let absPath;\n try {\n absPath = resolve.sync(path, {\n basedir: dirname(from),\n extensions: this.adjustImportsOptions.resolvableExtensions,\n });\n } catch (err) {\n return;\n }\n if (absPath) {\n let runtimeName = this.absPathToRuntimeName(absPath);\n if (runtimeName) {\n return { runtimeName, absPath };\n }\n }\n }\n\n @Memoize()\n private get resolvableExtensionsPattern() {\n return extensionsPattern(this.adjustImportsOptions.resolvableExtensions);\n }\n\n absPathToRuntimePath(absPath: string, owningPackage?: { root: string; name: string }) {\n let pkg = owningPackage || PackageCache.shared('embroider-stage3').ownerOfFile(absPath);\n if (pkg) {\n let packageRuntimeName = pkg.name;\n for (let [runtimeName, realName] of Object.entries(this.adjustImportsOptions.renamePackages)) {\n if (realName === packageRuntimeName) {\n packageRuntimeName = runtimeName;\n break;\n }\n }\n return join(packageRuntimeName, relative(pkg.root, absPath)).split(sep).join('/');\n } else if (absPath.startsWith(this.params.root)) {\n return join(this.params.modulePrefix, relative(this.params.root, absPath)).split(sep).join('/');\n } else {\n throw new Error(`bug: can't figure out the runtime name for ${absPath}`);\n }\n }\n\n absPathToRuntimeName(absPath: string, owningPackage?: { root: string; name: string }) {\n return this.absPathToRuntimePath(absPath, owningPackage)\n .replace(this.resolvableExtensionsPattern, '')\n .replace(/\\/index$/, '');\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.params.options.staticComponents || this.auditMode;\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.params.options.staticHelpers || this.auditMode;\n }\n\n private tryHelper(path: string, from: string): Resolution | null {\n for (let extension of this.adjustImportsOptions.resolvableExtensions) {\n let absPath = join(this.params.root, 'helpers', path) + extension;\n if (pathExistsSync(absPath)) {\n return {\n type: 'helper',\n modules: [\n {\n runtimeName: `${this.params.modulePrefix}/helpers/${path}`,\n path: explicitRelative(dirname(from), absPath),\n absPath,\n },\n ],\n };\n }\n }\n return null;\n }\n\n @Memoize()\n private get appPackage(): AppPackagePlaceholder {\n return { root: this.params.root, name: this.params.modulePrefix };\n }\n\n private tryComponent(path: string, from: string, withRuleLookup = true): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryComponent(parts[1], from, withRuleLookup, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryComponent(path, from, withRuleLookup, this.appPackage);\n }\n }\n\n private _tryComponent(\n path: string,\n from: string,\n withRuleLookup: boolean,\n targetPackage: Package | AppPackagePlaceholder\n ): Resolution | null {\n // The order here is important! We always put our .hbs paths first here, so\n // that if we have an hbs file of our own, that will be the first resolved\n // dependency. The first resolved dependency is special because we use that\n // as a key into the rules, and we want to be able to find our rules when\n // checking from our own template (among other times).\n\n let extensions = ['.hbs', ...this.adjustImportsOptions.resolvableExtensions.filter((e: string) => e !== '.hbs')];\n\n let componentModules = [] as string[];\n\n // first, the various places our template might be\n for (let extension of extensions) {\n let absPath = join(targetPackage.root, 'templates', 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n // then the various places our javascript might be\n for (let extension of extensions) {\n if (extension === '.hbs') {\n continue;\n }\n\n let absPath = join(targetPackage.root, 'components', path, 'index') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n if (componentModules.length > 0) {\n let componentRules;\n if (withRuleLookup) {\n componentRules = this.findComponentRules(componentModules[0]);\n }\n return {\n type: 'component',\n modules: componentModules.map(absPath => ({\n path: explicitRelative(dirname(from), absPath),\n absPath,\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n })),\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n };\n }\n\n return null;\n }\n\n resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n if (builtInHelpers.includes(path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message: `Missing helper`,\n detail: path,\n loc,\n },\n from\n );\n }\n\n resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null {\n if (this.staticHelpersEnabled) {\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (this.staticComponentsEnabled) {\n let found = this.tryComponent(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (\n hasArgs &&\n this.staticComponentsEnabled &&\n this.staticHelpersEnabled &&\n !builtInHelpers.includes(path) &&\n !this.isIgnoredComponent(path)\n ) {\n return this.add(\n {\n type: 'error',\n message: `Missing component or helper`,\n detail: path,\n loc,\n },\n from\n );\n } else {\n return null;\n }\n }\n\n resolveElement(tagName: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n if (tagName[0] === tagName[0].toLowerCase()) {\n // starts with lower case, so this can't be a component we need to\n // globally resolve\n return null;\n }\n\n let dName = dasherize(tagName);\n\n if (builtInComponents.includes(dName)) {\n return null;\n }\n\n let found = this.tryComponent(dName, from);\n if (found) {\n return this.add(found, from);\n }\n\n if (this.isIgnoredComponent(dName)) {\n return null;\n }\n\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: tagName,\n loc,\n },\n from\n );\n }\n\n resolveComponentHelper(\n component: ComponentLocator,\n from: string,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return this.add(\n {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n },\n from\n );\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findComponentRules(from);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message,\n detail: component.path,\n loc,\n },\n from\n );\n }\n let found = this.tryComponent(component.path, from);\n if (found) {\n return this.add(found, from);\n }\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: component.path,\n loc,\n },\n from\n );\n }\n}\n\nfunction humanReadableFile(root: string, file: string) {\n if (!root.endsWith('/')) {\n root += '/';\n }\n if (file.startsWith(root)) {\n return file.slice(root.length);\n }\n return file;\n}\n\n// we don't have a real Package for the app itself because the resolver has work\n// to do before we have even written out the app's own package.json and\n// therefore made it into a fully functional Package.\ninterface AppPackagePlaceholder {\n root: string;\n name: string;\n}\n\nexport type ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n"]}
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAO4B;AAC5B,0CAOyB;AACzB,+BAAoD;AAGpD,2DAA6C;AAG7C,yEAAuD;AACvD,6D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C;YACtD,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBACrF,OAAO,IAAI,CAAC;aACb;YACD,OAAO,IAAI,CAAC,GAAG,CACb;gBACE,IAAI,EAAE,OAAO;gBACb,OAAO;gBACP,MAAM,EAAE,SAAS,CAAC,IAAI;gBACtB,GAAG;aACJ,EACD,IAAI,CACL,CAAC;SACH;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,GAAG,CACb;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,SAAS,CAAC,IAAI;YACtB,GAAG;SACJ,EACD,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AA3hBC;IADC,IAAA,4BAAO,GAAE;0DAOT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAoET;AAsHD;IADC,IAAA,4BAAO,GAAE;iEAGT;AAqED;IADC,IAAA,4BAAO,GAAE;gDAGT;AA9UH,iCA8lBC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACvB,IAAI,IAAI,GAAG,CAAC;KACb;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n ActivePackageRules,\n ComponentRules,\n ModuleRules,\n PackageRules,\n PreprocessedComponentRule,\n preprocessComponentRule,\n} from './dependency-rules';\nimport {\n Package,\n PackageCache,\n Resolver,\n TemplateCompiler,\n explicitRelative,\n extensionsPattern,\n} from '@embroider/core';\nimport { dirname, join, relative, sep } from 'path';\n\nimport { Options as AdjustImportsOptions } from '@embroider/core/src/babel-plugin-adjust-imports';\nimport { Memoize } from 'typescript-memoize';\nimport Options from './options';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport { dasherize } from './dasherize-component-name';\nimport { makeResolverTransform } from './resolver-transform';\nimport { pathExistsSync } from 'fs-extra';\nimport resolve from 'resolve';\nimport type { ASTv1 } from '@glimmer/syntax';\n\nexport interface ComponentResolution {\n type: 'component';\n modules: ResolvedDep[];\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n}\n\nexport interface HelperResolution {\n type: 'helper';\n modules: ResolvedDep[];\n}\n\nexport type ResolutionResult = ComponentResolution | HelperResolution;\n\nexport interface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ninterface ResolverDependencyError extends Error {\n isTemplateResolverError?: boolean;\n loc?: Loc;\n moduleName?: string;\n}\n\nexport type Resolution = ResolutionResult | ResolutionFail;\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\n// TODO: this depends on the ember version. And it's probably missing some\n// private-but-used values.\nconst builtInHelpers = [\n '-get-dynamic-var',\n '-in-element',\n 'in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each',\n 'each-in',\n 'fn',\n 'get',\n 'has-block',\n 'has-block-params',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'if',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unless',\n 'with',\n 'yield',\n];\n\nconst builtInComponents = ['input', 'link-to', 'textarea'];\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;\n\nfunction extractOptions(options: Required<Options> | ResolverOptions): ResolverOptions {\n return {\n staticHelpers: options.staticHelpers,\n staticComponents: options.staticComponents,\n allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,\n };\n}\n\ninterface RehydrationParamsBase {\n root: string;\n modulePrefix: string;\n podModulePrefix?: string;\n options: ResolverOptions;\n activePackageRules: ActivePackageRules[];\n}\n\ninterface RehydrationParamsWithFile extends RehydrationParamsBase {\n adjustImportsOptionsPath: string;\n}\n\ninterface RehydrationParamsWithOptions extends RehydrationParamsBase {\n adjustImportsOptions: AdjustImportsOptions;\n}\n\ntype RehydrationParams = RehydrationParamsWithFile | RehydrationParamsWithOptions;\n\nexport function rehydrate(params: RehydrationParams) {\n return new CompatResolver(params);\n}\n\nexport default class CompatResolver implements Resolver {\n private dependencies: Map<string, Resolution[]> = new Map();\n private templateCompiler: TemplateCompiler | undefined;\n private auditMode = false;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: RehydrationParams;\n };\n\n constructor(private params: RehydrationParams) {\n this.params.options = extractOptions(this.params.options);\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'rehydrate',\n params,\n };\n }\n\n enter(moduleName: string) {\n let rules = this.findComponentRules(moduleName);\n let deps: Resolution[];\n if (rules?.dependsOnComponents) {\n deps = rules.dependsOnComponents.map(snippet => this.resolveComponentSnippet(snippet, rules!, moduleName));\n } else {\n deps = [];\n }\n this.dependencies.set(moduleName, deps);\n }\n\n private add(resolution: Resolution, from: string) {\n // this \"!\" is safe because we always `enter()` a module before hitting this\n this.dependencies.get(from)!.push(resolution);\n return resolution;\n }\n\n private findComponentRules(absPath: string): PreprocessedComponentRule | undefined {\n let rules = this.rules.components.get(absPath);\n if (rules) {\n return rules;\n }\n\n // co-located templates aren't visible to the resolver, because they never\n // get resolved from a template (they are always handled directly by the\n // corresponding JS module, which the resolver *does* see). This means their\n // paths won't ever be in `this.rules.components`. But we do want them to\n // \"inherit\" the rules that are attached to their corresonding JS module.\n if (absPath.endsWith('.hbs')) {\n let stem = absPath.slice(0, -4);\n for (let ext of this.adjustImportsOptions.resolvableExtensions) {\n if (ext !== '.hbs') {\n let rules = this.rules.components.get(stem + ext);\n if (rules) {\n return rules;\n }\n }\n }\n }\n return undefined;\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.ignoredComponents.includes(dasherizedName);\n }\n\n @Memoize()\n get adjustImportsOptions(): AdjustImportsOptions {\n const { params } = this;\n return 'adjustImportsOptionsPath' in params\n ? // eslint-disable-next-line @typescript-eslint/no-require-imports\n require(params.adjustImportsOptionsPath)\n : params.adjustImportsOptions;\n }\n\n @Memoize()\n private get rules() {\n if (!this.templateCompiler) {\n throw new Error(\n `Bug: Resolver needs to get linked into a TemplateCompiler before it can understand packageRules`\n );\n }\n\n // keyed by their first resolved dependency's runtimeName.\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // keyed by our own dasherized interpretation of the component's name.\n let ignoredComponents: string[] = [];\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.params.activePackageRules) {\n if (rule.components) {\n for (let [snippet, componentRules] of Object.entries(rule.components)) {\n if (componentRules.safeToIgnore) {\n ignoredComponents.push(this.standardDasherize(snippet, rule));\n continue;\n }\n let resolvedDep = this.resolveComponentSnippet(snippet, rule).modules[0];\n let processedRules = preprocessComponentRule(componentRules);\n\n // we always register our rules on the component's own first resolved\n // module, which must be a module in the app's module namespace.\n components.set(resolvedDep.absPath, processedRules);\n\n // if there's a custom layout, we also need to register our rules on\n // those templates.\n if (componentRules.layout) {\n if (componentRules.layout.appPath) {\n components.set(join(this.params.root, componentRules.layout.appPath), processedRules);\n } else if (componentRules.layout.addonPath) {\n for (let root of rule.roots) {\n components.set(join(root, componentRules.layout.addonPath), processedRules);\n }\n } else {\n throw new Error(\n `layout property in component rule must contain either appPath or addonPath: ${JSON.stringify(\n rule,\n null,\n 2\n )}`\n );\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n components.set(join(this.params.root, path), processedRules);\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n components.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { components, ignoredComponents };\n }\n\n resolveComponentSnippet(\n snippet: string,\n rule: PackageRules | ModuleRules,\n from = 'rule-snippet.hbs'\n ): ResolutionResult & { type: 'component' } {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let name = this.standardDasherize(snippet, rule);\n let found = this.tryComponent(name, from, false);\n if (found && found.type === 'component') {\n return found;\n }\n throw new Error(`unable to locate component ${snippet} referred to in rule ${JSON.stringify(rule, null, 2)}`);\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let ast: ASTv1.Template | ASTv1.Program;\n try {\n ast = this.templateCompiler.parse('snippet.hbs', snippet) as unknown as ASTv1.Template | ASTv1.Program;\n } catch (err) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n if ((ast.type === 'Program' || ast.type === 'Template') && ast.body.length > 0) {\n let first = ast.body[0];\n const isMustachePath = first.type === 'MustacheStatement' && first.path.type === 'PathExpression';\n const isComponent =\n isMustachePath && ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original === 'component';\n const hasStringParam =\n isComponent &&\n Array.isArray((first as ASTv1.MustacheStatement).params) &&\n (first as ASTv1.MustacheStatement).params[0].type === 'StringLiteral';\n if (isMustachePath && isComponent && hasStringParam) {\n return ((first as ASTv1.MustacheStatement).params[0] as ASTv1.StringLiteral).value;\n }\n if (isMustachePath) {\n return ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original;\n }\n if (first.type === 'ElementNode') {\n return dasherize(first.tag);\n }\n }\n throw new Error(`cannot identify a component in rule snippet: \"${snippet}\"`);\n }\n\n astTransformer(templateCompiler: TemplateCompiler): unknown {\n this.templateCompiler = templateCompiler;\n if (this.staticComponentsEnabled || this.staticHelpersEnabled) {\n return makeResolverTransform(this);\n }\n }\n\n // called by our audit tool. Forces staticComponents and staticHelpers to\n // activate so we can audit their behavior, while making their errors silent\n // until we can gather them up at the end of the build for the audit results.\n enableAuditMode() {\n this.auditMode = true;\n }\n\n errorsIn(moduleName: string): ResolutionFail[] {\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n return deps.filter(d => d.type === 'error') as ResolutionFail[];\n } else {\n return [];\n }\n }\n\n dependenciesOf(moduleName: string): ResolvedDep[] {\n let flatDeps: Map<string, ResolvedDep> = new Map();\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n for (let dep of deps) {\n if (dep.type === 'error') {\n if (!this.auditMode && !this.params.options.allowUnsafeDynamicComponents) {\n let e: ResolverDependencyError = new Error(\n `${dep.message}: ${dep.detail} in ${humanReadableFile(this.params.root, moduleName)}`\n );\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = moduleName;\n throw e;\n }\n } else {\n for (let entry of dep.modules) {\n let { runtimeName } = entry;\n flatDeps.set(runtimeName, entry);\n }\n }\n }\n }\n return [...flatDeps.values()];\n }\n\n resolveImport(path: string, from: string): { runtimeName: string; absPath: string } | undefined {\n let absPath;\n try {\n absPath = resolve.sync(path, {\n basedir: dirname(from),\n extensions: this.adjustImportsOptions.resolvableExtensions,\n });\n } catch (err) {\n return;\n }\n if (absPath) {\n let runtimeName = this.absPathToRuntimeName(absPath);\n if (runtimeName) {\n return { runtimeName, absPath };\n }\n }\n }\n\n @Memoize()\n private get resolvableExtensionsPattern() {\n return extensionsPattern(this.adjustImportsOptions.resolvableExtensions);\n }\n\n absPathToRuntimePath(absPath: string, owningPackage?: { root: string; name: string }) {\n let pkg = owningPackage || PackageCache.shared('embroider-stage3').ownerOfFile(absPath);\n if (pkg) {\n let packageRuntimeName = pkg.name;\n for (let [runtimeName, realName] of Object.entries(this.adjustImportsOptions.renamePackages)) {\n if (realName === packageRuntimeName) {\n packageRuntimeName = runtimeName;\n break;\n }\n }\n return join(packageRuntimeName, relative(pkg.root, absPath)).split(sep).join('/');\n } else if (absPath.startsWith(this.params.root)) {\n return join(this.params.modulePrefix, relative(this.params.root, absPath)).split(sep).join('/');\n } else {\n throw new Error(`bug: can't figure out the runtime name for ${absPath}`);\n }\n }\n\n absPathToRuntimeName(absPath: string, owningPackage?: { root: string; name: string }) {\n return this.absPathToRuntimePath(absPath, owningPackage)\n .replace(this.resolvableExtensionsPattern, '')\n .replace(/\\/index$/, '');\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.params.options.staticComponents || this.auditMode;\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.params.options.staticHelpers || this.auditMode;\n }\n\n private tryHelper(path: string, from: string): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryHelper(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryHelper(path, from, this.appPackage);\n }\n }\n\n private _tryHelper(path: string, from: string, targetPackage: Package | AppPackagePlaceholder): Resolution | null {\n for (let extension of this.adjustImportsOptions.resolvableExtensions) {\n let absPath = join(targetPackage.root, 'helpers', path) + extension;\n if (pathExistsSync(absPath)) {\n return {\n type: 'helper',\n modules: [\n {\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n path: explicitRelative(dirname(from), absPath),\n absPath,\n },\n ],\n };\n }\n }\n return null;\n }\n\n @Memoize()\n private get appPackage(): AppPackagePlaceholder {\n return { root: this.params.root, name: this.params.modulePrefix };\n }\n\n private tryComponent(path: string, from: string, withRuleLookup = true): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryComponent(parts[1], from, withRuleLookup, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryComponent(path, from, withRuleLookup, this.appPackage);\n }\n }\n\n private _tryComponent(\n path: string,\n from: string,\n withRuleLookup: boolean,\n targetPackage: Package | AppPackagePlaceholder\n ): Resolution | null {\n // The order here is important! We always put our .hbs paths first here, so\n // that if we have an hbs file of our own, that will be the first resolved\n // dependency. The first resolved dependency is special because we use that\n // as a key into the rules, and we want to be able to find our rules when\n // checking from our own template (among other times).\n\n let extensions = ['.hbs', ...this.adjustImportsOptions.resolvableExtensions.filter((e: string) => e !== '.hbs')];\n\n let componentModules = [] as string[];\n\n // first, the various places our template might be\n for (let extension of extensions) {\n let absPath = join(targetPackage.root, 'templates', 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n // then the various places our javascript might be\n for (let extension of extensions) {\n if (extension === '.hbs') {\n continue;\n }\n\n let absPath = join(targetPackage.root, 'components', path, 'index') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n if (componentModules.length > 0) {\n let componentRules;\n if (withRuleLookup) {\n componentRules = this.findComponentRules(componentModules[0]);\n }\n return {\n type: 'component',\n modules: componentModules.map(absPath => ({\n path: explicitRelative(dirname(from), absPath),\n absPath,\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n })),\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n };\n }\n\n return null;\n }\n\n resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n if (builtInHelpers.includes(path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message: `Missing helper`,\n detail: path,\n loc,\n },\n from\n );\n }\n\n resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null {\n if (this.staticHelpersEnabled) {\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (this.staticComponentsEnabled) {\n let found = this.tryComponent(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (\n hasArgs &&\n this.staticComponentsEnabled &&\n this.staticHelpersEnabled &&\n !builtInHelpers.includes(path) &&\n !this.isIgnoredComponent(path)\n ) {\n return this.add(\n {\n type: 'error',\n message: `Missing component or helper`,\n detail: path,\n loc,\n },\n from\n );\n } else {\n return null;\n }\n }\n\n resolveElement(tagName: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n if (tagName[0] === tagName[0].toLowerCase()) {\n // starts with lower case, so this can't be a component we need to\n // globally resolve\n return null;\n }\n\n let dName = dasherize(tagName);\n\n if (builtInComponents.includes(dName)) {\n return null;\n }\n\n let found = this.tryComponent(dName, from);\n if (found) {\n return this.add(found, from);\n }\n\n if (this.isIgnoredComponent(dName)) {\n return null;\n }\n\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: tagName,\n loc,\n },\n from\n );\n }\n\n resolveComponentHelper(\n component: ComponentLocator,\n from: string,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return this.add(\n {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n },\n from\n );\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findComponentRules(from);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message,\n detail: component.path,\n loc,\n },\n from\n );\n }\n let found = this.tryComponent(component.path, from);\n if (found) {\n return this.add(found, from);\n }\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: component.path,\n loc,\n },\n from\n );\n }\n}\n\nfunction humanReadableFile(root: string, file: string) {\n if (!root.endsWith('/')) {\n root += '/';\n }\n if (file.startsWith(root)) {\n return file.slice(root.length);\n }\n return file;\n}\n\n// we don't have a real Package for the app itself because the resolver has work\n// to do before we have even written out the app's own package.json and\n// therefore made it into a fully functional Package.\ninterface AppPackagePlaceholder {\n root: string;\n name: string;\n}\n\nexport type ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n"]}
package/src/v1-addon.js CHANGED
@@ -592,7 +592,10 @@ class V1Addon {
592
592
  }
593
593
  addonStylesTree() {
594
594
  if (this.customizes('treeForAddonStyles')) {
595
- return this.invokeOriginalTreeFor('addon-styles');
595
+ let custom = this.invokeOriginalTreeFor('addon-styles');
596
+ if (custom) {
597
+ return this.addonInstance.compileStyles(custom);
598
+ }
596
599
  }
597
600
  else if (this.hasStockTree('addon-styles')) {
598
601
  return this.addonInstance.compileStyles(this.stockTree('addon-styles'));
@@ -1 +1 @@
1
- {"version":3,"file":"v1-addon.js","sourceRoot":"","sources":["v1-addon.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAA6C;AAC7C,+BAA2D;AAC3D,mCAA2C;AAC3C,uCAAsD;AACtD,sEAAwE;AACxE,qDAA2D;AAC3D,kFAAwD;AACxD,2DAAiE;AAEjE,gFAA8C;AAC9C,oDAA4B;AAC5B,8EAAoD;AACpD,qCAA2C;AAC3C,0CASyB;AAEzB,0DAAiC;AACjC,kEAAyC;AAEzC,qDAAqE;AAGrE,sEAA6C;AAC7C,kFAA8C;AAC9C,gHAAqF;AACrF,iEAA0G;AAE1G,4GAAiF;AACjF,mCAAmC;AACnC,mGAAmF;AACnF,kGAA6E;AAC7E,sEAA4C;AAE5C,MAAM,cAAc,GAAoB,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO;IACP,cAAc;IACd,QAAQ;IACR,oBAAoB;IACpB,cAAc;IACd,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,uEAAuE;IACvE,8CAA8C;CAC/C,CAAoB,CAAC;AAEtB,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACr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9B,0EAA0E;QAC1E,qEAAqE;QACrE,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAA,yCAAkB,EAAC,MAAM,CAAC,EAAE;QAC9B,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO;QACP,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjD,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, isAbsolute, join, relative } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { existsSync, pathExistsSync } from 'fs-extra';\nimport buildFunnel, { Options as FunnelOptions } from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport RewritePackageJSON from './rewrite-package-json';\nimport { todo, unsupported } from '@embroider/core/src/messages';\nimport { 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 {\n AddonMeta,\n NodeTemplateCompiler,\n debug,\n PackageCache,\n Resolver,\n extensionsPattern,\n AddonInstance,\n AddonTreePath,\n} from '@embroider/core';\nimport Options from './options';\nimport walkSync from 'walk-sync';\nimport ObserveTree from './observe-tree';\nimport type { Options as HTMLBarsOptions } from 'ember-cli-htmlbars';\nimport { isEmbroiderMacrosPlugin } from '@embroider/macros/src/node';\nimport { TransformOptions, PluginItem } from '@babel/core';\nimport V1App from './v1-app';\nimport modulesCompat from './modules-compat';\nimport writeFile from 'broccoli-file-creator';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport { isEmberAutoImportDynamic, isCompactReexports, isColocationPlugin } from './detect-babel-plugins';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport TemplateCompilerBroccoliPlugin from './template-compiler-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\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 appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n/**\n * Creating a interface here just to keep the Resolver's structure as it is.\n */\ninterface ResolverParams {\n root: string;\n modulePrefix: string;\n}\n\nexport function resolver(params: ResolverParams): V1AddonCompatResolver {\n return new V1AddonCompatResolver(params);\n}\n\nclass V1AddonCompatResolver implements Resolver {\n params: ResolverParams;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: ResolverParams;\n };\n\n constructor(params: ResolverParams) {\n this.params = params;\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'resolver',\n params,\n };\n }\n astTransformer(_templateCompiler: NodeTemplateCompiler): unknown {\n return;\n }\n dependenciesOf(_moduleName: string): ResolvedDep[] {\n return [];\n }\n absPathToRuntimePath(absPath: string) {\n if (isAbsolute(absPath)) {\n return absPath;\n }\n return join(this.params.modulePrefix, absPath);\n }\n absPathToRuntimeName(absPath: string) {\n return this.absPathToRuntimePath(absPath)\n .replace(extensionsPattern(['.js', '.hbs']), '')\n .replace(/\\/index$/, '');\n }\n get adjustImportsOptions(): Resolver['adjustImportsOptions'] {\n throw new Error(`bug: the addon compat resolver only supports absPath mapping`);\n }\n}\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: Required<Options>,\n protected app: V1App,\n private packageCache: PackageCache,\n private orderIdx: number\n ) {\n if (addonInstance.registry) {\n this.updateRegistry(addonInstance.registry);\n }\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompiler(): NodeTemplateCompiler | undefined {\n let htmlbars = this.addonInstance.addons.find(a => a.name === 'ember-cli-htmlbars');\n if (htmlbars) {\n let options = (htmlbars as any).htmlbarsOptions() as HTMLBarsOptions;\n if (options?.plugins?.ast) {\n // our macros don't run here in stage1\n options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n prepHtmlbarsAstPluginsForUnwrap(this.addonInstance.registry);\n if (options.plugins.ast.length > 0) {\n const { cacheKey: compilerChecksum } = getEmberExports(options.templateCompilerPath);\n\n return new NodeTemplateCompiler({\n compilerPath: options.templateCompilerPath,\n compilerChecksum,\n EmberENV: {},\n plugins: options.plugins,\n resolver: this.templateResolver(),\n });\n }\n }\n }\n }\n\n @Memoize()\n templateResolver(): Resolver {\n return resolver({\n root: this.app.root,\n modulePrefix: this.moduleName,\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 // leaves hbs files as hbs, not js. The only transformation it is supposed\n // to do is applying any custom AST transforms and reserializing the results\n // back to HBS.\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.templateCompiler) {\n return new TemplateCompilerBroccoliPlugin(tree, this._addon.templateCompiler, 1);\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.templateCompiler) {\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\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\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 );\n })\n );\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 tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\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 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.templateCompiler) {\n babelConfig.plugins.push(this.templateCompiler.inlineTransformsBabelPlugin());\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 private 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 return this.invokeOriginalTreeFor('addon-styles');\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, ['components']);\n if (!this.addonOptions.staticAddonTrees) {\n let filenames: string[] = [];\n let templateOnlyComponentNames: string[] = [];\n\n tree = new ObserveTree(tree, outputDir => {\n filenames = walkSync(outputDir, { globs: ['**/*.js', '**/*.hbs'] })\n .map(f => `./${f.replace(/\\.js$/i, '')}`)\n .filter(notColocatedTemplate);\n });\n\n templateOnlyComponents = new ObserveTree(templateOnlyComponents, outputDir => {\n templateOnlyComponentNames = walkSync(outputDir, { globs: ['**/*.js'] }).map(\n f => `./${f.replace(/\\.js$/i, '')}`\n );\n });\n\n built.dynamicMeta.push(() => ({\n 'implicit-modules': filenames.concat(templateOnlyComponentNames),\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 if (!this.addonOptions.staticAddonTestSupportTrees) {\n let filenames: string[] = [];\n addonTestSupportTree = new ObserveTree(addonTestSupportTree, outputPath => {\n filenames = walkSync(outputPath, { globs: ['**/*.js', '**/*.hbs'] }).map(f => `./${f.replace(/.js$/i, '')}`);\n });\n built.dynamicMeta.push(() => ({\n 'implicit-test-modules': filenames,\n }));\n }\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 && 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: Required<Options>,\n app: V1App,\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 (NodeTemplateCompiler.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\nfunction notColocatedTemplate(path: string) {\n return !/^\\.\\/components\\/.*\\.hbs$/.test(path);\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":["v1-addon.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAA6C;AAC7C,+BAA2D;AAC3D,mCAA2C;AAC3C,uCAAsD;AACtD,sEAAwE;AACxE,qDAA2D;AAC3D,kFAAwD;AACxD,2DAAiE;AAEjE,gFAA8C;AAC9C,oDAA4B;AAC5B,8EAAoD;AACpD,qCAA2C;AAC3C,0CASyB;AAEzB,0DAAiC;AACjC,kEAAyC;AAEzC,qDAAqE;AAGrE,sEAA6C;AAC7C,kFAA8C;AAC9C,gHAAqF;AACrF,iEAA0G;AAE1G,4GAAiF;AACjF,mCAAmC;AACnC,mGAAmF;AACnF,kGAA6E;AAC7E,sEAA4C;AAE5C,MAAM,cAAc,GAAoB,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO;IACP,cAAc;IACd,QAAQ;IACR,oBAAoB;IACpB,cAAc;IACd,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,uEAAuE;IACvE,8CAA8C;CAC/C,CAAoB,CAAC;AAEtB,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,SAAS;IACT,cAAc;IACd,uBAAuB;IACv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,KAAK,CAAC;KACd;IAED,IAAI,IAAA,yCAAkB,EAAC,MAAM,CAAC,EAAE;QAC9B,0EAA0E;QAC1E,qEAAqE;QACrE,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAA,yCAAkB,EAAC,MAAM,CAAC,EAAE;QAC9B,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO;QACP,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjD,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, isAbsolute, join, relative } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { existsSync, pathExistsSync } from 'fs-extra';\nimport buildFunnel, { Options as FunnelOptions } from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport RewritePackageJSON from './rewrite-package-json';\nimport { todo, unsupported } from '@embroider/core/src/messages';\nimport { 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 {\n AddonMeta,\n NodeTemplateCompiler,\n debug,\n PackageCache,\n Resolver,\n extensionsPattern,\n AddonInstance,\n AddonTreePath,\n} from '@embroider/core';\nimport Options from './options';\nimport walkSync from 'walk-sync';\nimport ObserveTree from './observe-tree';\nimport type { Options as HTMLBarsOptions } from 'ember-cli-htmlbars';\nimport { isEmbroiderMacrosPlugin } from '@embroider/macros/src/node';\nimport { TransformOptions, PluginItem } from '@babel/core';\nimport V1App from './v1-app';\nimport modulesCompat from './modules-compat';\nimport writeFile from 'broccoli-file-creator';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport { isEmberAutoImportDynamic, isCompactReexports, isColocationPlugin } from './detect-babel-plugins';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport TemplateCompilerBroccoliPlugin from './template-compiler-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\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 appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n/**\n * Creating a interface here just to keep the Resolver's structure as it is.\n */\ninterface ResolverParams {\n root: string;\n modulePrefix: string;\n}\n\nexport function resolver(params: ResolverParams): V1AddonCompatResolver {\n return new V1AddonCompatResolver(params);\n}\n\nclass V1AddonCompatResolver implements Resolver {\n params: ResolverParams;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: ResolverParams;\n };\n\n constructor(params: ResolverParams) {\n this.params = params;\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'resolver',\n params,\n };\n }\n astTransformer(_templateCompiler: NodeTemplateCompiler): unknown {\n return;\n }\n dependenciesOf(_moduleName: string): ResolvedDep[] {\n return [];\n }\n absPathToRuntimePath(absPath: string) {\n if (isAbsolute(absPath)) {\n return absPath;\n }\n return join(this.params.modulePrefix, absPath);\n }\n absPathToRuntimeName(absPath: string) {\n return this.absPathToRuntimePath(absPath)\n .replace(extensionsPattern(['.js', '.hbs']), '')\n .replace(/\\/index$/, '');\n }\n get adjustImportsOptions(): Resolver['adjustImportsOptions'] {\n throw new Error(`bug: the addon compat resolver only supports absPath mapping`);\n }\n}\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: Required<Options>,\n protected app: V1App,\n private packageCache: PackageCache,\n private orderIdx: number\n ) {\n if (addonInstance.registry) {\n this.updateRegistry(addonInstance.registry);\n }\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompiler(): NodeTemplateCompiler | undefined {\n let htmlbars = this.addonInstance.addons.find(a => a.name === 'ember-cli-htmlbars');\n if (htmlbars) {\n let options = (htmlbars as any).htmlbarsOptions() as HTMLBarsOptions;\n if (options?.plugins?.ast) {\n // our macros don't run here in stage1\n options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n prepHtmlbarsAstPluginsForUnwrap(this.addonInstance.registry);\n if (options.plugins.ast.length > 0) {\n const { cacheKey: compilerChecksum } = getEmberExports(options.templateCompilerPath);\n\n return new NodeTemplateCompiler({\n compilerPath: options.templateCompilerPath,\n compilerChecksum,\n EmberENV: {},\n plugins: options.plugins,\n resolver: this.templateResolver(),\n });\n }\n }\n }\n }\n\n @Memoize()\n templateResolver(): Resolver {\n return resolver({\n root: this.app.root,\n modulePrefix: this.moduleName,\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 // leaves hbs files as hbs, not js. The only transformation it is supposed\n // to do is applying any custom AST transforms and reserializing the results\n // back to HBS.\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.templateCompiler) {\n return new TemplateCompilerBroccoliPlugin(tree, this._addon.templateCompiler, 1);\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.templateCompiler) {\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\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\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 );\n })\n );\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 tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\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 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.templateCompiler) {\n babelConfig.plugins.push(this.templateCompiler.inlineTransformsBabelPlugin());\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 private 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, ['components']);\n if (!this.addonOptions.staticAddonTrees) {\n let filenames: string[] = [];\n let templateOnlyComponentNames: string[] = [];\n\n tree = new ObserveTree(tree, outputDir => {\n filenames = walkSync(outputDir, { globs: ['**/*.js', '**/*.hbs'] })\n .map(f => `./${f.replace(/\\.js$/i, '')}`)\n .filter(notColocatedTemplate);\n });\n\n templateOnlyComponents = new ObserveTree(templateOnlyComponents, outputDir => {\n templateOnlyComponentNames = walkSync(outputDir, { globs: ['**/*.js'] }).map(\n f => `./${f.replace(/\\.js$/i, '')}`\n );\n });\n\n built.dynamicMeta.push(() => ({\n 'implicit-modules': filenames.concat(templateOnlyComponentNames),\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 if (!this.addonOptions.staticAddonTestSupportTrees) {\n let filenames: string[] = [];\n addonTestSupportTree = new ObserveTree(addonTestSupportTree, outputPath => {\n filenames = walkSync(outputPath, { globs: ['**/*.js', '**/*.hbs'] }).map(f => `./${f.replace(/.js$/i, '')}`);\n });\n built.dynamicMeta.push(() => ({\n 'implicit-test-modules': filenames,\n }));\n }\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 && 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: Required<Options>,\n app: V1App,\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 (NodeTemplateCompiler.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\nfunction notColocatedTemplate(path: string) {\n return !/^\\.\\/components\\/.*\\.hbs$/.test(path);\n}\n\nconst markedEmptyTree = new UnwatchedDir(process.cwd());\n\nconst stubbedSuper = () => {\n return markedEmptyTree;\n};\n\nstubbedSuper.treeFor = () => {\n return markedEmptyTree;\n};\n"]}