@embroider/compat 2.1.2-unstable.1ecd57e → 2.1.2-unstable.3878f42

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": "2.1.2-unstable.1ecd57e",
3
+ "version": "2.1.2-unstable.3878f42",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
29
29
  "@babel/preset-env": "^7.14.5",
30
30
  "@babel/traverse": "^7.14.5",
31
- "@embroider/macros": "1.10.1-unstable.1ecd57e",
31
+ "@embroider/macros": "1.10.1-unstable.3878f42",
32
32
  "@types/babel__code-frame": "^7.0.2",
33
33
  "@types/yargs": "^17.0.3",
34
34
  "assert-never": "^1.1.0",
@@ -62,8 +62,8 @@
62
62
  "yargs": "^17.0.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@embroider/sample-transforms": "0.0.0",
66
- "@embroider/test-support": "0.36.0",
65
+ "@embroider/sample-transforms": "workspace:*",
66
+ "@embroider/test-support": "workspace:*",
67
67
  "@glimmer/syntax": "^0.84.2",
68
68
  "@glint/template": "^1.0.0",
69
69
  "@types/babel__core": "^7.1.14",
@@ -83,10 +83,10 @@
83
83
  "code-equality-assertions": "^0.9.0",
84
84
  "ember-engines": "^0.8.19",
85
85
  "scenario-tester": "^2.1.2",
86
- "typescript": "*"
86
+ "typescript": "^4.9.0"
87
87
  },
88
88
  "peerDependencies": {
89
- "@embroider/core": "2.1.2-unstable.1ecd57e"
89
+ "@embroider/core": "2.1.2-unstable.3878f42"
90
90
  },
91
91
  "engines": {
92
92
  "node": "12.* || 14.* || >= 16"
package/src/audit.js CHANGED
@@ -129,16 +129,6 @@ class AuditResults {
129
129
  }
130
130
  exports.AuditResults = AuditResults;
131
131
  class Audit {
132
- constructor(appDir, options = {}) {
133
- this.appDir = appDir;
134
- this.options = options;
135
- this.modules = new Map();
136
- this.virtualModules = new Map();
137
- this.moduleQueue = new Set();
138
- this.findings = [];
139
- this.frames = new babel_visitor_1.CodeFrameStorage();
140
- this.resolver = new core_1.Resolver(this.resolverParams);
141
- }
142
132
  static async run(options) {
143
133
  let dir;
144
134
  if (options.outputDir) {
@@ -172,6 +162,16 @@ class Audit {
172
162
  throw err;
173
163
  }
174
164
  }
165
+ constructor(appDir, options = {}) {
166
+ this.appDir = appDir;
167
+ this.options = options;
168
+ this.modules = new Map();
169
+ this.virtualModules = new Map();
170
+ this.moduleQueue = new Set();
171
+ this.findings = [];
172
+ this.frames = new babel_visitor_1.CodeFrameStorage();
173
+ this.resolver = new core_1.Resolver(this.resolverParams);
174
+ }
175
175
  get pkg() {
176
176
  return (0, fs_extra_1.readJSONSync)((0, path_1.join)(this.appDir, 'package.json'));
177
177
  }
package/src/audit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsD;AACtD,+BAA6D;AAC7D,0CAAgG;AAChG,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AACzC,yDAO+B;AAE/B,yCAAmE;AAiBzB,2FAjBvB,kBAAU,OAiBuB;AAAE,6FAjBvB,oBAAY,OAiBuB;AAflE,MAAM,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC;AAqCxB,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC;AA6BD,SAAS,UAAU,CAAC,MAAkC;IACpD,OAAO,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC;AAMD,SAAS,QA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AAQ,CAAC,CAAC;YACnC,MAAM,GAAG;gBACP,YAAY,EAAE,CAAC,MAAM,CAAC;aACvB,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACnC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAChC;aAAM;YACL,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAjVC;IADC,IAAA,4BAAO,GAAE;gCAGT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAST;AAvEH,sBAuYC;AAED,SAAS,cAAc,CAAC,CAAM;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtE,CAAC;AAED,SAAS,MAAM,CAAC,GAAW,EAAE,KAAa;IACxC,MAAM,cAAc,GAAG,CAAC,CAAC;IACzB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,CAAC;KACf;IAED,OAAO,GAAG;SACP,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,oCAEC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { dirname, join, resolve as resolvePath } from 'path';\nimport { AppMeta, explicitRelative, hbsToJS, Resolver, ResolverOptions } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport jsdom from 'jsdom';\nimport groupBy from 'lodash/groupBy';\nimport fromPairs from 'lodash/fromPairs';\nimport {\n auditJS,\n CodeFrameStorage,\n ExportAll,\n InternalImport,\n isNamespaceMarker,\n NamespaceMarker,\n} from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\n\nconst { JSDOM } = jsdom;\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport interface Module {\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n imports: Import[];\n exports: string[];\n resolutions: { [source: string]: string | null };\n content: string;\n}\n\ninterface ResolutionFailure {\n isResolutionFailure: true;\n}\n\nfunction isResolutionFailure(result: string | ResolutionFailure | undefined): result is ResolutionFailure {\n return typeof result === 'object' && 'isResolutionFailure' in result;\n}\n\ninterface InternalModule {\n consumedFrom: (string | RootMarker)[];\n\n parsed?: {\n imports: InternalImport[];\n exports: Set<string | ExportAll>;\n isCJS: boolean;\n isAMD: boolean;\n dependencies: string[];\n transpiledContent: string | Buffer;\n };\n\n resolved?: Map<string, string | ResolutionFailure>;\n\n linked?: {\n exports: Set<string>;\n };\n}\n\ntype ParsedInternalModule = Omit<InternalModule, 'parsed'> & {\n parsed: NonNullable<InternalModule['parsed']>;\n};\n\ntype ResolvedInternalModule = Omit<ParsedInternalModule, 'resolved'> & {\n resolved: NonNullable<ParsedInternalModule['resolved']>;\n};\n\nfunction isResolved(module: InternalModule | undefined): module is ResolvedInternalModule {\n return Boolean(module?.parsed && module.resolved);\n}\n\ntype LinkedInternalModule = Omit<ResolvedInternalModule, 'linked'> & {\n linked: NonNullable<ResolvedInternalModule['linked']>;\n};\n\nfunction isLinked(module: InternalModule | undefined): module is LinkedInternalModule {\n return Boolean(module?.parsed && module.resolved && module.linked);\n}\n\nexport interface Import {\n source: string;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n }[];\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>) {\n let results = new this();\n for (let [filename, module] of modules) {\n let publicModule: Module = {\n appRelativePath: explicitRelative(baseDir, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(baseDir, entry);\n }\n }),\n resolutions: module.resolved\n ? fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(baseDir, target),\n ])\n )\n : {},\n imports: module.parsed?.imports\n ? module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n })),\n }))\n : [],\n exports: module.linked?.exports ? [...module.linked.exports] : [],\n content: module.parsed?.transpiledContent\n ? module.parsed?.transpiledContent.toString()\n : 'module failed to transpile',\n };\n results.modules[explicitRelative(baseDir, filename)] = publicModule;\n }\n for (let finding of findings) {\n let relFinding = Object.assign({}, finding, { filename: explicitRelative(baseDir, finding.filename) });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private modules: Map<string, InternalModule> = new Map();\n private virtualModules: Map<string, string> = new Map();\n private moduleQueue = new Set<string>();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n let dir: string;\n\n if (options.outputDir) {\n dir = options.outputDir;\n } else {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n dir = await this.findStage2Output(options);\n }\n\n let audit = new this(dir, options);\n if (options['reuse-build']) {\n if (!audit.meta.babel.isParallelSafe) {\n throw new BuildError(\n `You can't use the ${chalk.red(\n '--reuse-build'\n )} option because some of your babel or HBS plugins are non-serializable`\n );\n }\n }\n return audit.run();\n }\n\n private static async findStage2Output(options: AuditBuildOptions): Promise<string> {\n try {\n if (!options.app) {\n throw new Error(`AuditBuildOptions needs \"app\" directory`);\n }\n return readFileSync(join(options.app, 'dist/.stage2-output'), 'utf8');\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new BuildError(\n `${chalk.yellow(\n 'Your build'\n )} did not produce expected Embroider stage2 output.\\nMake sure you actually have Embroider configured.`\n );\n }\n throw err;\n }\n }\n\n constructor(private appDir: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.appDir, 'package.json'));\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.appDir, this.meta.babel.filename));\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(this.appDir, '.embroider', 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n private visitorFor(\n filename: string\n ): (\n this: Audit,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed']> | Finding[]> {\n if (filename.endsWith('.html')) {\n return this.visitHTML;\n } else if (filename.endsWith('.hbs')) {\n return this.visitHBS;\n } else if (filename.endsWith('.json')) {\n return this.visitJSON;\n } else {\n return this.visitJS;\n }\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let filename = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(filename);\n this.debug('visit', filename);\n let visitor = this.visitorFor(filename);\n let content: string | Buffer;\n if (this.virtualModules.has(filename)) {\n content = this.virtualModules.get(filename)!;\n } else {\n content = readFileSync(filename);\n }\n // cast is safe because the only way to get into the queue is to go\n // through scheduleVisit, and scheduleVisit creates the entry in\n // this.modules.\n let module: InternalModule = this.modules.get(filename)!;\n let visitResult = await visitor.call(this, filename, content);\n if (Array.isArray(visitResult)) {\n // the visitor was unable to figure out the ParseFields and returned\n // some number of Findings to us to explain why.\n for (let finding of visitResult) {\n this.pushFinding(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, filename);\n }\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n for (let asset of this.meta.assets) {\n if (asset.endsWith('.html')) {\n this.scheduleVisit(resolvePath(this.appDir, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n return AuditResults.create(this.appDir, this.findings, this.modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private linkModules() {\n for (let module of this.modules.values()) {\n if (isResolved(module)) {\n this.linkModule(module);\n }\n }\n }\n\n private linkModule(module: ResolvedInternalModule) {\n let exports = new Set<string>();\n for (let exp of module.parsed.exports) {\n if (typeof exp === 'string') {\n exports.add(exp);\n } else {\n let moduleName = module.resolved.get(exp.all)!;\n if (!isResolutionFailure(moduleName)) {\n let target = this.modules.get(moduleName)!;\n if (!isLinked(target) && isResolved(target)) {\n this.linkModule(target);\n }\n if (isLinked(target)) {\n for (let innerExp of target.linked.exports) {\n exports.add(innerExp);\n }\n } else {\n // our module doesn't successfully enter linked state because it\n // depends on stuff that also couldn't\n return;\n }\n }\n }\n }\n module.linked = {\n exports,\n };\n }\n\n private inspectModules() {\n for (let [filename, module] of this.modules) {\n if (isLinked(module)) {\n this.inspectImports(filename, module);\n }\n }\n }\n\n private inspectImports(filename: string, module: LinkedInternalModule) {\n for (let imp of module.parsed.imports) {\n let resolved = module.resolved.get(imp.source);\n if (isResolutionFailure(resolved)) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = this.modules.get(resolved)!;\n for (let specifier of imp.specifiers) {\n if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: LinkedInternalModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);\n }\n\n private async visitHTML(filename: string, content: Buffer | string): Promise<ParsedInternalModule['parsed']> {\n let dom = new JSDOM(content);\n let scripts = dom.window.document.querySelectorAll('script[type=\"module\"]') as NodeListOf<HTMLScriptElement>;\n let dependencies = [] as string[];\n for (let script of scripts) {\n let src = script.src;\n if (!src) {\n continue;\n }\n if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {\n // src was absolute, we don't handle it\n continue;\n }\n if (src.startsWith(this.meta['root-url'])) {\n // root-relative URLs are actually relative to the appDir\n src = explicitRelative(dirname(filename), resolvePath(this.appDir, src.replace(this.meta['root-url'], '')));\n }\n dependencies.push(src);\n }\n\n return {\n imports: [],\n exports: new Set(),\n isCJS: false,\n isAMD: false,\n dependencies,\n transpiledContent: content,\n };\n }\n\n private async visitJS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n try {\n let result = auditJS(rawSource, filename, this.babelConfig, this.frames);\n\n for (let problem of result.problems) {\n this.pushFinding({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.frames.render(problem.codeFrameIndex),\n });\n }\n return {\n exports: result.exports,\n imports: result.imports,\n isCJS: result.isCJS,\n isAMD: result.isAMD,\n dependencies: result.imports.map(i => i.source),\n transpiledContent: result.transpiledContent,\n };\n } catch (err) {\n if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {\n return [\n {\n filename,\n message: `failed to parse`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private async visitHBS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n let js = hbsToJS(rawSource);\n return this.visitJS(filename, js);\n }\n\n private async visitJSON(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n return [\n {\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n }\n return this.visitJS(filename, js);\n }\n\n private async resolveDeps(deps: string[], fromFile: string): Promise<InternalModule['resolved']> {\n let resolved = new Map() as NonNullable<InternalModule['resolved']>;\n for (let dep of deps) {\n let resolution = await this.resolver.nodeResolve(dep, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n case 'not_found':\n if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n resolved.set(dep, { isResolutionFailure: true as true });\n break;\n case 'real':\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n }\n }\n return resolved;\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n\n private scheduleVisit(filename: string, parent: string | RootMarker) {\n let record = this.modules.get(filename);\n if (!record) {\n this.debug(`discovered`, filename);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(filename, record);\n this.moduleQueue.add(filename);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport interface RootMarker {\n isRoot: true;\n}\n\nexport function isRootMarker(value: string | RootMarker | undefined): value is RootMarker {\n return Boolean(value && typeof value !== 'string' && value.isRoot);\n}\n"]}
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsD;AACtD,+BAA6D;AAC7D,0CAAgG;AAChG,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AACzC,yDAO+B;AAE/B,yCAAmE;AAiBzB,2FAjBvB,kBAAU,OAiBuB;AAAE,6FAjBvB,oBAAY,OAiBuB;AAflE,MAAM,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC;AAqCxB,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC;AA6BD,SAAS,UAAU,CAAC,MAAkC;IACpD,OAAO,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC;AAMD,SAAS,QAAQ,CAAC,MAAkC;IAClD,OAAO,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;A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AAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAChC;aAAM;YACL,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAjVC;IADC,IAAA,4BAAO,GAAE;gCAGT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAST;AAvEH,sBAuYC;AAED,SAAS,cAAc,CAAC,CAAM;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtE,CAAC;AAED,SAAS,MAAM,CAAC,GAAW,EAAE,KAAa;IACxC,MAAM,cAAc,GAAG,CAAC,CAAC;IACzB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,CAAC;KACf;IAED,OAAO,GAAG;SACP,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,oCAEC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { dirname, join, resolve as resolvePath } from 'path';\nimport { AppMeta, explicitRelative, hbsToJS, Resolver, ResolverOptions } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport jsdom from 'jsdom';\nimport groupBy from 'lodash/groupBy';\nimport fromPairs from 'lodash/fromPairs';\nimport {\n auditJS,\n CodeFrameStorage,\n ExportAll,\n InternalImport,\n isNamespaceMarker,\n NamespaceMarker,\n} from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\n\nconst { JSDOM } = jsdom;\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport interface Module {\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n imports: Import[];\n exports: string[];\n resolutions: { [source: string]: string | null };\n content: string;\n}\n\ninterface ResolutionFailure {\n isResolutionFailure: true;\n}\n\nfunction isResolutionFailure(result: string | ResolutionFailure | undefined): result is ResolutionFailure {\n return typeof result === 'object' && 'isResolutionFailure' in result;\n}\n\ninterface InternalModule {\n consumedFrom: (string | RootMarker)[];\n\n parsed?: {\n imports: InternalImport[];\n exports: Set<string | ExportAll>;\n isCJS: boolean;\n isAMD: boolean;\n dependencies: string[];\n transpiledContent: string | Buffer;\n };\n\n resolved?: Map<string, string | ResolutionFailure>;\n\n linked?: {\n exports: Set<string>;\n };\n}\n\ntype ParsedInternalModule = Omit<InternalModule, 'parsed'> & {\n parsed: NonNullable<InternalModule['parsed']>;\n};\n\ntype ResolvedInternalModule = Omit<ParsedInternalModule, 'resolved'> & {\n resolved: NonNullable<ParsedInternalModule['resolved']>;\n};\n\nfunction isResolved(module: InternalModule | undefined): module is ResolvedInternalModule {\n return Boolean(module?.parsed && module.resolved);\n}\n\ntype LinkedInternalModule = Omit<ResolvedInternalModule, 'linked'> & {\n linked: NonNullable<ResolvedInternalModule['linked']>;\n};\n\nfunction isLinked(module: InternalModule | undefined): module is LinkedInternalModule {\n return Boolean(module?.parsed && module.resolved && module.linked);\n}\n\nexport interface Import {\n source: string;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n }[];\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>) {\n let results = new this();\n for (let [filename, module] of modules) {\n let publicModule: Module = {\n appRelativePath: explicitRelative(baseDir, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(baseDir, entry);\n }\n }),\n resolutions: module.resolved\n ? fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(baseDir, target),\n ])\n )\n : {},\n imports: module.parsed?.imports\n ? module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n })),\n }))\n : [],\n exports: module.linked?.exports ? [...module.linked.exports] : [],\n content: module.parsed?.transpiledContent\n ? module.parsed?.transpiledContent.toString()\n : 'module failed to transpile',\n };\n results.modules[explicitRelative(baseDir, filename)] = publicModule;\n }\n for (let finding of findings) {\n let relFinding = Object.assign({}, finding, { filename: explicitRelative(baseDir, finding.filename) });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private modules: Map<string, InternalModule> = new Map();\n private virtualModules: Map<string, string> = new Map();\n private moduleQueue = new Set<string>();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n let dir: string;\n\n if (options.outputDir) {\n dir = options.outputDir;\n } else {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n dir = await this.findStage2Output(options);\n }\n\n let audit = new this(dir, options);\n if (options['reuse-build']) {\n if (!audit.meta.babel.isParallelSafe) {\n throw new BuildError(\n `You can't use the ${chalk.red(\n '--reuse-build'\n )} option because some of your babel or HBS plugins are non-serializable`\n );\n }\n }\n return audit.run();\n }\n\n private static async findStage2Output(options: AuditBuildOptions): Promise<string> {\n try {\n if (!options.app) {\n throw new Error(`AuditBuildOptions needs \"app\" directory`);\n }\n return readFileSync(join(options.app, 'dist/.stage2-output'), 'utf8');\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new BuildError(\n `${chalk.yellow(\n 'Your build'\n )} did not produce expected Embroider stage2 output.\\nMake sure you actually have Embroider configured.`\n );\n }\n throw err;\n }\n }\n\n constructor(private appDir: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.appDir, 'package.json'));\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.appDir, this.meta.babel.filename));\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(this.appDir, '.embroider', 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n private visitorFor(\n filename: string\n ): (\n this: Audit,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed']> | Finding[]> {\n if (filename.endsWith('.html')) {\n return this.visitHTML;\n } else if (filename.endsWith('.hbs')) {\n return this.visitHBS;\n } else if (filename.endsWith('.json')) {\n return this.visitJSON;\n } else {\n return this.visitJS;\n }\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let filename = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(filename);\n this.debug('visit', filename);\n let visitor = this.visitorFor(filename);\n let content: string | Buffer;\n if (this.virtualModules.has(filename)) {\n content = this.virtualModules.get(filename)!;\n } else {\n content = readFileSync(filename);\n }\n // cast is safe because the only way to get into the queue is to go\n // through scheduleVisit, and scheduleVisit creates the entry in\n // this.modules.\n let module: InternalModule = this.modules.get(filename)!;\n let visitResult = await visitor.call(this, filename, content);\n if (Array.isArray(visitResult)) {\n // the visitor was unable to figure out the ParseFields and returned\n // some number of Findings to us to explain why.\n for (let finding of visitResult) {\n this.pushFinding(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, filename);\n }\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n for (let asset of this.meta.assets) {\n if (asset.endsWith('.html')) {\n this.scheduleVisit(resolvePath(this.appDir, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n return AuditResults.create(this.appDir, this.findings, this.modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private linkModules() {\n for (let module of this.modules.values()) {\n if (isResolved(module)) {\n this.linkModule(module);\n }\n }\n }\n\n private linkModule(module: ResolvedInternalModule) {\n let exports = new Set<string>();\n for (let exp of module.parsed.exports) {\n if (typeof exp === 'string') {\n exports.add(exp);\n } else {\n let moduleName = module.resolved.get(exp.all)!;\n if (!isResolutionFailure(moduleName)) {\n let target = this.modules.get(moduleName)!;\n if (!isLinked(target) && isResolved(target)) {\n this.linkModule(target);\n }\n if (isLinked(target)) {\n for (let innerExp of target.linked.exports) {\n exports.add(innerExp);\n }\n } else {\n // our module doesn't successfully enter linked state because it\n // depends on stuff that also couldn't\n return;\n }\n }\n }\n }\n module.linked = {\n exports,\n };\n }\n\n private inspectModules() {\n for (let [filename, module] of this.modules) {\n if (isLinked(module)) {\n this.inspectImports(filename, module);\n }\n }\n }\n\n private inspectImports(filename: string, module: LinkedInternalModule) {\n for (let imp of module.parsed.imports) {\n let resolved = module.resolved.get(imp.source);\n if (isResolutionFailure(resolved)) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = this.modules.get(resolved)!;\n for (let specifier of imp.specifiers) {\n if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: LinkedInternalModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);\n }\n\n private async visitHTML(filename: string, content: Buffer | string): Promise<ParsedInternalModule['parsed']> {\n let dom = new JSDOM(content);\n let scripts = dom.window.document.querySelectorAll('script[type=\"module\"]') as NodeListOf<HTMLScriptElement>;\n let dependencies = [] as string[];\n for (let script of scripts) {\n let src = script.src;\n if (!src) {\n continue;\n }\n if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {\n // src was absolute, we don't handle it\n continue;\n }\n if (src.startsWith(this.meta['root-url'])) {\n // root-relative URLs are actually relative to the appDir\n src = explicitRelative(dirname(filename), resolvePath(this.appDir, src.replace(this.meta['root-url'], '')));\n }\n dependencies.push(src);\n }\n\n return {\n imports: [],\n exports: new Set(),\n isCJS: false,\n isAMD: false,\n dependencies,\n transpiledContent: content,\n };\n }\n\n private async visitJS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n try {\n let result = auditJS(rawSource, filename, this.babelConfig, this.frames);\n\n for (let problem of result.problems) {\n this.pushFinding({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.frames.render(problem.codeFrameIndex),\n });\n }\n return {\n exports: result.exports,\n imports: result.imports,\n isCJS: result.isCJS,\n isAMD: result.isAMD,\n dependencies: result.imports.map(i => i.source),\n transpiledContent: result.transpiledContent,\n };\n } catch (err) {\n if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {\n return [\n {\n filename,\n message: `failed to parse`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private async visitHBS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n let js = hbsToJS(rawSource);\n return this.visitJS(filename, js);\n }\n\n private async visitJSON(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n return [\n {\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.appDir, filename)),\n },\n ];\n }\n return this.visitJS(filename, js);\n }\n\n private async resolveDeps(deps: string[], fromFile: string): Promise<InternalModule['resolved']> {\n let resolved = new Map() as NonNullable<InternalModule['resolved']>;\n for (let dep of deps) {\n let resolution = await this.resolver.nodeResolve(dep, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n case 'not_found':\n if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n resolved.set(dep, { isResolutionFailure: true as true });\n break;\n case 'real':\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n }\n }\n return resolved;\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n\n private scheduleVisit(filename: string, parent: string | RootMarker) {\n let record = this.modules.get(filename);\n if (!record) {\n this.debug(`discovered`, filename);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(filename, record);\n this.moduleQueue.add(filename);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport interface RootMarker {\n isRoot: true;\n}\n\nexport function isRootMarker(value: string | RootMarker | undefined): value is RootMarker {\n return Boolean(value && typeof value !== 'string' && value.isRoot);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { NodePath } from '@babel/traverse';
2
2
  import type * as Babel from '@babel/core';
3
- export declare type Options = {
3
+ export type Options = {
4
4
  appRoot: string;
5
5
  };
6
6
  interface State {
@@ -0,0 +1,5 @@
1
+ import V1Addon from '../../v1-addon';
2
+ export default class extends V1Addon {
3
+ protected suppressesTree(_name: string): boolean;
4
+ reduceInstances(instances: V1Addon[]): V1Addon[];
5
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const v1_addon_1 = __importDefault(require("../../v1-addon"));
7
+ const semver_1 = require("semver");
8
+ class default_1 extends v1_addon_1.default {
9
+ // our heuristic for detecting tree suppression can't deal with the way
10
+ // test-waiters patches treeFor on other copies of its addon instances all
11
+ // over the place. It causes us to falsely detect that it's trying to suppress
12
+ // all tree output, reducing in empty copies.
13
+ suppressesTree(_name) {
14
+ return false;
15
+ }
16
+ reduceInstances(instances) {
17
+ if (!(0, semver_1.satisfies)(this.packageJSON.version, '>=3.0.2')) {
18
+ throw new Error(`@ember/test-waiters cannot work safely under embroider before version 3.0.2 due to https://github.com/emberjs/ember-test-waiters/pull/388. You have a copy at version ${this.packageJSON.version}.`);
19
+ }
20
+ // we know test waiters tries to dedup itself, so there's no point in building
21
+ // and smooshing many copies.
22
+ return [instances[0]];
23
+ }
24
+ }
25
+ exports.default = default_1;
26
+ //# sourceMappingURL=test-waiters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-waiters.js","sourceRoot":"","sources":["test-waiters.ts"],"names":[],"mappings":";;;;;AAAA,8DAAqC;AACrC,mCAAmC;AAEnC,eAAqB,SAAQ,kBAAO;IAClC,uEAAuE;IACvE,0EAA0E;IAC1E,8EAA8E;IAC9E,6CAA6C;IACnC,cAAc,CAAC,KAAa;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe,CAAC,SAAoB;QAClC,IAAI,CAAC,IAAA,kBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CACb,yKAAyK,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,CACrM,CAAC;SACH;QAED,8EAA8E;QAC9E,6BAA6B;QAC7B,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACF;AApBD,4BAoBC","sourcesContent":["import V1Addon from '../../v1-addon';\nimport { satisfies } from 'semver';\n\nexport default class extends V1Addon {\n // our heuristic for detecting tree suppression can't deal with the way\n // test-waiters patches treeFor on other copies of its addon instances all\n // over the place. It causes us to falsely detect that it's trying to suppress\n // all tree output, reducing in empty copies.\n protected suppressesTree(_name: string): boolean {\n return false;\n }\n\n reduceInstances(instances: V1Addon[]): V1Addon[] {\n if (!satisfies(this.packageJSON.version, '>=3.0.2')) {\n throw new Error(\n `@ember/test-waiters cannot work safely under embroider before version 3.0.2 due to https://github.com/emberjs/ember-test-waiters/pull/388. You have a copy at version ${this.packageJSON.version}.`\n );\n }\n\n // we know test waiters tries to dedup itself, so there's no point in building\n // and smooshing many copies.\n return [instances[0]];\n }\n}\n"]}
@@ -11,6 +11,6 @@ import V1Addon from '../v1-addon';
11
11
  * `config/environment` runtime value, but without needing it to actually export from the host app's module.
12
12
  */
13
13
  export default class extends V1Addon {
14
- get v2Tree(): any;
14
+ get v2Tree(): Node;
15
15
  static shouldApplyAdapter(addonInstance: any): boolean;
16
16
  }
@@ -1,4 +1,4 @@
1
1
  import V1Addon from '../v1-addon';
2
2
  export default class extends V1Addon {
3
- get v2Tree(): any;
3
+ get v2Tree(): Node;
4
4
  }
@@ -1,4 +1,4 @@
1
1
  import V1Addon from '../v1-addon';
2
2
  export default class extends V1Addon {
3
- get v2Tree(): any;
3
+ get v2Tree(): Node;
4
4
  }
@@ -47,11 +47,11 @@ export interface ModuleRules {
47
47
  dependsOnComponents?: ComponentSnippet[];
48
48
  dependsOnModules?: string[];
49
49
  }
50
- export declare type ArgumentMapping = string | {
50
+ export type ArgumentMapping = string | {
51
51
  name: string;
52
52
  becomes: string;
53
53
  };
54
- declare type ComponentSnippet = string;
54
+ type ComponentSnippet = string;
55
55
  export interface PreprocessedComponentRule {
56
56
  yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];
57
57
  yieldsArguments: Required<ComponentRules>['yieldsArguments'];
@@ -3,13 +3,13 @@ import { ActivePackageRules } from './dependency-rules';
3
3
  import type { WithJSUtils } from 'babel-plugin-ember-template-compilation';
4
4
  import { ResolverOptions as CoreResolverOptions } from '@embroider/core';
5
5
  import CompatOptions from './options';
6
- declare type Env = WithJSUtils<ASTPluginEnvironment> & {
6
+ type Env = WithJSUtils<ASTPluginEnvironment> & {
7
7
  filename: string;
8
8
  contents: string;
9
9
  strictMode?: boolean;
10
10
  locals?: string[];
11
11
  };
12
- declare type UserConfig = Pick<Required<CompatOptions>, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
12
+ type UserConfig = Pick<Required<CompatOptions>, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
13
13
  export interface CompatResolverOptions extends CoreResolverOptions {
14
14
  activePackageRules: ActivePackageRules[];
15
15
  options: UserConfig;
@@ -1,6 +1,6 @@
1
1
  import { Node } from 'broccoli-node-api';
2
2
  import { AddonMeta } from '@embroider/core';
3
- declare type GetMeta = () => Partial<AddonMeta>;
3
+ type GetMeta = () => Partial<AddonMeta>;
4
4
  export default function rewriteAddonTree(tree: Node, name: string, moduleName: string): {
5
5
  tree: Node;
6
6
  getMeta: GetMeta;
package/src/v1-addon.d.ts CHANGED
@@ -34,7 +34,7 @@ export default class V1Addon {
34
34
  protected get packageMeta(): Partial<AddonMeta>;
35
35
  protected get v2Trees(): Node[];
36
36
  protected throughTreeCache(nameOrNames: string | string[], category: string, fn: () => Node): Node;
37
- private suppressesTree;
37
+ protected suppressesTree(name: string): boolean;
38
38
  protected invokeOriginalTreeFor(name: string, { neuterPreprocessors }?: {
39
39
  neuterPreprocessors: boolean;
40
40
  }): Node | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"v1-addon.js","sourceRoot":"","sources":["v1-addon.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAA6C;AAC7C,+BAA+C;AAC/C,mCAA2C;AAC3C,uCAAsD;AACtD,sEAAwE;AACxE,qDAA2D;AAC3D,kFAAwD;AACxD,2DAAiE;AAEjE,gFAA8C;AAC9C,oDAA4B;AAC5B,8EAAoD;AACpD,qCAA2C;AAC3C,0CAA+F;AAE/F,0DAAiC;AACjC,kEAAyC;AAEzC,qDAAqE;AAGrE,sEAA6C;AAC7C,kFAA8C;AAC9C,gHAAqF;AACrF,iEAKgC;AAChC,4FAAgE;AAChE,mCAAmC;AACnC,kGAA6E;AAC7E,sEAA4C;AAG5C,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;IACvB,yBAAyB;IACzB,YAAY;IACZ,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,oBA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,MAAM,CAAC,EAAE;QACpC,qEAAqE;QACrE,oEAAoE;QACpE,4DAA4D;QAC5D,aAAa;QACb,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAA,+CAAwB,EAAC,MAAM,CAAC,EAAE;QACpC,2EAA2E;QAC3E,gDAAgD;QAChD,OAAO,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, 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 { AddonMeta, debug, PackageCache, AddonInstance, AddonTreePath } 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 {\n isEmberAutoImportDynamic,\n isCompactReexports,\n isColocationPlugin,\n isInlinePrecompilePlugin,\n} from './detect-babel-plugins';\nimport HbsToJSBroccoliPlugin from './hbs-to-js-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\nimport type { Options as EtcOptions } from 'babel-plugin-ember-template-compilation';\n\nconst stockTreeNames: AddonTreePath[] = Object.freeze([\n 'addon',\n 'addon-styles',\n 'styles',\n 'addon-test-support',\n 'test-support',\n 'app',\n 'public',\n 'vendor',\n // 'addon-templates' and 'templates are trees too, but they live inside\n // 'addon' and 'app' and we handle them there.\n]) as AddonTreePath[];\n\nconst dynamicTreeHooks = Object.freeze([\n 'treeFor',\n 'treeForAddon',\n 'treeForAddonTemplates',\n 'treeForAddonTestSupport',\n 'treeForApp',\n 'treeForPublic',\n 'treeForStyles',\n 'treeForTemplates',\n 'treeForTestSupport',\n 'treeForVendor',\n]);\n\nconst defaultMethods = {\n app: 'treeForApp',\n addon: 'treeForAddon',\n 'addon-styles': 'treeForAddonStyles',\n 'addon-templates': 'treeForAddonTemplates',\n 'addon-test-support': 'treeForAddonTestSupport',\n public: 'treeForPublic',\n styles: 'treeForStyles',\n templates: 'treeForTemplates',\n 'test-support': 'treeForTestSupport',\n vendor: 'treeForVendor',\n};\n\nconst appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n// This controls and types the interface between our new world and the classic\n// v1 addon instance.\nexport default class V1Addon {\n constructor(\n protected addonInstance: AddonInstance,\n protected addonOptions: 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 // Optional extensible hook for pruning down the list of redundant addon\n // instances produced by the classic ember-cli architecture. ember-cli\n // instantiates each addon *per consumer*, not per package. So a given package\n // will have many addon instances, and Embroider dutifully produces a V1Addon\n // instance for each one, and then needs to mimic the classic smooshing\n // behavior between them.\n //\n // But some packages (and ember-cli-babel is the motivating example) produce a\n // huge number of instances that do nothing useful and incur significant cost.\n // This hook allows their compat adapter to prune down the set, using\n // addon-specific knowledge of which instance(s) are actually important.\n //\n // The order of the instances is significant. The first one is the one with\n // the highest precedence, meaning its files would win under classic\n // smooshing.\n reduceInstances(instances: V1Addon[]): V1Addon[] {\n // the default beahvior is that all copies matter\n return instances;\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompilerBabelPlugin(): PluginItem | undefined {\n let 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 let opts: EtcOptions = {\n compilerPath: options.templateCompilerPath,\n targetFormat: 'hbs',\n enableLegacyModules: [\n 'ember-cli-htmlbars',\n 'ember-cli-htmlbars-inline-precompile',\n 'htmlbars-inline-precompile',\n ],\n transforms: options.plugins.ast as any,\n };\n return [require.resolve('babel-plugin-ember-template-compilation'), opts];\n }\n }\n }\n }\n\n private updateRegistry(registry: any) {\n // auto-import gets disabled because we support it natively\n registry.remove('js', 'ember-auto-import-analyzer');\n\n // here we're replacing the stock template compiler with our own. Ours\n // doesn't compile all the way to wire format -- it does source-to-source\n // transformation just to process custom AST transforms, while leaving the\n // template as a template. It does turn HBS files into equivalent JS files\n // (because in the general case, AST transforms may need to emit values in\n // Javascript scope), but those JS files will contain HBS strings, not wire\n // format.\n //\n // Even when no AST transforms are registered, we'll still need to register\n // a no-op transform here to avoid an exception coming out of ember-cli like\n // \"Addon templates were detected, but there are no template compilers\n // registered\".\n registry.remove('template', 'ember-cli-htmlbars');\n registry.add('template', {\n name: 'embroider-addon-templates',\n ext: 'hbs',\n _addon: this,\n toTree(this: { _addon: V1Addon }, tree: Node): Node {\n if (this._addon.templateCompilerBabelPlugin) {\n return new HbsToJSBroccoliPlugin(tree);\n } else {\n // when there are no custom AST transforms, we don't need to do\n // anything at all.\n return tree;\n }\n },\n });\n\n // first, look into the babel config and related packages to decide whether\n // we need to run babel at all in this stage.\n let needsCustomBabel = this.needsCustomBabel();\n\n // regardless of the answer, we modify the babel config, because even if\n // we're unregistering ember-cli-babel, some addons manually invoke\n // ember-cli-babel in their custom hooks, and in that case we want to be\n // sure we've taken out the babel plugins that really shouldn't run at this\n // stage.\n this.updateBabelConfig();\n\n if (!needsCustomBabel) {\n // no custom babel behavior, so we don't run the ember-cli-babel\n // preprocessor at all. We still need to register a no-op preprocessor to\n // prevent ember-cli from emitting a deprecation warning.\n registry.remove('js', 'ember-cli-babel');\n registry.add('js', {\n name: 'embroider-babel-noop',\n ext: 'js',\n toTree(tree: Node) {\n return tree;\n },\n });\n }\n }\n\n // we need to run custom inline hbs preprocessing if there are custom hbs\n // plugins and there are inline hbs templates\n private needsInlineHBS(): boolean {\n if (!this.templateCompilerBabelPlugin) {\n // no custom transforms\n return false;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-htmlbars-inline-precompile')) {\n // the older inline template compiler is present\n return true;\n }\n\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-htmlbars' && semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>4.0.0')\n )\n ) {\n // a version of ember-cli-htmlbars that natively supports inline hbs is present\n return true;\n }\n\n return false;\n }\n\n private needsCustomBabel() {\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-typescript' &&\n semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>=4.0.0-alpha.1')\n )\n ) {\n // This addon is using ember-cli-typescript 4, which relies on\n // ember-cli-babel to add the TypeScript transform Babel plugin.\n return true;\n }\n\n if (\n this.addonInstance.options &&\n this.addonInstance.options['ember-cli-babel'] &&\n this.addonInstance.options['ember-cli-babel'].enableTypeScriptTransform\n ) {\n // This addon has explicitly configured ember-cli-babel to add the\n // TypeScript transform Babel plugin.\n return true;\n }\n\n if ((this.options.babel?.plugins?.filter(babelPluginAllowedInStage1)?.length ?? 0) > 0) {\n // this addon has custom babel plugins, so we need to run them here in\n // stage1\n return true;\n }\n\n // even if there are no custom babel plugins, if we need to do any\n // preprocessing of inline handlebars templates we still need to run the\n // custom babel.\n return this.needsInlineHBS();\n }\n\n get name(): string {\n return this.packageJSON.name;\n }\n\n // you can override this to change the *input* packageJSON that the rest of\n // stage1 will see. If you want to see and change the *output* packageJSON see\n // `newPackageJSON`.\n protected get packageJSON() {\n return this.packageCache.get(this.root).packageJSON;\n }\n\n protected get newPackageJSON() {\n // shallow copy only! This is OK as long as we're only changing top-level\n // keys in this method\n let pkg = Object.assign({}, this.packageJSON);\n let meta: AddonMeta = Object.assign({}, this.packageCache.get(this.root).meta, this.packageMeta);\n pkg['ember-addon'] = meta;\n\n // classic addons don't get to customize their entrypoints like this. We\n // always rewrite them so their entrypoint is index.js, so whatever was here\n // is just misleading to stage3 packagers that might look (rollup does).\n delete pkg.main;\n delete pkg.module;\n delete pkg.exports;\n\n return pkg;\n }\n\n @Memoize()\n get root(): string {\n // addonInstance.root gets modified by a customized \"main\" or\n // \"ember-addon.main\" in package.json. We want the real package root here\n // (the place where package.json lives).\n return dirname(pkgUpSync({ cwd: this.addonInstance.root })!);\n }\n\n @Memoize()\n private get mainModule() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require((this.addonInstance as unknown as any).constructor._meta_.modulePath);\n\n if (typeof mod === 'function') {\n return mod.prototype;\n } else {\n return mod;\n }\n }\n\n protected get options() {\n if (!this.addonInstance.options) {\n this.addonInstance.options = {};\n return this.addonInstance.options;\n }\n // some addons (like ember-cli-inline-content) assign the *app's* options\n // onto their own this.options. Which means they (accidentally or on\n // purpose), always get the app's babel config, and it means when we try\n // to modify the addon's babel config we're accidentally modifying the\n // app's too.\n //\n // So here we do copying to ensure that we can modify the babel config\n // without altering anybody else. We're not doing cloneDeep because that\n // pulls on our lazy MacrosConfig if it appears in any babel configs here,\n // whereas we want to leave it unevaluated until babel actually uses it.\n let addonOptions =\n typeof this.addonInstance.options == 'function' ? this.addonInstance.options() : this.addonInstance.options;\n let options = Object.assign({}, addonOptions);\n if (options.babel) {\n options.babel = Object.assign({}, options.babel);\n if (options.babel.plugins) {\n options.babel.plugins = options.babel.plugins.slice();\n }\n }\n if (options['ember-cli-babel']) {\n options['ember-cli-babel'] = Object.assign({}, options['ember-cli-babel']);\n }\n\n if (typeof this.addonInstance.options == 'function') {\n this.addonInstance.options = () => options;\n } else {\n this.addonInstance.options = options;\n }\n\n return options;\n }\n\n protected customizes(...treeNames: string[]) {\n // get the real addon as we're going to compare with __proto__\n const realAddon = getRealAddon(this.addonInstance);\n return Boolean(\n treeNames.find(treeName => {\n return (\n // customized hook exists in actual code exported from their index.js\n this.mainModule[treeName] ||\n // addon instance doesn't match its own prototype\n (realAddon.__proto__ && realAddon[treeName] !== realAddon.__proto__[treeName]) ||\n this.customizesHookName(treeName)\n );\n })\n );\n }\n\n private customizesHookName(treeName: string): boolean {\n if (!this.addonInstance.treeForMethods) {\n // weird old addons don't even extend ember-cli's Addon base class and\n // might not have this.\n return false;\n }\n for (let [name, methodName] of Object.entries(defaultMethods)) {\n if (methodName === treeName) {\n return this.addonInstance.treeForMethods[name] !== methodName;\n }\n }\n return false;\n }\n\n @Memoize()\n private hasStockTree(treeName: AddonTreePath): boolean {\n if (this.suppressesTree(treeName)) {\n return false;\n }\n\n // we need to use this.addonInstance.root instead of this.root here because\n // we're looking for the classic location of the stock tree, and that\n // location is influenced by a customized ember-addon.main in package.json,\n // which is reflected in addonInstance.root.\n return (\n this.addonInstance.treePaths && existsSync(join(this.addonInstance.root, this.addonInstance.treePaths[treeName]))\n );\n }\n\n hasAnyTrees(): boolean {\n return Boolean(stockTreeNames.find(name => this.hasStockTree(name))) || this.customizes(...dynamicTreeHooks);\n }\n\n // we keep all these here to ensure that we always apply the same options to\n // the same tree, so that our cache doesn't need to worry about varying\n // options.\n private stockTreeFunnelOptions(treeName: string): FunnelOptions | undefined {\n switch (treeName) {\n case 'addon':\n return {\n exclude: ['styles/**'],\n };\n case 'styles':\n return {\n destDir: '_app_styles_',\n };\n case 'addon-test-support':\n return {\n destDir: 'test-support',\n };\n case 'app':\n return {\n exclude: ['styles/**'],\n destDir: appPublicationDir,\n };\n case 'public':\n return {\n destDir: `public/${this.moduleName}`,\n };\n case 'vendor':\n return {\n destDir: 'vendor',\n };\n }\n }\n\n protected stockTree(treeName: AddonTreePath): Node {\n return this.throughTreeCache(treeName, 'stock', () => {\n // adjust from the legacy \"root\" to our real root, because our rootTree\n // uses our real root but the stock trees are defined in terms of the\n // legacy root\n let srcDir = relative(this.root, join(this.addonInstance.root, this.addonInstance.treePaths[treeName]));\n let opts = Object.assign({ srcDir }, this.stockTreeFunnelOptions(treeName));\n return buildFunnel(this.rootTree, opts);\n })!;\n }\n\n @Memoize()\n protected get rootTree(): Node {\n if (this.packageCache.get(this.root).mayRebuild) {\n return new WatchedDir(this.root);\n } else {\n return new UnwatchedDir(this.root);\n }\n }\n\n @Memoize()\n private get moduleName(): string {\n if (typeof this.addonInstance.moduleName === 'function') {\n return this.addonInstance.moduleName();\n }\n return this.addonInstance.name;\n }\n\n // applies preprocessors to JS and HBS\n private transpile(tree: Node) {\n // Namespace the tree being passed to preprocessJs with the moduleName\n // to mimic classic build\n tree = buildFunnel(tree, { destDir: this.moduleName });\n\n if (this.addonInstance.shouldCompileTemplates() && this.addonInstance.registry.load('template')?.length > 0) {\n tree = this.app.preprocessRegistry.preprocessTemplates(tree, {\n registry: this.addonInstance.registry,\n });\n }\n\n tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\n });\n\n // Remove namespacing so that it gets written out to the node_modules\n // directory correctly.\n tree = buildFunnel(tree, {\n srcDir: this.moduleName,\n });\n\n return tree;\n }\n\n @Memoize()\n protected updateBabelConfig() {\n let packageOptions = this.options;\n let emberCLIBabelInstance = this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-babel');\n let version;\n\n if (emberCLIBabelInstance) {\n version = emberCLIBabelInstance.pkg.version;\n }\n\n if (!packageOptions['ember-cli-babel']) {\n packageOptions['ember-cli-babel'] = {};\n }\n\n if (!packageOptions.babel) {\n packageOptions.babel = {};\n }\n let babelConfig = packageOptions.babel as TransformOptions;\n\n Object.assign(packageOptions['ember-cli-babel'], {\n compileModules: false,\n disablePresetEnv: true,\n disableDebugTooling: true,\n disableEmberModulesAPIPolyfill: true,\n });\n\n if (version && semver.satisfies(semver.coerce(version) || version, '^5')) {\n unsupported(`${this.name} is using babel 5. Not installing our custom plugin.`);\n return;\n }\n\n if (!babelConfig.plugins) {\n babelConfig.plugins = [];\n } else {\n let hadAutoImport = Boolean(babelConfig.plugins.find(isEmberAutoImportDynamic));\n babelConfig.plugins = babelConfig.plugins.filter(babelPluginAllowedInStage1);\n if (hadAutoImport) {\n // if we removed ember-auto-import's dynamic import() plugin, the code\n // may use import() syntax and we need to re-add it to the parser.\n if (version && semver.satisfies(semver.coerce(version) || version, '^6')) {\n babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import'));\n } else {\n babelConfig.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));\n }\n }\n }\n\n if (this.templateCompilerBabelPlugin) {\n babelConfig.plugins.push(this.templateCompilerBabelPlugin);\n }\n }\n\n get v2Tree(): Node {\n return this.throughTreeCache(\n // these are all the kinds of trees that ember-cli's tree cache\n // understands. We need them all here because if *any* of these are\n // uncacheable, we want our whole v2 tree to be treated as uncacheable.\n [\n 'app',\n 'addon',\n 'addon-styles',\n 'addon-templates',\n 'addon-test-support',\n 'public',\n 'styles',\n 'templates',\n 'test-support',\n 'vendor',\n ],\n 'v2Tree',\n () => mergeTrees(this.v2Trees, { overwrite: true })\n );\n }\n\n // this is split out so that compatibility shims can override it to add more\n // things to the package metadata.\n protected get packageMeta(): Partial<AddonMeta> {\n let built = this.build();\n return mergeWithAppend(\n {\n version: 2,\n 'auto-upgraded': true,\n type: 'addon',\n },\n built.staticMeta,\n ...built.dynamicMeta.map(d => d())\n );\n }\n\n @Memoize()\n protected get v2Trees() {\n let { trees } = this.build();\n return trees;\n }\n\n protected throughTreeCache(nameOrNames: string | string[], category: string, fn: () => Node): Node;\n protected throughTreeCache(\n nameOrNames: string | string[],\n category: string,\n fn: () => Node | undefined\n ): Node | undefined {\n let cacheKey: string | undefined;\n if (typeof this.addonInstance.cacheKeyForTree === 'function') {\n let names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames];\n cacheKey = names.reduce((accum: string | undefined, name) => {\n if (accum == null) {\n // a previous name was uncacheable, so we're entirely uncacheable\n return undefined;\n }\n let key = this.addonInstance.cacheKeyForTree?.(name);\n if (key) {\n return accum + key;\n } else {\n return undefined;\n }\n }, '');\n if (cacheKey) {\n cacheKey = cacheKey + category;\n let cachedTree = this.app.addonTreeCache.get(cacheKey);\n if (cachedTree) {\n debug('cache hit %s %s %s', this.name, nameOrNames, category);\n return cachedTree;\n }\n }\n }\n debug('cache miss %s %s %s', this.name, nameOrNames, category);\n let tree = fn();\n if (tree && cacheKey) {\n this.app.addonTreeCache.set(cacheKey, tree);\n }\n return tree;\n }\n\n // In general, we can't reliably run addons' custom `treeFor()` methods,\n // because they recurse in a way that we absolutely don't want.\n //\n // But there is a very common use case that we *can* handle opportunisticaly,\n // which is a treeFor() that's used purely to guard whether `_super` will be\n // called or not.\n 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, {\n allowedPaths: ['components'],\n\n // if an addon has custom AST transforms, stage1 can rewrite .hbs to\n // .hbs.js\n templateExtensions: ['.hbs', '.hbs.js'],\n });\n 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 (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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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, 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 { AddonMeta, debug, PackageCache, AddonInstance, AddonTreePath } 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 {\n isEmberAutoImportDynamic,\n isCompactReexports,\n isColocationPlugin,\n isInlinePrecompilePlugin,\n} from './detect-babel-plugins';\nimport HbsToJSBroccoliPlugin from './hbs-to-js-broccoli-plugin';\nimport { fromPairs } from 'lodash';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport getRealAddon from './get-real-addon';\nimport type { Options as EtcOptions } from 'babel-plugin-ember-template-compilation';\n\nconst stockTreeNames: AddonTreePath[] = Object.freeze([\n 'addon',\n 'addon-styles',\n 'styles',\n 'addon-test-support',\n 'test-support',\n 'app',\n 'public',\n 'vendor',\n // 'addon-templates' and 'templates are trees too, but they live inside\n // 'addon' and 'app' and we handle them there.\n]) as AddonTreePath[];\n\nconst dynamicTreeHooks = Object.freeze([\n 'treeFor',\n 'treeForAddon',\n 'treeForAddonTemplates',\n 'treeForAddonTestSupport',\n 'treeForApp',\n 'treeForPublic',\n 'treeForStyles',\n 'treeForTemplates',\n 'treeForTestSupport',\n 'treeForVendor',\n]);\n\nconst defaultMethods = {\n app: 'treeForApp',\n addon: 'treeForAddon',\n 'addon-styles': 'treeForAddonStyles',\n 'addon-templates': 'treeForAddonTemplates',\n 'addon-test-support': 'treeForAddonTestSupport',\n public: 'treeForPublic',\n styles: 'treeForStyles',\n templates: 'treeForTemplates',\n 'test-support': 'treeForTestSupport',\n vendor: 'treeForVendor',\n};\n\nconst appPublicationDir = '_app_';\nconst fastbootPublicationDir = '_fastboot_';\n\n// This controls and types the interface between our new world and the classic\n// v1 addon instance.\nexport default class V1Addon {\n constructor(\n protected addonInstance: AddonInstance,\n protected addonOptions: 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 // Optional extensible hook for pruning down the list of redundant addon\n // instances produced by the classic ember-cli architecture. ember-cli\n // instantiates each addon *per consumer*, not per package. So a given package\n // will have many addon instances, and Embroider dutifully produces a V1Addon\n // instance for each one, and then needs to mimic the classic smooshing\n // behavior between them.\n //\n // But some packages (and ember-cli-babel is the motivating example) produce a\n // huge number of instances that do nothing useful and incur significant cost.\n // This hook allows their compat adapter to prune down the set, using\n // addon-specific knowledge of which instance(s) are actually important.\n //\n // The order of the instances is significant. The first one is the one with\n // the highest precedence, meaning its files would win under classic\n // smooshing.\n reduceInstances(instances: V1Addon[]): V1Addon[] {\n // the default beahvior is that all copies matter\n return instances;\n }\n\n // this is only defined when there are custom AST transforms that need it\n @Memoize()\n private get templateCompilerBabelPlugin(): PluginItem | undefined {\n let 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 let opts: EtcOptions = {\n compilerPath: options.templateCompilerPath,\n targetFormat: 'hbs',\n enableLegacyModules: [\n 'ember-cli-htmlbars',\n 'ember-cli-htmlbars-inline-precompile',\n 'htmlbars-inline-precompile',\n ],\n transforms: options.plugins.ast as any,\n };\n return [require.resolve('babel-plugin-ember-template-compilation'), opts];\n }\n }\n }\n }\n\n private updateRegistry(registry: any) {\n // auto-import gets disabled because we support it natively\n registry.remove('js', 'ember-auto-import-analyzer');\n\n // here we're replacing the stock template compiler with our own. Ours\n // doesn't compile all the way to wire format -- it does source-to-source\n // transformation just to process custom AST transforms, while leaving the\n // template as a template. It does turn HBS files into equivalent JS files\n // (because in the general case, AST transforms may need to emit values in\n // Javascript scope), but those JS files will contain HBS strings, not wire\n // format.\n //\n // Even when no AST transforms are registered, we'll still need to register\n // a no-op transform here to avoid an exception coming out of ember-cli like\n // \"Addon templates were detected, but there are no template compilers\n // registered\".\n registry.remove('template', 'ember-cli-htmlbars');\n registry.add('template', {\n name: 'embroider-addon-templates',\n ext: 'hbs',\n _addon: this,\n toTree(this: { _addon: V1Addon }, tree: Node): Node {\n if (this._addon.templateCompilerBabelPlugin) {\n return new HbsToJSBroccoliPlugin(tree);\n } else {\n // when there are no custom AST transforms, we don't need to do\n // anything at all.\n return tree;\n }\n },\n });\n\n // first, look into the babel config and related packages to decide whether\n // we need to run babel at all in this stage.\n let needsCustomBabel = this.needsCustomBabel();\n\n // regardless of the answer, we modify the babel config, because even if\n // we're unregistering ember-cli-babel, some addons manually invoke\n // ember-cli-babel in their custom hooks, and in that case we want to be\n // sure we've taken out the babel plugins that really shouldn't run at this\n // stage.\n this.updateBabelConfig();\n\n if (!needsCustomBabel) {\n // no custom babel behavior, so we don't run the ember-cli-babel\n // preprocessor at all. We still need to register a no-op preprocessor to\n // prevent ember-cli from emitting a deprecation warning.\n registry.remove('js', 'ember-cli-babel');\n registry.add('js', {\n name: 'embroider-babel-noop',\n ext: 'js',\n toTree(tree: Node) {\n return tree;\n },\n });\n }\n }\n\n // we need to run custom inline hbs preprocessing if there are custom hbs\n // plugins and there are inline hbs templates\n private needsInlineHBS(): boolean {\n if (!this.templateCompilerBabelPlugin) {\n // no custom transforms\n return false;\n }\n if (this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-htmlbars-inline-precompile')) {\n // the older inline template compiler is present\n return true;\n }\n\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-htmlbars' && semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>4.0.0')\n )\n ) {\n // a version of ember-cli-htmlbars that natively supports inline hbs is present\n return true;\n }\n\n return false;\n }\n\n private needsCustomBabel() {\n if (\n this.addonInstance.addons.find(\n (a: any) =>\n a.name === 'ember-cli-typescript' &&\n semver.satisfies(semver.coerce(a.pkg.version) || a.pkg.version, '>=4.0.0-alpha.1')\n )\n ) {\n // This addon is using ember-cli-typescript 4, which relies on\n // ember-cli-babel to add the TypeScript transform Babel plugin.\n return true;\n }\n\n if (\n this.addonInstance.options &&\n this.addonInstance.options['ember-cli-babel'] &&\n this.addonInstance.options['ember-cli-babel'].enableTypeScriptTransform\n ) {\n // This addon has explicitly configured ember-cli-babel to add the\n // TypeScript transform Babel plugin.\n return true;\n }\n\n if ((this.options.babel?.plugins?.filter(babelPluginAllowedInStage1)?.length ?? 0) > 0) {\n // this addon has custom babel plugins, so we need to run them here in\n // stage1\n return true;\n }\n\n // even if there are no custom babel plugins, if we need to do any\n // preprocessing of inline handlebars templates we still need to run the\n // custom babel.\n return this.needsInlineHBS();\n }\n\n get name(): string {\n return this.packageJSON.name;\n }\n\n // you can override this to change the *input* packageJSON that the rest of\n // stage1 will see. If you want to see and change the *output* packageJSON see\n // `newPackageJSON`.\n protected get packageJSON() {\n return this.packageCache.get(this.root).packageJSON;\n }\n\n protected get newPackageJSON() {\n // shallow copy only! This is OK as long as we're only changing top-level\n // keys in this method\n let pkg = Object.assign({}, this.packageJSON);\n let meta: AddonMeta = Object.assign({}, this.packageCache.get(this.root).meta, this.packageMeta);\n pkg['ember-addon'] = meta;\n\n // classic addons don't get to customize their entrypoints like this. We\n // always rewrite them so their entrypoint is index.js, so whatever was here\n // is just misleading to stage3 packagers that might look (rollup does).\n delete pkg.main;\n delete pkg.module;\n delete pkg.exports;\n\n return pkg;\n }\n\n @Memoize()\n get root(): string {\n // addonInstance.root gets modified by a customized \"main\" or\n // \"ember-addon.main\" in package.json. We want the real package root here\n // (the place where package.json lives).\n return dirname(pkgUpSync({ cwd: this.addonInstance.root })!);\n }\n\n @Memoize()\n private get mainModule() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require((this.addonInstance as unknown as any).constructor._meta_.modulePath);\n\n if (typeof mod === 'function') {\n return mod.prototype;\n } else {\n return mod;\n }\n }\n\n protected get options() {\n if (!this.addonInstance.options) {\n this.addonInstance.options = {};\n return this.addonInstance.options;\n }\n // some addons (like ember-cli-inline-content) assign the *app's* options\n // onto their own this.options. Which means they (accidentally or on\n // purpose), always get the app's babel config, and it means when we try\n // to modify the addon's babel config we're accidentally modifying the\n // app's too.\n //\n // So here we do copying to ensure that we can modify the babel config\n // without altering anybody else. We're not doing cloneDeep because that\n // pulls on our lazy MacrosConfig if it appears in any babel configs here,\n // whereas we want to leave it unevaluated until babel actually uses it.\n let addonOptions =\n typeof this.addonInstance.options == 'function' ? this.addonInstance.options() : this.addonInstance.options;\n let options = Object.assign({}, addonOptions);\n if (options.babel) {\n options.babel = Object.assign({}, options.babel);\n if (options.babel.plugins) {\n options.babel.plugins = options.babel.plugins.slice();\n }\n }\n if (options['ember-cli-babel']) {\n options['ember-cli-babel'] = Object.assign({}, options['ember-cli-babel']);\n }\n\n if (typeof this.addonInstance.options == 'function') {\n this.addonInstance.options = () => options;\n } else {\n this.addonInstance.options = options;\n }\n\n return options;\n }\n\n protected customizes(...treeNames: string[]) {\n // get the real addon as we're going to compare with __proto__\n const realAddon = getRealAddon(this.addonInstance);\n return Boolean(\n treeNames.find(treeName => {\n return (\n // customized hook exists in actual code exported from their index.js\n this.mainModule[treeName] ||\n // addon instance doesn't match its own prototype\n (realAddon.__proto__ && realAddon[treeName] !== realAddon.__proto__[treeName]) ||\n this.customizesHookName(treeName)\n );\n })\n );\n }\n\n private customizesHookName(treeName: string): boolean {\n if (!this.addonInstance.treeForMethods) {\n // weird old addons don't even extend ember-cli's Addon base class and\n // might not have this.\n return false;\n }\n for (let [name, methodName] of Object.entries(defaultMethods)) {\n if (methodName === treeName) {\n return this.addonInstance.treeForMethods[name] !== methodName;\n }\n }\n return false;\n }\n\n @Memoize()\n private hasStockTree(treeName: AddonTreePath): boolean {\n if (this.suppressesTree(treeName)) {\n return false;\n }\n\n // we need to use this.addonInstance.root instead of this.root here because\n // we're looking for the classic location of the stock tree, and that\n // location is influenced by a customized ember-addon.main in package.json,\n // which is reflected in addonInstance.root.\n return (\n this.addonInstance.treePaths && existsSync(join(this.addonInstance.root, this.addonInstance.treePaths[treeName]))\n );\n }\n\n hasAnyTrees(): boolean {\n return Boolean(stockTreeNames.find(name => this.hasStockTree(name))) || this.customizes(...dynamicTreeHooks);\n }\n\n // we keep all these here to ensure that we always apply the same options to\n // the same tree, so that our cache doesn't need to worry about varying\n // options.\n private stockTreeFunnelOptions(treeName: string): FunnelOptions | undefined {\n switch (treeName) {\n case 'addon':\n return {\n exclude: ['styles/**'],\n };\n case 'styles':\n return {\n destDir: '_app_styles_',\n };\n case 'addon-test-support':\n return {\n destDir: 'test-support',\n };\n case 'app':\n return {\n exclude: ['styles/**'],\n destDir: appPublicationDir,\n };\n case 'public':\n return {\n destDir: `public/${this.moduleName}`,\n };\n case 'vendor':\n return {\n destDir: 'vendor',\n };\n }\n }\n\n protected stockTree(treeName: AddonTreePath): Node {\n return this.throughTreeCache(treeName, 'stock', () => {\n // adjust from the legacy \"root\" to our real root, because our rootTree\n // uses our real root but the stock trees are defined in terms of the\n // legacy root\n let srcDir = relative(this.root, join(this.addonInstance.root, this.addonInstance.treePaths[treeName]));\n let opts = Object.assign({ srcDir }, this.stockTreeFunnelOptions(treeName));\n return buildFunnel(this.rootTree, opts);\n })!;\n }\n\n @Memoize()\n protected get rootTree(): Node {\n if (this.packageCache.get(this.root).mayRebuild) {\n return new WatchedDir(this.root);\n } else {\n return new UnwatchedDir(this.root);\n }\n }\n\n @Memoize()\n private get moduleName(): string {\n if (typeof this.addonInstance.moduleName === 'function') {\n return this.addonInstance.moduleName();\n }\n return this.addonInstance.name;\n }\n\n // applies preprocessors to JS and HBS\n private transpile(tree: Node) {\n // Namespace the tree being passed to preprocessJs with the moduleName\n // to mimic classic build\n tree = buildFunnel(tree, { destDir: this.moduleName });\n\n if (this.addonInstance.shouldCompileTemplates() && this.addonInstance.registry.load('template')?.length > 0) {\n tree = this.app.preprocessRegistry.preprocessTemplates(tree, {\n registry: this.addonInstance.registry,\n });\n }\n\n tree = this.addonInstance.preprocessJs(tree, '/', this.moduleName, {\n registry: this.addonInstance.registry,\n });\n\n // Remove namespacing so that it gets written out to the node_modules\n // directory correctly.\n tree = buildFunnel(tree, {\n srcDir: this.moduleName,\n });\n\n return tree;\n }\n\n @Memoize()\n protected updateBabelConfig() {\n let packageOptions = this.options;\n let emberCLIBabelInstance = this.addonInstance.addons.find((a: any) => a.name === 'ember-cli-babel');\n let version;\n\n if (emberCLIBabelInstance) {\n version = emberCLIBabelInstance.pkg.version;\n }\n\n if (!packageOptions['ember-cli-babel']) {\n packageOptions['ember-cli-babel'] = {};\n }\n\n if (!packageOptions.babel) {\n packageOptions.babel = {};\n }\n let babelConfig = packageOptions.babel as TransformOptions;\n\n Object.assign(packageOptions['ember-cli-babel'], {\n compileModules: false,\n disablePresetEnv: true,\n disableDebugTooling: true,\n disableEmberModulesAPIPolyfill: true,\n });\n\n if (version && semver.satisfies(semver.coerce(version) || version, '^5')) {\n unsupported(`${this.name} is using babel 5. Not installing our custom plugin.`);\n return;\n }\n\n if (!babelConfig.plugins) {\n babelConfig.plugins = [];\n } else {\n let hadAutoImport = Boolean(babelConfig.plugins.find(isEmberAutoImportDynamic));\n babelConfig.plugins = babelConfig.plugins.filter(babelPluginAllowedInStage1);\n if (hadAutoImport) {\n // if we removed ember-auto-import's dynamic import() plugin, the code\n // may use import() syntax and we need to re-add it to the parser.\n if (version && semver.satisfies(semver.coerce(version) || version, '^6')) {\n babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import'));\n } else {\n babelConfig.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));\n }\n }\n }\n\n if (this.templateCompilerBabelPlugin) {\n babelConfig.plugins.push(this.templateCompilerBabelPlugin);\n }\n }\n\n get v2Tree(): Node {\n return this.throughTreeCache(\n // these are all the kinds of trees that ember-cli's tree cache\n // understands. We need them all here because if *any* of these are\n // uncacheable, we want our whole v2 tree to be treated as uncacheable.\n [\n 'app',\n 'addon',\n 'addon-styles',\n 'addon-templates',\n 'addon-test-support',\n 'public',\n 'styles',\n 'templates',\n 'test-support',\n 'vendor',\n ],\n 'v2Tree',\n () => mergeTrees(this.v2Trees, { overwrite: true })\n );\n }\n\n // this is split out so that compatibility shims can override it to add more\n // things to the package metadata.\n protected get packageMeta(): Partial<AddonMeta> {\n let built = this.build();\n return mergeWithAppend(\n {\n version: 2,\n 'auto-upgraded': true,\n type: 'addon',\n },\n built.staticMeta,\n ...built.dynamicMeta.map(d => d())\n );\n }\n\n @Memoize()\n protected get v2Trees() {\n let { trees } = this.build();\n return trees;\n }\n\n protected throughTreeCache(nameOrNames: string | string[], category: string, fn: () => Node): Node;\n protected throughTreeCache(\n nameOrNames: string | string[],\n category: string,\n fn: () => Node | undefined\n ): Node | undefined {\n let cacheKey: string | undefined;\n if (typeof this.addonInstance.cacheKeyForTree === 'function') {\n let names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames];\n cacheKey = names.reduce((accum: string | undefined, name) => {\n if (accum == null) {\n // a previous name was uncacheable, so we're entirely uncacheable\n return undefined;\n }\n let key = this.addonInstance.cacheKeyForTree?.(name);\n if (key) {\n return accum + key;\n } else {\n return undefined;\n }\n }, '');\n if (cacheKey) {\n cacheKey = cacheKey + category;\n let cachedTree = this.app.addonTreeCache.get(cacheKey);\n if (cachedTree) {\n debug('cache hit %s %s %s', this.name, nameOrNames, category);\n return cachedTree;\n }\n }\n }\n debug('cache miss %s %s %s', this.name, nameOrNames, category);\n let tree = fn();\n if (tree && cacheKey) {\n this.app.addonTreeCache.set(cacheKey, tree);\n }\n return tree;\n }\n\n // In general, we can't reliably run addons' custom `treeFor()` methods,\n // because they recurse in a way that we absolutely don't want.\n //\n // But there is a very common use case that we *can* handle opportunisticaly,\n // which is a treeFor() that's used purely to guard whether `_super` will be\n // called or not.\n protected suppressesTree(name: string): boolean {\n if (!this.customizes('treeFor')) {\n return false;\n }\n // get the real addon as we're going to patch and restore `_super`\n const realAddon = getRealAddon(this.addonInstance);\n let origSuper = this.addonInstance._super;\n try {\n realAddon._super = stubbedSuper;\n let result = this.mainModule.treeFor?.call(this.addonInstance, name);\n if (result === markedEmptyTree) {\n // the method returns _super unchanged, so tree is not suppressed and we\n // understand what's going on\n return false;\n }\n if (result == null) {\n // the method nulled out the tree, so we are definitely suppressing\n return true;\n }\n // we can't tell what's really going on, don't suppress and hope for the\n // best\n unsupported(`${this.name} has a custom treeFor() method that is doing some arbitrary broccoli processing.`);\n return false;\n } finally {\n if (realAddon._super === stubbedSuper) {\n realAddon._super = origSuper;\n }\n }\n }\n\n protected invokeOriginalTreeFor(\n name: string,\n { neuterPreprocessors } = { neuterPreprocessors: false }\n ): Node | undefined {\n // @ts-expect-error have no idea why throughTreeCache overload is not working here..\n return this.throughTreeCache(name, 'original', () => {\n // get the real addon as we're going to patch and restore `preprocessJs`\n const realAddon = getRealAddon(this.addonInstance);\n let original;\n try {\n if (neuterPreprocessors) {\n original = realAddon.preprocessJs;\n realAddon.preprocessJs = function (tree: Node) {\n return tree;\n };\n }\n if (this.suppressesTree(name)) {\n return undefined;\n }\n return this.addonInstance._treeFor(name);\n } finally {\n if (neuterPreprocessors) {\n realAddon.preprocessJs = original;\n }\n }\n });\n }\n\n protected treeForAddon(built: IntermediateBuild): Node | undefined {\n // the extra isEngine condition is because ember-engines injects a\n // treeForAddon method into each engine addon that we really don't need or\n // want to run. Unfortunately there's not a more localized place to patch it\n // out, partly because ember-engines also uses a bogus inheritance strategy\n // (instead of providing a prototype that engine addons can extend it\n // patches things into their instance directly).\n if (this.customizes('treeForAddon', 'treeForAddonTemplates') && !this.isEngine()) {\n let tree = this.invokeOriginalTreeFor('addon', { neuterPreprocessors: true });\n if (tree) {\n tree = modulesCompat(tree);\n\n // this captures addons that are trying to escape their own package's\n // namespace\n let result = rewriteAddonTree(this.transpile(tree), this.name, this.moduleName);\n built.dynamicMeta.push(result.getMeta);\n return result.tree;\n }\n } else if (this.hasStockTree('addon')) {\n return this.transpile(this.stockTree('addon'));\n }\n }\n\n protected addonStylesTree(): Node | undefined {\n if (this.customizes('treeForAddonStyles')) {\n let custom = this.invokeOriginalTreeFor('addon-styles');\n if (custom) {\n return this.addonInstance.compileStyles(custom);\n }\n } else if (this.hasStockTree('addon-styles')) {\n return this.addonInstance.compileStyles(this.stockTree('addon-styles'));\n }\n }\n\n protected treeForTestSupport(): Node | undefined {\n if (this.customizes('treeForTestSupport')) {\n todo(`${this.name} has customized the test support tree`);\n } else if (this.hasStockTree('test-support')) {\n // this one doesn't go through transpile yet because it gets handled as\n // part of the consuming app. For example, imports should be relative to\n // the consuming app, not our own package.\n return buildFunnel(this.stockTree('test-support'), {\n destDir: `${appPublicationDir}/tests`,\n });\n }\n }\n\n private buildTreeForAddon(built: IntermediateBuild) {\n let tree = this.treeForAddon(built);\n if (!tree) {\n return;\n }\n let templateOnlyComponents: Node = new SynthesizeTemplateOnlyComponents(tree, {\n allowedPaths: ['components'],\n\n // if an addon has custom AST transforms, stage1 can rewrite .hbs to\n // .hbs.js\n templateExtensions: ['.hbs', '.hbs.js'],\n });\n 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 (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"]}
package/src/v1-app.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -51,13 +55,6 @@ const fs_1 = require("fs");
51
55
  const semver_1 = __importDefault(require("semver"));
52
56
  const moved_package_cache_1 = require("./moved-package-cache");
53
57
  class V1App {
54
- constructor(app) {
55
- this.app = app;
56
- this._publicAssets = Object.create(null);
57
- this._implicitScripts = [];
58
- this._implicitStyles = [];
59
- this.packageCache = new moved_package_cache_1.MovablePackageCache(node_1.MacrosConfig.for(app, this.root), this.root);
60
- }
61
58
  static create(app) {
62
59
  var _a;
63
60
  if ((_a = app.project.pkg.keywords) === null || _a === void 0 ? void 0 : _a.includes('ember-addon')) {
@@ -68,6 +65,13 @@ class V1App {
68
65
  return new V1App(app);
69
66
  }
70
67
  }
68
+ constructor(app) {
69
+ this.app = app;
70
+ this._publicAssets = Object.create(null);
71
+ this._implicitScripts = [];
72
+ this._implicitStyles = [];
73
+ this.packageCache = new moved_package_cache_1.MovablePackageCache(node_1.MacrosConfig.for(app, this.root), this.root);
74
+ }
71
75
  // always the name from package.json. Not the one that apps may have weirdly
72
76
  // customized.
73
77
  get name() {
package/src/v1-app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"v1-app.js","sourceRoot":"","sources":["v1-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAC7C,mCAA2C;AAC3C,+BAAsD;AACtD,sEAA0C;AAC1C,gFAA8C;AAC9C,qDAA6C;AAC7C,sDAA8B;AAE9B,2CAAsD;AACtD,6CAA6D;AAS7D,uCAA2G;AAC3G,gEAAsC;AACtC,iEAA4D;AAE5D,qDAAmF;AACnF,gFAAsD;AACtD,sEAAqC;AACrC,6DAAqC;AACrC,gHAAqF;AACrF,iEAA4F;AAC5F,kGAA6E;AAC7E,2BAAkC;AAElC,oDAA4B;AAC5B,+DAA4D;AAiB5D,MAAqB,KAAK;IAmBxB,YAAgC,GAAqB;QAArB,QAAG,GAAH,GAAG,CAAkB;QAN7C,kBAAa,GAAmC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpE,qBAAgB,GAAa,EAAE,CAAC;QAChC,oBAAe,GAAa,E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CAAC,WAAW,GAAG,IAAI,2BAAW,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,uBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,IAAI;QACN,wCAAwC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,qEAAqE;QACrE,OAAO,IAAA,WAAI,EAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { join, dirname, isAbsolute, sep } from 'path';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { WatchedDir } from 'broccoli-source';\nimport resolve from 'resolve';\nimport { Node } from 'broccoli-node-api';\nimport { V1Config, WriteV1Config } from './v1-config';\nimport { WriteV1AppBoot, ReadV1AppBoot } from './v1-appboot';\nimport {\n AddonMeta,\n Package,\n EmberAppInstance,\n OutputFileToInputFileMap,\n PackageInfo,\n AddonInstance,\n} from '@embroider/core';\nimport { writeJSONSync, ensureDirSync, copySync, readdirSync, pathExistsSync, existsSync } from 'fs-extra';\nimport AddToTree from './add-to-tree';\nimport DummyPackage, { OwningAddon } from './dummy-package';\nimport { TransformOptions } from '@babel/core';\nimport { isEmbroiderMacrosPlugin, MacrosConfig } from '@embroider/macros/src/node';\nimport resolvePackagePath from 'resolve-package-path';\nimport Concat from 'broccoli-concat';\nimport mapKeys from 'lodash/mapKeys';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport { isEmberAutoImportDynamic, isInlinePrecompilePlugin } from './detect-babel-plugins';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport { readFileSync } from 'fs';\nimport type { Options as HTMLBarsOptions } from 'ember-cli-htmlbars';\nimport semver from 'semver';\nimport { MovablePackageCache } from './moved-package-cache';\n\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\n\n// This controls and types the interface between our new world and the classic\n// v1 app instance.\n\ntype EmberCliHTMLBarsAddon = AddonInstance & {\n htmlbarsOptions(): HTMLBarsOptions;\n};\n\ninterface Group {\n outputFiles: OutputFileToInputFileMap;\n implicitKey: '_implicitStyles' | '_implicitScripts';\n vendorOutputPath: 'string';\n}\n\nexport default class V1App {\n // used to signal that this is a dummy app owned by a particular addon\n owningAddon: Package | undefined;\n\n static create(app: EmberAppInstance): V1App {\n if (app.project.pkg.keywords?.includes('ember-addon')) {\n // we are a dummy app, which is unfortunately weird and special\n return new V1DummyApp(app);\n } else {\n return new V1App(app);\n }\n }\n\n private _publicAssets: { [filePath: string]: string } = Object.create(null);\n private _implicitScripts: string[] = [];\n private _implicitStyles: string[] = [];\n\n packageCache: MovablePackageCache;\n\n protected constructor(protected app: EmberAppInstance) {\n this.packageCache = new MovablePackageCache(MacrosConfig.for(app, this.root), this.root);\n }\n\n // always the name from package.json. Not the one that apps may have weirdly\n // customized.\n get name(): string {\n return this.app.project.pkg.name;\n }\n\n get env(): string {\n return this.app.env;\n }\n\n @Memoize()\n get root(): string {\n return dirname(pkgUpSync({ cwd: this.app.project.root })!);\n }\n\n @Memoize()\n private get emberCLILocation() {\n const emberCLIPackage = resolvePackagePath('ember-cli', this.root);\n\n if (emberCLIPackage === null) {\n throw new Error(`Embroider: cannot resolve ember-cli's package.json`);\n }\n\n return dirname(emberCLIPackage);\n }\n\n @Memoize()\n get hasCompiledStyles() {\n return semver.gte(JSON.parse(readFileSync(`${this.emberCLILocation}/package.json`, 'utf8')).version, '3.18.0');\n }\n\n private requireFromEmberCLI(specifier: string) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve.sync(specifier, { basedir: this.emberCLILocation }));\n }\n\n private get configReplace() {\n return this.requireFromEmberCLI('broccoli-config-replace');\n }\n\n private get configLoader() {\n return this.requireFromEmberCLI('broccoli-config-loader');\n }\n\n private get appUtils() {\n return this.requireFromEmberCLI('./lib/utilities/ember-app-utils');\n }\n\n @Memoize()\n get addonTreeCache(): Map<string, Node> {\n return new Map();\n }\n\n @Memoize()\n get preprocessRegistry() {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get shouldBuildTests(): boolean {\n return this.app.tests || false;\n }\n\n configPath(): string {\n return this.app.project.configPath();\n }\n\n private get configTree() {\n return new this.configLoader(dirname(this.configPath()), {\n env: this.app.env,\n tests: this.app.tests || false,\n project: this.app.project,\n });\n }\n\n @Memoize()\n get config(): V1Config {\n return new V1Config(this.configTree, this.app.env);\n }\n\n get autoRun(): boolean {\n return this.app.options.autoRun;\n }\n\n @Memoize()\n get appBoot(): ReadV1AppBoot {\n let env = this.app.env;\n let appBootContentTree = new WriteV1AppBoot();\n\n let patterns = this.configReplacePatterns;\n\n appBootContentTree = new this.configReplace(appBootContentTree, this.configTree, {\n configPath: join('environments', `${env}.json`),\n files: ['config/app-boot.js'],\n patterns,\n });\n\n return new ReadV1AppBoot(appBootContentTree);\n }\n\n private get storeConfigInMeta(): boolean {\n return this.app.options.storeConfigInMeta;\n }\n\n @Memoize()\n private get configReplacePatterns() {\n return this.appUtils.configReplacePatterns({\n addons: this.app.project.addons,\n autoRun: this.autoRun,\n storeConfigInMeta: this.storeConfigInMeta,\n });\n }\n\n get htmlTree() {\n if (this.app.tests) {\n return mergeTrees([this.indexTree, this.testIndexTree]);\n } else {\n return this.indexTree;\n }\n }\n\n private get indexTree() {\n let indexFilePath = this.app.options.outputPaths.app.html;\n let index = buildFunnel(this.app.trees.app, {\n allowEmpty: true,\n include: [`index.html`],\n getDestinationPath: () => indexFilePath,\n annotation: 'app/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `${this.app.env}.json`),\n files: [indexFilePath],\n patterns: this.configReplacePatterns,\n annotation: 'ConfigReplace/indexTree',\n });\n }\n\n private get testIndexTree() {\n let index = buildFunnel(this.app.trees.tests, {\n allowEmpty: true,\n include: [`index.html`],\n destDir: 'tests',\n annotation: 'tests/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `test.json`),\n files: ['tests/index.html'],\n patterns: this.configReplacePatterns,\n annotation: 'ConfigReplace/testIndexTree',\n });\n }\n\n @Memoize()\n babelConfig(): TransformOptions {\n // this finds all the built-in babel configuration that comes with ember-cli-babel\n const babelAddon = (this.app.project as any).findAddonByName('ember-cli-babel');\n const babelConfig = babelAddon.buildBabelOptions({\n 'ember-cli-babel': {\n ...this.app.options['ember-cli-babel'],\n includeExternalHelpers: true,\n compileModules: false,\n disableDebugTooling: false,\n disablePresetEnv: false,\n disableEmberModulesAPIPolyfill: false,\n disableDecoratorTransforms: false,\n },\n });\n\n let plugins = babelConfig.plugins as any[];\n let presets = babelConfig.presets;\n\n // this finds any custom babel configuration that's on the app (either\n // because the app author explicitly added some, or because addons have\n // pushed plugins into it).\n let appBabel = this.app.options.babel;\n if (appBabel) {\n if (appBabel.plugins) {\n plugins = appBabel.plugins.concat(plugins);\n }\n if (appBabel.presets) {\n presets = appBabel.presets.concat(presets);\n }\n }\n\n plugins = plugins.filter(p => {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n return (\n !isEmbroiderMacrosPlugin(p) &&\n // similarly, if the app was already using an inline template compiler\n // babel plugin, we remove it here because we have our own\n // always-installed version of that (v2 addons are allowed to assume it\n // will be present in the final app build, the app doesn't get to turn\n // that off or configure it.)\n !isInlinePrecompilePlugin(p) &&\n !isEmberAutoImportDynamic(p)\n );\n });\n\n const config: TransformOptions = {\n babelrc: false,\n plugins,\n presets,\n // this is here because broccoli-middleware can't render a codeFrame full\n // of terminal codes. It would be nice to add something like\n // https://github.com/mmalecki/ansispan to broccoli-middleware so we can\n // leave color enabled.\n highlightCode: false,\n };\n\n return config;\n }\n\n @Memoize()\n babelMajorVersion(): 7 {\n let babelAddon = this.app.project.addons.find((a: any) => a.name === 'ember-cli-babel');\n if (babelAddon) {\n let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]);\n let babelMajor: number | undefined = babelAddonMajor;\n if (babelAddonMajor >= 8) {\n // `ember-cli-babel` v8 breaks lockstep with Babel, because it now\n // defines `@babel/core` as a peer dependency, so we need to check the\n // project's version of `@babel/core`:\n let babelVersion = this.app.project.pkg.devDependencies?.['@babel/core'];\n if (babelVersion) {\n babelMajor = semver.coerce(babelVersion)?.major;\n } else {\n babelMajor = 7;\n }\n }\n if (babelMajor !== 7) {\n throw new Error('`@embroider/compat` only supports apps and addons that use Babel v7.');\n }\n return babelMajor;\n }\n // if we didn't have our own babel plugin at all, it's safe to parse our\n // code with 7.\n return 7;\n }\n\n @Memoize()\n private transformedNodeFiles(): Map<string, string> {\n // any app.imports from node_modules that need custom transforms will need\n // to get copied into our own synthesized vendor package. app.imports from\n // node_modules that *don't* need custom transforms can just stay where they\n // are.\n let transformed = new Map();\n for (let transformConfig of this.app._customTransformsMap.values()) {\n for (let filename of transformConfig.files as string[]) {\n let preresolved = this.preresolvedNodeFile(filename);\n if (preresolved) {\n transformed.set(filename, preresolved);\n }\n }\n }\n return transformed;\n }\n\n private preresolvedNodeFile(filename: string) {\n // this regex is an exact copy of how ember-cli does this, so we align.\n let match = filename.match(/^node_modules\\/((@[^/]+\\/)?[^/]+)\\//);\n if (match) {\n // ember-cli has already done its own resolution of\n // `app.import('node_modules/something/...')`, so we go find its answer.\n for (let { name, path } of this.app._nodeModules.values()) {\n if (match[1] === name) {\n return filename.replace(match[0], path + sep);\n }\n }\n throw new Error(`bug: expected ember-cli to already have a resolved path for asset ${filename}`);\n }\n }\n\n private combinedVendor(addonTrees: Node[]): Node {\n let trees = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: 'vendor',\n destDir: 'vendor',\n })\n );\n if (this.vendorTree) {\n trees.push(\n buildFunnel(this.vendorTree, {\n destDir: 'vendor',\n })\n );\n }\n\n const tree = mergeTrees(trees, { overwrite: true });\n\n const outputGroups: Group[] = [\n // scripts\n {\n outputFiles: this.app._scriptOutputFiles,\n implicitKey: '_implicitScripts',\n vendorOutputPath: this.app.options.outputPaths.vendor.js,\n },\n // styles\n {\n outputFiles: this.app._styleOutputFiles,\n implicitKey: '_implicitStyles',\n vendorOutputPath: this.app.options.outputPaths.vendor.css,\n },\n ];\n\n const concatentations = [];\n\n // support: app.import / outputFile / using\n for (let entry of outputGroups) {\n const { outputFiles, implicitKey, vendorOutputPath } = entry;\n for (let importPath of Object.keys(outputFiles)) {\n const headerFiles = outputFiles[importPath];\n\n if (importPath === vendorOutputPath) {\n // these are the default ember-cli output files vendor.js or\n // vendor.css. Let embroider handle these.\n this[implicitKey] = headerFiles;\n } else if (headerFiles.length === 0) {\n // something went really wrong, open an issue\n throw new Error('Embroider: EWUT');\n } else if (headerFiles.length === 1) {\n // app.import(x, { outputFile: y }); where only one app.imports had this outputFile\n //\n // No concat needed. Simply serialize the remapping in the addon's\n // manifest, this ensures it is included in the final output with no extra work.\n this._publicAssets[headerFiles[0]] = importPath;\n } else {\n // app.import(x, { outputFile: y }); where multiple app.imports share one outputFile\n // Concat needed. Perform concat, and include the outputFile in the\n // addon's manifest. This ensures it is included in the final output\n this._publicAssets[importPath] = importPath;\n\n concatentations.push(\n new Concat(tree, {\n headerFiles,\n outputFile: importPath,\n annotation: `Package ${importPath}`,\n separator: '\\n;',\n sourceMapConfig: this.app.options['sourcemaps'],\n })\n );\n }\n }\n }\n\n this.addOtherAssets();\n return mergeTrees([tree, ...concatentations], { overwrite: true });\n }\n\n addOtherAssets() {\n for (let asset of this.app.otherAssetPaths) {\n this._publicAssets[`${asset.src}/${asset.file}`] = `${asset.dest}/${asset.file}`;\n }\n }\n\n private addNodeAssets(inputTree: Node): Node {\n let transformedNodeFiles = this.transformedNodeFiles();\n\n return new AddToTree(inputTree, outputPath => {\n for (let [localDestPath, sourcePath] of transformedNodeFiles) {\n let destPath = join(outputPath, localDestPath);\n ensureDirSync(dirname(destPath));\n copySync(sourcePath, destPath);\n }\n\n let remapAsset = this.remapAsset.bind(this);\n\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'implicit-scripts': this._implicitScripts.map(remapAsset),\n 'implicit-styles': this._implicitStyles.map(remapAsset),\n 'implicit-test-scripts': this.app.legacyTestFilesToAppend.map(remapAsset),\n 'implicit-test-styles': this.app.vendorTestStaticStyles.map(remapAsset),\n 'public-assets': mapKeys(this._publicAssets, (_, key) => remapAsset(key)),\n };\n let meta: PackageInfo = {\n name: '@embroider/synthesized-vendor',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n synthesizeVendorPackage(addonTrees: Node[]): Node {\n return this.applyCustomTransforms(this.addNodeAssets(this.combinedVendor(addonTrees)));\n }\n\n private combinedStyles(addonTrees: Node[]): Node {\n let trees: Node[] = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: '_app_styles_',\n })\n );\n let appStyles = this.app.trees.styles as Node | undefined;\n if (appStyles) {\n // Workaround for https://github.com/ember-cli/ember-cli/issues/9020\n //\n // The default app styles tree is unwatched and relies on side effects\n // elsewhere in ember-cli's build pipeline to actually get rebuilds to\n // work. Here we need it to actually be watched properly if we want to\n // rely on it, particularly when using BROCCOLI_ENABLED_MEMOIZE.\n if ((appStyles as any)._watched === false && (appStyles as any)._directoryPath) {\n appStyles = new WatchedDir((appStyles as any)._directoryPath);\n }\n trees.push(appStyles);\n }\n return mergeTrees(trees, { overwrite: true, annotation: 'embroider-v1-app-combined-styles' });\n }\n\n synthesizeStylesPackage(addonTrees: Node[]): Node {\n let options = {\n // we're deliberately not allowing this to be customized. It's an\n // internal implementation detail, and respecting outputPaths here is\n // unnecessary complexity. The corresponding code that adjusts the HTML\n // <link> is in updateHTML in app.ts.\n outputPaths: { app: `/assets/${this.name}.css` },\n registry: this.app.registry,\n minifyCSS: this.app.options.minifyCSS.options,\n };\n\n let nestedInput = buildFunnel(this.combinedStyles(addonTrees), { destDir: 'app/styles' });\n let styles = this.preprocessors.preprocessCss(nestedInput, '/app/styles', '/assets', options);\n\n return new AddToTree(styles, outputPath => {\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'public-assets': {},\n };\n let assetPath = join(outputPath, 'assets');\n if (pathExistsSync(assetPath)) {\n for (let file of readdirSync(assetPath)) {\n addonMeta['public-assets']![`./assets/${file}`] = `/assets/${file}`;\n }\n }\n let meta: PackageInfo = {\n name: '@embroider/synthesized-styles',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n // this is taken nearly verbatim from ember-cli.\n private applyCustomTransforms(externalTree: Node) {\n for (let customTransformEntry of this.app._customTransformsMap) {\n let transformName = customTransformEntry[0];\n let transformConfig = customTransformEntry[1];\n\n let transformTree = buildFunnel(externalTree, {\n files: transformConfig.files,\n annotation: `Funnel (custom transform: ${transformName})`,\n });\n\n externalTree = mergeTrees([externalTree, transformConfig.callback(transformTree, transformConfig.options)], {\n annotation: `TreeMerger (custom transform: ${transformName})`,\n overwrite: true,\n });\n }\n return externalTree;\n }\n\n private remapAsset(asset: string) {\n if (this.transformedNodeFiles().has(asset)) {\n // transformed node assets become local paths, because we have copied\n // those ones into our synthesized vendor package.\n return './' + asset;\n }\n let preresolved = this.preresolvedNodeFile(asset);\n if (preresolved) {\n // non-transformed node assets point directly at their pre-resolved\n // original files (this is an absolute path).\n return preresolved;\n }\n // non node assets are local paths. They need an explicit `/` or `.` at\n // the start.\n if (asset.startsWith('.') || isAbsolute(asset)) {\n return asset;\n }\n return './' + asset;\n }\n\n private preprocessJS(tree: Node): Node {\n // we're saving all our babel compilation for the final stage packager\n this.app.registry.remove('js', 'ember-cli-babel');\n\n // auto-import is supported natively so we don't need it here\n this.app.registry.remove('js', 'ember-auto-import-analyzer');\n\n tree = buildFunnel(tree, { destDir: this.name });\n\n tree = this.preprocessors.preprocessJs(tree, `/`, '/', {\n annotation: 'v1-app-preprocess-js',\n registry: this.app.registry,\n });\n\n tree = buildFunnel(tree, { srcDir: this.name });\n\n return tree;\n }\n\n get htmlbarsPlugins(): Transform[] {\n let addon = this.app.project.addons.find(\n (a: AddonInstance) => a.name === 'ember-cli-htmlbars'\n ) as unknown as EmberCliHTMLBarsAddon;\n let options = addon.htmlbarsOptions();\n if (options?.plugins?.ast) {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n prepHtmlbarsAstPluginsForUnwrap(this.app.registry);\n\n // classically, this list was backwards for silly historic reasons. But\n // we're the compatibility system, so we're putting it back into\n // reasonable order.\n options.plugins.ast.reverse();\n\n return options.plugins.ast;\n } else {\n return [];\n }\n }\n\n // our own appTree. Not to be confused with the one that combines the app js\n // from all addons too.\n private get appTree(): Node {\n return this.preprocessJS(\n buildFunnel(this.app.trees.app, {\n exclude: ['styles/**', '*.html'],\n })\n );\n }\n\n private get testsTree(): Node | undefined {\n if (this.shouldBuildTests && this.app.trees.tests) {\n return this.preprocessJS(\n buildFunnel(this.app.trees.tests, {\n destDir: 'tests',\n })\n );\n }\n }\n\n private get lintTree(): Node | undefined {\n if (this.shouldBuildTests) {\n return this.app.getLintTests();\n }\n }\n\n get vendorTree(): Node | undefined {\n return this.ensureTree(this.app.trees.vendor);\n }\n\n private ensureTree(maybeTree: string | Node | undefined): Node | undefined {\n if (typeof maybeTree === 'string') {\n // this is deliberately mimicking how ember-cli does it. We don't use\n // `this.root` on purpose, because that can differ from what ember-cli\n // considers the project.root. And we don't use path.resolve even though\n // that seems possibly more correct, because ember-cli always assumes the\n // input is relative.\n let resolvedPath = join(this.app.project.root, maybeTree);\n if (existsSync(resolvedPath)) {\n return new WatchedDir(maybeTree);\n } else {\n return undefined;\n }\n }\n return maybeTree;\n }\n\n @Memoize()\n private get preprocessors(): Preprocessors {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get publicTree(): Node | undefined {\n return this.ensureTree(this.app.trees.public);\n }\n\n processAppJS(): { appJS: Node } {\n let appTree = this.appTree;\n let testsTree = this.testsTree;\n let lintTree = this.lintTree;\n let config = new WriteV1Config(this.config, this.storeConfigInMeta);\n let patterns = this.configReplacePatterns;\n let configReplaced = new this.configReplace(config, this.configTree, {\n configPath: join('environments', `${this.app.env}.json`),\n files: ['config/environment.js'],\n patterns,\n });\n\n let trees: Node[] = [];\n trees.push(appTree);\n trees.push(\n new SynthesizeTemplateOnlyComponents(appTree, { allowedPaths: ['components'], templateExtensions: ['.hbs'] })\n );\n\n trees.push(configReplaced);\n if (testsTree) {\n trees.push(testsTree);\n }\n if (lintTree) {\n trees.push(lintTree);\n }\n return {\n appJS: mergeTrees(trees, { overwrite: true }),\n };\n }\n\n private withoutRootURL(src: string) {\n let rootURL = this.config.readConfig().rootURL;\n if ((src.startsWith(rootURL) && rootURL) || (!rootURL && !src.startsWith('/'))) {\n src = '/' + src.slice(rootURL.length);\n } else if (src.startsWith('/' + rootURL)) {\n src = src.slice(rootURL.length);\n }\n return src;\n }\n\n findAppScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {\n let appJS = scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.app.js);\n return throwIfMissing(\n appJS,\n this.app.options.outputPaths.app.js,\n scripts.map(s => s.src),\n entrypoint,\n 'app javascript'\n );\n }\n\n findAppStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {\n let style = styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.app.css.app);\n return throwIfMissing(\n style,\n this.app.options.outputPaths.app.css.app,\n styles.map(s => s.href),\n entrypoint,\n 'app css'\n );\n }\n\n findVendorScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {\n let vendor = scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.vendor.js);\n return throwIfMissing(\n vendor,\n this.app.options.outputPaths.vendor.js,\n scripts.map(s => s.src),\n entrypoint,\n 'vendor javascript'\n );\n }\n\n findVendorStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {\n let vendorStyle = styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.vendor.css);\n return throwIfMissing(\n vendorStyle,\n this.app.options.outputPaths.vendor.css,\n styles.map(s => s.href),\n entrypoint,\n 'vendor css'\n );\n }\n\n findTestSupportStyles(styles: HTMLLinkElement[]): HTMLLinkElement | undefined {\n return styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.testSupport.css);\n }\n\n findTestSupportScript(scripts: HTMLScriptElement[]): HTMLScriptElement | undefined {\n return scripts.find(\n script => this.withoutRootURL(script.src) === this.app.options.outputPaths.testSupport.js.testSupport\n );\n }\n\n findTestScript(scripts: HTMLScriptElement[]): HTMLScriptElement | undefined {\n return scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.tests.js);\n }\n}\n\nfunction throwIfMissing<T>(\n asset: T | undefined,\n needle: string,\n haystack: string[],\n entryfile: string,\n context: string\n): T {\n if (!asset) {\n throw new Error(\n `Could not find ${context}: \"${needle}\" in ${entryfile}. Found the following instead:\\n${haystack\n .map(asset => ` - ${asset}`)\n .join(\n '\\n'\n )}\\n\\nFor more information about this error: https://github.com/thoov/stitch/wiki/Could-not-find-asset-in-entry-file-error-help`\n );\n }\n\n return asset;\n}\n\nclass V1DummyApp extends V1App {\n constructor(app: EmberAppInstance) {\n super(app);\n this.owningAddon = new OwningAddon(this.app.project.root, this.packageCache);\n this.packageCache.seed(this.owningAddon);\n this.packageCache.seed(new DummyPackage(this.root, this.owningAddon, this.packageCache));\n }\n\n get name(): string {\n // here we accept the ember-cli behavior\n return this.app.name;\n }\n\n get root(): string {\n // this is the Known Hack for finding the true root of the dummy app.\n return join(this.app.project.configPath(), '..', '..');\n }\n}\n\ninterface Preprocessors {\n preprocessJs(tree: Node, a: string, b: string, options: object): Node;\n preprocessCss(tree: Node, a: string, b: string, options: object): Node;\n}\n"]}
1
+ {"version":3,"file":"v1-app.js","sourceRoot":"","sources":["v1-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAC7C,mCAA2C;AAC3C,+BAAsD;AACtD,sEAA0C;AAC1C,gFAA8C;AAC9C,qDAA6C;AAC7C,sDAA8B;AAE9B,2CAAsD;AACtD,6CAA6D;AAS7D,uCAA2G;AAC3G,gEAAsC;AACtC,iEAA4D;AAE5D,qDAAmF;AACnF,gFAAsD;AACtD,sEAAqC;AACrC,6DAAqC;AACrC,gHAAqF;AACrF,iEAA4F;AAC5F,kGAA6E;AAC7E,2BAAkC;AAElC,oDAA4B;AAC5B,+DAA4D;AAiB5D,MAAqB,KAAK;IAIxB,MAAM,CAAC,MAAM,CAAC,GAAqB;;QACjC,IAAI,MAAA,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,0CAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;YACrD,+DAA+D;YAC/D,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;SACvB;IACH,CAAC;IAQD,YAAgC,GAAqB;QAArB,QAAG,GAAH,GAAG,CAAkB;QAN7C,kBAAa,GAAmC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpE,qBAAgB,GAAa,EAAE,CAAC;QAChC,oBAAe,GAAa,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CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,IAAI;QACN,wCAAwC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,qEAAqE;QACrE,OAAO,IAAA,WAAI,EAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport { sync as pkgUpSync } from 'pkg-up';\nimport { join, dirname, isAbsolute, sep } from 'path';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { WatchedDir } from 'broccoli-source';\nimport resolve from 'resolve';\nimport { Node } from 'broccoli-node-api';\nimport { V1Config, WriteV1Config } from './v1-config';\nimport { WriteV1AppBoot, ReadV1AppBoot } from './v1-appboot';\nimport {\n AddonMeta,\n Package,\n EmberAppInstance,\n OutputFileToInputFileMap,\n PackageInfo,\n AddonInstance,\n} from '@embroider/core';\nimport { writeJSONSync, ensureDirSync, copySync, readdirSync, pathExistsSync, existsSync } from 'fs-extra';\nimport AddToTree from './add-to-tree';\nimport DummyPackage, { OwningAddon } from './dummy-package';\nimport { TransformOptions } from '@babel/core';\nimport { isEmbroiderMacrosPlugin, MacrosConfig } from '@embroider/macros/src/node';\nimport resolvePackagePath from 'resolve-package-path';\nimport Concat from 'broccoli-concat';\nimport mapKeys from 'lodash/mapKeys';\nimport SynthesizeTemplateOnlyComponents from './synthesize-template-only-components';\nimport { isEmberAutoImportDynamic, isInlinePrecompilePlugin } from './detect-babel-plugins';\nimport prepHtmlbarsAstPluginsForUnwrap from './prepare-htmlbars-ast-plugins';\nimport { readFileSync } from 'fs';\nimport type { Options as HTMLBarsOptions } from 'ember-cli-htmlbars';\nimport semver from 'semver';\nimport { MovablePackageCache } from './moved-package-cache';\n\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\n\n// This controls and types the interface between our new world and the classic\n// v1 app instance.\n\ntype EmberCliHTMLBarsAddon = AddonInstance & {\n htmlbarsOptions(): HTMLBarsOptions;\n};\n\ninterface Group {\n outputFiles: OutputFileToInputFileMap;\n implicitKey: '_implicitStyles' | '_implicitScripts';\n vendorOutputPath: 'string';\n}\n\nexport default class V1App {\n // used to signal that this is a dummy app owned by a particular addon\n owningAddon: Package | undefined;\n\n static create(app: EmberAppInstance): V1App {\n if (app.project.pkg.keywords?.includes('ember-addon')) {\n // we are a dummy app, which is unfortunately weird and special\n return new V1DummyApp(app);\n } else {\n return new V1App(app);\n }\n }\n\n private _publicAssets: { [filePath: string]: string } = Object.create(null);\n private _implicitScripts: string[] = [];\n private _implicitStyles: string[] = [];\n\n packageCache: MovablePackageCache;\n\n protected constructor(protected app: EmberAppInstance) {\n this.packageCache = new MovablePackageCache(MacrosConfig.for(app, this.root), this.root);\n }\n\n // always the name from package.json. Not the one that apps may have weirdly\n // customized.\n get name(): string {\n return this.app.project.pkg.name;\n }\n\n get env(): string {\n return this.app.env;\n }\n\n @Memoize()\n get root(): string {\n return dirname(pkgUpSync({ cwd: this.app.project.root })!);\n }\n\n @Memoize()\n private get emberCLILocation() {\n const emberCLIPackage = resolvePackagePath('ember-cli', this.root);\n\n if (emberCLIPackage === null) {\n throw new Error(`Embroider: cannot resolve ember-cli's package.json`);\n }\n\n return dirname(emberCLIPackage);\n }\n\n @Memoize()\n get hasCompiledStyles() {\n return semver.gte(JSON.parse(readFileSync(`${this.emberCLILocation}/package.json`, 'utf8')).version, '3.18.0');\n }\n\n private requireFromEmberCLI(specifier: string) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve.sync(specifier, { basedir: this.emberCLILocation }));\n }\n\n private get configReplace() {\n return this.requireFromEmberCLI('broccoli-config-replace');\n }\n\n private get configLoader() {\n return this.requireFromEmberCLI('broccoli-config-loader');\n }\n\n private get appUtils() {\n return this.requireFromEmberCLI('./lib/utilities/ember-app-utils');\n }\n\n @Memoize()\n get addonTreeCache(): Map<string, Node> {\n return new Map();\n }\n\n @Memoize()\n get preprocessRegistry() {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get shouldBuildTests(): boolean {\n return this.app.tests || false;\n }\n\n configPath(): string {\n return this.app.project.configPath();\n }\n\n private get configTree() {\n return new this.configLoader(dirname(this.configPath()), {\n env: this.app.env,\n tests: this.app.tests || false,\n project: this.app.project,\n });\n }\n\n @Memoize()\n get config(): V1Config {\n return new V1Config(this.configTree, this.app.env);\n }\n\n get autoRun(): boolean {\n return this.app.options.autoRun;\n }\n\n @Memoize()\n get appBoot(): ReadV1AppBoot {\n let env = this.app.env;\n let appBootContentTree = new WriteV1AppBoot();\n\n let patterns = this.configReplacePatterns;\n\n appBootContentTree = new this.configReplace(appBootContentTree, this.configTree, {\n configPath: join('environments', `${env}.json`),\n files: ['config/app-boot.js'],\n patterns,\n });\n\n return new ReadV1AppBoot(appBootContentTree);\n }\n\n private get storeConfigInMeta(): boolean {\n return this.app.options.storeConfigInMeta;\n }\n\n @Memoize()\n private get configReplacePatterns() {\n return this.appUtils.configReplacePatterns({\n addons: this.app.project.addons,\n autoRun: this.autoRun,\n storeConfigInMeta: this.storeConfigInMeta,\n });\n }\n\n get htmlTree() {\n if (this.app.tests) {\n return mergeTrees([this.indexTree, this.testIndexTree]);\n } else {\n return this.indexTree;\n }\n }\n\n private get indexTree() {\n let indexFilePath = this.app.options.outputPaths.app.html;\n let index = buildFunnel(this.app.trees.app, {\n allowEmpty: true,\n include: [`index.html`],\n getDestinationPath: () => indexFilePath,\n annotation: 'app/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `${this.app.env}.json`),\n files: [indexFilePath],\n patterns: this.configReplacePatterns,\n annotation: 'ConfigReplace/indexTree',\n });\n }\n\n private get testIndexTree() {\n let index = buildFunnel(this.app.trees.tests, {\n allowEmpty: true,\n include: [`index.html`],\n destDir: 'tests',\n annotation: 'tests/index.html',\n });\n return new this.configReplace(index, this.configTree, {\n configPath: join('environments', `test.json`),\n files: ['tests/index.html'],\n patterns: this.configReplacePatterns,\n annotation: 'ConfigReplace/testIndexTree',\n });\n }\n\n @Memoize()\n babelConfig(): TransformOptions {\n // this finds all the built-in babel configuration that comes with ember-cli-babel\n const babelAddon = (this.app.project as any).findAddonByName('ember-cli-babel');\n const babelConfig = babelAddon.buildBabelOptions({\n 'ember-cli-babel': {\n ...this.app.options['ember-cli-babel'],\n includeExternalHelpers: true,\n compileModules: false,\n disableDebugTooling: false,\n disablePresetEnv: false,\n disableEmberModulesAPIPolyfill: false,\n disableDecoratorTransforms: false,\n },\n });\n\n let plugins = babelConfig.plugins as any[];\n let presets = babelConfig.presets;\n\n // this finds any custom babel configuration that's on the app (either\n // because the app author explicitly added some, or because addons have\n // pushed plugins into it).\n let appBabel = this.app.options.babel;\n if (appBabel) {\n if (appBabel.plugins) {\n plugins = appBabel.plugins.concat(plugins);\n }\n if (appBabel.presets) {\n presets = appBabel.presets.concat(presets);\n }\n }\n\n plugins = plugins.filter(p => {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n return (\n !isEmbroiderMacrosPlugin(p) &&\n // similarly, if the app was already using an inline template compiler\n // babel plugin, we remove it here because we have our own\n // always-installed version of that (v2 addons are allowed to assume it\n // will be present in the final app build, the app doesn't get to turn\n // that off or configure it.)\n !isInlinePrecompilePlugin(p) &&\n !isEmberAutoImportDynamic(p)\n );\n });\n\n const config: TransformOptions = {\n babelrc: false,\n plugins,\n presets,\n // this is here because broccoli-middleware can't render a codeFrame full\n // of terminal codes. It would be nice to add something like\n // https://github.com/mmalecki/ansispan to broccoli-middleware so we can\n // leave color enabled.\n highlightCode: false,\n };\n\n return config;\n }\n\n @Memoize()\n babelMajorVersion(): 7 {\n let babelAddon = this.app.project.addons.find((a: any) => a.name === 'ember-cli-babel');\n if (babelAddon) {\n let babelAddonMajor = Number(babelAddon.pkg.version.split('.')[0]);\n let babelMajor: number | undefined = babelAddonMajor;\n if (babelAddonMajor >= 8) {\n // `ember-cli-babel` v8 breaks lockstep with Babel, because it now\n // defines `@babel/core` as a peer dependency, so we need to check the\n // project's version of `@babel/core`:\n let babelVersion = this.app.project.pkg.devDependencies?.['@babel/core'];\n if (babelVersion) {\n babelMajor = semver.coerce(babelVersion)?.major;\n } else {\n babelMajor = 7;\n }\n }\n if (babelMajor !== 7) {\n throw new Error('`@embroider/compat` only supports apps and addons that use Babel v7.');\n }\n return babelMajor;\n }\n // if we didn't have our own babel plugin at all, it's safe to parse our\n // code with 7.\n return 7;\n }\n\n @Memoize()\n private transformedNodeFiles(): Map<string, string> {\n // any app.imports from node_modules that need custom transforms will need\n // to get copied into our own synthesized vendor package. app.imports from\n // node_modules that *don't* need custom transforms can just stay where they\n // are.\n let transformed = new Map();\n for (let transformConfig of this.app._customTransformsMap.values()) {\n for (let filename of transformConfig.files as string[]) {\n let preresolved = this.preresolvedNodeFile(filename);\n if (preresolved) {\n transformed.set(filename, preresolved);\n }\n }\n }\n return transformed;\n }\n\n private preresolvedNodeFile(filename: string) {\n // this regex is an exact copy of how ember-cli does this, so we align.\n let match = filename.match(/^node_modules\\/((@[^/]+\\/)?[^/]+)\\//);\n if (match) {\n // ember-cli has already done its own resolution of\n // `app.import('node_modules/something/...')`, so we go find its answer.\n for (let { name, path } of this.app._nodeModules.values()) {\n if (match[1] === name) {\n return filename.replace(match[0], path + sep);\n }\n }\n throw new Error(`bug: expected ember-cli to already have a resolved path for asset ${filename}`);\n }\n }\n\n private combinedVendor(addonTrees: Node[]): Node {\n let trees = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: 'vendor',\n destDir: 'vendor',\n })\n );\n if (this.vendorTree) {\n trees.push(\n buildFunnel(this.vendorTree, {\n destDir: 'vendor',\n })\n );\n }\n\n const tree = mergeTrees(trees, { overwrite: true });\n\n const outputGroups: Group[] = [\n // scripts\n {\n outputFiles: this.app._scriptOutputFiles,\n implicitKey: '_implicitScripts',\n vendorOutputPath: this.app.options.outputPaths.vendor.js,\n },\n // styles\n {\n outputFiles: this.app._styleOutputFiles,\n implicitKey: '_implicitStyles',\n vendorOutputPath: this.app.options.outputPaths.vendor.css,\n },\n ];\n\n const concatentations = [];\n\n // support: app.import / outputFile / using\n for (let entry of outputGroups) {\n const { outputFiles, implicitKey, vendorOutputPath } = entry;\n for (let importPath of Object.keys(outputFiles)) {\n const headerFiles = outputFiles[importPath];\n\n if (importPath === vendorOutputPath) {\n // these are the default ember-cli output files vendor.js or\n // vendor.css. Let embroider handle these.\n this[implicitKey] = headerFiles;\n } else if (headerFiles.length === 0) {\n // something went really wrong, open an issue\n throw new Error('Embroider: EWUT');\n } else if (headerFiles.length === 1) {\n // app.import(x, { outputFile: y }); where only one app.imports had this outputFile\n //\n // No concat needed. Simply serialize the remapping in the addon's\n // manifest, this ensures it is included in the final output with no extra work.\n this._publicAssets[headerFiles[0]] = importPath;\n } else {\n // app.import(x, { outputFile: y }); where multiple app.imports share one outputFile\n // Concat needed. Perform concat, and include the outputFile in the\n // addon's manifest. This ensures it is included in the final output\n this._publicAssets[importPath] = importPath;\n\n concatentations.push(\n new Concat(tree, {\n headerFiles,\n outputFile: importPath,\n annotation: `Package ${importPath}`,\n separator: '\\n;',\n sourceMapConfig: this.app.options['sourcemaps'],\n })\n );\n }\n }\n }\n\n this.addOtherAssets();\n return mergeTrees([tree, ...concatentations], { overwrite: true });\n }\n\n addOtherAssets() {\n for (let asset of this.app.otherAssetPaths) {\n this._publicAssets[`${asset.src}/${asset.file}`] = `${asset.dest}/${asset.file}`;\n }\n }\n\n private addNodeAssets(inputTree: Node): Node {\n let transformedNodeFiles = this.transformedNodeFiles();\n\n return new AddToTree(inputTree, outputPath => {\n for (let [localDestPath, sourcePath] of transformedNodeFiles) {\n let destPath = join(outputPath, localDestPath);\n ensureDirSync(dirname(destPath));\n copySync(sourcePath, destPath);\n }\n\n let remapAsset = this.remapAsset.bind(this);\n\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'implicit-scripts': this._implicitScripts.map(remapAsset),\n 'implicit-styles': this._implicitStyles.map(remapAsset),\n 'implicit-test-scripts': this.app.legacyTestFilesToAppend.map(remapAsset),\n 'implicit-test-styles': this.app.vendorTestStaticStyles.map(remapAsset),\n 'public-assets': mapKeys(this._publicAssets, (_, key) => remapAsset(key)),\n };\n let meta: PackageInfo = {\n name: '@embroider/synthesized-vendor',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n synthesizeVendorPackage(addonTrees: Node[]): Node {\n return this.applyCustomTransforms(this.addNodeAssets(this.combinedVendor(addonTrees)));\n }\n\n private combinedStyles(addonTrees: Node[]): Node {\n let trees: Node[] = addonTrees.map(tree =>\n buildFunnel(tree, {\n allowEmpty: true,\n srcDir: '_app_styles_',\n })\n );\n let appStyles = this.app.trees.styles as Node | undefined;\n if (appStyles) {\n // Workaround for https://github.com/ember-cli/ember-cli/issues/9020\n //\n // The default app styles tree is unwatched and relies on side effects\n // elsewhere in ember-cli's build pipeline to actually get rebuilds to\n // work. Here we need it to actually be watched properly if we want to\n // rely on it, particularly when using BROCCOLI_ENABLED_MEMOIZE.\n if ((appStyles as any)._watched === false && (appStyles as any)._directoryPath) {\n appStyles = new WatchedDir((appStyles as any)._directoryPath);\n }\n trees.push(appStyles);\n }\n return mergeTrees(trees, { overwrite: true, annotation: 'embroider-v1-app-combined-styles' });\n }\n\n synthesizeStylesPackage(addonTrees: Node[]): Node {\n let options = {\n // we're deliberately not allowing this to be customized. It's an\n // internal implementation detail, and respecting outputPaths here is\n // unnecessary complexity. The corresponding code that adjusts the HTML\n // <link> is in updateHTML in app.ts.\n outputPaths: { app: `/assets/${this.name}.css` },\n registry: this.app.registry,\n minifyCSS: this.app.options.minifyCSS.options,\n };\n\n let nestedInput = buildFunnel(this.combinedStyles(addonTrees), { destDir: 'app/styles' });\n let styles = this.preprocessors.preprocessCss(nestedInput, '/app/styles', '/assets', options);\n\n return new AddToTree(styles, outputPath => {\n let addonMeta: AddonMeta = {\n type: 'addon',\n version: 2,\n 'public-assets': {},\n };\n let assetPath = join(outputPath, 'assets');\n if (pathExistsSync(assetPath)) {\n for (let file of readdirSync(assetPath)) {\n addonMeta['public-assets']![`./assets/${file}`] = `/assets/${file}`;\n }\n }\n let meta: PackageInfo = {\n name: '@embroider/synthesized-styles',\n version: '0.0.0',\n keywords: ['ember-addon'],\n 'ember-addon': addonMeta,\n };\n writeJSONSync(join(outputPath, 'package.json'), meta, { spaces: 2 });\n });\n }\n\n // this is taken nearly verbatim from ember-cli.\n private applyCustomTransforms(externalTree: Node) {\n for (let customTransformEntry of this.app._customTransformsMap) {\n let transformName = customTransformEntry[0];\n let transformConfig = customTransformEntry[1];\n\n let transformTree = buildFunnel(externalTree, {\n files: transformConfig.files,\n annotation: `Funnel (custom transform: ${transformName})`,\n });\n\n externalTree = mergeTrees([externalTree, transformConfig.callback(transformTree, transformConfig.options)], {\n annotation: `TreeMerger (custom transform: ${transformName})`,\n overwrite: true,\n });\n }\n return externalTree;\n }\n\n private remapAsset(asset: string) {\n if (this.transformedNodeFiles().has(asset)) {\n // transformed node assets become local paths, because we have copied\n // those ones into our synthesized vendor package.\n return './' + asset;\n }\n let preresolved = this.preresolvedNodeFile(asset);\n if (preresolved) {\n // non-transformed node assets point directly at their pre-resolved\n // original files (this is an absolute path).\n return preresolved;\n }\n // non node assets are local paths. They need an explicit `/` or `.` at\n // the start.\n if (asset.startsWith('.') || isAbsolute(asset)) {\n return asset;\n }\n return './' + asset;\n }\n\n private preprocessJS(tree: Node): Node {\n // we're saving all our babel compilation for the final stage packager\n this.app.registry.remove('js', 'ember-cli-babel');\n\n // auto-import is supported natively so we don't need it here\n this.app.registry.remove('js', 'ember-auto-import-analyzer');\n\n tree = buildFunnel(tree, { destDir: this.name });\n\n tree = this.preprocessors.preprocessJs(tree, `/`, '/', {\n annotation: 'v1-app-preprocess-js',\n registry: this.app.registry,\n });\n\n tree = buildFunnel(tree, { srcDir: this.name });\n\n return tree;\n }\n\n get htmlbarsPlugins(): Transform[] {\n let addon = this.app.project.addons.find(\n (a: AddonInstance) => a.name === 'ember-cli-htmlbars'\n ) as unknown as EmberCliHTMLBarsAddon;\n let options = addon.htmlbarsOptions();\n if (options?.plugins?.ast) {\n // even if the app was using @embroider/macros, we drop it from the config\n // here in favor of our globally-configured one.\n options.plugins.ast = options.plugins.ast.filter((p: any) => !isEmbroiderMacrosPlugin(p));\n prepHtmlbarsAstPluginsForUnwrap(this.app.registry);\n\n // classically, this list was backwards for silly historic reasons. But\n // we're the compatibility system, so we're putting it back into\n // reasonable order.\n options.plugins.ast.reverse();\n\n return options.plugins.ast;\n } else {\n return [];\n }\n }\n\n // our own appTree. Not to be confused with the one that combines the app js\n // from all addons too.\n private get appTree(): Node {\n return this.preprocessJS(\n buildFunnel(this.app.trees.app, {\n exclude: ['styles/**', '*.html'],\n })\n );\n }\n\n private get testsTree(): Node | undefined {\n if (this.shouldBuildTests && this.app.trees.tests) {\n return this.preprocessJS(\n buildFunnel(this.app.trees.tests, {\n destDir: 'tests',\n })\n );\n }\n }\n\n private get lintTree(): Node | undefined {\n if (this.shouldBuildTests) {\n return this.app.getLintTests();\n }\n }\n\n get vendorTree(): Node | undefined {\n return this.ensureTree(this.app.trees.vendor);\n }\n\n private ensureTree(maybeTree: string | Node | undefined): Node | undefined {\n if (typeof maybeTree === 'string') {\n // this is deliberately mimicking how ember-cli does it. We don't use\n // `this.root` on purpose, because that can differ from what ember-cli\n // considers the project.root. And we don't use path.resolve even though\n // that seems possibly more correct, because ember-cli always assumes the\n // input is relative.\n let resolvedPath = join(this.app.project.root, maybeTree);\n if (existsSync(resolvedPath)) {\n return new WatchedDir(maybeTree);\n } else {\n return undefined;\n }\n }\n return maybeTree;\n }\n\n @Memoize()\n private get preprocessors(): Preprocessors {\n return this.requireFromEmberCLI('ember-cli-preprocess-registry/preprocessors');\n }\n\n get publicTree(): Node | undefined {\n return this.ensureTree(this.app.trees.public);\n }\n\n processAppJS(): { appJS: Node } {\n let appTree = this.appTree;\n let testsTree = this.testsTree;\n let lintTree = this.lintTree;\n let config = new WriteV1Config(this.config, this.storeConfigInMeta);\n let patterns = this.configReplacePatterns;\n let configReplaced = new this.configReplace(config, this.configTree, {\n configPath: join('environments', `${this.app.env}.json`),\n files: ['config/environment.js'],\n patterns,\n });\n\n let trees: Node[] = [];\n trees.push(appTree);\n trees.push(\n new SynthesizeTemplateOnlyComponents(appTree, { allowedPaths: ['components'], templateExtensions: ['.hbs'] })\n );\n\n trees.push(configReplaced);\n if (testsTree) {\n trees.push(testsTree);\n }\n if (lintTree) {\n trees.push(lintTree);\n }\n return {\n appJS: mergeTrees(trees, { overwrite: true }),\n };\n }\n\n private withoutRootURL(src: string) {\n let rootURL = this.config.readConfig().rootURL;\n if ((src.startsWith(rootURL) && rootURL) || (!rootURL && !src.startsWith('/'))) {\n src = '/' + src.slice(rootURL.length);\n } else if (src.startsWith('/' + rootURL)) {\n src = src.slice(rootURL.length);\n }\n return src;\n }\n\n findAppScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {\n let appJS = scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.app.js);\n return throwIfMissing(\n appJS,\n this.app.options.outputPaths.app.js,\n scripts.map(s => s.src),\n entrypoint,\n 'app javascript'\n );\n }\n\n findAppStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {\n let style = styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.app.css.app);\n return throwIfMissing(\n style,\n this.app.options.outputPaths.app.css.app,\n styles.map(s => s.href),\n entrypoint,\n 'app css'\n );\n }\n\n findVendorScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {\n let vendor = scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.vendor.js);\n return throwIfMissing(\n vendor,\n this.app.options.outputPaths.vendor.js,\n scripts.map(s => s.src),\n entrypoint,\n 'vendor javascript'\n );\n }\n\n findVendorStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {\n let vendorStyle = styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.vendor.css);\n return throwIfMissing(\n vendorStyle,\n this.app.options.outputPaths.vendor.css,\n styles.map(s => s.href),\n entrypoint,\n 'vendor css'\n );\n }\n\n findTestSupportStyles(styles: HTMLLinkElement[]): HTMLLinkElement | undefined {\n return styles.find(style => this.withoutRootURL(style.href) === this.app.options.outputPaths.testSupport.css);\n }\n\n findTestSupportScript(scripts: HTMLScriptElement[]): HTMLScriptElement | undefined {\n return scripts.find(\n script => this.withoutRootURL(script.src) === this.app.options.outputPaths.testSupport.js.testSupport\n );\n }\n\n findTestScript(scripts: HTMLScriptElement[]): HTMLScriptElement | undefined {\n return scripts.find(script => this.withoutRootURL(script.src) === this.app.options.outputPaths.tests.js);\n }\n}\n\nfunction throwIfMissing<T>(\n asset: T | undefined,\n needle: string,\n haystack: string[],\n entryfile: string,\n context: string\n): T {\n if (!asset) {\n throw new Error(\n `Could not find ${context}: \"${needle}\" in ${entryfile}. Found the following instead:\\n${haystack\n .map(asset => ` - ${asset}`)\n .join(\n '\\n'\n )}\\n\\nFor more information about this error: https://github.com/thoov/stitch/wiki/Could-not-find-asset-in-entry-file-error-help`\n );\n }\n\n return asset;\n}\n\nclass V1DummyApp extends V1App {\n constructor(app: EmberAppInstance) {\n super(app);\n this.owningAddon = new OwningAddon(this.app.project.root, this.packageCache);\n this.packageCache.seed(this.owningAddon);\n this.packageCache.seed(new DummyPackage(this.root, this.owningAddon, this.packageCache));\n }\n\n get name(): string {\n // here we accept the ember-cli behavior\n return this.app.name;\n }\n\n get root(): string {\n // this is the Known Hack for finding the true root of the dummy app.\n return join(this.app.project.configPath(), '..', '..');\n }\n}\n\ninterface Preprocessors {\n preprocessJs(tree: Node, a: string, b: string, options: object): Node;\n preprocessCss(tree: Node, a: string, b: string, options: object): Node;\n}\n"]}
@@ -12,6 +12,13 @@ const fs_extra_1 = require("fs-extra");
12
12
  const core_1 = require("@embroider/core");
13
13
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
14
14
  class V1InstanceCache {
15
+ static forApp(emberApp, options) {
16
+ let instance = (0, core_1.getOrCreate)(this.caches, emberApp, () => new this(emberApp, options));
17
+ if (!(0, isEqual_1.default)(instance.options, options)) {
18
+ throw new Error(`attempted double set of app Options`);
19
+ }
20
+ return instance;
21
+ }
15
22
  constructor(oldApp, options) {
16
23
  this.options = options;
17
24
  // maps from package root directories to known V1 instances of that packages.
@@ -26,13 +33,6 @@ class V1InstanceCache {
26
33
  this.addAddon(addon);
27
34
  });
28
35
  }
29
- static forApp(emberApp, options) {
30
- let instance = (0, core_1.getOrCreate)(this.caches, emberApp, () => new this(emberApp, options));
31
- if (!(0, isEqual_1.default)(instance.options, options)) {
32
- throw new Error(`attempted double set of app Options`);
33
- }
34
- return instance;
35
- }
36
36
  adapterClass(addonInstance) {
37
37
  let packageName = addonInstance.pkg.name;
38
38
  // if the user registered something (including "null", which allows
@@ -1 +1 @@
1
- {"version":3,"file":"v1-instance-cache.js","sourceRoot":"","sources":["v1-instance-cache.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,iCAAiC;;;;;AAEjC,sDAA6B;AAC7B,0DAAyD;AACzD,uCAA0C;AAC1C,0CAA6D;AAE7D,6DAAqC;AAErC,MAAqB,eAAe;IAmBlC,YAAoB,MAAW,EAAU,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;QARnE,6EAA6E;QAC7E,8EAA8E;QAC9E,4CAA4C;QACpC,WAAM,GAA2B,IAAI,GAAG,EAAE,CAAC;QAMjD,IAAI,CAAC,GAAG,GAAG,gBAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAElB,uEAAuE;Q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AC,CAAC,CAAC,kBAAO,CAAC;SAChF;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,QAAQ,CAAC,aAA4B;QAC3C,uEAAuE;QACvE,6DAA6D;QAC7D,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,IAAI,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,OAAO,GAAG,IAAI,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrG,IAAI,IAAI,GAAG,IAAA,kBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;;AAzEH,kCA0EC;AAzEQ,sBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC","sourcesContent":["// All access to class ember-cli-provided Addon and EmberApp instances of v1\n// packages is supposed to go through here. This lets us control the boundary\n// between the new and old words.\n\nimport V1App from './v1-app';\nimport V1Addon, { V1AddonConstructor } from './v1-addon';\nimport { pathExistsSync } from 'fs-extra';\nimport { AddonInstance, getOrCreate } from '@embroider/core';\nimport Options from './options';\nimport isEqual from 'lodash/isEqual';\n\nexport default class V1InstanceCache {\n static caches: WeakMap<object, V1InstanceCache> = new WeakMap();\n\n static forApp(emberApp: object, options: Required<Options>): V1InstanceCache {\n let instance = getOrCreate(this.caches, emberApp, () => new this(emberApp, options));\n if (!isEqual(instance.options, options)) {\n throw new Error(`attempted double set of app Options`);\n }\n return instance;\n }\n\n // maps from package root directories to known V1 instances of that packages.\n // There can be many because a single copy of an addon may be consumed by many\n // other packages and each gets an instance.\n private addons: Map<string, V1Addon[]> = new Map();\n\n app: V1App;\n orderIdx: number;\n\n private constructor(oldApp: any, private options: Required<Options>) {\n this.app = V1App.create(oldApp);\n this.orderIdx = 0;\n\n // no reason to do this on demand because oldApp already eagerly loaded\n // all descendants\n (oldApp.project.addons as AddonInstance[]).forEach(addon => {\n this.addAddon(addon);\n });\n }\n\n private adapterClass(addonInstance: AddonInstance): V1AddonConstructor {\n let packageName = addonInstance.pkg.name;\n // if the user registered something (including \"null\", which allows\n // disabling the built-in adapters), that takes precedence.\n let AdapterClass = this.options.compatAdapters.get(packageName);\n\n if (AdapterClass === null) {\n return V1Addon;\n }\n\n if (!AdapterClass) {\n let path = `${__dirname}/compat-adapters/${packageName}.js`;\n if (pathExistsSync(path)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n AdapterClass = require(path).default;\n }\n }\n\n if (!AdapterClass) {\n return V1Addon;\n }\n\n if (AdapterClass.shouldApplyAdapter) {\n return AdapterClass.shouldApplyAdapter(addonInstance) ? AdapterClass : V1Addon;\n }\n\n return AdapterClass;\n }\n\n private addAddon(addonInstance: AddonInstance) {\n // Traverse and add any nested addons. This must happen _before_ we add\n // the addon itself to correctly preserve the addon ordering.\n addonInstance.addons.forEach(a => this.addAddon(a));\n\n this.orderIdx += 1;\n let Klass = this.adapterClass(addonInstance);\n let v1Addon = new Klass(addonInstance, this.options, this.app, this.app.packageCache, this.orderIdx);\n let pkgs = getOrCreate(this.addons, v1Addon.root, () => []);\n pkgs.push(v1Addon);\n }\n\n getAddons(root: string): V1Addon[] {\n return this.addons.get(root) || [];\n }\n}\n"]}
1
+ {"version":3,"file":"v1-instance-cache.js","sourceRoot":"","sources":["v1-instance-cache.ts"],"names":[],"m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C,IAAI,EAAE,CAAC;IACrC,CAAC;;AAzEH,kCA0EC;AAzEQ,sBAAM,GAAqC,IAAI,OAAO,EAAE,CAAC","sourcesContent":["// All access to class ember-cli-provided Addon and EmberApp instances of v1\n// packages is supposed to go through here. This lets us control the boundary\n// between the new and old words.\n\nimport V1App from './v1-app';\nimport V1Addon, { V1AddonConstructor } from './v1-addon';\nimport { pathExistsSync } from 'fs-extra';\nimport { AddonInstance, getOrCreate } from '@embroider/core';\nimport Options from './options';\nimport isEqual from 'lodash/isEqual';\n\nexport default class V1InstanceCache {\n static caches: WeakMap<object, V1InstanceCache> = new WeakMap();\n\n static forApp(emberApp: object, options: Required<Options>): V1InstanceCache {\n let instance = getOrCreate(this.caches, emberApp, () => new this(emberApp, options));\n if (!isEqual(instance.options, options)) {\n throw new Error(`attempted double set of app Options`);\n }\n return instance;\n }\n\n // maps from package root directories to known V1 instances of that packages.\n // There can be many because a single copy of an addon may be consumed by many\n // other packages and each gets an instance.\n private addons: Map<string, V1Addon[]> = new Map();\n\n app: V1App;\n orderIdx: number;\n\n private constructor(oldApp: any, private options: Required<Options>) {\n this.app = V1App.create(oldApp);\n this.orderIdx = 0;\n\n // no reason to do this on demand because oldApp already eagerly loaded\n // all descendants\n (oldApp.project.addons as AddonInstance[]).forEach(addon => {\n this.addAddon(addon);\n });\n }\n\n private adapterClass(addonInstance: AddonInstance): V1AddonConstructor {\n let packageName = addonInstance.pkg.name;\n // if the user registered something (including \"null\", which allows\n // disabling the built-in adapters), that takes precedence.\n let AdapterClass = this.options.compatAdapters.get(packageName);\n\n if (AdapterClass === null) {\n return V1Addon;\n }\n\n if (!AdapterClass) {\n let path = `${__dirname}/compat-adapters/${packageName}.js`;\n if (pathExistsSync(path)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n AdapterClass = require(path).default;\n }\n }\n\n if (!AdapterClass) {\n return V1Addon;\n }\n\n if (AdapterClass.shouldApplyAdapter) {\n return AdapterClass.shouldApplyAdapter(addonInstance) ? AdapterClass : V1Addon;\n }\n\n return AdapterClass;\n }\n\n private addAddon(addonInstance: AddonInstance) {\n // Traverse and add any nested addons. This must happen _before_ we add\n // the addon itself to correctly preserve the addon ordering.\n addonInstance.addons.forEach(a => this.addAddon(a));\n\n this.orderIdx += 1;\n let Klass = this.adapterClass(addonInstance);\n let v1Addon = new Klass(addonInstance, this.options, this.app, this.app.packageCache, this.orderIdx);\n let pkgs = getOrCreate(this.addons, v1Addon.root, () => []);\n pkgs.push(v1Addon);\n }\n\n getAddons(root: string): V1Addon[] {\n return this.addons.get(root) || [];\n }\n}\n"]}