@embroider/core 3.4.20-unstable.b89b741 → 3.4.20-unstable.d367b87

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/core",
3
- "version": "3.4.20-unstable.b89b741",
3
+ "version": "3.4.20-unstable.d367b87",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -49,9 +49,9 @@
49
49
  "semver": "^7.3.5",
50
50
  "typescript-memoize": "^1.0.1",
51
51
  "walk-sync": "^3.0.0",
52
- "@embroider/macros": "1.16.10-unstable.b89b741",
53
- "@embroider/reverse-exports": "0.1.1-unstable.b89b741",
54
- "@embroider/shared-internals": "2.8.2-unstable.b89b741"
52
+ "@embroider/macros": "1.16.10-unstable.d367b87",
53
+ "@embroider/reverse-exports": "0.1.1-unstable.d367b87",
54
+ "@embroider/shared-internals": "2.8.2-unstable.d367b87"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@glimmer/syntax": "^0.84.2",
package/src/index.d.ts CHANGED
@@ -9,6 +9,6 @@ export { Resolver } from './module-resolver';
9
9
  export { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';
10
10
  export type { Options as ResolverOptions } from './module-resolver-options';
11
11
  export { ResolverLoader } from './resolver-loader';
12
- export { virtualContent } from './virtual-content';
12
+ export { virtualContent, type VirtualResponse } from './virtual-content';
13
13
  export type { Engine } from './app-files';
14
14
  export * from '@embroider/shared-internals';
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uCAOoB;AAHlB,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,+GAAA,mBAAmB,OAAA;AAErB,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAEvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,mDAAwE;AAA/D,+HAAA,OAAO,OAAgB;AAChC,iDAAiE;AAAxD,oHAAA,OAAO,OAAuB;AACvC,uCAA4F;AAAnF,gGAAA,IAAI,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,iGAAA,KAAK,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA;AACvE,qDAA6C;AAApC,2GAAA,QAAQ,OAAA;AACjB,mDAAkH;AAAzG,+GAAA,aAAa,OAAA;AAEtB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAGvB,8EAA8E;AAC9E,+DAA+D;AAC/D,8DAA4C","sourcesContent":["export {\n Packager,\n PackagerConstructor,\n Variant,\n applyVariantToBabelConfig,\n getAppMeta,\n getPackagerCacheDir,\n} from './packager';\nexport { HTMLEntrypoint, BundleSummary } from './html-entrypoint';\nexport { default as Stage } from './stage';\nexport { default as Options, optionsWithDefaults } from './options';\nexport { default as WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport { Resolver } from './module-resolver';\nexport { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';\nexport type { Options as ResolverOptions } from './module-resolver-options';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent } from './virtual-content';\nexport type { Engine } from './app-files';\n\n// this is reexported because we already make users manage a peerDep from some\n// other packages (like embroider/webpack and @embroider/compat\nexport * from '@embroider/shared-internals';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uCAOoB;AAHlB,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,+GAAA,mBAAmB,OAAA;AAErB,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAEvB,qCAAoE;AAAvC,8GAAA,mBAAmB,OAAA;AAChD,mDAAwE;AAA/D,+HAAA,OAAO,OAAgB;AAChC,iDAAiE;AAAxD,oHAAA,OAAO,OAAuB;AACvC,uCAA4F;AAAnF,gGAAA,IAAI,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,iGAAA,KAAK,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA;AACvE,qDAA6C;AAApC,2GAAA,QAAQ,OAAA;AACjB,mDAAkH;AAAzG,+GAAA,aAAa,OAAA;AAEtB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qDAAyE;AAAhE,iHAAA,cAAc,OAAA;AAGvB,8EAA8E;AAC9E,+DAA+D;AAC/D,8DAA4C","sourcesContent":["export {\n Packager,\n PackagerConstructor,\n Variant,\n applyVariantToBabelConfig,\n getAppMeta,\n getPackagerCacheDir,\n} from './packager';\nexport { HTMLEntrypoint, BundleSummary } from './html-entrypoint';\nexport { default as Stage } from './stage';\nexport { default as Options, optionsWithDefaults } from './options';\nexport { default as WaitForTrees, OutputPaths } from './wait-for-trees';\nexport { compile as jsHandlebarsCompile } from './js-handlebars';\nexport { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';\nexport { Resolver } from './module-resolver';\nexport { ModuleRequest, type Resolution, type RequestAdapter, type RequestAdapterCreate } from './module-request';\nexport type { Options as ResolverOptions } from './module-resolver-options';\nexport { ResolverLoader } from './resolver-loader';\nexport { virtualContent, type VirtualResponse } from './virtual-content';\nexport type { Engine } from './app-files';\n\n// this is reexported because we already make users manage a peerDep from some\n// other packages (like embroider/webpack and @embroider/compat\nexport * from '@embroider/shared-internals';\n"]}
@@ -1,10 +1,8 @@
1
+ import type { VirtualResponse } from './virtual-content';
1
2
  export type Resolution<T = unknown, E = unknown> = {
2
3
  type: 'found';
3
4
  filename: string;
4
- isVirtual: boolean;
5
- result: T;
6
- } | {
7
- type: 'ignored';
5
+ virtual: VirtualResponse | false;
8
6
  result: T;
9
7
  } | {
10
8
  type: 'not_found';
@@ -18,7 +16,7 @@ export interface RequestAdapter<Res extends Resolution> {
18
16
  readonly debugType: string;
19
17
  resolve(request: ModuleRequest<Res>): Promise<Res>;
20
18
  notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);
21
- virtualResponse(request: ModuleRequest<Res>, virtualFileName: string): Res | (() => Promise<Res>);
19
+ virtualResponse(request: ModuleRequest<Res>, response: VirtualResponse): Res | (() => Promise<Res>);
22
20
  }
23
21
  export interface InitialRequestState {
24
22
  readonly specifier: string;
@@ -36,10 +34,11 @@ export declare class ModuleRequest<Res extends Resolution = Resolution> implemen
36
34
  get resolvedTo(): Res | (() => Promise<Res>) | undefined;
37
35
  alias(newSpecifier: string): this;
38
36
  rehome(newFromFile: string): this;
39
- virtualize(virtualFileName: string): this;
37
+ virtualize(virtualResponse: VirtualResponse): this;
40
38
  withMeta(meta: Record<string, any> | undefined): this;
41
39
  notFound(): this;
42
40
  resolveTo(res: Res | (() => Promise<Res>)): this;
43
41
  defaultResolve(): Promise<Res>;
44
42
  clone(): this;
45
43
  }
44
+ export declare function extractResolution<Res extends Resolution = Resolution>(res: Res | (() => Promise<Res>)): Promise<Res>;
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _ModuleRequest_adapter, _ModuleRequest_specifier, _ModuleRequest_fromFile, _ModuleRequest_meta, _ModuleRequest_resolvedTo;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ModuleRequest = void 0;
16
+ exports.extractResolution = extractResolution;
16
17
  class ModuleRequest {
17
18
  static create(createAdapter, params) {
18
19
  let result = createAdapter(params);
@@ -62,8 +63,8 @@ class ModuleRequest {
62
63
  __classPrivateFieldSet(result, _ModuleRequest_fromFile, newFromFile, "f");
63
64
  return result;
64
65
  }
65
- virtualize(virtualFileName) {
66
- return this.resolveTo(__classPrivateFieldGet(this, _ModuleRequest_adapter, "f").virtualResponse(this, virtualFileName));
66
+ virtualize(virtualResponse) {
67
+ return this.resolveTo(__classPrivateFieldGet(this, _ModuleRequest_adapter, "f").virtualResponse(this, virtualResponse));
67
68
  }
68
69
  withMeta(meta) {
69
70
  let result = this.clone();
@@ -88,4 +89,12 @@ class ModuleRequest {
88
89
  }
89
90
  exports.ModuleRequest = ModuleRequest;
90
91
  _ModuleRequest_adapter = new WeakMap(), _ModuleRequest_specifier = new WeakMap(), _ModuleRequest_fromFile = new WeakMap(), _ModuleRequest_meta = new WeakMap(), _ModuleRequest_resolvedTo = new WeakMap();
92
+ async function extractResolution(res) {
93
+ if (typeof res === 'function') {
94
+ return await res();
95
+ }
96
+ else {
97
+ return res;
98
+ }
99
+ }
91
100
  //# sourceMappingURL=module-request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"module-request.js","sourceRoot":"","sources":["module-request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsCA,MAAa,aAAa;IACxB,MAAM,CAAC,MAAM,CACX,aAA8C,EAC9C,MAAY;QAEZ,IAAI,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAQD,YAAoB,OAA4B,EAAE,UAA+B;QANjF,yCAA8B;QAC9B,2CAAmB;QACnB,0CAAkB;QAClB,sCAA2C;QAC3C,4CAAoD;QAGlD,uBAAA,IAAI,0BAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,4BAAc,UAAU,CAAC,SAAS,MAAA,CAAC;QACvC,uBAAA,IAAI,2BAAa,UAAU,CAAC,QAAQ,MAAA,CAAC;QACrC,uBAAA,IAAI,uBAAS,UAAU,CAAC,IAAI,MAAA,CAA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;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,uBAAA,IAAI,8BAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,SAAS,CAAC,GAA+B;QACvC,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1B,uBAAA,MAAM,6BAAe,GAAG,MAAA,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,cAAc;QACZ,OAAO,uBAAA,IAAI,8BAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,aAAa,CAAC,uBAAA,IAAI,8BAAS,EAAE,IAAI,CAAS,CAAC;IACxD,CAAC;CACF;AA1FD,sCA0FC","sourcesContent":["// This is generic because different build systems have different ways of\n// representing a found module, and we just pass those values through.\nexport type Resolution<T = unknown, E = unknown> =\n | { type: 'found'; filename: string; isVirtual: boolean; result: T }\n\n // used for requests that are special and don't represent real files that\n // embroider can possibly do anything custom with.\n //\n // the motivating use case for introducing this is Vite's depscan which marks\n // almost everything as \"external\" as a way to tell esbuild to stop traversing\n // once it has been seen the first time.\n | { type: 'ignored'; result: T }\n\n // the important thing about this Resolution is that embroider should do its\n // fallback behaviors here.\n | { type: 'not_found'; err: E };\n\nexport type RequestAdapterCreate<Init, Res extends Resolution> = (\n params: Init\n) => { initialState: InitialRequestState; adapter: RequestAdapter<Res> } | undefined;\n\nexport interface RequestAdapter<Res extends Resolution> {\n readonly debugType: string;\n resolve(request: ModuleRequest<Res>): Promise<Res>;\n\n // the function-returning variants of both of these are only because webpack\n // plugins are a pain in the butt. Integrators are encouraged to use the plain\n // Response-returning variants in all sane build environments.\n notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);\n virtualResponse(request: ModuleRequest<Res>, virtualFileName: string): Res | (() => Promise<Res>);\n}\n\nexport interface InitialRequestState {\n readonly specifier: string;\n readonly fromFile: string;\n readonly meta: Record<string, unknown> | undefined;\n}\n\nexport class ModuleRequest<Res extends Resolution = Resolution> implements ModuleRequest<Res> {\n static create<Init, Res extends Resolution>(\n createAdapter: RequestAdapterCreate<Init, Res>,\n params: Init\n ): ModuleRequest<Res> | undefined {\n let result = createAdapter(params);\n if (result) {\n return new ModuleRequest(result.adapter, result.initialState);\n }\n }\n\n #adapter: RequestAdapter<Res>;\n #specifier: string;\n #fromFile: string;\n #meta: Record<string, unknown> | undefined;\n #resolvedTo: Res | (() => Promise<Res>) | undefined;\n\n private constructor(adapter: RequestAdapter<Res>, initialize: InitialRequestState) {\n this.#adapter = adapter;\n this.#specifier = initialize.specifier;\n this.#fromFile = initialize.fromFile;\n this.#meta = initialize.meta;\n }\n\n get specifier(): string {\n return this.#specifier;\n }\n\n get fromFile(): string {\n return this.#fromFile;\n }\n\n get debugType(): string {\n return this.#adapter.debugType;\n }\n\n get meta(): Record<string, unknown> | undefined {\n return this.#meta;\n }\n\n get resolvedTo(): Res | (() => Promise<Res>) | undefined {\n return this.#resolvedTo;\n }\n\n alias(newSpecifier: string): this {\n if (this.#specifier === newSpecifier) {\n return this;\n }\n let result = this.clone();\n result.#specifier = newSpecifier;\n return result;\n }\n\n rehome(newFromFile: string): this {\n if (this.#fromFile === newFromFile) {\n return this;\n }\n let result = this.clone();\n result.#fromFile = newFromFile;\n return result;\n }\n\n virtualize(virtualFileName: string): this {\n return this.resolveTo(this.#adapter.virtualResponse(this, virtualFileName));\n }\n\n withMeta(meta: Record<string, any> | undefined): this {\n let result = this.clone();\n result.#meta = meta;\n result.#resolvedTo = this.#resolvedTo;\n return result;\n }\n\n notFound(): this {\n return this.resolveTo(this.#adapter.notFoundResponse(this));\n }\n\n resolveTo(res: Res | (() => Promise<Res>)): this {\n let result = this.clone();\n result.#resolvedTo = res;\n return result;\n }\n\n defaultResolve(): Promise<Res> {\n return this.#adapter.resolve(this);\n }\n\n clone(): this {\n return new ModuleRequest(this.#adapter, this) as this;\n }\n}\n"]}
1
+ {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AK,UAAU,EAAE,CAAC;QAC9B,OAAO,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["import type { VirtualResponse } from './virtual-content';\n\n// This is generic because different build systems have different ways of\n// representing a found module, and we just pass those values through.\nexport type Resolution<T = unknown, E = unknown> =\n | { type: 'found'; filename: string; virtual: VirtualResponse | false; result: T }\n\n // the important thing about this Resolution is that embroider should do its\n // fallback behaviors here.\n | { type: 'not_found'; err: E };\n\nexport type RequestAdapterCreate<Init, Res extends Resolution> = (\n params: Init\n) => { initialState: InitialRequestState; adapter: RequestAdapter<Res> } | undefined;\n\nexport interface RequestAdapter<Res extends Resolution> {\n readonly debugType: string;\n resolve(request: ModuleRequest<Res>): Promise<Res>;\n\n // the function-returning variants of both of these are only because webpack\n // plugins are a pain in the butt. Integrators are encouraged to use the plain\n // Response-returning variants in all sane build environments.\n notFoundResponse(request: ModuleRequest<Res>): Res | (() => Promise<Res>);\n virtualResponse(request: ModuleRequest<Res>, response: VirtualResponse): Res | (() => Promise<Res>);\n}\n\nexport interface InitialRequestState {\n readonly specifier: string;\n readonly fromFile: string;\n readonly meta: Record<string, unknown> | undefined;\n}\n\nexport class ModuleRequest<Res extends Resolution = Resolution> implements ModuleRequest<Res> {\n static create<Init, Res extends Resolution>(\n createAdapter: RequestAdapterCreate<Init, Res>,\n params: Init\n ): ModuleRequest<Res> | undefined {\n let result = createAdapter(params);\n if (result) {\n return new ModuleRequest(result.adapter, result.initialState);\n }\n }\n\n #adapter: RequestAdapter<Res>;\n #specifier: string;\n #fromFile: string;\n #meta: Record<string, unknown> | undefined;\n #resolvedTo: Res | (() => Promise<Res>) | undefined;\n\n private constructor(adapter: RequestAdapter<Res>, initialize: InitialRequestState) {\n this.#adapter = adapter;\n this.#specifier = initialize.specifier;\n this.#fromFile = initialize.fromFile;\n this.#meta = initialize.meta;\n }\n\n get specifier(): string {\n return this.#specifier;\n }\n\n get fromFile(): string {\n return this.#fromFile;\n }\n\n get debugType(): string {\n return this.#adapter.debugType;\n }\n\n get meta(): Record<string, unknown> | undefined {\n return this.#meta;\n }\n\n get resolvedTo(): Res | (() => Promise<Res>) | undefined {\n return this.#resolvedTo;\n }\n\n alias(newSpecifier: string): this {\n if (this.#specifier === newSpecifier) {\n return this;\n }\n let result = this.clone();\n result.#specifier = newSpecifier;\n return result;\n }\n\n rehome(newFromFile: string): this {\n if (this.#fromFile === newFromFile) {\n return this;\n }\n let result = this.clone();\n result.#fromFile = newFromFile;\n return result;\n }\n\n virtualize(virtualResponse: VirtualResponse): this {\n return this.resolveTo(this.#adapter.virtualResponse(this, virtualResponse));\n }\n\n withMeta(meta: Record<string, any> | undefined): this {\n let result = this.clone();\n result.#meta = meta;\n result.#resolvedTo = this.#resolvedTo;\n return result;\n }\n\n notFound(): this {\n return this.resolveTo(this.#adapter.notFoundResponse(this));\n }\n\n resolveTo(res: Res | (() => Promise<Res>)): this {\n let result = this.clone();\n result.#resolvedTo = res;\n return result;\n }\n\n defaultResolve(): Promise<Res> {\n return this.#adapter.resolve(this);\n }\n\n clone(): this {\n return new ModuleRequest(this.#adapter, this) as this;\n }\n}\n\nexport async function extractResolution<Res extends Resolution = Resolution>(\n res: Res | (() => Promise<Res>)\n): Promise<Res> {\n if (typeof res === 'function') {\n return await res();\n } else {\n return res;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Package } from '@embroider/shared-internals';
2
2
  import { RewrittenPackageCache } from '@embroider/shared-internals';
3
3
  import type { Options, EngineConfig } from './module-resolver-options';
4
- import type { ModuleRequest, Resolution } from './module-request';
4
+ import { type ModuleRequest, type Resolution } from './module-request';
5
5
  export declare class Resolver {
6
6
  readonly options: Options;
7
7
  constructor(options: Options);
@@ -19,6 +19,8 @@ export declare class Resolver {
19
19
  err: Error;
20
20
  }>;
21
21
  get packageCache(): RewrittenPackageCache;
22
+ private afterResolve;
23
+ private handleSyntheticComponents;
22
24
  private logicalPackage;
23
25
  private generateFastbootSwitch;
24
26
  private handleFastbootSwitch;
@@ -17,13 +17,12 @@ const debug_1 = __importDefault(require("debug"));
17
17
  const assert_never_1 = __importDefault(require("assert-never"));
18
18
  const reverse_exports_1 = require("@embroider/reverse-exports");
19
19
  const resolve_exports_1 = require("resolve.exports");
20
- const virtual_content_1 = require("./virtual-content");
21
20
  const typescript_memoize_1 = require("typescript-memoize");
22
21
  const describe_exports_1 = require("./describe-exports");
23
22
  const fs_1 = require("fs");
24
23
  const node_resolve_1 = require("./node-resolve");
25
- const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
26
24
  const semver_1 = require("semver");
25
+ const module_request_1 = require("./module-request");
27
26
  const debug = (0, debug_1.default)('embroider:resolver');
28
27
  // Using a formatter makes this work lazy so nothing happens when we aren't
29
28
  // logging. It is unfortunate that formatters are a globally mutable config and
@@ -95,19 +94,14 @@ class Resolver {
95
94
  request = await this.beforeResolve(request);
96
95
  let resolution;
97
96
  if (request.resolvedTo) {
98
- if (typeof request.resolvedTo === 'function') {
99
- resolution = await request.resolvedTo();
100
- }
101
- else {
102
- resolution = request.resolvedTo;
103
- }
97
+ resolution = await (0, module_request_1.extractResolution)(request.resolvedTo);
104
98
  }
105
99
  else {
106
100
  resolution = await request.defaultResolve();
107
101
  }
102
+ resolution = await this.afterResolve(request, resolution);
108
103
  switch (resolution.type) {
109
104
  case 'found':
110
- case 'ignored':
111
105
  return resolution;
112
106
  case 'not_found':
113
107
  break;
@@ -121,12 +115,7 @@ class Resolver {
121
115
  return resolution;
122
116
  }
123
117
  if (nextRequest.resolvedTo) {
124
- if (typeof nextRequest.resolvedTo === 'function') {
125
- return await nextRequest.resolvedTo();
126
- }
127
- else {
128
- return nextRequest.resolvedTo;
129
- }
118
+ return await (0, module_request_1.extractResolution)(nextRequest.resolvedTo);
130
119
  }
131
120
  if (nextRequest.fromFile === request.fromFile && nextRequest.specifier === request.specifier) {
132
121
  throw new Error('Bug Discovered! New request is not === original request but has the same fromFile and specifier. This will likely create a loop.');
@@ -142,6 +131,34 @@ class Resolver {
142
131
  get packageCache() {
143
132
  return shared_internals_2.RewrittenPackageCache.shared('embroider', this.options.appRoot);
144
133
  }
134
+ async afterResolve(request, resolution) {
135
+ resolution = await this.handleSyntheticComponents(request, resolution);
136
+ return resolution;
137
+ }
138
+ async handleSyntheticComponents(request, resolution) {
139
+ // Key assumption: the system's defaultResolve performs extension search for
140
+ // extensionless requests, with JS at a higher priority than HBS.
141
+ // When the request had an explicit ".js" extension, the system default
142
+ // extension search doesn't help us locate an HBS, so we need to check for
143
+ // it ourselves here.
144
+ if (resolution.type === 'not_found') {
145
+ let hbsSpecifier = (0, shared_internals_1.syntheticJStoHBS)(request.specifier);
146
+ if (hbsSpecifier) {
147
+ resolution = await this.resolve(request.alias(hbsSpecifier));
148
+ }
149
+ }
150
+ // At this point, we might have resolved an HBS file (either because the
151
+ // request was extensionless and the default search found it, or because of
152
+ // our own code above) when the request was for a JS file.
153
+ if (resolution.type === 'found') {
154
+ let syntheticId = (0, shared_internals_1.needsSyntheticComponentJS)(request.specifier, resolution.filename);
155
+ if (syntheticId && (0, shared_internals_1.isInComponents)(resolution.filename, this.packageCache)) {
156
+ let newRequest = logTransition(`synthetic component JS`, request, request.virtualize({ type: 'template-only-component-js', specifier: syntheticId }));
157
+ return await (0, module_request_1.extractResolution)(newRequest.resolvedTo);
158
+ }
159
+ }
160
+ return resolution;
161
+ }
145
162
  logicalPackage(owningPackage, file) {
146
163
  let logicalLocation = this.reverseSearchAppTree(owningPackage, file);
147
164
  if (logicalLocation) {
@@ -177,8 +194,8 @@ class Resolver {
177
194
  let { names } = (0, describe_exports_1.describeExports)((0, fs_1.readFileSync)((0, path_1.resolve)(pkg.root, fastbootFile.shadowedFilename), 'utf8'), {
178
195
  configFile: false,
179
196
  });
180
- let switchFile = (0, virtual_content_1.fastbootSwitch)(candidate, (0, path_1.resolve)(pkg.root, 'package.json'), names);
181
- if (switchFile === request.fromFile) {
197
+ let switchFile = fastbootSwitch(candidate, (0, path_1.resolve)(pkg.root, 'package.json'), names);
198
+ if (switchFile.specifier === request.fromFile) {
182
199
  return logTransition('internal lookup from fastbootSwitch', request);
183
200
  }
184
201
  else {
@@ -198,7 +215,7 @@ class Resolver {
198
215
  if (request.resolvedTo) {
199
216
  return request;
200
217
  }
201
- let match = (0, virtual_content_1.decodeFastbootSwitch)(request.fromFile);
218
+ let match = decodeFastbootSwitch(request.fromFile);
202
219
  if (!match) {
203
220
  return request;
204
221
  }
@@ -245,68 +262,74 @@ class Resolver {
245
262
  if (request.resolvedTo) {
246
263
  return request;
247
264
  }
248
- let im = (0, virtual_content_1.decodeImplicitModules)(request.specifier);
249
- if (!im) {
250
- return request;
251
- }
252
- let pkg = this.packageCache.ownerOfFile(request.fromFile);
253
- if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
254
- throw new Error(`bug: found implicit modules import in non-ember package at ${request.fromFile}`);
255
- }
256
- let packageName = (0, shared_internals_1.packageName)(im.fromFile);
257
- if (packageName) {
258
- let dep = this.packageCache.resolve(packageName, pkg);
259
- return logTransition(`dep's implicit modules`, request, request.virtualize((0, path_1.resolve)(dep.root, `-embroider-${im.type}.js`)));
260
- }
261
- else {
262
- return logTransition(`own implicit modules`, request, request.virtualize((0, path_1.resolve)(pkg.root, `-embroider-${im.type}.js`)));
265
+ for (let variant of ['', 'test-']) {
266
+ let suffix = `-embroider-implicit-${variant}modules.js`;
267
+ if (!request.specifier.endsWith(suffix)) {
268
+ continue;
269
+ }
270
+ let filename = request.specifier.slice(0, -1 * suffix.length);
271
+ if (!filename.endsWith('/') && filename.endsWith('\\')) {
272
+ continue;
273
+ }
274
+ filename = filename.slice(0, -1);
275
+ let pkg = this.packageCache.ownerOfFile(request.fromFile);
276
+ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
277
+ throw new Error(`bug: found implicit modules import in non-ember package at ${request.fromFile}`);
278
+ }
279
+ let type = `implicit-${variant}modules`;
280
+ let packageName = (0, shared_internals_1.packageName)(filename);
281
+ if (packageName) {
282
+ let dep = this.packageCache.resolve(packageName, pkg);
283
+ return logTransition(`dep's implicit modules`, request, request.virtualize({ type, specifier: (0, path_1.resolve)(dep.root, `-embroider-${type}.js`), fromFile: dep.root }));
284
+ }
285
+ else {
286
+ return logTransition(`own implicit modules`, request, request.virtualize({ type, specifier: (0, path_1.resolve)(pkg.root, `-embroider-${type}.js`), fromFile: pkg.root }));
287
+ }
263
288
  }
289
+ return request;
264
290
  }
265
291
  handleEntrypoint(request) {
266
292
  var _a;
267
293
  if (request.resolvedTo) {
268
294
  return request;
269
295
  }
270
- //TODO move the extra forwardslash handling out into the vite plugin
271
- const candidates = [
272
- '@embroider/virtual/compat-modules',
273
- '/@embroider/virtual/compat-modules',
274
- './@embroider/virtual/compat-modules',
275
- ];
276
- if (!candidates.some(c => request.specifier.startsWith(c + '/') || request.specifier === c)) {
296
+ const compatModulesSpecifier = '@embroider/virtual/compat-modules';
297
+ let isCompatModules = request.specifier === compatModulesSpecifier || request.specifier.startsWith(compatModulesSpecifier + '/');
298
+ if (!isCompatModules) {
277
299
  return request;
278
300
  }
279
- const result = /\.?\/?@embroider\/virtual\/compat-modules(?:\/(?<packageName>.*))?/.exec(request.specifier);
280
- if (!result) {
281
- // TODO make a better error
282
- throw new Error('entrypoint does not match pattern' + request.specifier);
283
- }
284
- const { packageName } = result.groups;
285
301
  const requestingPkg = this.packageCache.ownerOfFile(request.fromFile);
286
302
  if (!(requestingPkg === null || requestingPkg === void 0 ? void 0 : requestingPkg.isV2Ember())) {
287
303
  throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
288
304
  }
289
305
  let pkg;
290
- if (packageName) {
291
- pkg = this.packageCache.resolve(packageName, requestingPkg);
306
+ if (request.specifier === compatModulesSpecifier) {
307
+ pkg = requestingPkg;
292
308
  }
293
309
  else {
294
- pkg = requestingPkg;
310
+ let packageName = request.specifier.slice(compatModulesSpecifier.length + 1);
311
+ pkg = this.packageCache.resolve(packageName, requestingPkg);
295
312
  }
296
313
  let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-entrypoint.js', {
297
314
  browser: true,
298
315
  conditions: ['default', 'imports'],
299
316
  });
300
- return logTransition('entrypoint', request, request.virtualize((0, path_1.resolve)(pkg.root, (_a = matched === null || matched === void 0 ? void 0 : matched[0]) !== null && _a !== void 0 ? _a : '-embroider-entrypoint.js')));
317
+ let specifier = (0, path_1.resolve)(pkg.root, (_a = matched === null || matched === void 0 ? void 0 : matched[0]) !== null && _a !== void 0 ? _a : '-embroider-entrypoint.js');
318
+ return logTransition('entrypoint', request, request.virtualize({
319
+ type: 'entrypoint',
320
+ specifier,
321
+ fromDir: (0, path_1.dirname)(specifier),
322
+ }));
301
323
  }
302
324
  handleRouteEntrypoint(request) {
303
325
  if (request.resolvedTo) {
304
326
  return request;
305
327
  }
306
- let routeName = (0, virtual_route_entrypoint_1.decodePublicRouteEntrypoint)(request.specifier);
307
- if (!routeName) {
328
+ const publicPrefix = '@embroider/core/route/';
329
+ if (!request.specifier.startsWith(publicPrefix)) {
308
330
  return request;
309
331
  }
332
+ let routeName = request.specifier.slice(publicPrefix.length);
310
333
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
311
334
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
312
335
  throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
@@ -315,39 +338,32 @@ class Resolver {
315
338
  browser: true,
316
339
  conditions: ['default', 'imports'],
317
340
  });
318
- return logTransition('route entrypoint', request, request.virtualize((0, virtual_route_entrypoint_1.encodeRouteEntrypoint)(pkg.root, matched === null || matched === void 0 ? void 0 : matched[0], routeName)));
341
+ let target = matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`;
342
+ let specifier = (0, path_1.resolve)(pkg.root, target);
343
+ return logTransition('route entrypoint', request, request.virtualize({ type: 'route-entrypoint', specifier, route: routeName, fromDir: (0, path_1.dirname)(specifier) }));
319
344
  }
320
345
  handleImplicitTestScripts(request) {
321
- //TODO move the extra forwardslash handling out into the vite plugin
322
- const candidates = [
323
- '@embroider/virtual/test-support.js',
324
- '/@embroider/virtual/test-support.js',
325
- './@embroider/virtual/test-support.js',
326
- ];
327
- if (!candidates.includes(request.specifier)) {
346
+ if (request.specifier !== '@embroider/virtual/test-support.js') {
328
347
  return request;
329
348
  }
330
349
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
331
350
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
332
351
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/test-support.js. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
333
352
  }
334
- return logTransition('test-support', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-test-support.js')));
353
+ return logTransition('test-support', request, request.virtualize({ type: 'test-support-js', specifier: (0, path_1.resolve)(pkg.root, '-embroider-test-support.js') }));
335
354
  }
336
355
  handleTestSupportStyles(request) {
337
- //TODO move the extra forwardslash handling out into the vite plugin
338
- const candidates = [
339
- '@embroider/virtual/test-support.css',
340
- '/@embroider/virtual/test-support.css',
341
- './@embroider/virtual/test-support.css',
342
- ];
343
- if (!candidates.includes(request.specifier)) {
356
+ if (request.specifier !== '@embroider/virtual/test-support.css') {
344
357
  return request;
345
358
  }
346
359
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
347
360
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
348
361
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/test-support.css. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
349
362
  }
350
- return logTransition('test-support-styles', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-test-support-styles.css')));
363
+ return logTransition('test-support-styles', request, request.virtualize({
364
+ type: 'test-support-css',
365
+ specifier: (0, path_1.resolve)(pkg.root, '-embroider-test-support-styles.css'),
366
+ }));
351
367
  }
352
368
  async handleGlobalsCompat(request) {
353
369
  if (request.resolvedTo) {
@@ -377,35 +393,28 @@ class Resolver {
377
393
  }
378
394
  }
379
395
  handleVendorStyles(request) {
380
- //TODO move the extra forwardslash handling out into the vite plugin
381
- const candidates = [
382
- '@embroider/virtual/vendor.css',
383
- '/@embroider/virtual/vendor.css',
384
- './@embroider/virtual/vendor.css',
385
- ];
386
- if (!candidates.includes(request.specifier)) {
396
+ if (request.specifier !== '@embroider/virtual/vendor.css') {
387
397
  return request;
388
398
  }
389
399
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
390
400
  if (!pkg || !this.options.engines.some(e => e.root === (pkg === null || pkg === void 0 ? void 0 : pkg.root))) {
391
401
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app or Engine. The top-level Ember app is the only one that has support for @embroider/virtual/vendor.css. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
392
402
  }
393
- return logTransition('vendor-styles', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-vendor-styles.css')));
403
+ return logTransition('vendor-styles', request, request.virtualize({ type: 'vendor-css', specifier: (0, path_1.resolve)(pkg.root, '-embroider-vendor-styles.css') }));
394
404
  }
395
405
  resolveHelper(path, inEngine, request) {
396
406
  let target = this.parseGlobalPath(path, inEngine);
397
407
  return logTransition('resolveHelper', request, request.alias(`${target.packageName}/helpers/${target.memberName}`).rehome((0, path_1.resolve)(inEngine.root, 'package.json')));
398
408
  }
399
409
  async resolveComponent(path, inEngine, request) {
410
+ var _a, _b;
400
411
  let target = this.parseGlobalPath(path, inEngine);
401
412
  let hbsModule = null;
402
413
  let jsModule = null;
403
414
  // first, the various places our template might be.
404
415
  for (let candidate of this.componentTemplateCandidates(target.packageName)) {
405
416
  let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`;
406
- let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from).withMeta({
407
- runtimeFallback: false,
408
- }));
417
+ let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from));
409
418
  if (resolution.type === 'found') {
410
419
  hbsModule = resolution;
411
420
  break;
@@ -414,12 +423,7 @@ class Resolver {
414
423
  // then the various places our javascript might be.
415
424
  for (let candidate of this.componentJSCandidates(target.packageName)) {
416
425
  let candidateSpecifier = `${target.packageName}${candidate.prefix}${target.memberName}${candidate.suffix}`;
417
- let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from).withMeta({
418
- runtimeFallback: false,
419
- }));
420
- if (resolution.type === 'ignored') {
421
- return logTransition(`resolving to ignored component`, request, request.resolveTo(resolution));
422
- }
426
+ let resolution = await this.resolve(request.alias(candidateSpecifier).rehome(target.from));
423
427
  // .hbs is a resolvable extension for us, so we need to exclude it here.
424
428
  // It matches as a priority lower than .js, so finding an .hbs means
425
429
  // there's definitely not a .js.
@@ -432,7 +436,13 @@ class Resolver {
432
436
  if (!this.emberVersionSupportsSeparateTemplates) {
433
437
  throw new Error(`Components with separately resolved templates were removed at Ember 6.0. Migrate to either co-located js/ts + hbs files or to gjs/gts. https://deprecations.emberjs.com/id/component-template-resolving/. Bad template was: ${hbsModule.filename}.`);
434
438
  }
435
- return logTransition(`resolveComponent found legacy HBS`, request, request.virtualize((0, virtual_content_1.virtualPairComponent)(hbsModule.filename, jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename)));
439
+ return logTransition(`resolveComponent found legacy HBS`, request, request.virtualize({
440
+ type: 'component-pair',
441
+ hbsModule: hbsModule.filename,
442
+ jsModule: (_a = jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename) !== null && _a !== void 0 ? _a : null,
443
+ debugName: (0, path_1.basename)(hbsModule.filename).replace(/\.(js|hbs)$/, ''),
444
+ specifier: `${this.options.appRoot}/embroider-pair-component/${encodeURIComponent(hbsModule.filename)}/__vpc__/${encodeURIComponent((_b = jsModule === null || jsModule === void 0 ? void 0 : jsModule.filename) !== null && _b !== void 0 ? _b : '')}`,
445
+ }));
436
446
  }
437
447
  else if (jsModule) {
438
448
  return logTransition(`resolving to resolveComponent found only JS`, request, request.resolveTo(jsModule));
@@ -446,13 +456,8 @@ class Resolver {
446
456
  // component, so here to resolve the ambiguity we need to actually resolve
447
457
  // that candidate to see if it works.
448
458
  let helperCandidate = this.resolveHelper(path, inEngine, request);
449
- let helperMatch = await this.resolve(request.alias(helperCandidate.specifier).rehome(helperCandidate.fromFile).withMeta({
450
- runtimeFallback: false,
451
- }));
452
- // for the case of 'ignored' that means that esbuild found this helper in an external
453
- // package so it should be considered found in this case and we should not look for a
454
- // component with this name
455
- if (helperMatch.type === 'found' || helperMatch.type === 'ignored') {
459
+ let helperMatch = await this.resolve(request.alias(helperCandidate.specifier).rehome(helperCandidate.fromFile));
460
+ if (helperMatch.type === 'found') {
456
461
  return logTransition('resolve to ambiguous case matched a helper', request, request.resolveTo(helperMatch));
457
462
  }
458
463
  // unlike resolveHelper, resolveComponent already does pre-resolution in
@@ -755,20 +760,14 @@ class Resolver {
755
760
  return request;
756
761
  }
757
762
  handleVendor(request) {
758
- //TODO move the extra forwardslash handling out into the vite plugin
759
- const candidates = [
760
- '@embroider/virtual/vendor.js',
761
- '/@embroider/virtual/vendor.js',
762
- './@embroider/virtual/vendor.js',
763
- ];
764
- if (!candidates.includes(request.specifier)) {
763
+ if (request.specifier !== '@embroider/virtual/vendor.js') {
765
764
  return request;
766
765
  }
767
766
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
768
767
  if ((pkg === null || pkg === void 0 ? void 0 : pkg.root) !== this.options.engines[0].root) {
769
768
  throw new Error(`bug: found an import of ${request.specifier} in ${request.fromFile}, but this is not the top-level Ember app. The top-level Ember app is the only one that has support for @embroider/virtual/vendor.js. If you think something should be fixed in Embroider, please open an issue on https://github.com/embroider-build/embroider/issues.`);
770
769
  }
771
- return logTransition('vendor', request, request.virtualize((0, path_1.resolve)(pkg.root, '-embroider-vendor.js')));
770
+ return logTransition('vendor', request, request.virtualize({ type: 'vendor-js', specifier: (0, path_1.resolve)(pkg.root, '-embroider-vendor.js') }));
772
771
  }
773
772
  resolveWithinMovedPackage(request, pkg) {
774
773
  let levels = ['..'];
@@ -1024,14 +1023,12 @@ class Resolver {
1024
1023
  case 'fastboot-only':
1025
1024
  return request.alias(matched.entry['fastboot-js'].specifier).rehome(matched.entry['fastboot-js'].fromFile);
1026
1025
  case 'both':
1027
- let foundAppJS = await this.resolve(request.alias(matched.entry['app-js'].specifier).rehome(matched.entry['app-js'].fromFile).withMeta({
1028
- runtimeFallback: false,
1029
- }));
1026
+ let foundAppJS = await this.resolve(request.alias(matched.entry['app-js'].specifier).rehome(matched.entry['app-js'].fromFile));
1030
1027
  if (foundAppJS.type !== 'found') {
1031
1028
  throw new Error(`${matched.entry['app-js'].fromPackageName} declared ${inEngineSpecifier} in packageJSON.ember-addon.app-js, but that module does not exist`);
1032
1029
  }
1033
1030
  let { names } = (0, describe_exports_1.describeExports)((0, fs_1.readFileSync)(foundAppJS.filename, 'utf8'), { configFile: false });
1034
- return request.virtualize((0, virtual_content_1.fastbootSwitch)(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names));
1031
+ return request.virtualize(fastbootSwitch(matched.matched, (0, path_1.resolve)(engine.root, 'package.json'), names));
1035
1032
  }
1036
1033
  }
1037
1034
  // check whether the given file with the given owningPackage is an addon's
@@ -1122,4 +1119,27 @@ function engineRelativeName(pkg, filename) {
1122
1119
  return '.' + outsideName.slice(pkg.name.length);
1123
1120
  }
1124
1121
  }
1122
+ const fastbootSwitchSuffix = '/embroider_fastboot_switch';
1123
+ function fastbootSwitch(specifier, fromFile, names) {
1124
+ let filename = `${(0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier)}${fastbootSwitchSuffix}`;
1125
+ let virtualSpecifier;
1126
+ if (names.size > 0) {
1127
+ virtualSpecifier = `${filename}?names=${[...names].join(',')}`;
1128
+ }
1129
+ else {
1130
+ virtualSpecifier = filename;
1131
+ }
1132
+ return {
1133
+ type: 'fastboot-switch',
1134
+ specifier: virtualSpecifier,
1135
+ names,
1136
+ hasDefaultExport: 'x',
1137
+ };
1138
+ }
1139
+ function decodeFastbootSwitch(filename) {
1140
+ let index = filename.indexOf(fastbootSwitchSuffix);
1141
+ if (index >= 0) {
1142
+ return { filename: filename.slice(0, index) };
1143
+ }
1144
+ }
1125
1145
  //# sourceMappingURL=module-resolver.js.map