@embroider/core 3.4.20-unstable.e6197c7 → 3.4.20-unstable.e73d3a7

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.
Files changed (37) hide show
  1. package/package.json +4 -4
  2. package/src/index.d.ts +1 -1
  3. package/src/index.js +1 -2
  4. package/src/index.js.map +1 -1
  5. package/src/module-request.d.ts +1 -0
  6. package/src/module-request.js +9 -0
  7. package/src/module-request.js.map +1 -1
  8. package/src/module-resolver.d.ts +9 -3
  9. package/src/module-resolver.js +134 -78
  10. package/src/module-resolver.js.map +1 -1
  11. package/src/node-resolve.d.ts +6 -1
  12. package/src/node-resolve.js +27 -9
  13. package/src/node-resolve.js.map +1 -1
  14. package/src/packager.d.ts +0 -8
  15. package/src/packager.js +0 -9
  16. package/src/packager.js.map +1 -1
  17. package/src/virtual-content.d.ts +26 -31
  18. package/src/virtual-content.js +42 -105
  19. package/src/virtual-content.js.map +1 -1
  20. package/src/virtual-entrypoint.d.ts +4 -6
  21. package/src/virtual-entrypoint.js +2 -56
  22. package/src/virtual-entrypoint.js.map +1 -1
  23. package/src/virtual-route-entrypoint.d.ts +4 -10
  24. package/src/virtual-route-entrypoint.js +1 -39
  25. package/src/virtual-route-entrypoint.js.map +1 -1
  26. package/src/virtual-test-support-styles.d.ts +5 -2
  27. package/src/virtual-test-support-styles.js +2 -5
  28. package/src/virtual-test-support-styles.js.map +1 -1
  29. package/src/virtual-test-support.d.ts +5 -2
  30. package/src/virtual-test-support.js +2 -5
  31. package/src/virtual-test-support.js.map +1 -1
  32. package/src/virtual-vendor-styles.d.ts +5 -1
  33. package/src/virtual-vendor-styles.js +2 -1
  34. package/src/virtual-vendor-styles.js.map +1 -1
  35. package/src/virtual-vendor.d.ts +5 -2
  36. package/src/virtual-vendor.js +4 -8
  37. package/src/virtual-vendor.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"m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AC;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;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { virtualContent, type VirtualResponse } 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 virtual: VirtualResponse\n ): Resolution<NodeResolution, Error> {\n return {\n type: 'found',\n filename: virtual.specifier,\n virtual,\n result: {\n type: 'virtual' as const,\n content: virtualContent(virtual.specifier, this.resolver).src,\n filename: virtual.specifier,\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 }, virtual: 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 default:\n throw assertNever(resolution);\n }\n}\n"]}
1
+ {"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAkIA,kCAqBC;AAvJD,uDAAyE;AACzE,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAEvC,8DAA8D;AAC9D,qDAAkH;AAGlH,MAAa,kBAAkB;IAe7B,YAA4B,QAAkB,EAAU,UAAoB;QAAhD,aAAQ,GAAR,QAAQ,CAAU;QAAU,eAAU,GAAV,UAAU,CAAU;IAAG,CAAC;IAEhF,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,OAAwB;QAExB,OAAO;YACL,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,OAAO,CAAC,SAAS;YAC3B,OAAO;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,SAAkB;gBACxB,OAAO,EAAE,IAAA,gCAAc,EAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG;gBACnD,QAAQ,EAAE,OAAO,CAAC,SAAS;aAC5B;SACF,CAAC;IACJ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IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,mCAAI,iBAAiB;KAClD,CAAC,CAAC;IACH,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;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC","sourcesContent":["import { virtualContent, type VirtualResponse } 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; extensions: string[] },\n Resolution<NodeResolution, Error>\n > = ({ resolver, specifier, fromFile, extensions }) => {\n return {\n initialState: {\n specifier,\n fromFile,\n meta: undefined,\n },\n adapter: new NodeRequestAdapter(resolver, extensions),\n };\n };\n\n private constructor(private resolver: Resolver, private extensions: string[]) {}\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 virtual: VirtualResponse\n ): Resolution<NodeResolution, Error> {\n return {\n type: 'found',\n filename: virtual.specifier,\n virtual,\n result: {\n type: 'virtual' as const,\n content: virtualContent(virtual, this.resolver).src,\n filename: virtual.specifier,\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, this.extensions)) {\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 if (filename.endsWith('.hbs') && !candidate.endsWith('.hbs')) {\n // Evaluating the `handlebars` NPM package installs a Node extension\n // that puts `*.hbs` in the automatic search path. But we can't control\n // its priority, and it's really important to us that `.hbs` cannot\n // shadow other extensions with higher priority. For example, when both\n // `.ts` and `.hbs` exist, resolving is supposed to find the `.ts`.\n //\n // This covers the case where we found an hbs \"by accident\", when we\n // weren't actually expecting it.\n continue;\n }\n return { type: 'found', filename, result: { type: 'real' as 'real', filename }, virtual: false };\n }\n\n return { type: 'not_found', err: initialError };\n }\n}\n\nconst defaultExtensions = ['.hbs.js', '.hbs'];\n\nfunction* candidates(specifier: string, extensions: string[]) {\n yield specifier;\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 interface NodeResolveOpts {\n extensions?: string[];\n}\n\nexport async function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string,\n opts?: NodeResolveOpts\n): Promise<NodeResolution | NodeResolutionError> {\n let request = ModuleRequest.create(NodeRequestAdapter.create, {\n resolver,\n fromFile,\n specifier,\n extensions: opts?.extensions ?? defaultExtensions,\n });\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 default:\n throw assertNever(resolution);\n }\n}\n"]}
package/src/packager.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { AppMeta } from '@embroider/shared-internals';
2
1
  export interface Variant {
3
2
  name: string;
4
3
  runtime: 'all' | 'browser' | 'fastboot';
@@ -12,13 +11,6 @@ export interface Packager {
12
11
  build(): Promise<void>;
13
12
  }
14
13
  export declare function applyVariantToBabelConfig(variant: Variant, babelConfig: any): any;
15
- /**
16
- * Get the app meta-data for a package
17
- */
18
- export declare function getAppMeta(pathToVanillaApp: string): {
19
- name: string;
20
- "ember-addon": AppMeta;
21
- };
22
14
  /**
23
15
  * Get the path to a cache directory in the recommended location
24
16
  *
package/src/packager.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyVariantToBabelConfig = applyVariantToBabelConfig;
4
- exports.getAppMeta = getAppMeta;
5
4
  exports.getPackagerCacheDir = getPackagerCacheDir;
6
5
  const shared_internals_1 = require("@embroider/shared-internals");
7
- const fs_extra_1 = require("fs-extra");
8
6
  const lodash_1 = require("lodash");
9
7
  const path_1 = require("path");
10
8
  function applyVariantToBabelConfig(variant, babelConfig) {
@@ -25,13 +23,6 @@ function applyVariantToBabelConfig(variant, babelConfig) {
25
23
  }
26
24
  return babelConfig;
27
25
  }
28
- /**
29
- * Get the app meta-data for a package
30
- */
31
- function getAppMeta(pathToVanillaApp) {
32
- let pkg = JSON.parse((0, fs_extra_1.readFileSync)((0, path_1.join)(pathToVanillaApp, 'package.json'), 'utf8'));
33
- return pkg;
34
- }
35
26
  /**
36
27
  * Get the path to a cache directory in the recommended location
37
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;AAwEA,8DAkBC;AAKD,gCAGC;AAOD,kDAEC;AA1GD,kEAAqD;AACrD,uCAAwC;AACxC,mCAAmC;AACnC,+BAA4B;AAoE5B,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,WAAgB;IAC1E,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CACzE,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,mBAAmB,GAAG,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;YACjD,mBAAmB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YACnE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,gBAAwB;IACjD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,gBAAgB,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnF,OAAO,GAA0D,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { AppMeta } from '@embroider/shared-internals';\nimport { tmpdir } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the app meta-data for a package\n */\nexport function getAppMeta(pathToVanillaApp: string) {\n let pkg = JSON.parse(readFileSync(join(pathToVanillaApp, 'package.json'), 'utf8'));\n return pkg as unknown as { name: string; 'ember-addon': AppMeta };\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
1
+ {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;AAsEA,8DAkBC;AAOD,kDAEC;AAjGD,kEAAqD;AACrD,mCAAmC;AACnC,+BAA4B;AAoE5B,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,WAAgB;IAC1E,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CACzE,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,mBAAmB,GAAG,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;YACjD,mBAAmB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YACnE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { tmpdir } from '@embroider/shared-internals';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
@@ -1,40 +1,35 @@
1
1
  import type { Resolver } from '.';
2
+ import { type TestSupportResponse } from './virtual-test-support';
3
+ import { type TestSupportStylesResponse } from './virtual-test-support-styles';
4
+ import { type VirtualVendorResponse } from './virtual-vendor';
5
+ import { type VirtualVendorStylesResponse } from './virtual-vendor-styles';
6
+ import { type EntrypointResponse } from './virtual-entrypoint';
7
+ import { type RouteEntrypointResponse } from './virtual-route-entrypoint';
2
8
  export type VirtualResponse = {
3
9
  specifier: string;
4
- } & ({
5
- type: 'fastboot-switch';
6
- } | {
7
- type: 'implicit-modules';
8
- } | {
9
- type: 'implicit-test-modules';
10
- } | {
11
- type: 'entrypoint';
12
- } | {
13
- type: 'route-entrypoint';
14
- } | {
15
- type: 'test-support-js';
16
- } | {
17
- type: 'test-support-css';
18
- } | {
19
- type: 'vendor-js';
20
- } | {
21
- type: 'vendor-css';
22
- } | {
23
- type: 'component-pair';
24
- });
10
+ } & (FastbootSwitchResponse | ImplicitModulesResponse | EntrypointResponse | RouteEntrypointResponse | TestSupportResponse | TestSupportStylesResponse | VirtualVendorResponse | VirtualVendorStylesResponse | VirtualPairResponse | TemplateOnlyComponentResponse);
25
11
  export interface VirtualContentResult {
26
12
  src: string;
27
13
  watches: string[];
28
14
  }
29
- export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
30
- export declare function virtualPairComponent(appRoot: string, hbsModule: string, jsModule: string | undefined): string;
31
- export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
32
- export declare function decodeFastbootSwitch(filename: string): {
33
- names: string[];
34
- hasDefaultExport: boolean;
35
- filename: string;
36
- } | undefined;
37
- export declare function decodeImplicitModules(filename: string): {
15
+ export declare function virtualContent(response: VirtualResponse, resolver: Resolver): VirtualContentResult;
16
+ export interface VirtualPairResponse {
17
+ type: 'component-pair';
18
+ specifier: string;
19
+ hbsModule: string;
20
+ jsModule: string | null;
21
+ debugName: string;
22
+ }
23
+ interface FastbootSwitchResponse {
24
+ type: 'fastboot-switch';
25
+ names: Set<string>;
26
+ }
27
+ export interface ImplicitModulesResponse {
38
28
  type: 'implicit-modules' | 'implicit-test-modules';
39
29
  fromFile: string;
40
- } | undefined;
30
+ }
31
+ export interface TemplateOnlyComponentResponse {
32
+ type: 'template-only-component-js';
33
+ specifier: string;
34
+ }
35
+ export {};
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.virtualContent = virtualContent;
4
- exports.virtualPairComponent = virtualPairComponent;
5
- exports.fastbootSwitch = fastbootSwitch;
6
- exports.decodeFastbootSwitch = decodeFastbootSwitch;
7
- exports.decodeImplicitModules = decodeImplicitModules;
8
7
  const path_1 = require("path");
9
8
  const _1 = require(".");
10
9
  const js_handlebars_1 = require("./js-handlebars");
@@ -14,48 +13,37 @@ const virtual_vendor_1 = require("./virtual-vendor");
14
13
  const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
15
14
  const virtual_entrypoint_1 = require("./virtual-entrypoint");
16
15
  const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
16
+ const assert_never_1 = __importDefault(require("assert-never"));
17
17
  // Given a filename that was passed to your ModuleRequest's `virtualize()`,
18
18
  // this produces the corresponding contents. It's a static, stateless function
19
19
  // because we recognize that that process that did resolution might not be the
20
20
  // same one that loads the content.
21
- function virtualContent(filename, resolver) {
22
- let entrypoint = (0, virtual_entrypoint_1.decodeEntrypoint)(filename);
23
- if (entrypoint) {
24
- return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, entrypoint);
21
+ function virtualContent(response, resolver) {
22
+ switch (response.type) {
23
+ case 'entrypoint':
24
+ return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, response);
25
+ case 'vendor-js':
26
+ return (0, virtual_vendor_1.renderVendor)(response, resolver);
27
+ case 'vendor-css':
28
+ return (0, virtual_vendor_styles_1.renderVendorStyles)(response, resolver);
29
+ case 'test-support-css':
30
+ return (0, virtual_test_support_styles_1.renderTestSupportStyles)(response, resolver);
31
+ case 'test-support-js':
32
+ return (0, virtual_test_support_1.renderImplicitTestScripts)(response, resolver);
33
+ case 'component-pair':
34
+ return pairedComponentShim(response);
35
+ case 'implicit-modules':
36
+ case 'implicit-test-modules':
37
+ return renderImplicitModules(response, resolver);
38
+ case 'route-entrypoint':
39
+ return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(response, resolver);
40
+ case 'fastboot-switch':
41
+ return renderFastbootSwitchTemplate(response);
42
+ case 'template-only-component-js':
43
+ return renderTemplateOnlyComponent(response);
44
+ default:
45
+ throw (0, assert_never_1.default)(response);
25
46
  }
26
- let routeEntrypoint = (0, virtual_route_entrypoint_1.decodeRouteEntrypoint)(filename);
27
- if (routeEntrypoint) {
28
- return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(resolver, routeEntrypoint);
29
- }
30
- let match = decodeVirtualPairComponent(filename);
31
- if (match) {
32
- return pairedComponentShim(match);
33
- }
34
- let fb = decodeFastbootSwitch(filename);
35
- if (fb) {
36
- return renderFastbootSwitchTemplate(fb);
37
- }
38
- let im = decodeImplicitModules(filename);
39
- if (im) {
40
- return renderImplicitModules(im, resolver);
41
- }
42
- let isVendor = (0, virtual_vendor_1.decodeVirtualVendor)(filename);
43
- if (isVendor) {
44
- return (0, virtual_vendor_1.renderVendor)(filename, resolver);
45
- }
46
- let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
47
- if (isImplicitTestScripts) {
48
- return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
49
- }
50
- let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
51
- if (isVendorStyles) {
52
- return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
53
- }
54
- let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
55
- if (isTestSupportStyles) {
56
- return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
57
- }
58
- throw new Error(`not an @embroider/core virtual file: ${filename}`);
59
47
  }
60
48
  function pairedComponentShim(params) {
61
49
  return {
@@ -90,57 +78,12 @@ import templateOnlyComponent from "@ember/component/template-only";
90
78
  export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
91
79
  {{/if}}
92
80
  `);
93
- const pairComponentMarker = '/embroider-pair-component/';
94
- const pairComponentPattern = /\/embroider-pair-component\/(?<hbsModule>[^\/]*)\/__vpc__\/(?<jsModule>[^\/]*)$/;
95
- function virtualPairComponent(appRoot, hbsModule, jsModule) {
96
- return `${appRoot}/embroider-pair-component/${encodeURIComponent(hbsModule)}/__vpc__/${encodeURIComponent(jsModule !== null && jsModule !== void 0 ? jsModule : '')}`;
97
- }
98
- function decodeVirtualPairComponent(filename) {
99
- // Performance: avoid paying regex exec cost unless needed
100
- if (!filename.includes(pairComponentMarker)) {
101
- return null;
102
- }
103
- let match = pairComponentPattern.exec(filename);
104
- if (!match) {
105
- return null;
106
- }
107
- let { hbsModule, jsModule } = match.groups;
108
- return {
109
- hbsModule: decodeURIComponent(hbsModule),
110
- jsModule: jsModule ? decodeURIComponent(jsModule) : null,
111
- debugName: (0, path_1.basename)(decodeURIComponent(hbsModule)).replace(/\.(js|hbs)$/, ''),
112
- };
113
- }
114
- const fastbootSwitchSuffix = '/embroider_fastboot_switch';
115
- const fastbootSwitchPattern = /(?<original>.+)\/embroider_fastboot_switch(?:\?names=(?<names>.+))?$/;
116
- function fastbootSwitch(specifier, fromFile, names) {
117
- let filename = `${(0, path_1.resolve)((0, path_1.dirname)(fromFile), specifier)}${fastbootSwitchSuffix}`;
118
- if (names.size > 0) {
119
- return `${filename}?names=${[...names].join(',')}`;
120
- }
121
- else {
122
- return filename;
123
- }
124
- }
125
- function decodeFastbootSwitch(filename) {
126
- var _a, _b, _c;
127
- // Performance: avoid paying regex exec cost unless needed
128
- if (!filename.includes(fastbootSwitchSuffix)) {
129
- return;
130
- }
131
- let match = fastbootSwitchPattern.exec(filename);
132
- if (match) {
133
- let names = (_c = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.names) === null || _b === void 0 ? void 0 : _b.split(',')) !== null && _c !== void 0 ? _c : [];
134
- return {
135
- names: names.filter(name => name !== 'default'),
136
- hasDefaultExport: names.includes('default'),
137
- filename: match.groups.original,
138
- };
139
- }
140
- }
141
81
  function renderFastbootSwitchTemplate(params) {
142
82
  return {
143
- src: fastbootSwitchTemplate(params),
83
+ src: fastbootSwitchTemplate({
84
+ names: [...params.names].filter(name => name !== 'default'),
85
+ hasDefaultExport: params.names.has('default'),
86
+ }),
144
87
  watches: [],
145
88
  };
146
89
  }
@@ -159,21 +102,7 @@ export default mod.default;
159
102
  export const {{name}} = mod.{{name}};
160
103
  {{/each}}
161
104
  `);
162
- const implicitModulesPattern = /(?<filename>.*)[\\/]-embroider-implicit-(?<test>test-)?modules\.js$/;
163
- function decodeImplicitModules(filename) {
164
- // Performance: avoid paying regex exec cost unless needed
165
- if (!filename.includes('-embroider-implicit-')) {
166
- return;
167
- }
168
- let m = implicitModulesPattern.exec(filename);
169
- if (m) {
170
- return {
171
- type: m.groups.test ? 'implicit-test-modules' : 'implicit-modules',
172
- fromFile: m.groups.filename,
173
- };
174
- }
175
- }
176
- function renderImplicitModules({ type, fromFile, }, resolver) {
105
+ function renderImplicitModules({ type, fromFile }, resolver) {
177
106
  let resolvableExtensionsPattern = (0, _1.extensionsPattern)(resolver.options.resolvableExtensions);
178
107
  const pkg = resolver.packageCache.ownerOfFile(fromFile);
179
108
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
@@ -273,4 +202,12 @@ function orderAddons(depA, depB) {
273
202
  }
274
203
  return depAIdx - depBIdx;
275
204
  }
205
+ function renderTemplateOnlyComponent({ specifier }) {
206
+ let watches = [specifier];
207
+ let hbs = (0, _1.syntheticJStoHBS)(specifier);
208
+ if (hbs) {
209
+ watches.push(hbs);
210
+ }
211
+ return { src: (0, _1.templateOnlyComponentSource)(), watches };
212
+ }
276
213
  //# sourceMappingURL=virtual-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;AA0CA,wCA+CC;AA8CD,oDAIC;AAuBD,wCAOC;AAED,oDAcC;AAgCD,sDAcC;AAvOD,+BAAoE;AAEpE,wBAAsC;AACtC,mDAA0C;AAC1C,iEAA8F;AAC9F,+EAAiG;AACjG,qDAAqE;AACrE,mEAAwF;AAExF,6DAA0E;AAC1E,yEAA0F;AA4B1F,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,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,KAAK,G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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 { 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 type VirtualResponse = { specifier: string } & (\n | {\n type: 'fastboot-switch';\n }\n | {\n type: 'implicit-modules';\n }\n | {\n type: 'implicit-test-modules';\n }\n | {\n type: 'entrypoint';\n }\n | { type: 'route-entrypoint' }\n | { type: 'test-support-js' }\n | { type: 'test-support-css' }\n | { type: 'vendor-js' }\n | { type: 'vendor-css' }\n | { type: 'component-pair' }\n);\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 hbsModule: string;\n jsModule: 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 hbsModule}}}\";\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 jsModule}}\nimport component from \"{{{js-string-escape jsModule}}}\";\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 = /\\/embroider-pair-component\\/(?<hbsModule>[^\\/]*)\\/__vpc__\\/(?<jsModule>[^\\/]*)$/;\n\nexport function virtualPairComponent(appRoot: string, hbsModule: string, jsModule: string | undefined): string {\n return `${appRoot}/embroider-pair-component/${encodeURIComponent(hbsModule)}/__vpc__/${encodeURIComponent(\n jsModule ?? ''\n )}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { hbsModule: string; jsModule: 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 return {\n hbsModule: decodeURIComponent(hbsModule),\n jsModule: jsModule ? decodeURIComponent(jsModule) : null,\n debugName: basename(decodeURIComponent(hbsModule)).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"]}
1
+ {"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;;;;AAmCA,wCA0BC;AA7DD,+BAAwC;AAExC,wBAAqF;AACrF,mDAA0C;AAC1C,iEAA6F;AAC7F,+EAAwG;AACxG,qDAA4E;AAC5E,mEAA+F;AAE/F,6DAAiF;AACjF,yEAAiG;AACjG,gEAAuC;AAoBvC,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAyB,EAAE,QAAkB;IAC1E,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,YAAY;YACf,OAAO,IAAA,qCAAgB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9C,KAAK,WAAW;YACd,OAAO,IAAA,6BAAY,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1C,KAAK,YAAY;YACf,OAAO,IAAA,0CAAkB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,KAAK,kBAAkB;YACrB,OAAO,IAAA,qDAAuB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrD,KAAK,iBAAiB;YACpB,OAAO,IAAA,gDAAyB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvD,KAAK,gBAAgB;YACnB,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACvC,KAAK,kBAAkB,CAAC;QACxB,KAAK,uBAAuB;YAC1B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,K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AK,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,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;AAOD,SAAS,2BAA2B,CAAC,EAAE,SAAS,EAAiC;IAC/E,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAA,mBAAgB,EAAC,SAAS,CAAC,CAAC;IACtC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAA,8BAA2B,GAAE,EAAE,OAAO,EAAE,CAAC;AACzD,CAAC","sourcesContent":["import { posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { extensionsPattern, syntheticJStoHBS, templateOnlyComponentSource } from '.';\nimport { compile } from './js-handlebars';\nimport { renderImplicitTestScripts, type TestSupportResponse } from './virtual-test-support';\nimport { renderTestSupportStyles, type TestSupportStylesResponse } from './virtual-test-support-styles';\nimport { renderVendor, type VirtualVendorResponse } from './virtual-vendor';\nimport { renderVendorStyles, type VirtualVendorStylesResponse } from './virtual-vendor-styles';\n\nimport { type EntrypointResponse, renderEntrypoint } from './virtual-entrypoint';\nimport { renderRouteEntrypoint, type RouteEntrypointResponse } from './virtual-route-entrypoint';\nimport assertNever from 'assert-never';\n\nexport type VirtualResponse = { specifier: string } & (\n | FastbootSwitchResponse\n | ImplicitModulesResponse\n | EntrypointResponse\n | RouteEntrypointResponse\n | TestSupportResponse\n | TestSupportStylesResponse\n | VirtualVendorResponse\n | VirtualVendorStylesResponse\n | VirtualPairResponse\n | TemplateOnlyComponentResponse\n);\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(response: VirtualResponse, resolver: Resolver): VirtualContentResult {\n switch (response.type) {\n case 'entrypoint':\n return renderEntrypoint(resolver, response);\n case 'vendor-js':\n return renderVendor(response, resolver);\n case 'vendor-css':\n return renderVendorStyles(response, resolver);\n case 'test-support-css':\n return renderTestSupportStyles(response, resolver);\n case 'test-support-js':\n return renderImplicitTestScripts(response, resolver);\n case 'component-pair':\n return pairedComponentShim(response);\n case 'implicit-modules':\n case 'implicit-test-modules':\n return renderImplicitModules(response, resolver);\n case 'route-entrypoint':\n return renderRouteEntrypoint(response, resolver);\n case 'fastboot-switch':\n return renderFastbootSwitchTemplate(response);\n case 'template-only-component-js':\n return renderTemplateOnlyComponent(response);\n default:\n throw assertNever(response);\n }\n}\n\ninterface PairedComponentShimParams {\n hbsModule: string;\n jsModule: 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 hbsModule}}}\";\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 jsModule}}\nimport component from \"{{{js-string-escape jsModule}}}\";\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 interface VirtualPairResponse {\n type: 'component-pair';\n specifier: string;\n hbsModule: string;\n jsModule: string | null;\n debugName: string;\n}\n\ninterface FastbootSwitchResponse {\n type: 'fastboot-switch';\n names: Set<string>;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchResponse): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate({\n names: [...params.names].filter(name => name !== 'default'),\n hasDefaultExport: params.names.has('default'),\n }),\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: { names: string[]; hasDefaultExport: boolean }) => string;\n\nexport interface ImplicitModulesResponse {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n}\n\nfunction renderImplicitModules({ type, fromFile }: ImplicitModulesResponse, resolver: Resolver): 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\nexport interface TemplateOnlyComponentResponse {\n type: 'template-only-component-js';\n specifier: string;\n}\n\nfunction renderTemplateOnlyComponent({ specifier }: TemplateOnlyComponentResponse): VirtualContentResult {\n let watches = [specifier];\n let hbs = syntheticJStoHBS(specifier);\n if (hbs) {\n watches.push(hbs);\n }\n return { src: templateOnlyComponentSource(), watches };\n}\n"]}
@@ -1,12 +1,10 @@
1
1
  import { AppFiles, type RouteFiles } from './app-files';
2
2
  import type { Resolver } from './module-resolver';
3
- import { type PackageCachePublicAPI } from '@embroider/shared-internals';
4
- import { type ModuleRequest } from './module-request';
5
- import { type VirtualResponse } from './virtual-content';
6
- export declare function virtualEntrypoint(request: ModuleRequest, packageCache: PackageCachePublicAPI): VirtualResponse | undefined;
7
- export declare function decodeEntrypoint(filename: string): {
3
+ export interface EntrypointResponse {
4
+ type: 'entrypoint';
8
5
  fromDir: string;
9
- } | undefined;
6
+ specifier: string;
7
+ }
10
8
  export declare function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined;
11
9
  export declare function renderEntrypoint(resolver: Resolver, { fromDir }: {
12
10
  fromDir: string;
@@ -3,8 +3,6 @@ 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.virtualEntrypoint = virtualEntrypoint;
7
- exports.decodeEntrypoint = decodeEntrypoint;
8
6
  exports.staticAppPathsPattern = staticAppPathsPattern;
9
7
  exports.renderEntrypoint = renderEntrypoint;
10
8
  exports.importPaths = importPaths;
@@ -17,59 +15,8 @@ const lodash_1 = require("lodash");
17
15
  const path_1 = require("path");
18
16
  const shared_internals_1 = require("@embroider/shared-internals");
19
17
  const walk_sync_1 = __importDefault(require("walk-sync"));
20
- const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
21
18
  const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
22
19
  const options_1 = require("./options");
23
- const resolve_exports_1 = require("resolve.exports");
24
- const entrypointPattern = /(?<filename>.*)[\\/]-embroider-entrypoint.js/;
25
- function virtualEntrypoint(request, packageCache) {
26
- var _a;
27
- //TODO move the extra forwardslash handling out into the vite plugin
28
- const candidates = [
29
- '@embroider/virtual/compat-modules',
30
- '/@embroider/virtual/compat-modules',
31
- './@embroider/virtual/compat-modules',
32
- ];
33
- if (!candidates.some(c => request.specifier.startsWith(c + '/') || request.specifier === c)) {
34
- return undefined;
35
- }
36
- const result = /\.?\/?@embroider\/virtual\/compat-modules(?:\/(?<packageName>.*))?/.exec(request.specifier);
37
- if (!result) {
38
- throw new Error('bug: entrypoint does not match pattern' + request.specifier);
39
- }
40
- const { packageName } = result.groups;
41
- const requestingPkg = packageCache.ownerOfFile(request.fromFile);
42
- if (!(requestingPkg === null || requestingPkg === void 0 ? void 0 : requestingPkg.isV2Ember())) {
43
- throw new Error(`bug: found entrypoint import in non-ember package at ${request.fromFile}`);
44
- }
45
- let pkg;
46
- if (packageName) {
47
- pkg = packageCache.resolve(packageName, requestingPkg);
48
- }
49
- else {
50
- pkg = requestingPkg;
51
- }
52
- let matched = (0, resolve_exports_1.exports)(pkg.packageJSON, '-embroider-entrypoint.js', {
53
- browser: true,
54
- conditions: ['default', 'imports'],
55
- });
56
- return {
57
- type: 'entrypoint',
58
- 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'),
59
- };
60
- }
61
- function decodeEntrypoint(filename) {
62
- // Performance: avoid paying regex exec cost unless needed
63
- if (!filename.includes('-embroider-entrypoint')) {
64
- return;
65
- }
66
- let m = entrypointPattern.exec(filename);
67
- if (m) {
68
- return {
69
- fromDir: m.groups.filename,
70
- };
71
- }
72
- }
73
20
  function staticAppPathsPattern(staticAppPaths) {
74
21
  if (staticAppPaths && staticAppPaths.length > 0) {
75
22
  return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => (0, escape_string_regexp_1.default)(staticAppPath)).join('|') + ')(?:$|/)');
@@ -77,7 +24,6 @@ function staticAppPathsPattern(staticAppPaths) {
77
24
  }
78
25
  function renderEntrypoint(resolver, { fromDir }) {
79
26
  var _a;
80
- // this is new
81
27
  const owner = resolver.packageCache.ownerOfFile(fromDir);
82
28
  let eagerModules = [];
83
29
  if (!owner) {
@@ -136,10 +82,10 @@ function renderEntrypoint(resolver, { fromDir }) {
136
82
  for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
137
83
  splitRoute(routeName, routeFiles, resolver.options.splitAtRoutes, (_, filename) => {
138
84
  requiredAppFiles.push([filename]);
139
- }, (routeNames, _files) => {
85
+ }, (routeNames) => {
140
86
  lazyRoutes.push({
141
87
  names: routeNames,
142
- path: (0, virtual_route_entrypoint_1.encodePublicRouteEntrypoint)(routeNames, _files),
88
+ path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,
143
89
  });
144
90
  });
145
91
  }