@embroider/core 3.5.0 → 3.5.1-unstable.b3b53c1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +22 -11
- package/src/app-files.d.ts +3 -5
- package/src/app-files.js +25 -8
- package/src/app-files.js.map +1 -1
- package/src/index.d.ts +5 -5
- package/src/index.js +3 -4
- package/src/index.js.map +1 -1
- package/src/measure-concat.js +1 -2
- package/src/measure-concat.js.map +1 -1
- package/src/messages.js.map +1 -1
- package/src/module-request.d.ts +44 -0
- package/src/module-request.js +100 -0
- package/src/module-request.js.map +1 -0
- package/src/module-resolver-options.d.ts +42 -0
- package/src/module-resolver-options.js +164 -0
- package/src/module-resolver-options.js.map +1 -0
- package/src/module-resolver.d.ts +24 -61
- package/src/module-resolver.js +469 -322
- package/src/module-resolver.js.map +1 -1
- package/src/node-resolve.d.ts +35 -0
- package/src/node-resolve.js +130 -0
- package/src/node-resolve.js.map +1 -0
- package/src/options.d.ts +0 -7
- package/src/options.js +0 -1
- package/src/options.js.map +1 -1
- package/src/packager.d.ts +0 -8
- package/src/packager.js +0 -9
- package/src/packager.js.map +1 -1
- package/src/resolver-loader.js +8 -1
- package/src/resolver-loader.js.map +1 -1
- package/src/virtual-content.d.ts +32 -12
- package/src/virtual-content.js +83 -184
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +21 -0
- package/src/virtual-entrypoint.js +273 -0
- package/src/virtual-entrypoint.js.map +1 -0
- package/src/virtual-route-entrypoint.d.ts +10 -0
- package/src/virtual-route-entrypoint.js +62 -0
- package/src/virtual-route-entrypoint.js.map +1 -0
- package/src/virtual-test-support-styles.d.ts +7 -0
- package/src/virtual-test-support-styles.js +61 -0
- package/src/virtual-test-support-styles.js.map +1 -0
- package/src/virtual-test-support.d.ts +7 -0
- package/src/virtual-test-support.js +65 -0
- package/src/virtual-test-support.js.map +1 -0
- package/src/virtual-vendor-styles.d.ts +8 -0
- package/src/virtual-vendor-styles.js +83 -0
- package/src/virtual-vendor-styles.js.map +1 -0
- package/src/virtual-vendor.d.ts +7 -0
- package/src/virtual-vendor.js +53 -0
- package/src/virtual-vendor.js.map +1 -0
- package/types/virtual/index.d.ts +9 -0
- package/types/virtual/index.js +3 -0
- package/src/asset.d.ts +0 -32
- package/src/asset.js +0 -3
- package/src/asset.js.map +0 -1
- package/src/ember-html.d.ts +0 -43
- package/src/ember-html.js +0 -110
- package/src/ember-html.js.map +0 -1
- package/src/portable-babel-config.d.ts +0 -11
- package/src/portable-babel-config.js +0 -132
- package/src/portable-babel-config.js.map +0 -1
- package/src/portable-babel-launcher.d.ts +0 -6
- package/src/portable-babel-launcher.js +0 -75
- package/src/portable-babel-launcher.js.map +0 -1
- package/src/to-broccoli-plugin.d.ts +0 -8
- package/src/to-broccoli-plugin.js +0 -30
- package/src/to-broccoli-plugin.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;AAYA,wCA0BC;AAwDD,0DAMC;AAED,4DAEC;AAwBD,oDAMC;AAyBD,wCAOC;AAED,oDAcC;AAoBD,sDAcC;AAxND,+BAAoE;AAEpE,wBAAwD;AACxD,mDAA0C;AAE1C,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAC/C,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,mCAAmC;AACnC,SAAgB,cAAc,CAAC,QAAgB,EAAE,QAAkB;IACjE,IAAI,SAAS,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,MAAM,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,oBAAoB,CAAC,MA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AAC,IAA0B,EAAE,UAAkB;IAC3E,IAAI,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,QAAQ,GAAG,EAAgC,CAAC;QAChD,KAAK,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;AAED,MAAM,qBAAqB,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;;;;;;CAqBrC,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';\n\nconst externalESPrefix = '/@embroider/ext-es/';\nconst externalCJSPrefix = '/@embroider/ext-cjs/';\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): string {\n let cjsExtern = decodeVirtualExternalCJSModule(filename);\n if (cjsExtern) {\n return renderCJSExternalShim(cjsExtern);\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 fastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, 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({ moduleName, exports }: { moduleName: string; exports: string[] }): string {\n return externalESShim({\n moduleName,\n default: exports.includes('default'),\n names: exports.filter(n => n !== 'default'),\n });\n}\n\nconst pairedComponentShim = 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: { relativeHBSModule: string; relativeJSModule: string | null; debugName: string }) => 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 url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');\n let nameString = url.searchParams.get('exports');\n if (nameString) {\n exports = nameString.split(',');\n }\n let moduleName = url.pathname.slice(1);\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>.*)\\/(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | null): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(hbsModule, jsModule);\n }\n return `${hbsModule}/${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\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\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): string {\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 lazyModules: { runtime: string; buildtime: string }[] = [];\n let eagerModules: 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 lazyModules.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 eagerModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return implicitModulesTemplate({ lazyModules, eagerModules });\n}\n\nconst implicitModulesTemplate = compile(`\nimport { importSync as i } from '@embroider/macros';\nlet d = window.define;\n{{#each lazyModules as |module|}}\nd(\"{{js-string-escape module.runtime}}\", function(){ return i(\"{{js-string-escape module.buildtime}}\");});\n{{/each}}\n{{#each eagerModules as |module|}}\nimport \"{{js-string-escape module}}\";\n{{/each}}\n`) as (params: { eagerModules: string[]; lazyModules: { 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\nconst renderCJSExternalShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{/if}}\n{{!-\n There are plenty of hand-written AMD defines floating around\n that lack this, and they will break when other build systems\n encounter them.\n\n As far as I can tell, Ember's loader was already treating this\n case as a module, so in theory we aren't breaking anything by\n marking it as such when other packagers come looking.\n\n todo: get review on this part.\n-}}\nif (m.default && !m.__esModule) {\n m.__esModule = true;\n}\nmodule.exports = m;\n`) as (params: { moduleName: string }) => string;\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;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EhB,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"]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { AppFiles, type RouteFiles } from './app-files';
|
2
|
+
import type { Resolver } from './module-resolver';
|
3
|
+
export interface EntrypointResponse {
|
4
|
+
type: 'entrypoint';
|
5
|
+
fromDir: string;
|
6
|
+
specifier: string;
|
7
|
+
}
|
8
|
+
export declare function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined;
|
9
|
+
export declare function renderEntrypoint(resolver: Resolver, { fromDir }: {
|
10
|
+
fromDir: string;
|
11
|
+
}): {
|
12
|
+
src: string;
|
13
|
+
watches: string[];
|
14
|
+
};
|
15
|
+
export declare function importPaths(resolver: Resolver, { engine }: AppFiles, engineRelativePath: string): {
|
16
|
+
runtime: string;
|
17
|
+
buildtime: string;
|
18
|
+
};
|
19
|
+
export declare function splitRoute(routeName: string, files: RouteFiles, splitAtRoutes: (RegExp | string)[] | undefined, addToParent: (routeName: string, filename: string) => void, addLazyBundle: (routeNames: string[], files: string[]) => void): void;
|
20
|
+
export declare function getAppFiles(appRoot: string): Set<string>;
|
21
|
+
export declare function getFastbootFiles(appRoot: string): Set<string>;
|
@@ -0,0 +1,273 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.staticAppPathsPattern = staticAppPathsPattern;
|
7
|
+
exports.renderEntrypoint = renderEntrypoint;
|
8
|
+
exports.importPaths = importPaths;
|
9
|
+
exports.splitRoute = splitRoute;
|
10
|
+
exports.getAppFiles = getAppFiles;
|
11
|
+
exports.getFastbootFiles = getFastbootFiles;
|
12
|
+
const app_files_1 = require("./app-files");
|
13
|
+
const js_handlebars_1 = require("./js-handlebars");
|
14
|
+
const lodash_1 = require("lodash");
|
15
|
+
const path_1 = require("path");
|
16
|
+
const shared_internals_1 = require("@embroider/shared-internals");
|
17
|
+
const walk_sync_1 = __importDefault(require("walk-sync"));
|
18
|
+
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
|
19
|
+
const options_1 = require("./options");
|
20
|
+
function staticAppPathsPattern(staticAppPaths) {
|
21
|
+
if (staticAppPaths && staticAppPaths.length > 0) {
|
22
|
+
return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => (0, escape_string_regexp_1.default)(staticAppPath)).join('|') + ')(?:$|/)');
|
23
|
+
}
|
24
|
+
}
|
25
|
+
function renderEntrypoint(resolver, { fromDir }) {
|
26
|
+
var _a;
|
27
|
+
const owner = resolver.packageCache.ownerOfFile(fromDir);
|
28
|
+
let eagerModules = [];
|
29
|
+
if (!owner) {
|
30
|
+
throw new Error('Owner expected'); // ToDo: Really bad error, update message
|
31
|
+
}
|
32
|
+
let engine = resolver.owningEngine(owner);
|
33
|
+
let isApp = (owner === null || owner === void 0 ? void 0 : owner.root) === resolver.options.engines[0].root;
|
34
|
+
let hasFastboot = Boolean(resolver.options.engines[0].activeAddons.find(a => a.name === 'ember-cli-fastboot'));
|
35
|
+
let appFiles = new app_files_1.AppFiles({
|
36
|
+
package: owner,
|
37
|
+
addons: new Map(engine.activeAddons.map(addon => [
|
38
|
+
resolver.packageCache.get(addon.root),
|
39
|
+
addon.canResolveFromFile,
|
40
|
+
])),
|
41
|
+
isApp,
|
42
|
+
modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,
|
43
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
44
|
+
}, getAppFiles(fromDir), hasFastboot ? getFastbootFiles(owner.root) : new Set(), (0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions), staticAppPathsPattern(resolver.options.staticAppPaths), resolver.options.podModulePrefix);
|
45
|
+
let options = (_a = resolver.options.options) !== null && _a !== void 0 ? _a : (0, options_1.optionsWithDefaults)();
|
46
|
+
let requiredAppFiles = [appFiles.otherAppFiles];
|
47
|
+
if (!options.staticComponents) {
|
48
|
+
requiredAppFiles.push(appFiles.components);
|
49
|
+
}
|
50
|
+
if (!options.staticHelpers) {
|
51
|
+
requiredAppFiles.push(appFiles.helpers);
|
52
|
+
}
|
53
|
+
if (!options.staticModifiers) {
|
54
|
+
requiredAppFiles.push(appFiles.modifiers);
|
55
|
+
}
|
56
|
+
let styles = [];
|
57
|
+
// only import styles from engines with a parent (this excludeds the parent application) as their styles
|
58
|
+
// will be inserted via a direct <link> tag.
|
59
|
+
if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {
|
60
|
+
styles.push({
|
61
|
+
path: '@embroider/virtual/vendor.css',
|
62
|
+
});
|
63
|
+
}
|
64
|
+
let lazyEngines = [];
|
65
|
+
if (isApp) {
|
66
|
+
// deliberately ignoring the app (which is the first entry in the engines array)
|
67
|
+
let [, ...childEngines] = resolver.options.engines;
|
68
|
+
for (let childEngine of childEngines) {
|
69
|
+
let target = `@embroider/virtual/compat-modules/${childEngine.packageName}`;
|
70
|
+
if (childEngine.isLazy) {
|
71
|
+
lazyEngines.push({
|
72
|
+
names: [childEngine.packageName],
|
73
|
+
path: target,
|
74
|
+
});
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
eagerModules.push(target);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
let lazyRoutes = [];
|
82
|
+
for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
|
83
|
+
splitRoute(routeName, routeFiles, resolver.options.splitAtRoutes, (_, filename) => {
|
84
|
+
requiredAppFiles.push([filename]);
|
85
|
+
}, (routeNames) => {
|
86
|
+
lazyRoutes.push({
|
87
|
+
names: routeNames,
|
88
|
+
path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,
|
89
|
+
});
|
90
|
+
});
|
91
|
+
}
|
92
|
+
let [fastboot, nonFastboot] = (0, lodash_1.partition)(excludeDotFiles((0, lodash_1.flatten)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
|
93
|
+
let amdModules = nonFastboot.map(file => importPaths(resolver, appFiles, file));
|
94
|
+
let fastbootOnlyAmdModules = fastboot.map(file => importPaths(resolver, appFiles, file));
|
95
|
+
let params = {
|
96
|
+
amdModules,
|
97
|
+
fastbootOnlyAmdModules,
|
98
|
+
lazyRoutes,
|
99
|
+
lazyEngines,
|
100
|
+
eagerModules,
|
101
|
+
styles,
|
102
|
+
// this is a backward-compatibility feature: addons can force inclusion of modules.
|
103
|
+
defineModulesFrom: './-embroider-implicit-modules.js',
|
104
|
+
};
|
105
|
+
return {
|
106
|
+
src: entryTemplate(params),
|
107
|
+
watches: [fromDir],
|
108
|
+
};
|
109
|
+
}
|
110
|
+
const entryTemplate = (0, js_handlebars_1.compile)(`
|
111
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
112
|
+
|
113
|
+
{{#if styles}}
|
114
|
+
if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {
|
115
|
+
{{#each styles as |stylePath| ~}}
|
116
|
+
await import("{{js-string-escape stylePath.path}}");
|
117
|
+
{{/each}}
|
118
|
+
}
|
119
|
+
{{/if}}
|
120
|
+
|
121
|
+
{{#if defineModulesFrom ~}}
|
122
|
+
import implicitModules from "{{js-string-escape defineModulesFrom}}";
|
123
|
+
{{/if}}
|
124
|
+
|
125
|
+
{{#each eagerModules as |eagerModule| ~}}
|
126
|
+
import "{{js-string-escape eagerModule}}";
|
127
|
+
{{/each}}
|
128
|
+
|
129
|
+
{{#each amdModules as |amdModule index| ~}}
|
130
|
+
import * as amdModule{{index}} from "{{js-string-escape amdModule.buildtime}}"
|
131
|
+
{{/each}}
|
132
|
+
|
133
|
+
let exportFastbootModules = {};
|
134
|
+
|
135
|
+
{{#if fastbootOnlyAmdModules}}
|
136
|
+
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
137
|
+
let fastbootModules = {};
|
138
|
+
|
139
|
+
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
140
|
+
fastbootModules["{{js-string-escape amdModule.runtime}}"] = import("{{js-string-escape amdModule.buildtime}}");
|
141
|
+
{{/each}}
|
142
|
+
|
143
|
+
const resolvedValues = await Promise.all(Object.values(fastbootModules));
|
144
|
+
|
145
|
+
Object.keys(fastbootModules).forEach((k, i) => {
|
146
|
+
exportFasbootModules[k] = resolvedValues[i];
|
147
|
+
})
|
148
|
+
}
|
149
|
+
{{/if}}
|
150
|
+
|
151
|
+
|
152
|
+
{{#if lazyRoutes}}
|
153
|
+
window._embroiderRouteBundles_ = [
|
154
|
+
{{#each lazyRoutes as |route|}}
|
155
|
+
{
|
156
|
+
names: {{json-stringify route.names}},
|
157
|
+
load: function() {
|
158
|
+
return import("{{js-string-escape route.path}}");
|
159
|
+
}
|
160
|
+
},
|
161
|
+
{{/each}}
|
162
|
+
]
|
163
|
+
{{/if}}
|
164
|
+
|
165
|
+
{{#if lazyEngines}}
|
166
|
+
window._embroiderEngineBundles_ = [
|
167
|
+
{{#each lazyEngines as |engine|}}
|
168
|
+
{
|
169
|
+
names: {{json-stringify engine.names}},
|
170
|
+
load: function() {
|
171
|
+
return import("{{js-string-escape engine.path}}");
|
172
|
+
}
|
173
|
+
},
|
174
|
+
{{/each}}
|
175
|
+
]
|
176
|
+
{{/if}}
|
177
|
+
|
178
|
+
export default Object.assign(
|
179
|
+
{},
|
180
|
+
implicitModules,
|
181
|
+
{
|
182
|
+
{{#each amdModules as |amdModule index| ~}}
|
183
|
+
"{{js-string-escape amdModule.runtime}}": amdModule{{index}},
|
184
|
+
{{/each}}
|
185
|
+
},
|
186
|
+
exportFastbootModules
|
187
|
+
);
|
188
|
+
`);
|
189
|
+
function excludeDotFiles(files) {
|
190
|
+
return files.filter(file => !file.startsWith('.') && !file.includes('/.'));
|
191
|
+
}
|
192
|
+
function importPaths(resolver, { engine }, engineRelativePath) {
|
193
|
+
let resolvableExtensionsPattern = (0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions);
|
194
|
+
let noHBS = engineRelativePath.replace(resolvableExtensionsPattern, '').replace(/\.hbs$/, '');
|
195
|
+
return {
|
196
|
+
runtime: `${engine.modulePrefix}/${noHBS}`,
|
197
|
+
buildtime: `./${engineRelativePath}`,
|
198
|
+
};
|
199
|
+
}
|
200
|
+
function splitRoute(routeName, files, splitAtRoutes, addToParent, addLazyBundle) {
|
201
|
+
let shouldSplit = routeName && shouldSplitRoute(routeName, splitAtRoutes);
|
202
|
+
let ownFiles = [];
|
203
|
+
let ownNames = new Set();
|
204
|
+
if (files.template) {
|
205
|
+
if (shouldSplit) {
|
206
|
+
ownFiles.push(files.template);
|
207
|
+
ownNames.add(routeName);
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
addToParent(routeName, files.template);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
if (files.controller) {
|
214
|
+
if (shouldSplit) {
|
215
|
+
ownFiles.push(files.controller);
|
216
|
+
ownNames.add(routeName);
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
addToParent(routeName, files.controller);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
if (files.route) {
|
223
|
+
if (shouldSplit) {
|
224
|
+
ownFiles.push(files.route);
|
225
|
+
ownNames.add(routeName);
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
addToParent(routeName, files.route);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
for (let [childName, childFiles] of files.children) {
|
232
|
+
splitRoute(`${routeName}.${childName}`, childFiles, splitAtRoutes, (childRouteName, childFile) => {
|
233
|
+
// this is our child calling "addToParent"
|
234
|
+
if (shouldSplit) {
|
235
|
+
ownFiles.push(childFile);
|
236
|
+
ownNames.add(childRouteName);
|
237
|
+
}
|
238
|
+
else {
|
239
|
+
addToParent(childRouteName, childFile);
|
240
|
+
}
|
241
|
+
}, (routeNames, files) => {
|
242
|
+
addLazyBundle(routeNames, files);
|
243
|
+
});
|
244
|
+
}
|
245
|
+
if (ownFiles.length > 0) {
|
246
|
+
addLazyBundle([...ownNames], ownFiles);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
function shouldSplitRoute(routeName, splitAtRoutes) {
|
250
|
+
if (!splitAtRoutes) {
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
return splitAtRoutes.find(pattern => {
|
254
|
+
if (typeof pattern === 'string') {
|
255
|
+
return pattern === routeName;
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
return pattern.test(routeName);
|
259
|
+
}
|
260
|
+
});
|
261
|
+
}
|
262
|
+
function getAppFiles(appRoot) {
|
263
|
+
const files = (0, walk_sync_1.default)(appRoot, {
|
264
|
+
ignore: ['_babel_filter_.js', 'app.js', 'assets', 'testem.js', 'node_modules'],
|
265
|
+
});
|
266
|
+
return new Set(files);
|
267
|
+
}
|
268
|
+
function getFastbootFiles(appRoot) {
|
269
|
+
const appDirPath = (0, path_1.join)(appRoot, '_fastboot_');
|
270
|
+
const files = (0, walk_sync_1.default)(appDirPath);
|
271
|
+
return new Set(files);
|
272
|
+
}
|
273
|
+
//# sourceMappingURL=virtual-entrypoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-entrypoint.js","sourceRoot":"","sources":["virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAkBA,sDAIC;AAED,4CAqHC;AA8FD,kCAOC;AAED,gC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YAChC,OAAO,OAAO,KAAK,SAAS,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,OAAO,EAAE;QACxC,MAAM,EAAE,CAAC,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC;KAC/E,CAAC,CAAC;IACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAa,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import { AppFiles, type RouteFiles } from './app-files';\nimport { compile } from './js-handlebars';\nimport type { Resolver } from './module-resolver';\nimport type { CompatResolverOptions } from '../../compat/src/resolver-transform';\nimport { flatten, partition } from 'lodash';\nimport { join } from 'path';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport walkSync from 'walk-sync';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport escapeRegExp from 'escape-string-regexp';\nimport { optionsWithDefaults } from './options';\n\nexport interface EntrypointResponse {\n type: 'entrypoint';\n fromDir: string;\n specifier: string;\n}\n\nexport function staticAppPathsPattern(staticAppPaths: string[] | undefined): RegExp | undefined {\n if (staticAppPaths && staticAppPaths.length > 0) {\n return new RegExp('^(?:' + staticAppPaths.map(staticAppPath => escapeRegExp(staticAppPath)).join('|') + ')(?:$|/)');\n }\n}\n\nexport function renderEntrypoint(\n resolver: Resolver,\n { fromDir }: { fromDir: string }\n): { src: string; watches: string[] } {\n const owner = resolver.packageCache.ownerOfFile(fromDir);\n\n let eagerModules: string[] = [];\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 options = (resolver.options as CompatResolverOptions).options ?? optionsWithDefaults();\n\n let requiredAppFiles = [appFiles.otherAppFiles];\n if (!options.staticComponents) {\n requiredAppFiles.push(appFiles.components);\n }\n if (!options.staticHelpers) {\n requiredAppFiles.push(appFiles.helpers);\n }\n if (!options.staticModifiers) {\n requiredAppFiles.push(appFiles.modifiers);\n }\n\n let styles = [];\n // only import styles from engines with a parent (this excludeds the parent application) as their styles\n // will be inserted via a direct <link> tag.\n if (!appFiles.engine.isApp && appFiles.engine.package.isLazyEngine()) {\n styles.push({\n path: '@embroider/virtual/vendor.css',\n });\n }\n\n let lazyEngines: { names: string[]; path: string }[] = [];\n\n if (isApp) {\n // deliberately ignoring the app (which is the first entry in the engines array)\n let [, ...childEngines] = resolver.options.engines;\n for (let childEngine of childEngines) {\n let target = `@embroider/virtual/compat-modules/${childEngine.packageName}`;\n\n if (childEngine.isLazy) {\n lazyEngines.push({\n names: [childEngine.packageName],\n path: target,\n });\n } else {\n eagerModules.push(target);\n }\n }\n }\n\n let lazyRoutes: { names: string[]; path: string }[] = [];\n for (let [routeName, routeFiles] of appFiles.routeFiles.children) {\n splitRoute(\n routeName,\n routeFiles,\n resolver.options.splitAtRoutes,\n (_: string, filename: string) => {\n requiredAppFiles.push([filename]);\n },\n (routeNames: string[]) => {\n lazyRoutes.push({\n names: routeNames,\n path: `@embroider/core/route/${encodeURIComponent(routeNames[0])}`,\n });\n }\n );\n }\n\n let [fastboot, nonFastboot] = partition(excludeDotFiles(flatten(requiredAppFiles)), file =>\n appFiles.isFastbootOnly.get(file)\n );\n\n let amdModules = nonFastboot.map(file => importPaths(resolver, appFiles, file));\n let fastbootOnlyAmdModules = fastboot.map(file => importPaths(resolver, appFiles, file));\n\n let params = {\n amdModules,\n fastbootOnlyAmdModules,\n lazyRoutes,\n lazyEngines,\n eagerModules,\n styles,\n // this is a backward-compatibility feature: addons can force inclusion of modules.\n defineModulesFrom: './-embroider-implicit-modules.js',\n };\n\n return {\n src: entryTemplate(params),\n watches: [fromDir],\n };\n}\n\nconst entryTemplate = compile(`\nimport { macroCondition, getGlobalConfig } from '@embroider/macros';\n\n{{#if styles}}\n if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {\n {{#each styles as |stylePath| ~}}\n await import(\"{{js-string-escape stylePath.path}}\");\n {{/each}}\n }\n{{/if}}\n\n{{#if defineModulesFrom ~}}\n import implicitModules from \"{{js-string-escape defineModulesFrom}}\";\n{{/if}}\n\n{{#each eagerModules as |eagerModule| ~}}\n import \"{{js-string-escape eagerModule}}\";\n{{/each}}\n\n{{#each amdModules as |amdModule index| ~}}\n import * as amdModule{{index}} from \"{{js-string-escape amdModule.buildtime}}\"\n{{/each}}\n\nlet exportFastbootModules = {};\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 exportFasbootModules[k] = resolvedValues[i];\n })\n }\n{{/if}}\n\n\n{{#if lazyRoutes}}\nwindow._embroiderRouteBundles_ = [\n {{#each lazyRoutes as |route|}}\n {\n names: {{json-stringify route.names}},\n load: function() {\n return import(\"{{js-string-escape route.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\n{{#if lazyEngines}}\nwindow._embroiderEngineBundles_ = [\n {{#each lazyEngines as |engine|}}\n {\n names: {{json-stringify engine.names}},\n load: function() {\n return import(\"{{js-string-escape engine.path}}\");\n }\n },\n {{/each}}\n]\n{{/if}}\n\nexport default Object.assign(\n {},\n implicitModules,\n {\n {{#each amdModules as |amdModule index| ~}}\n \"{{js-string-escape amdModule.runtime}}\": amdModule{{index}},\n {{/each}}\n },\n exportFastbootModules\n);\n`) as (params: {\n amdModules: { runtime: string; buildtime: string }[];\n fastbootOnlyAmdModules?: { runtime: string; buildtime: string }[];\n defineModulesFrom?: string;\n eagerModules?: string[];\n lazyRoutes?: { names: string[]; path: string }[];\n lazyEngines?: { names: string[]; path: string }[];\n styles?: { path: string }[];\n}) => string;\n\nfunction excludeDotFiles(files: string[]) {\n return files.filter(file => !file.startsWith('.') && !file.includes('/.'));\n}\n\nexport function importPaths(resolver: Resolver, { engine }: AppFiles, engineRelativePath: string) {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n let noHBS = engineRelativePath.replace(resolvableExtensionsPattern, '').replace(/\\.hbs$/, '');\n return {\n runtime: `${engine.modulePrefix}/${noHBS}`,\n buildtime: `./${engineRelativePath}`,\n };\n}\n\nexport function splitRoute(\n routeName: string,\n files: RouteFiles,\n splitAtRoutes: (RegExp | string)[] | undefined,\n addToParent: (routeName: string, filename: string) => void,\n addLazyBundle: (routeNames: string[], files: string[]) => void\n) {\n let shouldSplit = routeName && shouldSplitRoute(routeName, splitAtRoutes);\n let ownFiles = [];\n let ownNames = new Set() as Set<string>;\n\n if (files.template) {\n if (shouldSplit) {\n ownFiles.push(files.template);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.template);\n }\n }\n\n if (files.controller) {\n if (shouldSplit) {\n ownFiles.push(files.controller);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.controller);\n }\n }\n\n if (files.route) {\n if (shouldSplit) {\n ownFiles.push(files.route);\n ownNames.add(routeName);\n } else {\n addToParent(routeName, files.route);\n }\n }\n\n for (let [childName, childFiles] of files.children) {\n splitRoute(\n `${routeName}.${childName}`,\n childFiles,\n splitAtRoutes,\n (childRouteName: string, childFile: string) => {\n // this is our child calling \"addToParent\"\n if (shouldSplit) {\n ownFiles.push(childFile);\n ownNames.add(childRouteName);\n } else {\n addToParent(childRouteName, childFile);\n }\n },\n (routeNames: string[], files: string[]) => {\n addLazyBundle(routeNames, files);\n }\n );\n }\n\n if (ownFiles.length > 0) {\n addLazyBundle([...ownNames], ownFiles);\n }\n}\n\nfunction shouldSplitRoute(routeName: string, splitAtRoutes: (RegExp | string)[] | undefined) {\n if (!splitAtRoutes) {\n return false;\n }\n return splitAtRoutes.find(pattern => {\n if (typeof pattern === 'string') {\n return pattern === routeName;\n } else {\n return pattern.test(routeName);\n }\n });\n}\n\nexport function getAppFiles(appRoot: string): Set<string> {\n const files: string[] = walkSync(appRoot, {\n ignore: ['_babel_filter_.js', 'app.js', 'assets', 'testem.js', 'node_modules'],\n });\n return new Set(files);\n}\n\nexport function getFastbootFiles(appRoot: string): Set<string> {\n const appDirPath = join(appRoot, '_fastboot_');\n const files: string[] = walkSync(appDirPath);\n return new Set(files);\n}\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
export interface RouteEntrypointResponse {
|
3
|
+
type: 'route-entrypoint';
|
4
|
+
fromDir: string;
|
5
|
+
route: string;
|
6
|
+
}
|
7
|
+
export declare function renderRouteEntrypoint({ fromDir, route }: RouteEntrypointResponse, resolver: Resolver): {
|
8
|
+
src: string;
|
9
|
+
watches: string[];
|
10
|
+
};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.renderRouteEntrypoint = renderRouteEntrypoint;
|
4
|
+
const app_files_1 = require("./app-files");
|
5
|
+
const js_handlebars_1 = require("./js-handlebars");
|
6
|
+
const shared_internals_1 = require("@embroider/shared-internals");
|
7
|
+
const lodash_1 = require("lodash");
|
8
|
+
const virtual_entrypoint_1 = require("./virtual-entrypoint");
|
9
|
+
function renderRouteEntrypoint({ fromDir, route }, resolver) {
|
10
|
+
const owner = resolver.packageCache.ownerOfFile(fromDir);
|
11
|
+
if (!owner) {
|
12
|
+
throw new Error('Owner expected'); // ToDo: Really bad error, update message
|
13
|
+
}
|
14
|
+
let engine = resolver.owningEngine(owner);
|
15
|
+
let isApp = (owner === null || owner === void 0 ? void 0 : owner.root) === resolver.options.engines[0].root;
|
16
|
+
let hasFastboot = Boolean(resolver.options.engines[0].activeAddons.find(a => a.name === 'ember-cli-fastboot'));
|
17
|
+
let appFiles = new app_files_1.AppFiles({
|
18
|
+
package: owner,
|
19
|
+
addons: new Map(engine.activeAddons.map(addon => [
|
20
|
+
resolver.packageCache.get(addon.root),
|
21
|
+
addon.canResolveFromFile,
|
22
|
+
])),
|
23
|
+
isApp,
|
24
|
+
modulePrefix: isApp ? resolver.options.modulePrefix : engine.packageName,
|
25
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
26
|
+
}, (0, virtual_entrypoint_1.getAppFiles)(fromDir), hasFastboot ? (0, virtual_entrypoint_1.getFastbootFiles)(owner.root) : new Set(), (0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions), (0, virtual_entrypoint_1.staticAppPathsPattern)(resolver.options.staticAppPaths), resolver.options.podModulePrefix);
|
27
|
+
let src = '';
|
28
|
+
for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
|
29
|
+
(0, virtual_entrypoint_1.splitRoute)(routeName, routeFiles, resolver.options.splitAtRoutes, (_, _filename) => {
|
30
|
+
// noop
|
31
|
+
}, (routeNames, routeFiles) => {
|
32
|
+
if (routeNames[0] === route) {
|
33
|
+
let [fastboot, nonFastboot] = (0, lodash_1.partition)(routeFiles, file => appFiles.isFastbootOnly.get(file));
|
34
|
+
const amdModules = nonFastboot.map(f => (0, virtual_entrypoint_1.importPaths)(resolver, appFiles, f));
|
35
|
+
const fastbootOnlyAmdModules = fastboot.map(f => (0, virtual_entrypoint_1.importPaths)(resolver, appFiles, f));
|
36
|
+
src = routeEntryTemplate({
|
37
|
+
amdModules,
|
38
|
+
fastbootOnlyAmdModules,
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
return { src, watches: [] };
|
44
|
+
}
|
45
|
+
const routeEntryTemplate = (0, js_handlebars_1.compile)(`
|
46
|
+
const output = {};
|
47
|
+
export default output;
|
48
|
+
|
49
|
+
{{#each amdModules as |amdModule index| ~}}
|
50
|
+
import * as amdModule{{index}} from "{{js-string-escape amdModule.buildtime}}"
|
51
|
+
output["{{js-string-escape amdModule.runtime}}"] = amdModule{{index}};
|
52
|
+
{{/each}}
|
53
|
+
|
54
|
+
{{#if fastbootOnlyAmdModules}}
|
55
|
+
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
56
|
+
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
57
|
+
output["{{js-string-escape amdModule.runtime}}"] = await import("{{js-string-escape amdModule.buildtime}}");
|
58
|
+
{{/each}}
|
59
|
+
}
|
60
|
+
{{/if}}
|
61
|
+
`);
|
62
|
+
//# sourceMappingURL=virtual-route-entrypoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-route-entrypoint.js","sourceRoot":"","sources":["virtual-route-entrypoint.ts"],"names":[],"mappings":";;AAcA,sDA6DC;AA1ED,2CAAuC;AAEvC,mDAA0C;AAC1C,kEAAgE;AACh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,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 { compile } from './js-handlebars';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport { partition } from 'lodash';\nimport { getAppFiles, getFastbootFiles, importPaths, splitRoute, staticAppPathsPattern } from './virtual-entrypoint';\n\nexport interface RouteEntrypointResponse {\n type: 'route-entrypoint';\n fromDir: string;\n route: string;\n}\n\nexport function renderRouteEntrypoint(\n { fromDir, route }: RouteEntrypointResponse,\n resolver: Resolver\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"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export interface TestSupportStylesResponse {
|
4
|
+
type: 'test-support-css';
|
5
|
+
specifier: string;
|
6
|
+
}
|
7
|
+
export declare function renderTestSupportStyles(response: TestSupportStylesResponse, resolver: Resolver): VirtualContentResult;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.renderTestSupportStyles = renderTestSupportStyles;
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const lodash_1 = require("lodash");
|
9
|
+
const resolve_1 = __importDefault(require("resolve"));
|
10
|
+
function renderTestSupportStyles(response, resolver) {
|
11
|
+
const filename = response.specifier;
|
12
|
+
const owner = resolver.packageCache.ownerOfFile(filename);
|
13
|
+
if (!owner) {
|
14
|
+
throw new Error(`Failed to find a valid owner for ${filename}`);
|
15
|
+
}
|
16
|
+
return { src: getTestSupportStyles(owner, resolver), watches: [] };
|
17
|
+
}
|
18
|
+
function getTestSupportStyles(owner, resolver) {
|
19
|
+
let engineConfig = resolver.owningEngine(owner);
|
20
|
+
let engine = {
|
21
|
+
package: owner,
|
22
|
+
addons: new Map(engineConfig.activeAddons.map(addon => [
|
23
|
+
resolver.packageCache.get(addon.root),
|
24
|
+
addon.canResolveFromFile,
|
25
|
+
])),
|
26
|
+
isApp: true,
|
27
|
+
modulePrefix: resolver.options.modulePrefix,
|
28
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
29
|
+
};
|
30
|
+
return generateTestSupportStyles(engine);
|
31
|
+
}
|
32
|
+
function generateTestSupportStyles(engine) {
|
33
|
+
let result = impliedAddonTestSupportStyles(engine).map((sourcePath) => {
|
34
|
+
let source = (0, fs_1.readFileSync)(sourcePath);
|
35
|
+
return `${source}`;
|
36
|
+
});
|
37
|
+
return result.join('');
|
38
|
+
}
|
39
|
+
function impliedAddonTestSupportStyles(engine) {
|
40
|
+
let result = [];
|
41
|
+
for (let addon of (0, lodash_1.sortBy)(Array.from(engine.addons.keys()), pkg => {
|
42
|
+
switch (pkg.name) {
|
43
|
+
case 'loader.js':
|
44
|
+
return 0;
|
45
|
+
case 'ember-source':
|
46
|
+
return 10;
|
47
|
+
default:
|
48
|
+
return 1000;
|
49
|
+
}
|
50
|
+
})) {
|
51
|
+
let implicitStyles = addon.meta['implicit-test-styles'];
|
52
|
+
if (implicitStyles) {
|
53
|
+
let options = { basedir: addon.root };
|
54
|
+
for (let mod of implicitStyles) {
|
55
|
+
result.push(resolve_1.default.sync(mod, options));
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return result;
|
60
|
+
}
|
61
|
+
//# sourceMappingURL=virtual-test-support-styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-test-support-styles.js","sourceRoot":"","sources":["virtual-test-support-styles.ts"],"names":[],"mappings":";;;;;AAcA,0DAOC;AAnBD,2BAAkC;AAClC,mCAAgC;AAChC,sDAA8B;AAU9B,SAAgB,uBAAuB,CAAC,QAAmC,EAAE,QAAkB;IAC7F,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC;IACpC,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,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc,EAAE,QAAkB;IAC9D,IAAI,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,MAAM,GAAW;QACnB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI,GAAG,CACb,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAmB;YACvD,KAAK,CAAC,kBAAkB;SACzB,CAAC,CACH;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY;QAC3C,eAAe,EAAE,oBAAoB;KACtC,CAAC;IAEF,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,yBAAyB,CAAC,MAAc;IAC/C,IAAI,MAAM,GAAa,6BAA6B,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,UAAkB,EAAU,EAAE;QAC9F,IAAI,MAAM,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,CAAC;QACtC,OAAO,GAAG,MAAM,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAW,CAAC;AACnC,CAAC;AAED,SAAS,6BAA6B,CAAC,MAAc;IACnD,IAAI,MAAM,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,KAAK,IAAI,IAAA,eAAM,EAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;QAC/D,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,WAAW;gBACd,OAAO,CAAC,CAAC;YACX,KAAK,cAAc;gBACjB,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;QACH,IAAI,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACxD,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,cAAc,EAAE,CAAC;gBAC/B,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 } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { readFileSync } from 'fs';\nimport { sortBy } from 'lodash';\nimport resolve from 'resolve';\nimport type { Engine } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport interface TestSupportStylesResponse {\n type: 'test-support-css';\n specifier: string;\n}\n\nexport function renderTestSupportStyles(response: TestSupportStylesResponse, resolver: Resolver): VirtualContentResult {\n const filename = response.specifier;\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: getTestSupportStyles(owner, resolver), watches: [] };\n}\n\nfunction getTestSupportStyles(owner: Package, resolver: Resolver): string {\n let engineConfig = resolver.owningEngine(owner);\n let engine: Engine = {\n package: owner,\n addons: new Map(\n engineConfig.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp: true,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n };\n\n return generateTestSupportStyles(engine);\n}\n\nfunction generateTestSupportStyles(engine: Engine): string {\n let result: string[] = impliedAddonTestSupportStyles(engine).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n\n return result.join('') as string;\n}\n\nfunction impliedAddonTestSupportStyles(engine: Engine): string[] {\n let result: Array<string> = [];\n for (let addon of sortBy(Array.from(engine.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 implicitStyles = addon.meta['implicit-test-styles'];\n if (implicitStyles) {\n let options = { basedir: addon.root };\n for (let mod of implicitStyles) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export interface TestSupportResponse {
|
4
|
+
type: 'test-support-js';
|
5
|
+
specifier: string;
|
6
|
+
}
|
7
|
+
export declare function renderImplicitTestScripts(response: TestSupportResponse, resolver: Resolver): VirtualContentResult;
|