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

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.
@@ -3,70 +3,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NodeModuleRequest = void 0;
6
+ exports.NodeRequestAdapter = void 0;
7
7
  exports.nodeResolve = nodeResolve;
8
8
  const virtual_content_1 = require("./virtual-content");
9
9
  const path_1 = require("path");
10
10
  const shared_internals_1 = require("@embroider/shared-internals");
11
11
  const assert_never_1 = __importDefault(require("assert-never"));
12
- class NodeModuleRequest {
13
- constructor(resolver, specifier, fromFile, isVirtual, meta, isNotFound, resolvedTo) {
12
+ // these would be circular, but they're type-only so it's fine
13
+ const module_request_1 = require("./module-request");
14
+ class NodeRequestAdapter {
15
+ constructor(resolver) {
14
16
  this.resolver = resolver;
15
- this.specifier = specifier;
16
- this.fromFile = fromFile;
17
- this.isVirtual = isVirtual;
18
- this.meta = meta;
19
- this.isNotFound = isNotFound;
20
- this.resolvedTo = resolvedTo;
21
17
  }
22
18
  get debugType() {
23
19
  return 'node';
24
20
  }
25
- alias(specifier) {
26
- return new NodeModuleRequest(this.resolver, specifier, this.fromFile, false, this.meta, false, undefined);
21
+ notFoundResponse(request) {
22
+ let err = new Error(`module not found ${request.specifier}`);
23
+ err.code = 'MODULE_NOT_FOUND';
24
+ return {
25
+ type: 'not_found',
26
+ err,
27
+ };
27
28
  }
28
- rehome(fromFile) {
29
- if (this.fromFile === fromFile) {
30
- return this;
31
- }
32
- else {
33
- return new NodeModuleRequest(this.resolver, this.specifier, fromFile, false, this.meta, false, undefined);
34
- }
35
- }
36
- virtualize(filename) {
37
- return new NodeModuleRequest(this.resolver, filename, this.fromFile, true, this.meta, false, undefined);
38
- }
39
- withMeta(meta) {
40
- return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, meta, this.isNotFound, this.resolvedTo);
41
- }
42
- notFound() {
43
- return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, this.meta, true, undefined);
29
+ virtualResponse(_request, virtualFileName) {
30
+ return {
31
+ type: 'found',
32
+ filename: virtualFileName,
33
+ isVirtual: true,
34
+ result: {
35
+ type: 'virtual',
36
+ content: (0, virtual_content_1.virtualContent)(virtualFileName, this.resolver).src,
37
+ filename: virtualFileName,
38
+ },
39
+ };
44
40
  }
45
- resolveTo(resolution) {
46
- return new NodeModuleRequest(this.resolver, this.specifier, this.fromFile, this.isVirtual, this.meta, this.isNotFound, resolution);
47
- }
48
- async defaultResolve() {
49
- const request = this;
50
- if (request.isVirtual) {
51
- return {
52
- type: 'found',
53
- filename: request.specifier,
54
- isVirtual: true,
55
- result: {
56
- type: 'virtual',
57
- content: (0, virtual_content_1.virtualContent)(request.specifier, this.resolver).src,
58
- filename: request.specifier,
59
- },
60
- };
61
- }
62
- if (request.isNotFound) {
63
- let err = new Error(`module not found ${request.specifier}`);
64
- err.code = 'MODULE_NOT_FOUND';
65
- return {
66
- type: 'not_found',
67
- err,
68
- };
69
- }
41
+ async resolve(request) {
70
42
  // require.resolve does not like when we resolve from virtual paths.
71
43
  // That is, a request like "../thing.js" from
72
44
  // "/a/real/path/VIRTUAL_SUBDIR/virtual.js" has an unambiguous target of
@@ -107,7 +79,17 @@ class NodeModuleRequest {
107
79
  return { type: 'not_found', err: initialError };
108
80
  }
109
81
  }
110
- exports.NodeModuleRequest = NodeModuleRequest;
82
+ exports.NodeRequestAdapter = NodeRequestAdapter;
83
+ NodeRequestAdapter.create = ({ resolver, specifier, fromFile }) => {
84
+ return {
85
+ initialState: {
86
+ specifier,
87
+ fromFile,
88
+ meta: undefined,
89
+ },
90
+ adapter: new NodeRequestAdapter(resolver),
91
+ };
92
+ };
111
93
  function* candidates(specifier) {
112
94
  yield specifier;
113
95
  const extensions = ['.hbs.js', '.hbs'];
@@ -116,7 +98,8 @@ function* candidates(specifier) {
116
98
  }
117
99
  }
118
100
  async function nodeResolve(resolver, specifier, fromFile) {
119
- let resolution = await resolver.resolve(new NodeModuleRequest(resolver, specifier, fromFile, false, undefined, false, undefined));
101
+ let request = module_request_1.ModuleRequest.create(NodeRequestAdapter.create, { resolver, fromFile, specifier });
102
+ let resolution = await resolver.resolve(request);
120
103
  switch (resolution.type) {
121
104
  case 'not_found':
122
105
  return resolution;
@@ -1 +1 @@
1
- {"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAyJA,kCAoBC;AA7KD,uDAAmD;AACnD,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAKvC,MAAa,iBAAiB;IAC5B,YACU,QAAkB,EACjB,SAAiB,EACjB,QAAgB,EAChB,SAAkB,EAClB,IAAqC,EACrC,UAAmB,EACnB,UAAyD;QAN1D,aAAQ,GAAR,QAAQ,CAAU;QACjB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAiC;QACrC,eAAU,GAAV,UAAU,CAAS;QACnB,eAAU,GAAV,UAAU,CAA+C;IACjE,CAAC;IAEJ,IAAI,SAAS;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,SAAiB;QACrB,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAS,CAAC;IACpH,CAAC;IACD,MAAM,CAAC,QAAgB;QACrB,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,iBAAiB,CAAC,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AAS;YACZ,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAC;QACJ;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { virtualContent } from './virtual-content';\nimport { dirname, resolve, isAbsolute } from 'path';\nimport { explicitRelative } from '@embroider/shared-internals';\nimport assertNever from 'assert-never';\n\n// these would be circular, but they're type-only so it's fine\nimport type { ModuleRequest, Resolution, Resolver } from './module-resolver';\n\nexport class NodeModuleRequest implements ModuleRequest {\n constructor(\n private resolver: Resolver,\n readonly specifier: string,\n readonly fromFile: string,\n readonly isVirtual: boolean,\n readonly meta: Record<string, any> | undefined,\n readonly isNotFound: boolean,\n readonly resolvedTo: Resolution<NodeResolution, Error> | undefined\n ) {}\n\n get debugType() {\n return 'node';\n }\n\n alias(specifier: string): this {\n return new NodeModuleRequest(this.resolver, specifier, this.fromFile, false, this.meta, false, undefined) as this;\n }\n rehome(fromFile: string): this {\n if (this.fromFile === fromFile) {\n return this;\n } else {\n return new NodeModuleRequest(this.resolver, this.specifier, fromFile, false, this.meta, false, undefined) as this;\n }\n }\n virtualize(filename: string): this {\n return new NodeModuleRequest(this.resolver, filename, this.fromFile, true, this.meta, false, undefined) as this;\n }\n withMeta(meta: Record<string, any> | undefined): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n meta,\n this.isNotFound,\n this.resolvedTo\n ) as this;\n }\n notFound(): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n this.meta,\n true,\n undefined\n ) as this;\n }\n\n resolveTo(resolution: Resolution<NodeResolution, Error>): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n this.meta,\n this.isNotFound,\n resolution\n ) as this;\n }\n\n async defaultResolve(): Promise<Resolution<NodeResolution, Error>> {\n const request = this;\n if (request.isVirtual) {\n return {\n type: 'found',\n filename: request.specifier,\n isVirtual: true,\n result: {\n type: 'virtual' as 'virtual',\n content: virtualContent(request.specifier, this.resolver).src,\n filename: request.specifier,\n },\n };\n }\n if (request.isNotFound) {\n let err = new Error(`module not found ${request.specifier}`);\n (err as any).code = 'MODULE_NOT_FOUND';\n return {\n type: 'not_found',\n err,\n };\n }\n\n // require.resolve does not like when we resolve from virtual paths.\n // That is, a request like \"../thing.js\" from\n // \"/a/real/path/VIRTUAL_SUBDIR/virtual.js\" has an unambiguous target of\n // \"/a/real/path/thing.js\", but require.resolve won't do that path\n // adjustment until after checking whether VIRTUAL_SUBDIR actually\n // exists.\n //\n // We can do the path adjustments before doing require.resolve.\n let { specifier } = request;\n let fromDir = dirname(request.fromFile);\n if (!isAbsolute(specifier) && specifier.startsWith('.')) {\n let targetPath = resolve(fromDir, specifier);\n let newFromDir = dirname(targetPath);\n if (fromDir !== newFromDir) {\n specifier = explicitRelative(newFromDir, targetPath);\n fromDir = newFromDir;\n }\n }\n\n let initialError;\n\n for (let candidate of candidates(specifier)) {\n let filename;\n try {\n filename = require.resolve(candidate, {\n paths: [fromDir],\n });\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n\n if (!initialError) {\n initialError = err;\n }\n\n continue;\n }\n return { type: 'found', filename, result: { type: 'real' as 'real', filename }, isVirtual: false };\n }\n\n return { type: 'not_found', err: initialError };\n }\n}\n\nfunction* candidates(specifier: string) {\n yield specifier;\n\n const extensions = ['.hbs.js', '.hbs'];\n\n for (let ext of extensions) {\n yield `${specifier}${ext}`;\n }\n}\n\ntype NodeResolution = { type: 'virtual'; filename: string; content: string } | { type: 'real'; filename: string };\n\ntype NodeResolutionError = { type: 'not_found'; err: Error };\n\nexport async function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string\n): Promise<NodeResolution | NodeResolutionError> {\n let resolution = await resolver.resolve(\n new NodeModuleRequest(resolver, specifier, fromFile, false, undefined, false, undefined)\n );\n switch (resolution.type) {\n case 'not_found':\n return resolution;\n case 'found':\n return resolution.result;\n case 'ignored':\n throw new Error(\n `bug: this is supposed to be impossible because NodeModuleRequest.prototype.defaultResove does not use \"ignored\"`\n );\n default:\n throw assertNever(resolution);\n }\n}\n"]}
1
+ {"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAmHA,kCAmBC;AAtID,uDAAmD;AACnD,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAEvC,8DAA8D;AAC9D,qDAAkH;AAGlH,MAAa,kBAAkB;IAe7B,YAA4B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAElD,IAAI,SAAS;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gBAAgB,CAAC,OAAyD;QACxE,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,oBAAoB,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5D,GAAW,CAAC,IAAI,GAAG,kBAAkB,CAAC;QACvC,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,GAAG;SACJ,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAA0D,EAC1D,eAAuB;QAEvB,OAAO;YACL,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,eAAe;YACzB,SAAS,EAAE,IAAI;YACf,MAAM,EAAE;gBACN,IAAI,EAAE,SAAsB;gBAC5B,OAAO,EAAE,IAAA,gCAAc,EAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG;gBAC3D,QAAQ,EAAE,eAAe;aAC1B;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAyD;QACrE,oEAAoE;QACpE,6CAA6C;QAC7C,wEAAwE;QACxE,kEAAkE;QAClE,kEAAkE;QAClE,UAAU;QACV,EAAE;QACF,+DAA+D;QAC/D,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC5B,IAAI,OAAO,GAAG,IAA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,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxC,OAAO;QACL,YAAY,EAAE;YACZ,SAAS;YACT,QAAQ;YACR,IAAI,EAAE,SAAS;SAChB;QACD,OAAO,EAAE,IAAI,kBAAkB,CAAC,QAAQ,CAAC;KAC1C,CAAC;AACJ,CAAC,CAAC;AA+EJ,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAiB;IACpC,MAAM,SAAS,CAAC;IAEhB,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,GAAG,SAAS,GAAG,GAAG,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAMM,KAAK,UAAU,WAAW,CAC/B,QAAkB,EAClB,SAAiB,EACjB,QAAgB;IAEhB,IAAI,OAAO,GAAG,8BAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IACjG,IAAI,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAQ,CAAC,CAAC;IAClD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B,KAAK,SAAS;YACZ,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAC;QACJ;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { virtualContent } from './virtual-content';\nimport { dirname, resolve, isAbsolute } from 'path';\nimport { explicitRelative } from '@embroider/shared-internals';\nimport assertNever from 'assert-never';\n\n// these would be circular, but they're type-only so it's fine\nimport { ModuleRequest, type RequestAdapter, type RequestAdapterCreate, type Resolution } from './module-request';\nimport type { Resolver } from './module-resolver';\n\nexport class NodeRequestAdapter implements RequestAdapter<Resolution<NodeResolution, Error>> {\n static create: RequestAdapterCreate<\n { resolver: Resolver; specifier: string; fromFile: string },\n Resolution<NodeResolution, Error>\n > = ({ resolver, specifier, fromFile }) => {\n return {\n initialState: {\n specifier,\n fromFile,\n meta: undefined,\n },\n adapter: new NodeRequestAdapter(resolver),\n };\n };\n\n private constructor(private resolver: Resolver) {}\n\n get debugType() {\n return 'node';\n }\n\n notFoundResponse(request: ModuleRequest<Resolution<NodeResolution, Error>>): Resolution<NodeResolution, Error> {\n let err = new Error(`module not found ${request.specifier}`);\n (err as any).code = 'MODULE_NOT_FOUND';\n return {\n type: 'not_found',\n err,\n };\n }\n\n virtualResponse(\n _request: ModuleRequest<Resolution<NodeResolution, Error>>,\n virtualFileName: string\n ): Resolution<NodeResolution, Error> {\n return {\n type: 'found',\n filename: virtualFileName,\n isVirtual: true,\n result: {\n type: 'virtual' as 'virtual',\n content: virtualContent(virtualFileName, this.resolver).src,\n filename: virtualFileName,\n },\n };\n }\n\n async resolve(request: ModuleRequest<Resolution<NodeResolution, Error>>): Promise<Resolution<NodeResolution, Error>> {\n // require.resolve does not like when we resolve from virtual paths.\n // That is, a request like \"../thing.js\" from\n // \"/a/real/path/VIRTUAL_SUBDIR/virtual.js\" has an unambiguous target of\n // \"/a/real/path/thing.js\", but require.resolve won't do that path\n // adjustment until after checking whether VIRTUAL_SUBDIR actually\n // exists.\n //\n // We can do the path adjustments before doing require.resolve.\n let { specifier } = request;\n let fromDir = dirname(request.fromFile);\n if (!isAbsolute(specifier) && specifier.startsWith('.')) {\n let targetPath = resolve(fromDir, specifier);\n let newFromDir = dirname(targetPath);\n if (fromDir !== newFromDir) {\n specifier = explicitRelative(newFromDir, targetPath);\n fromDir = newFromDir;\n }\n }\n\n let initialError;\n\n for (let candidate of candidates(specifier)) {\n let filename;\n try {\n filename = require.resolve(candidate, {\n paths: [fromDir],\n });\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n\n if (!initialError) {\n initialError = err;\n }\n\n continue;\n }\n return { type: 'found', filename, result: { type: 'real' as 'real', filename }, isVirtual: false };\n }\n\n return { type: 'not_found', err: initialError };\n }\n}\n\nfunction* candidates(specifier: string) {\n yield specifier;\n\n const extensions = ['.hbs.js', '.hbs'];\n\n for (let ext of extensions) {\n yield `${specifier}${ext}`;\n }\n}\n\ntype NodeResolution = { type: 'virtual'; filename: string; content: string } | { type: 'real'; filename: string };\n\ntype NodeResolutionError = { type: 'not_found'; err: Error };\n\nexport async function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string\n): Promise<NodeResolution | NodeResolutionError> {\n let request = ModuleRequest.create(NodeRequestAdapter.create, { resolver, fromFile, specifier });\n let resolution = await resolver.resolve(request!);\n switch (resolution.type) {\n case 'not_found':\n return resolution;\n case 'found':\n return resolution.result;\n case 'ignored':\n throw new Error(\n `bug: this is supposed to be impossible because NodeModuleRequest.prototype.defaultResove does not use \"ignored\"`\n );\n default:\n throw assertNever(resolution);\n }\n}\n"]}
package/src/options.d.ts CHANGED
@@ -8,8 +8,5 @@ export default interface Options {
8
8
  resolve: string[];
9
9
  useMethod?: string;
10
10
  }[];
11
- amdCompatibility?: false | 'cjs' | {
12
- es: [string, string[]][];
13
- };
14
11
  }
15
12
  export declare function optionsWithDefaults(options?: Options): Required<Options>;
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;AAsHA,kDAcC;AAdD,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,KAAc;KACjC,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all modifiers at build time. This\n // causes unused modifiers to be left out of the build (\"tree shaking\" of\n // modifiers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticModifiers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/main/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, modifier, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), modifiers\n // (which are governed by staticModifiers) or the route-specific files (routes,\n // route templates, and controllers which are governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n\n // Ember classically used a runtime AMD module loader.\n //\n // Embroider *can* locate the vast majority of modules statically, but when an\n // addon is doing something highly dynamic (like injecting AMD `define()`\n // statements directly into a <script>), we still may not be able to locate\n // them. So Embroider can emit a placeholder shim for the missing module that\n // attempts to locate it at runtime in the classic AMD loader.\n //\n // This shim can be generated as commonJS (cjs) or an ES module (es). The\n // default is cjs.\n //\n // CJS is useful when you're building in an environment that is tolerant of\n // mixed CJS and ES modules (like Webpack), because the set of exported names\n // from the module doesn't need to be known in advance. For this reason, CJS\n // shims are generated on-demand and are fully-automatic. This is the default\n // for maximum backward-compatibility.\n //\n // ES is useful when you're building in a strict ES module environment (like\n // Vite). It's fully spec-defined and doesn't suffer interoperability\n // complexities. The downside is, we can only emit a correct shim for a module\n // if you tell embroider what set of names it exports. Example:\n\n // emberExternals: {\n // es: [\n // // import { first, second } from \"my-library\";\n // ['my-library', ['first', 'second']],\n // // import Example from \"my-library/components/example\";\n // ['my-library/components/example', ['default']]\n // ];\n // }\n\n // It is not recommended to use `es` mode without also using\n // staticEmberSource, because without staticEmberSource ember itself needs\n // many external shims.\n //\n // false means we don't do any external shimming.\n amdCompatibility?:\n | false\n | 'cjs'\n | {\n es: [string, string[]][];\n };\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticModifiers: false,\n staticComponents: false,\n splitAtRoutes: [],\n staticAppPaths: [],\n pluginHints: [],\n amdCompatibility: 'cjs' as const,\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;AA2EA,kDAcC;AAdD,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,KAAc;KACjC,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all modifiers at build time. This\n // causes unused modifiers to be left out of the build (\"tree shaking\" of\n // modifiers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticModifiers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/main/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, modifier, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), modifiers\n // (which are governed by staticModifiers) or the route-specific files (routes,\n // route templates, and controllers which are governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticModifiers: false,\n staticComponents: false,\n splitAtRoutes: [],\n staticAppPaths: [],\n pluginHints: [],\n amdCompatibility: 'cjs' as const,\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
@@ -4,8 +4,6 @@ export interface VirtualContentResult {
4
4
  watches: string[];
5
5
  }
6
6
  export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
7
- export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
8
- export declare function virtualExternalCJSModule(specifier: string): string;
9
7
  export declare function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string;
10
8
  export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
11
9
  export declare function decodeFastbootSwitch(filename: string): {
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.virtualContent = virtualContent;
4
- exports.virtualExternalESModule = virtualExternalESModule;
5
- exports.virtualExternalCJSModule = virtualExternalCJSModule;
6
4
  exports.virtualPairComponent = virtualPairComponent;
7
5
  exports.fastbootSwitch = fastbootSwitch;
8
6
  exports.decodeFastbootSwitch = decodeFastbootSwitch;
@@ -16,17 +14,11 @@ const virtual_vendor_1 = require("./virtual-vendor");
16
14
  const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
17
15
  const virtual_entrypoint_1 = require("./virtual-entrypoint");
18
16
  const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
19
- const externalESPrefix = '/@embroider/ext-es/';
20
- const externalCJSPrefix = '/@embroider/ext-cjs/';
21
17
  // Given a filename that was passed to your ModuleRequest's `virtualize()`,
22
18
  // this produces the corresponding contents. It's a static, stateless function
23
19
  // because we recognize that that process that did resolution might not be the
24
20
  // same one that loads the content.
25
21
  function virtualContent(filename, resolver) {
26
- let cjsExtern = decodeVirtualExternalCJSModule(filename);
27
- if (cjsExtern) {
28
- return renderCJSExternalShim(cjsExtern);
29
- }
30
22
  let entrypoint = (0, virtual_entrypoint_1.decodeEntrypoint)(filename);
31
23
  if (entrypoint) {
32
24
  return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, entrypoint);
@@ -35,10 +27,6 @@ function virtualContent(filename, resolver) {
35
27
  if (routeEntrypoint) {
36
28
  return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(resolver, routeEntrypoint);
37
29
  }
38
- let extern = decodeVirtualExternalESModule(filename);
39
- if (extern) {
40
- return renderESExternalShim(extern);
41
- }
42
30
  let match = decodeVirtualPairComponent(filename);
43
31
  if (match) {
44
32
  return pairedComponentShim(match);
@@ -69,33 +57,6 @@ function virtualContent(filename, resolver) {
69
57
  }
70
58
  throw new Error(`not an @embroider/core virtual file: ${filename}`);
71
59
  }
72
- const externalESShim = (0, js_handlebars_1.compile)(`
73
- {{#if (eq moduleName "require")}}
74
- const m = window.requirejs;
75
- export default m;
76
- const has = m.has;
77
- export { has }
78
- {{else}}
79
- const m = window.require("{{{js-string-escape moduleName}}}");
80
- {{#if default}}
81
- export default m.default;
82
- {{/if}}
83
- {{#if names}}
84
- const { {{#each names as |name|}}{{name}}, {{/each}} } = m;
85
- export { {{#each names as |name|}}{{name}}, {{/each}} }
86
- {{/if}}
87
- {{/if}}
88
- `);
89
- function renderESExternalShim({ moduleName, exports, }) {
90
- return {
91
- src: externalESShim({
92
- moduleName,
93
- default: exports.includes('default'),
94
- names: exports.filter(n => n !== 'default'),
95
- }),
96
- watches: [],
97
- };
98
- }
99
60
  function pairedComponentShim(params) {
100
61
  return {
101
62
  src: pairedComponentShimTemplate(params),
@@ -129,34 +90,6 @@ import templateOnlyComponent from "@ember/component/template-only";
129
90
  export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
130
91
  {{/if}}
131
92
  `);
132
- function virtualExternalESModule(specifier, exports) {
133
- if (exports) {
134
- return externalESPrefix + specifier + `/exports=${exports.join(',')}`;
135
- }
136
- else {
137
- return externalESPrefix + specifier;
138
- }
139
- }
140
- function virtualExternalCJSModule(specifier) {
141
- return externalCJSPrefix + specifier;
142
- }
143
- function decodeVirtualExternalESModule(filename) {
144
- if (filename.startsWith(externalESPrefix)) {
145
- let exports = [];
146
- let components = filename.split('/exports=');
147
- let nameString = components[1];
148
- if (nameString) {
149
- exports = nameString.split(',');
150
- }
151
- let moduleName = components[0].slice(externalESPrefix.length);
152
- return { moduleName, exports };
153
- }
154
- }
155
- function decodeVirtualExternalCJSModule(filename) {
156
- if (filename.startsWith(externalCJSPrefix)) {
157
- return { moduleName: filename.slice(externalCJSPrefix.length) };
158
- }
159
- }
160
93
  const pairComponentMarker = '-embroider-pair-component';
161
94
  const pairComponentPattern = /^(?<hbsModule>.*)__vpc__(?<jsModule>[^\/]*)-embroider-pair-component$/;
162
95
  function virtualPairComponent(hbsModule, jsModule) {
@@ -346,41 +279,4 @@ function orderAddons(depA, depB) {
346
279
  }
347
280
  return depAIdx - depBIdx;
348
281
  }
349
- function renderCJSExternalShim(params) {
350
- return {
351
- src: renderCJSExternalShimTemplate(params),
352
- watches: [],
353
- };
354
- }
355
- const renderCJSExternalShimTemplate = (0, js_handlebars_1.compile)(`
356
- module.exports = new Proxy({}, {
357
- get(target, prop) {
358
-
359
- {{!- our proxy always presents as ES module so that we can intercept "get('default')" -}}
360
- if (prop === '__esModule') {
361
- return true;
362
- }
363
-
364
- {{#if (eq moduleName "require")}}
365
- const m = window.requirejs;
366
- {{else}}
367
- const m = window.require("{{{js-string-escape moduleName}}}");
368
- {{/if}}
369
-
370
- {{!-
371
- There are plenty of hand-written AMD defines floating around
372
- that lack an __esModule declaration.
373
-
374
- As far as I can tell, Ember's loader was already treating the Boolean(m.default)===true
375
- case as a module, so in theory we aren't breaking anything by
376
- treating it as such when other packagers come looking.
377
- -}}
378
- if (prop === 'default' && !m.__esModule && !m.default) {
379
- return m;
380
- }
381
-
382
- return m[prop];
383
- }
384
- });
385
- `);
386
282
  //# sourceMappingURL=virtual-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;AAwBA,wCAwDC;AA8ED,0DAMC;AAED,4DAEC;AAwBD,oDAMC;AAyBD,wCAOC;AAED,oDAcC;AAgCD,sDAcC;AApSD,+BAAoE;AAEpE,wBAAwD;AACxD,mDAA0C;AAC1C,iEAA8F;AAC9F,+EAAiG;AACjG,qDAAqE;AACrE,mEAAwF;AAExF,6DAA0E;AAC1E,yEAA0F;AAE1F,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAC/C,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAOjD,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAgB,EAAE,QAAkB;IACjE,IAAI,SAAS,GAAG,8BAA8B,CAAC,Q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CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA8B;IAC3D,OAAO;QACL,GAAG,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1C,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,6BAA6B,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B7C,CAA+C,CAAC","sourcesContent":["import { dirname, basename, resolve, posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\nimport { decodeImplicitTestScripts, renderImplicitTestScripts } from './virtual-test-support';\nimport { decodeTestSupportStyles, renderTestSupportStyles } from './virtual-test-support-styles';\nimport { decodeVirtualVendor, renderVendor } from './virtual-vendor';\nimport { decodeVirtualVendorStyles, renderVendorStyles } from './virtual-vendor-styles';\n\nimport { decodeEntrypoint, renderEntrypoint } from './virtual-entrypoint';\nimport { decodeRouteEntrypoint, renderRouteEntrypoint } from './virtual-route-entrypoint';\n\nconst externalESPrefix = '/@embroider/ext-es/';\nconst externalCJSPrefix = '/@embroider/ext-cjs/';\n\nexport interface VirtualContentResult {\n src: string;\n watches: string[];\n}\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(filename: string, resolver: Resolver): VirtualContentResult {\n let cjsExtern = decodeVirtualExternalCJSModule(filename);\n if (cjsExtern) {\n return renderCJSExternalShim(cjsExtern);\n }\n\n let entrypoint = decodeEntrypoint(filename);\n if (entrypoint) {\n return renderEntrypoint(resolver, entrypoint);\n }\n\n let routeEntrypoint = decodeRouteEntrypoint(filename);\n if (routeEntrypoint) {\n return renderRouteEntrypoint(resolver, routeEntrypoint);\n }\n\n let extern = decodeVirtualExternalESModule(filename);\n if (extern) {\n return renderESExternalShim(extern);\n }\n let match = decodeVirtualPairComponent(filename);\n if (match) {\n return pairedComponentShim(match);\n }\n\n let fb = decodeFastbootSwitch(filename);\n if (fb) {\n return renderFastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n let isVendor = decodeVirtualVendor(filename);\n if (isVendor) {\n return renderVendor(filename, resolver);\n }\n\n let isImplicitTestScripts = decodeImplicitTestScripts(filename);\n if (isImplicitTestScripts) {\n return renderImplicitTestScripts(filename, resolver);\n }\n\n let isVendorStyles = decodeVirtualVendorStyles(filename);\n if (isVendorStyles) {\n return renderVendorStyles(filename, resolver);\n }\n\n let isTestSupportStyles = decodeTestSupportStyles(filename);\n if (isTestSupportStyles) {\n return renderTestSupportStyles(filename, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\nconst externalESShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\nexport default m;\nconst has = m.has;\nexport { has }\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{#if default}}\nexport default m.default;\n{{/if}}\n{{#if names}}\nconst { {{#each names as |name|}}{{name}}, {{/each}} } = m;\nexport { {{#each names as |name|}}{{name}}, {{/each}} }\n{{/if}}\n{{/if}}\n`) as (params: { moduleName: string; default: boolean; names: string[] }) => string;\n\nfunction renderESExternalShim({\n moduleName,\n exports,\n}: {\n moduleName: string;\n exports: string[];\n}): VirtualContentResult {\n return {\n src: externalESShim({\n moduleName,\n default: exports.includes('default'),\n names: exports.filter(n => n !== 'default'),\n }),\n watches: [],\n };\n}\n\ninterface PairedComponentShimParams {\n relativeHBSModule: string;\n relativeJSModule: string | null;\n debugName: string;\n}\n\nfunction pairedComponentShim(params: PairedComponentShimParams): VirtualContentResult {\n return {\n src: pairedComponentShimTemplate(params),\n watches: [],\n };\n}\n\nconst pairedComponentShimTemplate = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape relativeHBSModule}}}\";\nimport { deprecate } from \"@ember/debug\";\n\n\ndeprecate(\"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '{{debugName}}'.\",\n false, {\n id: 'component-template-resolving',\n url: 'https://deprecations.emberjs.com/id/component-template-resolving',\n until: '6.0.0',\n for: 'ember-source',\n since: {\n available: '5.10.0',\n enabled: '5.10.0',\n },\n }\n);\n\n{{#if relativeJSModule}}\nimport component from \"{{{js-string-escape relativeJSModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: PairedComponentShimParams) => string;\n\nexport function virtualExternalESModule(specifier: string, exports: string[] | undefined): string {\n if (exports) {\n return externalESPrefix + specifier + `/exports=${exports.join(',')}`;\n } else {\n return externalESPrefix + specifier;\n }\n}\n\nexport function virtualExternalCJSModule(specifier: string): string {\n return externalCJSPrefix + specifier;\n}\n\nfunction decodeVirtualExternalESModule(filename: string): { moduleName: string; exports: string[] } | undefined {\n if (filename.startsWith(externalESPrefix)) {\n let exports: string[] = [];\n let components = filename.split('/exports=');\n let nameString = components[1];\n if (nameString) {\n exports = nameString.split(',');\n }\n let moduleName = components[0].slice(externalESPrefix.length);\n return { moduleName, exports };\n }\n}\n\nfunction decodeVirtualExternalCJSModule(filename: string) {\n if (filename.startsWith(externalCJSPrefix)) {\n return { moduleName: filename.slice(externalCJSPrefix.length) };\n }\n}\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)__vpc__(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(dirname(hbsModule), jsModule);\n }\n return `${hbsModule}__vpc__${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(pairComponentMarker)) {\n return null;\n }\n let match = pairComponentPattern.exec(filename);\n if (!match) {\n return null;\n }\n let { hbsModule, jsModule } = match.groups! as { hbsModule: string; jsModule: string };\n // target our real hbs module from our virtual module\n let relativeHBSModule = explicitRelative(dirname(filename), hbsModule);\n return {\n relativeHBSModule,\n relativeJSModule: decodeURIComponent(jsModule) || null,\n debugName: basename(relativeHBSModule).replace(/\\.(js|hbs)$/, ''),\n };\n}\n\nconst fastbootSwitchSuffix = '/embroider_fastboot_switch';\nconst fastbootSwitchPattern = /(?<original>.+)\\/embroider_fastboot_switch(?:\\?names=(?<names>.+))?$/;\nexport function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string {\n let filename = `${resolve(dirname(fromFile), specifier)}${fastbootSwitchSuffix}`;\n if (names.size > 0) {\n return `${filename}?names=${[...names].join(',')}`;\n } else {\n return filename;\n }\n}\n\nexport function decodeFastbootSwitch(filename: string) {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(fastbootSwitchSuffix)) {\n return;\n }\n let match = fastbootSwitchPattern.exec(filename);\n if (match) {\n let names = match.groups?.names?.split(',') ?? [];\n return {\n names: names.filter(name => name !== 'default'),\n hasDefaultExport: names.includes('default'),\n filename: match.groups!.original,\n };\n }\n}\n\ninterface FastbootSwitchParams {\n names: string[];\n hasDefaultExport: boolean;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchParams): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate(params),\n watches: [],\n };\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: FastbootSwitchParams) => string;\n\nconst implicitModulesPattern = /(?<filename>.*)[\\\\/]-embroider-implicit-(?<test>test-)?modules\\.js$/;\n\nexport function decodeImplicitModules(\n filename: string\n): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-implicit-')) {\n return;\n }\n let m = implicitModulesPattern.exec(filename);\n if (m) {\n return {\n type: m.groups!.test ? 'implicit-test-modules' : 'implicit-modules',\n fromFile: m.groups!.filename,\n };\n }\n}\n\nfunction renderImplicitModules(\n {\n type,\n fromFile,\n }: {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n },\n resolver: Resolver\n): VirtualContentResult {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let ownModules: { runtime: string; buildtime: string }[] = [];\n let dependencyModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n ownModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n dependencyModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };\n}\n\nconst implicitModulesTemplate = compile(`\n\n\n{{#each dependencyModules as |module index|}}\n import dep{{index}} from \"{{js-string-escape module}}\";\n{{/each}}\n\n{{#each ownModules as |module index|}}\n import * as own{{index}} from \"{{js-string-escape module.buildtime}}\";\n{{/each}}\n\nexport default Object.assign({},\n {{#each dependencyModules as |module index|}}\n dep{{index}},\n {{/each}}\n {\n {{#each ownModules as |module index|}}\n \"{{js-string-escape module.runtime}}\": own{{index}},\n {{/each}}\n }\n);\n`) as (params: { dependencyModules: string[]; ownModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nfunction renderCJSExternalShim(params: { moduleName: string }): VirtualContentResult {\n return {\n src: renderCJSExternalShimTemplate(params),\n watches: [],\n };\n}\n\nconst renderCJSExternalShimTemplate = compile(`\nmodule.exports = new Proxy({}, {\n get(target, prop) {\n\n {{!- our proxy always presents as ES module so that we can intercept \"get('default')\" -}}\n if (prop === '__esModule') {\n return true;\n }\n\n {{#if (eq moduleName \"require\")}}\n const m = window.requirejs;\n {{else}}\n const m = window.require(\"{{{js-string-escape moduleName}}}\");\n {{/if}}\n\n {{!-\n There are plenty of hand-written AMD defines floating around\n that lack an __esModule declaration.\n\n As far as I can tell, Ember's loader was already treating the Boolean(m.default)===true\n case as a module, so in theory we aren't breaking anything by\n treating it as such when other packagers come looking.\n -}}\n if (prop === 'default' && !m.__esModule && !m.default) {\n return m;\n }\n\n return m[prop];\n }\n});\n`) as (params: { moduleName: string }) => string;\n"]}
1
+ {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;AAqBA,wCA+CC;AA8CD,oDAMC;AAyBD,wCAOC;AAED,oDAcC;AAgCD,sDAcC;AAtND,+BAAoE;AAEpE,wBAAwD;AACxD,mDAA0C;AAC1C,iEAA8F;AAC9F,+EAAiG;AACjG,qDAAqE;AACrE,mEAAwF;AAExF,6DAA0E;AAC1E,yEAA0F;AAO1F,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAgB,EAAE,QAAkB;IACjE,IAAI,UAAU,GAAG,IAAA,qCAAgB,EAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAA,qCAAgB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,eAAe,GAAG,IAAA,gDAAqB,EAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,IAAA,gDAAqB,EAAC,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AO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,IAAa;IAC/C,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC","sourcesContent":["import { dirname, basename, resolve, posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\nimport { decodeImplicitTestScripts, renderImplicitTestScripts } from './virtual-test-support';\nimport { decodeTestSupportStyles, renderTestSupportStyles } from './virtual-test-support-styles';\nimport { decodeVirtualVendor, renderVendor } from './virtual-vendor';\nimport { decodeVirtualVendorStyles, renderVendorStyles } from './virtual-vendor-styles';\n\nimport { decodeEntrypoint, renderEntrypoint } from './virtual-entrypoint';\nimport { decodeRouteEntrypoint, renderRouteEntrypoint } from './virtual-route-entrypoint';\n\nexport interface VirtualContentResult {\n src: string;\n watches: string[];\n}\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(filename: string, resolver: Resolver): VirtualContentResult {\n let entrypoint = decodeEntrypoint(filename);\n if (entrypoint) {\n return renderEntrypoint(resolver, entrypoint);\n }\n\n let routeEntrypoint = decodeRouteEntrypoint(filename);\n if (routeEntrypoint) {\n return renderRouteEntrypoint(resolver, routeEntrypoint);\n }\n\n let match = decodeVirtualPairComponent(filename);\n if (match) {\n return pairedComponentShim(match);\n }\n\n let fb = decodeFastbootSwitch(filename);\n if (fb) {\n return renderFastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n let isVendor = decodeVirtualVendor(filename);\n if (isVendor) {\n return renderVendor(filename, resolver);\n }\n\n let isImplicitTestScripts = decodeImplicitTestScripts(filename);\n if (isImplicitTestScripts) {\n return renderImplicitTestScripts(filename, resolver);\n }\n\n let isVendorStyles = decodeVirtualVendorStyles(filename);\n if (isVendorStyles) {\n return renderVendorStyles(filename, resolver);\n }\n\n let isTestSupportStyles = decodeTestSupportStyles(filename);\n if (isTestSupportStyles) {\n return renderTestSupportStyles(filename, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\ninterface PairedComponentShimParams {\n relativeHBSModule: string;\n relativeJSModule: string | null;\n debugName: string;\n}\n\nfunction pairedComponentShim(params: PairedComponentShimParams): VirtualContentResult {\n return {\n src: pairedComponentShimTemplate(params),\n watches: [],\n };\n}\n\nconst pairedComponentShimTemplate = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape relativeHBSModule}}}\";\nimport { deprecate } from \"@ember/debug\";\n\n\ndeprecate(\"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '{{debugName}}'.\",\n false, {\n id: 'component-template-resolving',\n url: 'https://deprecations.emberjs.com/id/component-template-resolving',\n until: '6.0.0',\n for: 'ember-source',\n since: {\n available: '5.10.0',\n enabled: '5.10.0',\n },\n }\n);\n\n{{#if relativeJSModule}}\nimport component from \"{{{js-string-escape relativeJSModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: PairedComponentShimParams) => string;\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)__vpc__(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(dirname(hbsModule), jsModule);\n }\n return `${hbsModule}__vpc__${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(pairComponentMarker)) {\n return null;\n }\n let match = pairComponentPattern.exec(filename);\n if (!match) {\n return null;\n }\n let { hbsModule, jsModule } = match.groups! as { hbsModule: string; jsModule: string };\n // target our real hbs module from our virtual module\n let relativeHBSModule = explicitRelative(dirname(filename), hbsModule);\n return {\n relativeHBSModule,\n relativeJSModule: decodeURIComponent(jsModule) || null,\n debugName: basename(relativeHBSModule).replace(/\\.(js|hbs)$/, ''),\n };\n}\n\nconst fastbootSwitchSuffix = '/embroider_fastboot_switch';\nconst fastbootSwitchPattern = /(?<original>.+)\\/embroider_fastboot_switch(?:\\?names=(?<names>.+))?$/;\nexport function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string {\n let filename = `${resolve(dirname(fromFile), specifier)}${fastbootSwitchSuffix}`;\n if (names.size > 0) {\n return `${filename}?names=${[...names].join(',')}`;\n } else {\n return filename;\n }\n}\n\nexport function decodeFastbootSwitch(filename: string) {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(fastbootSwitchSuffix)) {\n return;\n }\n let match = fastbootSwitchPattern.exec(filename);\n if (match) {\n let names = match.groups?.names?.split(',') ?? [];\n return {\n names: names.filter(name => name !== 'default'),\n hasDefaultExport: names.includes('default'),\n filename: match.groups!.original,\n };\n }\n}\n\ninterface FastbootSwitchParams {\n names: string[];\n hasDefaultExport: boolean;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchParams): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate(params),\n watches: [],\n };\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: FastbootSwitchParams) => string;\n\nconst implicitModulesPattern = /(?<filename>.*)[\\\\/]-embroider-implicit-(?<test>test-)?modules\\.js$/;\n\nexport function decodeImplicitModules(\n filename: string\n): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-implicit-')) {\n return;\n }\n let m = implicitModulesPattern.exec(filename);\n if (m) {\n return {\n type: m.groups!.test ? 'implicit-test-modules' : 'implicit-modules',\n fromFile: m.groups!.filename,\n };\n }\n}\n\nfunction renderImplicitModules(\n {\n type,\n fromFile,\n }: {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n },\n resolver: Resolver\n): VirtualContentResult {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let ownModules: { runtime: string; buildtime: string }[] = [];\n let dependencyModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n ownModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n dependencyModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };\n}\n\nconst implicitModulesTemplate = compile(`\n\n\n{{#each dependencyModules as |module index|}}\n import dep{{index}} from \"{{js-string-escape module}}\";\n{{/each}}\n\n{{#each ownModules as |module index|}}\n import * as own{{index}} from \"{{js-string-escape module.buildtime}}\";\n{{/each}}\n\nexport default Object.assign({},\n {{#each dependencyModules as |module index|}}\n dep{{index}},\n {{/each}}\n {\n {{#each ownModules as |module index|}}\n \"{{js-string-escape module.runtime}}\": own{{index}},\n {{/each}}\n }\n);\n`) as (params: { dependencyModules: string[]; ownModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n"]}
@@ -75,26 +75,19 @@ function renderRouteEntrypoint(resolver, { fromDir, route }) {
75
75
  return { src, watches: [] };
76
76
  }
77
77
  const routeEntryTemplate = (0, js_handlebars_1.compile)(`
78
- let d = window.define;
78
+ const output = {};
79
+ export default output;
79
80
 
80
81
  {{#each amdModules as |amdModule index| ~}}
81
82
  import * as amdModule{{index}} from "{{js-string-escape amdModule.buildtime}}"
82
- d("{{js-string-escape amdModule.runtime}}", function(){ return amdModule{{index}}; });
83
+ output["{{js-string-escape amdModule.runtime}}"] = amdModule{{index}};
83
84
  {{/each}}
84
85
 
85
86
  {{#if fastbootOnlyAmdModules}}
86
87
  if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
87
- let fastbootModules = {};
88
-
89
88
  {{#each fastbootOnlyAmdModules as |amdModule| ~}}
90
- fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
89
+ output["{{js-string-escape amdModule.runtime}}"] = await import("{{js-string-escape amdModule.buildtime}}");
91
90
  {{/each}}
92
-
93
- const resolvedValues = await Promise.all(Object.values(fastbootModules));
94
-
95
- Object.keys(fastbootModules).forEach((k, i) => {
96
- d(k, function(){ return resolvedValues[i];});
97
- })
98
91
  }
99
92
  {{/if}}
100
93
  `);
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-route-entrypoint.js","sourceRoot":"","sources":["virtual-route-entrypoint.ts"],"names":[],"mappings":";;AAWA,sDAKC;AAED,sDAYC;AAED,kEAEC;AAED,kEAOC;AAED,sDA6DC;AAzGD,2C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Package } from '@embroider/shared-internals/src/package';\nimport { AppFiles } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport { resolve } from 'path';\nimport { compile } from './js-handlebars';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport { partition } from 'lodash';\nimport { getAppFiles, getFastbootFiles, importPaths, splitRoute, staticAppPathsPattern } from './virtual-entrypoint';\n\nconst entrypointPattern = /(?<filename>.*)[\\\\/]-embroider-route-entrypoint.js:route=(?<route>.*)/;\n\nexport function encodeRouteEntrypoint(packagePath: string, matched: string | undefined, routeName: string): string {\n return resolve(\n packagePath,\n matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`\n );\n}\n\nexport function decodeRouteEntrypoint(filename: string): { fromDir: string; route: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-route-entrypoint')) {\n return;\n }\n let m = entrypointPattern.exec(filename);\n if (m) {\n return {\n fromDir: m.groups!.filename,\n route: m.groups!.route,\n };\n }\n}\n\nexport function encodePublicRouteEntrypoint(routeNames: string[], _files: string[]) {\n return `@embroider/core/route/${encodeURIComponent(routeNames[0])}`;\n}\n\nexport function decodePublicRouteEntrypoint(specifier: string): string | null {\n const publicPrefix = '@embroider/core/route/';\n if (!specifier.startsWith(publicPrefix)) {\n return null;\n }\n\n return specifier.slice(publicPrefix.length);\n}\n\nexport function renderRouteEntrypoint(\n resolver: Resolver,\n { fromDir, route }: { fromDir: string; route: string }\n): { src: string; watches: string[] } {\n const owner = resolver.packageCache.ownerOfFile(fromDir);\n\n if (!owner) {\n throw new Error('Owner expected'); // ToDo: Really bad error, update message\n }\n\n let engine = resolver.owningEngine(owner);\n let isApp = owner?.root === resolver.options.engines[0]!.root;\n let hasFastboot = Boolean(resolver.options.engines[0]!.activeAddons.find(a => a.name === 'ember-cli-fastboot'));\n\n let appFiles = new AppFiles(\n {\n package: owner,\n addons: new Map(\n engine.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp,\n modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,\n appRelativePath: 'NOT_USED_DELETE_ME',\n },\n getAppFiles(fromDir),\n hasFastboot ? getFastbootFiles(owner.root) : new Set(),\n extensionsPattern(resolver.options.resolvableExtensions),\n staticAppPathsPattern(resolver.options.staticAppPaths),\n resolver.options.podModulePrefix\n );\n\n let src = '';\n\n for (let [routeName, routeFiles] of appFiles.routeFiles.children) {\n splitRoute(\n routeName,\n routeFiles,\n resolver.options.splitAtRoutes,\n (_: string, _filename: string) => {\n // noop\n },\n (routeNames: string[], routeFiles: string[]) => {\n if (routeNames[0] === route) {\n let [fastboot, nonFastboot] = partition(routeFiles, file => appFiles.isFastbootOnly.get(file));\n\n const amdModules = nonFastboot.map(f => importPaths(resolver, appFiles, f));\n const fastbootOnlyAmdModules = fastboot.map(f => importPaths(resolver, appFiles, f));\n\n src = routeEntryTemplate({\n amdModules,\n fastbootOnlyAmdModules,\n });\n }\n }\n );\n }\n\n return { src, watches: [] };\n}\n\nconst routeEntryTemplate = compile(`\nlet d = window.define;\n\n{{#each amdModules as |amdModule index| ~}}\n import * as amdModule{{index}} from \"{{js-string-escape amdModule.buildtime}}\"\n d(\"{{js-string-escape amdModule.runtime}}\", function(){ return amdModule{{index}}; });\n{{/each}}\n\n{{#if fastbootOnlyAmdModules}}\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {\n let fastbootModules = {};\n\n {{#each fastbootOnlyAmdModules as |amdModule| ~}}\n fastbootModules[\"{{js-string-escape amdModule.runtime}}\"] = import(\"{{js-string-escape amdModule.buildtime}}\");\n {{/each}}\n\n const resolvedValues = await Promise.all(Object.values(fastbootModules));\n\n Object.keys(fastbootModules).forEach((k, i) => {\n d(k, function(){ return resolvedValues[i];});\n })\n }\n{{/if}}\n`) as (params: {\n amdModules: { runtime: string; buildtime: string }[];\n fastbootOnlyAmdModules: { runtime: string; buildtime: string }[];\n}) => string;\n"]}
1
+ {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,EAAE,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;CAgBlC,CAGW,CAAC","sourcesContent":["import type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { AppFiles } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport { resolve } from 'path';\nimport { compile } from './js-handlebars';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport { partition } from 'lodash';\nimport { getAppFiles, getFastbootFiles, importPaths, splitRoute, staticAppPathsPattern } from './virtual-entrypoint';\n\nconst entrypointPattern = /(?<filename>.*)[\\\\/]-embroider-route-entrypoint.js:route=(?<route>.*)/;\n\nexport function encodeRouteEntrypoint(packagePath: string, matched: string | undefined, routeName: string): string {\n return resolve(\n packagePath,\n matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`\n );\n}\n\nexport function decodeRouteEntrypoint(filename: string): { fromDir: string; route: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-route-entrypoint')) {\n return;\n }\n let m = entrypointPattern.exec(filename);\n if (m) {\n return {\n fromDir: m.groups!.filename,\n route: m.groups!.route,\n };\n }\n}\n\nexport function encodePublicRouteEntrypoint(routeNames: string[], _files: string[]) {\n return `@embroider/core/route/${encodeURIComponent(routeNames[0])}`;\n}\n\nexport function decodePublicRouteEntrypoint(specifier: string): string | null {\n const publicPrefix = '@embroider/core/route/';\n if (!specifier.startsWith(publicPrefix)) {\n return null;\n }\n\n return specifier.slice(publicPrefix.length);\n}\n\nexport function renderRouteEntrypoint(\n resolver: Resolver,\n { fromDir, route }: { fromDir: string; route: string }\n): { src: string; watches: string[] } {\n const owner = resolver.packageCache.ownerOfFile(fromDir);\n\n if (!owner) {\n throw new Error('Owner expected'); // ToDo: Really bad error, update message\n }\n\n let engine = resolver.owningEngine(owner);\n let isApp = owner?.root === resolver.options.engines[0]!.root;\n let hasFastboot = Boolean(resolver.options.engines[0]!.activeAddons.find(a => a.name === 'ember-cli-fastboot'));\n\n let appFiles = new AppFiles(\n {\n package: owner,\n addons: new Map(\n engine.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp,\n modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,\n appRelativePath: 'NOT_USED_DELETE_ME',\n },\n getAppFiles(fromDir),\n hasFastboot ? getFastbootFiles(owner.root) : new Set(),\n extensionsPattern(resolver.options.resolvableExtensions),\n staticAppPathsPattern(resolver.options.staticAppPaths),\n resolver.options.podModulePrefix\n );\n\n let src = '';\n\n for (let [routeName, routeFiles] of appFiles.routeFiles.children) {\n splitRoute(\n routeName,\n routeFiles,\n resolver.options.splitAtRoutes,\n (_: string, _filename: string) => {\n // noop\n },\n (routeNames: string[], routeFiles: string[]) => {\n if (routeNames[0] === route) {\n let [fastboot, nonFastboot] = partition(routeFiles, file => appFiles.isFastbootOnly.get(file));\n\n const amdModules = nonFastboot.map(f => importPaths(resolver, appFiles, f));\n const fastbootOnlyAmdModules = fastboot.map(f => importPaths(resolver, appFiles, f));\n\n src = routeEntryTemplate({\n amdModules,\n fastbootOnlyAmdModules,\n });\n }\n }\n );\n }\n\n return { src, watches: [] };\n}\n\nconst routeEntryTemplate = compile(`\nconst output = {};\nexport default output;\n\n{{#each amdModules as |amdModule index| ~}}\n import * as amdModule{{index}} from \"{{js-string-escape amdModule.buildtime}}\"\n output[\"{{js-string-escape amdModule.runtime}}\"] = amdModule{{index}};\n{{/each}}\n\n{{#if fastbootOnlyAmdModules}}\n if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {\n {{#each fastbootOnlyAmdModules as |amdModule| ~}}\n output[\"{{js-string-escape amdModule.runtime}}\"] = await import(\"{{js-string-escape amdModule.buildtime}}\");\n {{/each}}\n }\n{{/if}}\n`) as (params: {\n amdModules: { runtime: string; buildtime: string }[];\n fastbootOnlyAmdModules: { runtime: string; buildtime: string }[];\n}) => string;\n"]}
@@ -7,7 +7,6 @@ exports.decodeVirtualVendor = decodeVirtualVendor;
7
7
  exports.renderVendor = renderVendor;
8
8
  const shared_internals_1 = require("@embroider/shared-internals");
9
9
  const fs_extra_1 = require("fs-extra");
10
- const lodash_1 = require("lodash");
11
10
  const path_1 = require("path");
12
11
  const resolve_1 = __importDefault(require("resolve"));
13
12
  function decodeVirtualVendor(filename) {
@@ -22,10 +21,7 @@ function renderVendor(filename, resolver) {
22
21
  }
23
22
  function getVendor(owner, resolver, filename) {
24
23
  let engineConfig = resolver.owningEngine(owner);
25
- let addons = new Map(engineConfig.activeAddons.map(addon => [
26
- resolver.packageCache.get(addon.root),
27
- addon.canResolveFromFile,
28
- ]));
24
+ let addons = engineConfig.activeAddons.map(addon => resolver.packageCache.get(addon.root));
29
25
  let path = (0, path_1.join)((0, shared_internals_1.locateEmbroiderWorkingDir)(resolver.options.appRoot), 'ember-env.json');
30
26
  if (!(0, fs_extra_1.lstatSync)(path).isFile()) {
31
27
  throw new Error(`Failed to read the ember-env.json when generating content for ${filename}`);
@@ -43,22 +39,11 @@ function generateVendor(addons, emberENV) {
43
39
  vendor.unshift(`var runningTests=false;`);
44
40
  // Add _ember_env_.js
45
41
  vendor.unshift(`window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`);
46
- // Add _loader_.js
47
- vendor.push(`loader.makeDefaultExport=false;`);
48
42
  return vendor.join('');
49
43
  }
50
44
  function impliedAddonVendors(addons) {
51
45
  let result = [];
52
- for (let addon of (0, lodash_1.sortBy)(Array.from(addons.keys()), pkg => {
53
- switch (pkg.name) {
54
- case 'loader.js':
55
- return 0;
56
- case 'ember-source':
57
- return 10;
58
- default:
59
- return 1000;
60
- }
61
- })) {
46
+ for (let addon of addons) {
62
47
  let implicitScripts = addon.meta['implicit-scripts'];
63
48
  if (implicitScripts) {
64
49
  let options = { basedir: addon.root };
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-vendor.js","sourceRo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AE,CAAC;YACpB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { type Package, locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { lstatSync, readFileSync, readJSONSync } from 'fs-extra';\nimport { sortBy } from 'lodash';\nimport { join } from 'path';\nimport resolve from 'resolve';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport function decodeVirtualVendor(filename: string): boolean {\n return filename.endsWith('-embroider-vendor.js');\n}\n\nexport function renderVendor(filename: string, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(filename);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${filename}`);\n }\n return { src: getVendor(owner, resolver, filename), watches: [] };\n}\n\nfunction getVendor(owner: Package, resolver: Resolver, filename: string): string {\n let engineConfig = resolver.owningEngine(owner);\n let addons = new Map(\n engineConfig.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n );\n\n let path = join(locateEmbroiderWorkingDir(resolver.options.appRoot), 'ember-env.json');\n if (!lstatSync(path).isFile()) {\n throw new Error(`Failed to read the ember-env.json when generating content for ${filename}`);\n }\n let emberENV = readJSONSync(path);\n\n return generateVendor(addons, emberENV);\n}\n\nfunction generateVendor(addons: Map<V2AddonPackage, string>, emberENV?: unknown): string {\n // Add addons implicit-scripts\n let vendor: string[] = impliedAddonVendors(addons).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n // Add _testing_prefix_.js\n vendor.unshift(`var runningTests=false;`);\n // Add _ember_env_.js\n vendor.unshift(`window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`);\n // Add _loader_.js\n vendor.push(`loader.makeDefaultExport=false;`);\n\n return vendor.join('') as string;\n}\n\nfunction impliedAddonVendors(addons: Map<V2AddonPackage, string>): string[] {\n let result: Array<string> = [];\n for (let addon of sortBy(Array.from(addons.keys()), pkg => {\n switch (pkg.name) {\n case 'loader.js':\n return 0;\n case 'ember-source':\n return 10;\n default:\n return 1000;\n }\n })) {\n let implicitScripts = addon.meta['implicit-scripts'];\n if (implicitScripts) {\n let options = { basedir: addon.root };\n for (let mod of implicitScripts) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
1
+ {"version":3,"file":"virtual-vendor.js","sourceRoot":"","sources":["virtual-vendor.ts"],"names":[],"mappings":";;;;;AAQA,kDAEC;AAED,oCAMC;AAlBD,kEAAsF;AAEtF,uCAAiE;AACjE,+BAA4B;AAC5B,sDAA8B;AAI9B,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,YAAY,CAAC,QAAgB,EAAE,QAAkB;IAC/D,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACpE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,QAAkB,EAAE,QAAgB;IACrE,IAAI,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,KA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AAM,EAAE,CAAC;QACzB,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACrD,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { type Package, locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { lstatSync, readFileSync, readJSONSync } from 'fs-extra';\nimport { join } from 'path';\nimport resolve from 'resolve';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport function decodeVirtualVendor(filename: string): boolean {\n return filename.endsWith('-embroider-vendor.js');\n}\n\nexport function renderVendor(filename: string, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(filename);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${filename}`);\n }\n return { src: getVendor(owner, resolver, filename), watches: [] };\n}\n\nfunction getVendor(owner: Package, resolver: Resolver, filename: string): string {\n let engineConfig = resolver.owningEngine(owner);\n let addons = engineConfig.activeAddons.map(addon => resolver.packageCache.get(addon.root) as V2AddonPackage);\n\n let path = join(locateEmbroiderWorkingDir(resolver.options.appRoot), 'ember-env.json');\n if (!lstatSync(path).isFile()) {\n throw new Error(`Failed to read the ember-env.json when generating content for ${filename}`);\n }\n let emberENV = readJSONSync(path);\n\n return generateVendor(addons, emberENV);\n}\n\nfunction generateVendor(addons: V2AddonPackage[], emberENV?: unknown): string {\n // Add addons implicit-scripts\n let vendor: string[] = impliedAddonVendors(addons).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n // Add _testing_prefix_.js\n vendor.unshift(`var runningTests=false;`);\n // Add _ember_env_.js\n vendor.unshift(`window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`);\n\n return vendor.join('') as string;\n}\n\nfunction impliedAddonVendors(addons: V2AddonPackage[]): string[] {\n let result: Array<string> = [];\n for (let addon of addons) {\n let implicitScripts = addon.meta['implicit-scripts'];\n if (implicitScripts) {\n let options = { basedir: addon.root };\n for (let mod of implicitScripts) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}