@embroider/core 3.4.15-unstable.eb93cd5 → 3.4.16-unstable.2ff89c0

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.15-unstable.eb93cd5",
3
+ "version": "3.4.16-unstable.2ff89c0",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "@babel/parser": "^7.14.5",
22
22
  "@babel/traverse": "^7.14.5",
23
23
  "assert-never": "^1.2.1",
24
- "babel-plugin-ember-template-compilation": "^2.1.1",
24
+ "babel-plugin-ember-template-compilation": "^2.3.0",
25
25
  "broccoli-node-api": "^1.7.0",
26
26
  "broccoli-persistent-filter": "^3.1.2",
27
27
  "broccoli-plugin": "^4.0.7",
@@ -41,9 +41,9 @@
41
41
  "resolve.exports": "^2.0.2",
42
42
  "typescript-memoize": "^1.0.1",
43
43
  "walk-sync": "^3.0.0",
44
- "@embroider/macros": "1.16.6-unstable.eb93cd5",
45
- "@embroider/reverse-exports": "0.1.1-unstable.eb93cd5",
46
- "@embroider/shared-internals": "2.6.3-unstable.eb93cd5"
44
+ "@embroider/macros": "1.16.7-unstable.2ff89c0",
45
+ "@embroider/reverse-exports": "0.1.1-unstable.2ff89c0",
46
+ "@embroider/shared-internals": "2.6.4-unstable.2ff89c0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@glimmer/syntax": "^0.84.2",
@@ -61,8 +61,8 @@
61
61
  "fixturify": "^2.1.1",
62
62
  "tmp": "^0.1.0",
63
63
  "typescript": "^5.4.5",
64
- "@embroider/sample-transforms": "0.0.0",
65
- "@embroider/test-support": "0.36.0"
64
+ "@embroider/test-support": "0.36.0",
65
+ "@embroider/sample-transforms": "0.0.0"
66
66
  },
67
67
  "engines": {
68
68
  "node": "12.* || 14.* || >= 16"
@@ -17,6 +17,7 @@ export interface Options {
17
17
  amdCompatibility: Required<UserOptions['amdCompatibility']>;
18
18
  autoRun: boolean;
19
19
  staticAppPaths: string[];
20
+ emberVersion: string;
20
21
  }
21
22
  export interface EngineConfig {
22
23
  packageName: string;
@@ -108,6 +109,9 @@ export declare class Resolver {
108
109
  private locateActiveAddon;
109
110
  private external;
110
111
  private fallbackResolve;
112
+ private restoreRehomedRequest;
113
+ private relativeFallbackResolve;
114
+ private maybeFallbackToActiveAddon;
111
115
  private getEntryFromMergeMap;
112
116
  private withResolvableExtensions;
113
117
  private searchAppTree;
@@ -674,17 +674,11 @@ class Resolver {
674
674
  return request;
675
675
  }
676
676
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
677
- if (!pkg || !pkg.isV2Ember()) {
678
- return request;
679
- }
680
677
  // real deps take precedence over renaming rules. That is, a package like
681
678
  // ember-source might provide backburner via module renaming, but if you
682
679
  // have an explicit dependency on backburner you should still get that real
683
680
  // copy.
684
- // if (pkg.root === this.options.engines[0].root && request.specifier === `${pkg.name}/environment/config`) {
685
- // return logTransition('legacy config location', request, request.alias(`${pkg.name}/app/environment/config`));
686
- // }
687
- if (!pkg.hasDependency(packageName)) {
681
+ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.hasDependency(packageName))) {
688
682
  for (let [candidate, replacement] of Object.entries(this.options.renameModules)) {
689
683
  if (candidate === request.specifier) {
690
684
  return logTransition(`renameModules`, request, request.alias(replacement));
@@ -702,6 +696,9 @@ class Resolver {
702
696
  return logTransition(`renamePackages`, request, request.alias(request.specifier.replace(packageName, this.options.renamePackages[packageName])));
703
697
  }
704
698
  }
699
+ if (!pkg || !pkg.isV2Ember()) {
700
+ return request;
701
+ }
705
702
  if (pkg.name === packageName) {
706
703
  // we found a self-import
707
704
  if (pkg.meta['auto-upgraded']) {
@@ -897,7 +894,7 @@ class Resolver {
897
894
  }
898
895
  }
899
896
  async fallbackResolve(request) {
900
- var _a, _b, _c;
897
+ var _a, _b;
901
898
  if (request.isVirtual) {
902
899
  throw new Error('Build tool bug detected! Fallback resolve should never see a virtual request. It is expected that the defaultResolve for your bundler has already resolved this request');
903
900
  }
@@ -925,56 +922,33 @@ class Resolver {
925
922
  return request;
926
923
  }
927
924
  let pkg = this.packageCache.ownerOfFile(request.fromFile);
928
- if (!pkg) {
929
- return logTransition('no identifiable owningPackage', request);
925
+ if (pkg) {
926
+ ({ pkg, request } = this.restoreRehomedRequest(pkg, request));
930
927
  }
931
- // meta.originalFromFile gets set when we want to try to rehome a request
932
- // but then come back to the original location here in the fallback when the
933
- // rehomed request fails
934
- let movedPkg = this.packageCache.maybeMoved(pkg);
935
- if (movedPkg !== pkg) {
936
- let originalFromFile = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.originalFromFile;
937
- if (typeof originalFromFile !== 'string') {
938
- throw new Error(`bug: embroider resolver's meta is not propagating`);
928
+ if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
929
+ // this request is coming from a file that appears to be owned by no ember
930
+ // package. We offer one fallback behavior for such files. They're allowed
931
+ // to resolve from the app's namespace.
932
+ //
933
+ // This makes it possible for integrations like vite to leave references
934
+ // to the app in their pre-bundled dependencies, which will end up in an
935
+ // arbitrary cache that is not inside any particular package.
936
+ let description = pkg ? 'non-ember package' : 'unowned module';
937
+ let packageName = (0, shared_internals_1.packageName)(request.specifier);
938
+ if (packageName === this.options.modulePrefix) {
939
+ return logTransition(`fallbackResolver: ${description} resolved app namespace`, request, request.rehome(this.packageCache.maybeMoved(this.packageCache.get(this.options.appRoot)).root));
939
940
  }
940
- request = request.rehome(originalFromFile);
941
- pkg = movedPkg;
942
- }
943
- if (!pkg.isV2Ember()) {
944
- return logTransition('fallbackResolve: not in an ember package', request);
941
+ return logTransition(`fallbackResolver: ${description}`, request);
945
942
  }
946
943
  let packageName = (0, shared_internals_1.packageName)(request.specifier);
947
944
  if (!packageName) {
948
945
  // this is a relative import
949
- let withinEngine = this.engineConfig(pkg.name);
950
- if (withinEngine) {
951
- // it's a relative import inside an engine (which also means app), which
952
- // means we may need to satisfy the request via app tree merging.
953
- let logicalName = engineRelativeName(pkg, (0, path_1.resolve)((0, path_1.dirname)(request.fromFile), request.specifier));
954
- if (!logicalName) {
955
- return logTransition('fallbackResolve: relative failure because this file is not externally accessible', request);
956
- }
957
- let appJSMatch = await this.searchAppTree(request, withinEngine, logicalName);
958
- if (appJSMatch) {
959
- return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
960
- }
961
- else {
962
- return logTransition('fallbackResolve: relative appJs search failure', request);
963
- }
964
- }
965
- else {
966
- // nothing else to do for relative imports
967
- return logTransition('fallbackResolve: relative failure', request);
968
- }
946
+ return this.relativeFallbackResolve(pkg, request);
969
947
  }
970
- // auto-upgraded packages can fall back to the set of known active addons
971
948
  if (pkg.needsLooseResolving()) {
972
- let addon = this.locateActiveAddon(packageName);
973
- if (addon) {
974
- const rehomed = request.rehome(addon.canResolveFromFile);
975
- if (rehomed !== request) {
976
- return logTransition(`activeAddons`, request, rehomed);
977
- }
949
+ let activeAddon = this.maybeFallbackToActiveAddon(request, packageName);
950
+ if (activeAddon) {
951
+ return activeAddon;
978
952
  }
979
953
  }
980
954
  let logicalLocation = this.reverseSearchAppTree(pkg, request.fromFile);
@@ -998,7 +972,7 @@ class Resolver {
998
972
  return logTransition('fallbackResolve: non-relative appJsMatch', request, appJSMatch);
999
973
  }
1000
974
  }
1001
- if (pkg.needsLooseResolving() && ((_c = (_b = request.meta) === null || _b === void 0 ? void 0 : _b.runtimeFallback) !== null && _c !== void 0 ? _c : true)) {
975
+ if (pkg.needsLooseResolving() && ((_b = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.runtimeFallback) !== null && _b !== void 0 ? _b : true)) {
1002
976
  // auto-upgraded packages can fall back to attempting to find dependencies at
1003
977
  // runtime. Native v2 packages can only get this behavior in the
1004
978
  // isExplicitlyExternal case above because they need to explicitly ask for
@@ -1017,6 +991,54 @@ class Resolver {
1017
991
  // non-resolvable, which will presumably cause a static build error in stage3.
1018
992
  return logTransition('fallbackResolve final exit', request);
1019
993
  }
994
+ restoreRehomedRequest(pkg, request) {
995
+ var _a;
996
+ // meta.originalFromFile gets set when we want to try to rehome a request
997
+ // but then come back to the original location here in the fallback when the
998
+ // rehomed request fails
999
+ let movedPkg = this.packageCache.maybeMoved(pkg);
1000
+ if (movedPkg !== pkg) {
1001
+ let originalFromFile = (_a = request.meta) === null || _a === void 0 ? void 0 : _a.originalFromFile;
1002
+ if (typeof originalFromFile !== 'string') {
1003
+ throw new Error(`bug: embroider resolver's meta is not propagating`);
1004
+ }
1005
+ request = request.rehome(originalFromFile);
1006
+ pkg = movedPkg;
1007
+ }
1008
+ return { pkg, request };
1009
+ }
1010
+ async relativeFallbackResolve(pkg, request) {
1011
+ let withinEngine = this.engineConfig(pkg.name);
1012
+ if (withinEngine) {
1013
+ // it's a relative import inside an engine (which also means app), which
1014
+ // means we may need to satisfy the request via app tree merging.
1015
+ let logicalName = engineRelativeName(pkg, (0, path_1.resolve)((0, path_1.dirname)(request.fromFile), request.specifier));
1016
+ if (!logicalName) {
1017
+ return logTransition('fallbackResolve: relative failure because this file is not externally accessible', request);
1018
+ }
1019
+ let appJSMatch = await this.searchAppTree(request, withinEngine, logicalName);
1020
+ if (appJSMatch) {
1021
+ return logTransition('fallbackResolve: relative appJsMatch', request, appJSMatch);
1022
+ }
1023
+ else {
1024
+ return logTransition('fallbackResolve: relative appJs search failure', request);
1025
+ }
1026
+ }
1027
+ else {
1028
+ // nothing else to do for relative imports
1029
+ return logTransition('fallbackResolve: relative failure', request);
1030
+ }
1031
+ }
1032
+ maybeFallbackToActiveAddon(request, requestedPackageName) {
1033
+ // auto-upgraded packages can fall back to the set of known active addons
1034
+ let addon = this.locateActiveAddon(requestedPackageName);
1035
+ if (addon) {
1036
+ const rehomed = request.rehome(addon.canResolveFromFile);
1037
+ if (rehomed !== request) {
1038
+ return logTransition(`activeAddons`, request, rehomed);
1039
+ }
1040
+ }
1041
+ }
1020
1042
  getEntryFromMergeMap(inEngineSpecifier, root) {
1021
1043
  var _a;
1022
1044
  let entry;