@embroider/core 3.4.20-unstable.947c6d2 → 3.4.20-unstable.b470496
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 +7 -7
- package/src/index.d.ts +3 -3
- package/src/index.js +3 -3
- package/src/index.js.map +1 -1
- package/src/module-request.d.ts +43 -0
- package/src/module-request.js +91 -0
- package/src/module-request.js.map +1 -0
- package/src/module-resolver.d.ts +1 -28
- package/src/module-resolver.js +123 -124
- package/src/module-resolver.js.map +1 -1
- package/src/node-resolve.d.ts +13 -16
- package/src/node-resolve.js +38 -57
- package/src/node-resolve.js.map +1 -1
- package/src/virtual-content.d.ts +24 -10
- package/src/virtual-content.js +35 -114
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +4 -2
- package/src/virtual-entrypoint.js +2 -18
- package/src/virtual-entrypoint.js.map +1 -1
- package/src/virtual-route-entrypoint.d.ts +4 -9
- package/src/virtual-route-entrypoint.js +1 -33
- package/src/virtual-route-entrypoint.js.map +1 -1
- package/src/virtual-test-support-styles.d.ts +5 -2
- package/src/virtual-test-support-styles.js +2 -5
- package/src/virtual-test-support-styles.js.map +1 -1
- package/src/virtual-test-support.d.ts +5 -2
- package/src/virtual-test-support.js +2 -5
- package/src/virtual-test-support.js.map +1 -1
- package/src/virtual-vendor-styles.d.ts +5 -1
- package/src/virtual-vendor-styles.js +2 -1
- package/src/virtual-vendor-styles.js.map +1 -1
- package/src/virtual-vendor.d.ts +5 -2
- package/src/virtual-vendor.js +4 -8
- package/src/virtual-vendor.js.map +1 -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-entrypoint.js","sourceRoot":"","sources":["virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAeA,4CAWC;AAED,sDAIC;AAED,4CAsHC;AA8FD,kCA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AK,CAAC,CAAC;QACnC,CAAC,CACF,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,aAAa,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAiB,EAAE,aAA8C;IACzF,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;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 { encodePublicRouteEntrypoint } from './virtual-route-entrypoint';\nimport escapeRegExp from 'escape-string-regexp';\nimport { optionsWithDefaults } from './options';\n\nconst entrypointPattern = /(?<filename>.*)[\\\\/]-embroider-entrypoint.js/;\n\nexport function decodeEntrypoint(filename: string): { fromDir: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-entrypoint')) {\n return;\n }\n let m = entrypointPattern.exec(filename);\n if (m) {\n return {\n fromDir: m.groups!.filename,\n };\n }\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 // this is new\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[], _files: string[]) => {\n lazyRoutes.push({\n names: routeNames,\n path: encodePublicRouteEntrypoint(routeNames, _files),\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"]}
|
1
|
+
{"version":3,"file":"virtual-entrypoint.js","sourceRoot":"","sources":["virtual-entrypoint.ts"],"names":[],"mappings":";;;;;AAkBA,sDAIC;AAED,4CAqHC;AA8FD,kCAOC;AAED,gCA6DC;AAeD,kCAKC;AAED,4CAIC;AA3UD,2CAAwD;AACxD,mDAA0C;AAG1C,mCAA4C;AAC5C,+BAA4B;AAC5B,kEAAgE;AAChE,0DAAiC;AAEjC,gFAAgD;AAChD,uCAAgD;AAQhD,SAAgB,qBAAqB,CAAC,cAAoC;IACxE,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,IAAA,8BAAY,EAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IACtH,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAC9B,QAAkB,EAClB,EAAE,OAAO,EAAuB;;IAEhC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,YAAY,GAAa,EAAE,CAAC;IAEhC,IAAI,CAAC,KAAK,EAAE,CAA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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"]}
|
@@ -1,15 +1,10 @@
|
|
1
1
|
import type { Resolver } from './module-resolver';
|
2
|
-
export
|
3
|
-
|
2
|
+
export interface RouteEntrypointResponse {
|
3
|
+
type: 'route-entrypoint';
|
4
4
|
fromDir: string;
|
5
5
|
route: string;
|
6
|
-
}
|
7
|
-
export declare function
|
8
|
-
export declare function decodePublicRouteEntrypoint(specifier: string): string | null;
|
9
|
-
export declare function renderRouteEntrypoint(resolver: Resolver, { fromDir, route }: {
|
10
|
-
fromDir: string;
|
11
|
-
route: string;
|
12
|
-
}): {
|
6
|
+
}
|
7
|
+
export declare function renderRouteEntrypoint({ fromDir, route }: RouteEntrypointResponse, resolver: Resolver): {
|
13
8
|
src: string;
|
14
9
|
watches: string[];
|
15
10
|
};
|
@@ -1,44 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.encodeRouteEntrypoint = encodeRouteEntrypoint;
|
4
|
-
exports.decodeRouteEntrypoint = decodeRouteEntrypoint;
|
5
|
-
exports.encodePublicRouteEntrypoint = encodePublicRouteEntrypoint;
|
6
|
-
exports.decodePublicRouteEntrypoint = decodePublicRouteEntrypoint;
|
7
3
|
exports.renderRouteEntrypoint = renderRouteEntrypoint;
|
8
4
|
const app_files_1 = require("./app-files");
|
9
|
-
const path_1 = require("path");
|
10
5
|
const js_handlebars_1 = require("./js-handlebars");
|
11
6
|
const shared_internals_1 = require("@embroider/shared-internals");
|
12
7
|
const lodash_1 = require("lodash");
|
13
8
|
const virtual_entrypoint_1 = require("./virtual-entrypoint");
|
14
|
-
|
15
|
-
function encodeRouteEntrypoint(packagePath, matched, routeName) {
|
16
|
-
return (0, path_1.resolve)(packagePath, matched ? `${matched}:route=${routeName}` : `-embroider-route-entrypoint.js:route=${routeName}`);
|
17
|
-
}
|
18
|
-
function decodeRouteEntrypoint(filename) {
|
19
|
-
// Performance: avoid paying regex exec cost unless needed
|
20
|
-
if (!filename.includes('-embroider-route-entrypoint')) {
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
let m = entrypointPattern.exec(filename);
|
24
|
-
if (m) {
|
25
|
-
return {
|
26
|
-
fromDir: m.groups.filename,
|
27
|
-
route: m.groups.route,
|
28
|
-
};
|
29
|
-
}
|
30
|
-
}
|
31
|
-
function encodePublicRouteEntrypoint(routeNames, _files) {
|
32
|
-
return `@embroider/core/route/${encodeURIComponent(routeNames[0])}`;
|
33
|
-
}
|
34
|
-
function decodePublicRouteEntrypoint(specifier) {
|
35
|
-
const publicPrefix = '@embroider/core/route/';
|
36
|
-
if (!specifier.startsWith(publicPrefix)) {
|
37
|
-
return null;
|
38
|
-
}
|
39
|
-
return specifier.slice(publicPrefix.length);
|
40
|
-
}
|
41
|
-
function renderRouteEntrypoint(resolver, { fromDir, route }) {
|
9
|
+
function renderRouteEntrypoint({ fromDir, route }, resolver) {
|
42
10
|
const owner = resolver.packageCache.ownerOfFile(fromDir);
|
43
11
|
if (!owner) {
|
44
12
|
throw new Error('Owner expected'); // ToDo: Really bad error, update message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-route-entrypoint.js","sourceRoot":"","sources":["virtual-route-entrypoint.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"virtual-route-entrypoint.js","sourceRoot":"","sources":["virtual-route-entrypoint.ts"],"names":[],"mappings":";;AAcA,sDA6DC;AA1ED,2CAAuC;AAEvC,mDAA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GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;CAgBlC,CAGW,CAAC","sourcesContent":["import type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { AppFiles } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport { 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"]}
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import type { Resolver } from './module-resolver';
|
2
2
|
import type { VirtualContentResult } from './virtual-content';
|
3
|
-
export
|
4
|
-
|
3
|
+
export interface TestSupportStylesResponse {
|
4
|
+
type: 'test-support-css';
|
5
|
+
specifier: string;
|
6
|
+
}
|
7
|
+
export declare function renderTestSupportStyles(response: TestSupportStylesResponse, resolver: Resolver): VirtualContentResult;
|
@@ -3,15 +3,12 @@ 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.decodeTestSupportStyles = decodeTestSupportStyles;
|
7
6
|
exports.renderTestSupportStyles = renderTestSupportStyles;
|
8
7
|
const fs_1 = require("fs");
|
9
8
|
const lodash_1 = require("lodash");
|
10
9
|
const resolve_1 = __importDefault(require("resolve"));
|
11
|
-
function
|
12
|
-
|
13
|
-
}
|
14
|
-
function renderTestSupportStyles(filename, resolver) {
|
10
|
+
function renderTestSupportStyles(response, resolver) {
|
11
|
+
const filename = response.specifier;
|
15
12
|
const owner = resolver.packageCache.ownerOfFile(filename);
|
16
13
|
if (!owner) {
|
17
14
|
throw new Error(`Failed to find a valid owner for ${filename}`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-test-support-styles.js","sourceRoot":"","sources":["virtual-test-support-styles.ts"],"names":[],"mappings":";;;;;
|
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,KAA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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"]}
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import type { Resolver } from './module-resolver';
|
2
2
|
import type { VirtualContentResult } from './virtual-content';
|
3
|
-
export
|
4
|
-
|
3
|
+
export interface TestSupportResponse {
|
4
|
+
type: 'test-support-js';
|
5
|
+
specifier: string;
|
6
|
+
}
|
7
|
+
export declare function renderImplicitTestScripts(response: TestSupportResponse, resolver: Resolver): VirtualContentResult;
|
@@ -3,14 +3,11 @@ 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.decodeImplicitTestScripts = decodeImplicitTestScripts;
|
7
6
|
exports.renderImplicitTestScripts = renderImplicitTestScripts;
|
8
7
|
const fs_1 = require("fs");
|
9
8
|
const resolve_1 = __importDefault(require("resolve"));
|
10
|
-
function
|
11
|
-
|
12
|
-
}
|
13
|
-
function renderImplicitTestScripts(filename, resolver) {
|
9
|
+
function renderImplicitTestScripts(response, resolver) {
|
10
|
+
const filename = response.specifier;
|
14
11
|
const owner = resolver.packageCache.ownerOfFile(filename);
|
15
12
|
if (!owner) {
|
16
13
|
throw new Error(`Failed to find a valid owner for ${filename}`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-test-support.js","sourceRoot":"","sources":["virtual-test-support.ts"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"file":"virtual-test-support.js","sourceRoot":"","sources":["virtual-test-support.ts"],"names":[],"mappings":";;;;;AAaA,8DAOC;AAlBD,2BAAkC;AAClC,sDAA8B;AAU9B,SAAgB,yBAAyB,CAAC,QAA6B,EAAE,QAAkB;IACzF,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAA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;IAEF,yEAAyE;IACzE,kEAAkE;IAClE,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,OAAO,CAAC,4DAA4D,CAAC,CAAC,EAAE,CAAC,CAAC;IACnH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAW,CAAC;AACnC,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAc;IAC7C,IAAI,MAAM,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACnD,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1D,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Package } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { readFileSync } from 'fs';\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 TestSupportResponse {\n type: 'test-support-js';\n specifier: string;\n}\n\nexport function renderImplicitTestScripts(response: TestSupportResponse, 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: getTestSupport(owner, resolver), watches: [] };\n}\n\nfunction getTestSupport(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 generateTestSupport(engine);\n}\n\nfunction generateTestSupport(engine: Engine): string {\n // Add classic addons test-support\n let result: string[] = impliedAddonTestSupport(engine);\n let hasEmbroiderMacrosTestSupport = result.find(sourcePath =>\n sourcePath.endsWith('embroider-macros-test-support.js')\n );\n result = result.map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n\n // Add _testing_suffix_.js\n result.push(`\nvar runningTests=true;\nif (typeof Testem !== 'undefined' && (typeof QUnit !== 'undefined' || typeof Mocha !== 'undefined')) {\n Testem.hookIntoTestFramework();\n}`);\n\n // whether or not anybody was actually using @embroider/macros explicitly\n // as an addon, we ensure its test-support file is always present.\n if (!hasEmbroiderMacrosTestSupport) {\n result.unshift(`${readFileSync(require.resolve('@embroider/macros/src/vendor/embroider-macros-test-support'))}`);\n }\n\n return result.join('') as string;\n}\n\nfunction impliedAddonTestSupport(engine: Engine): string[] {\n let result: Array<string> = [];\n for (let addon of Array.from(engine.addons.keys())) {\n let implicitScripts = addon.meta['implicit-test-scripts'];\n if (implicitScripts) {\n let options = { basedir: addon.root };\n for (let mod of implicitScripts) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
|
@@ -1,4 +1,8 @@
|
|
1
1
|
import type { Resolver } from './module-resolver';
|
2
2
|
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export interface VirtualVendorStylesResponse {
|
4
|
+
type: 'vendor-css';
|
5
|
+
specifier: string;
|
6
|
+
}
|
3
7
|
export declare function decodeVirtualVendorStyles(filename: string): boolean;
|
4
|
-
export declare function renderVendorStyles(
|
8
|
+
export declare function renderVendorStyles(response: VirtualVendorStylesResponse, resolver: Resolver): VirtualContentResult;
|
@@ -11,7 +11,8 @@ const resolve_1 = __importDefault(require("resolve"));
|
|
11
11
|
function decodeVirtualVendorStyles(filename) {
|
12
12
|
return filename.endsWith('-embroider-vendor-styles.css');
|
13
13
|
}
|
14
|
-
function renderVendorStyles(
|
14
|
+
function renderVendorStyles(response, resolver) {
|
15
|
+
const filename = response.specifier;
|
15
16
|
const owner = resolver.packageCache.ownerOfFile(filename);
|
16
17
|
if (!owner) {
|
17
18
|
throw new Error(`Failed to find a valid owner for ${filename}`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-vendor-styles.js","sourceRoot":"","sources":["virtual-vendor-styles.ts"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"file":"virtual-vendor-styles.js","sourceRoot":"","sources":["virtual-vendor-styles.ts"],"names":[],"mappings":";;;;;AAcA,8DAEC;AAED,gDAOC;AAvBD,2BAAkC;AAClC,mCAAgC;AAChC,sDAA8B;AAU9B,SAAgB,yBAAyB,CAAC,QAAgB;IACxD,OAAO,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB,CAAC,QAAqC,EAAE,QAAkB;IAC1F,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,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAkB;IACzD,IAAI,YAAY,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IAC9C,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,0EAA0E;QAC1E,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,IAAI,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAmB;IACjD,IAAI,cAAc,GAAG,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,cAAc,EAAE,CAAC;QACnB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;QACpC,KAAK,IAAI,GAAG,IAAI,cAAc,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1C,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 { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\nimport type { Engine } from './app-files';\n\nexport interface VirtualVendorStylesResponse {\n type: 'vendor-css';\n specifier: string;\n}\n\nexport function decodeVirtualVendorStyles(filename: string): boolean {\n return filename.endsWith('-embroider-vendor-styles.css');\n}\n\nexport function renderVendorStyles(response: VirtualVendorStylesResponse, 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: getVendorStyles(owner, resolver), watches: [] };\n}\n\nfunction getVendorStyles(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: engineConfig.root === resolver.options.engines[0].root,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n };\n\n return generateVendorStyles(engine);\n}\n\nfunction generateVendorStyles(engine: Engine): string {\n let result: string[] = impliedAddonVendorStyles(engine).map(sourcePath => readFileSync(sourcePath, 'utf-8'));\n\n // add the engines own styles but only if it is not the top-level app, that is provided by @embroider/synthesized-styles\n if (!engine.isApp) {\n let engineStyles = [];\n\n engineStyles = getAddonImplicitStyles(engine.package as V2AddonPackage).map(sourcePath =>\n readFileSync(sourcePath, 'utf-8')\n );\n\n // add engine's own implicit styles after all vendor styles\n if (engineStyles.length) {\n result = [...result, ...engineStyles];\n }\n }\n\n return result.join('') as string;\n}\n\nfunction impliedAddonVendorStyles(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 // exclude lazy engines because they will handle their own css importation\n if (addon.isLazyEngine()) {\n continue;\n }\n\n let styles = getAddonImplicitStyles(addon);\n\n if (styles.length) {\n result = [...styles, ...result];\n }\n }\n return result;\n}\n\nfunction getAddonImplicitStyles(pkg: V2AddonPackage): string[] {\n let implicitStyles = pkg.meta['implicit-styles'];\n let styles = [];\n if (implicitStyles) {\n let options = { basedir: pkg.root };\n for (let mod of implicitStyles) {\n styles.push(resolve.sync(mod, options));\n }\n }\n return styles;\n}\n"]}
|
package/src/virtual-vendor.d.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
import type { Resolver } from './module-resolver';
|
2
2
|
import type { VirtualContentResult } from './virtual-content';
|
3
|
-
export
|
4
|
-
|
3
|
+
export interface VirtualVendorResponse {
|
4
|
+
type: 'vendor-js';
|
5
|
+
specifier: string;
|
6
|
+
}
|
7
|
+
export declare function renderVendor(response: VirtualVendorResponse, resolver: Resolver): VirtualContentResult;
|
package/src/virtual-vendor.js
CHANGED
@@ -3,21 +3,17 @@ 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.decodeVirtualVendor = decodeVirtualVendor;
|
7
6
|
exports.renderVendor = renderVendor;
|
8
7
|
const shared_internals_1 = require("@embroider/shared-internals");
|
9
8
|
const fs_extra_1 = require("fs-extra");
|
10
9
|
const path_1 = require("path");
|
11
10
|
const resolve_1 = __importDefault(require("resolve"));
|
12
|
-
function
|
13
|
-
|
14
|
-
}
|
15
|
-
function renderVendor(filename, resolver) {
|
16
|
-
const owner = resolver.packageCache.ownerOfFile(filename);
|
11
|
+
function renderVendor(response, resolver) {
|
12
|
+
const owner = resolver.packageCache.ownerOfFile(response.specifier);
|
17
13
|
if (!owner) {
|
18
|
-
throw new Error(`Failed to find a valid owner for ${
|
14
|
+
throw new Error(`Failed to find a valid owner for ${response.specifier}`);
|
19
15
|
}
|
20
|
-
return { src: getVendor(owner, resolver,
|
16
|
+
return { src: getVendor(owner, resolver, response.specifier), watches: [] };
|
21
17
|
}
|
22
18
|
function getVendor(owner, resolver, filename) {
|
23
19
|
let engineConfig = resolver.owningEngine(owner);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-vendor.js","sourceRoot":"","sources":["virtual-vendor.ts"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"file":"virtual-vendor.js","sourceRoot":"","sources":["virtual-vendor.ts"],"names":[],"mappings":";;;;;AAaA,oCAMC;AAnBD,kEAAsF;AAEtF,uCAAiE;AACjE,+BAA4B;AAC5B,sDAA8B;AAS9B,SAAgB,YAAY,CAAC,QAA+B,EAAE,QAAkB;IAC9E,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC9E,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,QAAkB,EAAE,QAAgB;IACrE,IAAI,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC,CAAC;IAE7G,IAAI,IAAI,GAAG,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACvF,I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,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { type Package, locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { lstatSync, readFileSync, readJSONSync } from 'fs-extra';\nimport { join } from 'path';\nimport resolve from 'resolve';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport interface VirtualVendorResponse {\n type: 'vendor-js';\n specifier: string;\n}\n\nexport function renderVendor(response: VirtualVendorResponse, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(response.specifier);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${response.specifier}`);\n }\n return { src: getVendor(owner, resolver, response.specifier), watches: [] };\n}\n\nfunction getVendor(owner: Package, resolver: Resolver, filename: string): string {\n let engineConfig = resolver.owningEngine(owner);\n let addons = engineConfig.activeAddons.map(addon => resolver.packageCache.get(addon.root) as V2AddonPackage);\n\n let path = join(locateEmbroiderWorkingDir(resolver.options.appRoot), 'ember-env.json');\n if (!lstatSync(path).isFile()) {\n throw new Error(`Failed to read the ember-env.json when generating content for ${filename}`);\n }\n let emberENV = readJSONSync(path);\n\n return generateVendor(addons, emberENV);\n}\n\nfunction generateVendor(addons: V2AddonPackage[], emberENV?: unknown): string {\n // Add addons implicit-scripts\n let vendor: string[] = impliedAddonVendors(addons).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n // Add _testing_prefix_.js\n vendor.unshift(`var runningTests=false;`);\n // Add _ember_env_.js\n vendor.unshift(`window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`);\n\n return vendor.join('') as string;\n}\n\nfunction impliedAddonVendors(addons: V2AddonPackage[]): string[] {\n let result: Array<string> = [];\n for (let addon of addons) {\n let implicitScripts = addon.meta['implicit-scripts'];\n if (implicitScripts) {\n let options = { basedir: addon.root };\n for (let mod of implicitScripts) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import Plugin from 'broccoli-plugin';
|
2
|
-
import type { PackagerConstructor, Variant } from './packager';
|
3
|
-
import type Stage from './stage';
|
4
|
-
interface BroccoliPackager<Options> {
|
5
|
-
new (stage: Stage, variants: Variant[], options?: Options): Plugin;
|
6
|
-
}
|
7
|
-
export default function toBroccoliPlugin<Options>(packagerClass: PackagerConstructor<Options>): BroccoliPackager<Options>;
|
8
|
-
export {};
|
@@ -1,30 +0,0 @@
|
|
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.default = toBroccoliPlugin;
|
7
|
-
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
8
|
-
const shared_internals_1 = require("@embroider/shared-internals");
|
9
|
-
function toBroccoliPlugin(packagerClass) {
|
10
|
-
class PackagerRunner extends broccoli_plugin_1.default {
|
11
|
-
constructor(stage, variants, options) {
|
12
|
-
super([stage.tree], {
|
13
|
-
persistentOutput: true,
|
14
|
-
needsCache: false,
|
15
|
-
annotation: packagerClass.annotation,
|
16
|
-
});
|
17
|
-
this.stage = stage;
|
18
|
-
this.variants = variants;
|
19
|
-
this.options = options;
|
20
|
-
}
|
21
|
-
async build() {
|
22
|
-
if (!this.packager) {
|
23
|
-
this.packager = new packagerClass(this.stage.inputPath, this.outputPath, this.variants, msg => console.log(msg.split(shared_internals_1.tmpdir).join('$TMPDIR')), this.options);
|
24
|
-
}
|
25
|
-
return this.packager.build();
|
26
|
-
}
|
27
|
-
}
|
28
|
-
return PackagerRunner;
|
29
|
-
}
|
30
|
-
//# sourceMappingURL=to-broccoli-plugin.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"to-broccoli-plugin.js","sourceRoot":"","sources":["to-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AASA,mCA2BC;AApCD,sEAAqC;AAGrC,kEAAqD;AAMrD,SAAwB,gBAAgB,CACtC,aAA2C;IAE3C,MAAM,cAAe,SAAQ,yBAAM;QAEjC,YAAoB,KAAY,EAAU,QAAmB,EAAU,OAAiB;YACtF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAClB,gBAAgB,EAAE,IAAI;gBACtB,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;YALe,UAAK,GAAL,KAAK,CAAO;YAAU,aAAQ,GAAR,QAAQ,CAAW;YAAU,YAAO,GAAP,OAAO,CAAU;QAMxF,CAAC;QAED,KAAK,CAAC,KAAK;YACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,EACpB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,QAAQ,EACb,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EACrD,IAAI,CAAC,OAAO,CACb,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Packager, PackagerConstructor, Variant } from './packager';\nimport type Stage from './stage';\nimport { tmpdir } from '@embroider/shared-internals';\n\ninterface BroccoliPackager<Options> {\n new (stage: Stage, variants: Variant[], options?: Options): Plugin;\n}\n\nexport default function toBroccoliPlugin<Options>(\n packagerClass: PackagerConstructor<Options>\n): BroccoliPackager<Options> {\n class PackagerRunner extends Plugin {\n private packager: Packager | undefined;\n constructor(private stage: Stage, private variants: Variant[], private options?: Options) {\n super([stage.tree], {\n persistentOutput: true,\n needsCache: false,\n annotation: packagerClass.annotation,\n });\n }\n\n async build() {\n if (!this.packager) {\n this.packager = new packagerClass(\n this.stage.inputPath,\n this.outputPath,\n this.variants,\n msg => console.log(msg.split(tmpdir).join('$TMPDIR')),\n this.options\n );\n }\n return this.packager.build();\n }\n }\n return PackagerRunner;\n}\n"]}
|