@embroider/compat 3.4.2 → 3.4.4-unstable.12a42ca

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/compat",
3
- "version": "3.4.2",
3
+ "version": "3.4.4-unstable.12a42ca",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -19,6 +19,9 @@
19
19
  "bin": {
20
20
  "embroider-compat-audit": "./src/audit-cli.js"
21
21
  },
22
+ "scripts": {
23
+ "test": "jest"
24
+ },
22
25
  "dependencies": {
23
26
  "@babel/code-frame": "^7.14.5",
24
27
  "@babel/core": "^7.14.5",
@@ -27,6 +30,7 @@
27
30
  "@babel/preset-env": "^7.14.5",
28
31
  "@babel/runtime": "^7.18.6",
29
32
  "@babel/traverse": "^7.14.5",
33
+ "@embroider/macros": "1.13.5-unstable.12a42ca",
30
34
  "@types/babel__code-frame": "^7.0.2",
31
35
  "@types/yargs": "^17.0.3",
32
36
  "assert-never": "^1.1.0",
@@ -59,10 +63,12 @@
59
63
  "tree-sync": "^2.1.0",
60
64
  "typescript-memoize": "^1.0.1",
61
65
  "walk-sync": "^3.0.0",
62
- "yargs": "^17.0.1",
63
- "@embroider/macros": "1.13.4"
66
+ "yargs": "^17.0.1"
64
67
  },
65
68
  "devDependencies": {
69
+ "@embroider/core": "3.4.4-unstable.12a42ca",
70
+ "@embroider/sample-transforms": "workspace:*",
71
+ "@embroider/test-support": "workspace:*",
66
72
  "@glimmer/syntax": "^0.84.3",
67
73
  "@glint/template": "^1.0.0",
68
74
  "@types/babel__core": "^7.1.14",
@@ -81,19 +87,13 @@
81
87
  "broccoli-node-api": "^1.7.0",
82
88
  "code-equality-assertions": "^0.9.0",
83
89
  "ember-engines": "^0.8.19",
84
- "scenario-tester": "^2.1.2",
85
- "typescript": "^5.1.6",
86
- "@embroider/test-support": "0.36.0",
87
- "@embroider/sample-transforms": "0.0.0",
88
- "@embroider/core": "^3.4.3"
90
+ "scenario-tester": "^3.0.1",
91
+ "typescript": "^5.1.6"
89
92
  },
90
93
  "peerDependencies": {
91
- "@embroider/core": "^3.4.3"
94
+ "@embroider/core": "3.4.4-unstable.12a42ca"
92
95
  },
93
96
  "engines": {
94
97
  "node": "12.* || 14.* || >= 16"
95
- },
96
- "scripts": {
97
- "test": "jest"
98
98
  }
99
- }
99
+ }
package/src/audit.js CHANGED
@@ -424,6 +424,11 @@ class Audit {
424
424
  async resolveDeps(deps, fromFile) {
425
425
  let resolved = new Map();
426
426
  for (let dep of deps) {
427
+ if (['@embroider/macros'].includes(dep)) {
428
+ // the audit process deliberately removes the @embroider/macros babel
429
+ // plugins, so the imports are still present and should be left alone.
430
+ continue;
431
+ }
427
432
  let resolution = await this.resolver.nodeResolve(dep, fromFile);
428
433
  switch (resolution.type) {
429
434
  case 'virtual':
@@ -432,11 +437,6 @@ class Audit {
432
437
  this.scheduleVisit(resolution.filename, fromFile);
433
438
  break;
434
439
  case 'not_found':
435
- if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {
436
- // the audit process deliberately removes the @embroider/macros babel
437
- // plugins, so the imports are still present and should be left alone.
438
- continue;
439
- }
440
440
  resolved.set(dep, { isResolutionFailure: true });
441
441
  break;
442
442
  case 'real':
package/src/audit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsD;AACtD,+BAA6D;AAE7D,0CAAwH;AACxH,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AAEzC,yDAAqF;AAErF,yCAAmE;AAiBzB,2FAjBvB,kBAAU,OAiBuB;AAAE,6FAjBvB,oBAAY,OAiBuB;AAflE,MAAM,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC;AAqCxB,SAAS,mBAAmB,CAAC,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nC,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;AAxXD,sBAwXC;AA3VC;IADC,IAAA,4BAAO,GAAE;gCAGT;AAGD;IADC,IAAA,4BAAO,GAAE;yCAIT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAST;AAsUH,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 type { AppMeta, ResolverOptions } from '@embroider/core';\nimport { explicitRelative, hbsToJS, locateEmbroiderWorkingDir, Resolver, RewrittenPackageCache } 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 type { ExportAll, InternalImport, NamespaceMarker } from './audit/babel-visitor';\nimport { auditJS, CodeFrameStorage, isNamespaceMarker } 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 if (!options['reuse-build']) {\n await buildApp(options);\n }\n\n let audit = new this(options.app, 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 constructor(private originAppRoot: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.movedAppRoot, 'package.json'));\n }\n\n @Memoize()\n private get movedAppRoot() {\n let cache = RewrittenPackageCache.shared('embroider', this.originAppRoot);\n return cache.maybeMoved(cache.get(this.originAppRoot)).root;\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.movedAppRoot, 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(locateEmbroiderWorkingDir(this.originAppRoot), '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.movedAppRoot, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n\n return AuditResults.create(this.originAppRoot, 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(\n dirname(filename),\n resolvePath(this.movedAppRoot, src.replace(this.meta['root-url'], ''))\n );\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.originAppRoot, 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.originAppRoot, 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;AAE7D,0CAAwH;AACxH,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AAEzC,yDAAqF;AAErF,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;AAUD,MAAa,YAAY;IAAzB;QACE,YAAO,GAA+B,EAAE,CAAC;QACzC,aAAQ,GAAc,EAAE,CAAC;IA+F3B,CAAC;IA7FC,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,QAAmB,EAAE,OAAoC;;QACtF,IAAI,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,QAAQ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AG,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 type { AppMeta, ResolverOptions } from '@embroider/core';\nimport { explicitRelative, hbsToJS, locateEmbroiderWorkingDir, Resolver, RewrittenPackageCache } 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 type { ExportAll, InternalImport, NamespaceMarker } from './audit/babel-visitor';\nimport { auditJS, CodeFrameStorage, isNamespaceMarker } 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 if (!options['reuse-build']) {\n await buildApp(options);\n }\n\n let audit = new this(options.app, 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 constructor(private originAppRoot: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.movedAppRoot, 'package.json'));\n }\n\n @Memoize()\n private get movedAppRoot() {\n let cache = RewrittenPackageCache.shared('embroider', this.originAppRoot);\n return cache.maybeMoved(cache.get(this.originAppRoot)).root;\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.movedAppRoot, 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(locateEmbroiderWorkingDir(this.originAppRoot), '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.movedAppRoot, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n\n return AuditResults.create(this.originAppRoot, 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(\n dirname(filename),\n resolvePath(this.movedAppRoot, src.replace(this.meta['root-url'], ''))\n );\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.originAppRoot, 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.originAppRoot, 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 if (['@embroider/macros'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n\n let resolution = await this.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 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,5 +1 @@
1
- import type { AddonMeta } from '@embroider/core';
2
- import { EmberDataBase } from '../ember-data';
3
- export default class EmberDataStore extends EmberDataBase {
4
- get packageMeta(): Partial<AddonMeta>;
5
- }
1
+ export { EmberDataBase as default } from '../ember-data';
@@ -1,18 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ember_data_1 = require("../ember-data");
4
- class EmberDataStore extends ember_data_1.EmberDataBase {
5
- get packageMeta() {
6
- var _a;
7
- let meta = super.packageMeta;
8
- // this is here because the compat-adapter for @ember-data/debug adds this
9
- // to externals because it has an undeclared peerDep on us, and thus might
10
- // resolve totally incorrect copies. By making it external we leave it up to
11
- // runtime, where we will find this implicit-module for the actual copy of
12
- // @ember-data/store that is active in app.
13
- meta['implicit-modules'] = [...((_a = meta['implicit-modules']) !== null && _a !== void 0 ? _a : []), './index.js'];
14
- return meta;
15
- }
16
- }
17
- exports.default = EmberDataStore;
3
+ exports.default = void 0;
4
+ var ember_data_1 = require("../ember-data");
5
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return ember_data_1.EmberDataBase; } });
18
6
  //# sourceMappingURL=store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["store.ts"],"names":[],"mappings":";;AACA,8CAA8C;AAE9C,MAAqB,cAAe,SAAQ,0BAAa;IACvD,IAAI,WAAW;;QACb,IAAI,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAE7B,0EAA0E;QAC1E,0EAA0E;QAC1E,4EAA4E;QAC5E,0EAA0E;QAC1E,2CAA2C;QAC3C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,kBAAkB,CAAC,mCAAI,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;QAE/E,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAbD,iCAaC","sourcesContent":["import type { AddonMeta } from '@embroider/core';\nimport { EmberDataBase } from '../ember-data';\n\nexport default class EmberDataStore extends EmberDataBase {\n get packageMeta(): Partial<AddonMeta> {\n let meta = super.packageMeta;\n\n // this is here because the compat-adapter for @ember-data/debug adds this\n // to externals because it has an undeclared peerDep on us, and thus might\n // resolve totally incorrect copies. By making it external we leave it up to\n // runtime, where we will find this implicit-module for the actual copy of\n // @ember-data/store that is active in app.\n meta['implicit-modules'] = [...(meta['implicit-modules'] ?? []), './index.js'];\n\n return meta;\n }\n}\n"]}
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["store.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AAAhD,qGAAA,aAAa,OAAW","sourcesContent":["export { EmberDataBase as default } from '../ember-data';\n"]}
@@ -0,0 +1,5 @@
1
+ import V1Addon from '../v1-addon';
2
+ import type { AddonMeta } from '@embroider/core';
3
+ export default class extends V1Addon {
4
+ get packageMeta(): Partial<AddonMeta>;
5
+ }
@@ -0,0 +1,19 @@
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
+ class default_1 extends v1_addon_1.default {
8
+ get packageMeta() {
9
+ let meta = super.packageMeta;
10
+ // this file is not accessible from the outside of ember-fetch and is not being used inside ember-fetch so it's dead code
11
+ // but it is importing `@ember/polyfills` which casues ember-source@5 to crash because it has been removed
12
+ if (meta['implicit-modules']) {
13
+ meta['implicit-modules'] = meta['implicit-modules'].filter(mod => mod !== './utils/mung-options-for-fetch');
14
+ }
15
+ return meta;
16
+ }
17
+ }
18
+ exports.default = default_1;
19
+ //# sourceMappingURL=ember-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ember-fetch.js","sourceRoot":"","sources":["ember-fetch.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAGlC,eAAqB,SAAQ,kBAAO;IAClC,IAAI,WAAW;QACb,IAAI,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAE7B,yHAAyH;QACzH,0GAA0G;QAC1G,IAAI,IAAI,CAAC,kBAAkB,CAAC,EAAE;YAC5B,IAAI,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,gCAAgC,CAAC,CAAC;SAC7G;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAZD,4BAYC","sourcesContent":["import V1Addon from '../v1-addon';\nimport type { AddonMeta } from '@embroider/core';\n\nexport default class extends V1Addon {\n get packageMeta(): Partial<AddonMeta> {\n let meta = super.packageMeta;\n\n // this file is not accessible from the outside of ember-fetch and is not being used inside ember-fetch so it's dead code\n // but it is importing `@ember/polyfills` which casues ember-source@5 to crash because it has been removed\n if (meta['implicit-modules']) {\n meta['implicit-modules'] = meta['implicit-modules'].filter(mod => mod !== './utils/mung-options-for-fetch');\n }\n\n return meta;\n }\n}\n"]}
@@ -177,7 +177,7 @@ class CompatAppBuilder {
177
177
  // For TS, we defer to ember-cli-babel, and the setting for
178
178
  // "enableTypescriptTransform" can be set with and without
179
179
  // ember-cli-typescript
180
- return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];
180
+ return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js', '.gjs', '.gts'];
181
181
  }
182
182
  *emberEntrypoints(htmlTreePath) {
183
183
  let classicEntrypoints = [
@@ -233,10 +233,6 @@ class CompatAppBuilder {
233
233
  resolverConfig(engines) {
234
234
  let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
235
235
  let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
236
- let activeAddons = {};
237
- for (let addon of this.allActiveAddons) {
238
- activeAddons[addon.name] = addon.root;
239
- }
240
236
  let options = {
241
237
  staticHelpers: this.options.staticHelpers,
242
238
  staticModifiers: this.options.staticModifiers,
@@ -245,7 +241,6 @@ class CompatAppBuilder {
245
241
  };
246
242
  let config = {
247
243
  // this part is the base ModuleResolverOptions as required by @embroider/core
248
- activeAddons,
249
244
  renameModules,
250
245
  renamePackages,
251
246
  resolvableExtensions: this.resolvableExtensions(),
@@ -257,9 +252,10 @@ class CompatAppBuilder {
257
252
  root: (0, fs_extra_1.realpathSync)(index === 0 ? this.root : appFiles.engine.package.root),
258
253
  fastbootFiles: appFiles.fastbootFiles,
259
254
  activeAddons: [...appFiles.engine.addons]
260
- .map(a => ({
261
- name: a.name,
262
- root: a.root,
255
+ .map(([addon, canResolveFromFile]) => ({
256
+ name: addon.name,
257
+ root: addon.root,
258
+ canResolveFromFile,
263
259
  }))
264
260
  // the traditional order is the order in which addons will run, such
265
261
  // that the last one wins. Our resolver's order is the order to
@@ -345,7 +341,7 @@ class CompatAppBuilder {
345
341
  }
346
342
  impliedAddonAssets(type, { engine }) {
347
343
  let result = [];
348
- for (let addon of (0, sortBy_1.default)(Array.from(engine.addons), this.scriptPriority.bind(this))) {
344
+ for (let addon of (0, sortBy_1.default)(Array.from(engine.addons.keys()), this.scriptPriority.bind(this))) {
349
345
  let implicitScripts = addon.meta[type];
350
346
  if (implicitScripts) {
351
347
  let styles = [];
@@ -540,11 +536,21 @@ class CompatAppBuilder {
540
536
  if (!child.isEngine()) {
541
537
  this.findActiveAddons(child, engine, true);
542
538
  }
543
- engine.addons.add(child);
539
+ let canResolveFrom;
540
+ if (pkg === this.appPackageWithMovedDeps) {
541
+ // we want canResolveFrom to always be a rewritten package path, and our
542
+ // app's package is not rewritten yet here.
543
+ canResolveFrom = (0, path_1.resolve)(this.root, 'package.json');
544
+ }
545
+ else {
546
+ // whereas our addons are already moved
547
+ canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
548
+ }
549
+ engine.addons.set(child, canResolveFrom);
544
550
  }
545
551
  // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
546
552
  if (!isChild) {
547
- engine.addons = new Set([...engine.addons].sort((a, b) => {
553
+ engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
548
554
  return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
549
555
  }));
550
556
  }
@@ -553,7 +559,7 @@ class CompatAppBuilder {
553
559
  let queue = [
554
560
  {
555
561
  package: this.appPackageWithMovedDeps,
556
- addons: new Set(),
562
+ addons: new Map(),
557
563
  parent: undefined,
558
564
  sourcePath: appJSPath,
559
565
  modulePrefix: this.modulePrefix(),
@@ -568,12 +574,12 @@ class CompatAppBuilder {
568
574
  break;
569
575
  }
570
576
  this.findActiveAddons(current.package, current);
571
- for (let addon of current.addons) {
577
+ for (let addon of current.addons.keys()) {
572
578
  if (addon.isEngine() && !seenEngines.has(addon)) {
573
579
  seenEngines.add(addon);
574
580
  queue.push({
575
581
  package: addon,
576
- addons: new Set(),
582
+ addons: new Map(),
577
583
  parent: current,
578
584
  sourcePath: addon.root,
579
585
  modulePrefix: addon.name,
@@ -843,6 +849,7 @@ class CompatAppBuilder {
843
849
  this.addResolverConfig(resolverConfig);
844
850
  let babelConfig = this.babelConfig(resolverConfig);
845
851
  this.addBabelConfig(babelConfig);
852
+ (0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'macros-config.json'), JSON.stringify(this.compatApp.macrosConfig.babelPluginConfig()[0], null, 2));
846
853
  }
847
854
  combinePackageJSON(meta) {
848
855
  let pkgLayers = [this.origAppPackage.packageJSON];
@@ -1061,10 +1068,16 @@ class CompatAppBuilder {
1061
1068
  let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
1062
1069
  let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
1063
1070
  let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(appFiles, file));
1064
- // this is a backward-compatibility feature: addons can force inclusion of
1065
- // modules.
1066
- eagerModules.push('./-embroider-implicit-modules.js');
1067
- let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules, styles };
1071
+ let params = {
1072
+ amdModules,
1073
+ fastbootOnlyAmdModules,
1074
+ lazyRoutes,
1075
+ lazyEngines,
1076
+ eagerModules,
1077
+ styles,
1078
+ // this is a backward-compatibility feature: addons can force inclusion of modules.
1079
+ defineModulesFrom: './-embroider-implicit-modules.js',
1080
+ };
1068
1081
  if (entryParams) {
1069
1082
  Object.assign(params, entryParams);
1070
1083
  }
@@ -1116,9 +1129,6 @@ class CompatAppBuilder {
1116
1129
  (0, core_1.explicitRelative)((0, path_2.dirname)(myName), this.topAppJSAsset(appFiles, prepared).relativePath),
1117
1130
  ];
1118
1131
  let amdModules = [];
1119
- // this is a backward-compatibility feature: addons can force inclusion of
1120
- // test support modules.
1121
- eagerModules.push('./-embroider-implicit-test-modules.js');
1122
1132
  for (let relativePath of engine.tests) {
1123
1133
  amdModules.push(this.importPaths(engine, relativePath));
1124
1134
  }
@@ -1126,6 +1136,8 @@ class CompatAppBuilder {
1126
1136
  amdModules,
1127
1137
  eagerModules,
1128
1138
  testSuffix: true,
1139
+ // this is a backward-compatibility feature: addons can force inclusion of test support modules.
1140
+ defineModulesFrom: './-embroider-implicit-test-modules.js',
1129
1141
  });
1130
1142
  asset = {
1131
1143
  kind: 'in-memory',
@@ -1197,6 +1209,15 @@ let d = w.define;
1197
1209
  }
1198
1210
  {{/if}}
1199
1211
 
1212
+ {{#if defineModulesFrom ~}}
1213
+ import implicitModules from "{{js-string-escape defineModulesFrom}}";
1214
+
1215
+ for(const [name, module] of Object.entries(implicitModules)) {
1216
+ d(name, function() { return module });
1217
+ }
1218
+ {{/if}}
1219
+
1220
+
1200
1221
  {{#each eagerModules as |eagerModule| ~}}
1201
1222
  i("{{js-string-escape eagerModule}}");
1202
1223
  {{/each}}
@@ -1207,9 +1228,17 @@ let d = w.define;
1207
1228
 
1208
1229
  {{#if fastbootOnlyAmdModules}}
1209
1230
  if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
1231
+ let fastbootModules = {};
1232
+
1210
1233
  {{#each fastbootOnlyAmdModules as |amdModule| ~}}
1211
- d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
1234
+ fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
1212
1235
  {{/each}}
1236
+
1237
+ const resolvedValues = await Promise.all(Object.values(fastbootModules));
1238
+
1239
+ Object.keys(fastbootModules).forEach((k, i) => {
1240
+ d(k, function(){ return resolvedValues[i];});
1241
+ })
1213
1242
  }
1214
1243
  {{/if}}
1215
1244