@embroider/core 3.4.9 → 3.4.10-unstable.3beedad

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +13 -11
  2. package/src/app-files.d.ts +2 -3
  3. package/src/app-files.js +1 -1
  4. package/src/app-files.js.map +1 -1
  5. package/src/asset.d.ts +2 -6
  6. package/src/asset.js.map +1 -1
  7. package/src/describe-exports.js.map +1 -1
  8. package/src/ember-html.d.ts +3 -6
  9. package/src/ember-html.js +6 -17
  10. package/src/ember-html.js.map +1 -1
  11. package/src/html-entrypoint.js.map +1 -1
  12. package/src/html-placeholder.js.map +1 -1
  13. package/src/index.d.ts +2 -2
  14. package/src/index.js.map +1 -1
  15. package/src/messages.js.map +1 -1
  16. package/src/module-resolver.d.ts +25 -15
  17. package/src/module-resolver.js +281 -191
  18. package/src/module-resolver.js.map +1 -1
  19. package/src/node-resolve.d.ts +33 -0
  20. package/src/node-resolve.js +131 -0
  21. package/src/node-resolve.js.map +1 -0
  22. package/src/options.js.map +1 -1
  23. package/src/packager.js.map +1 -1
  24. package/src/portable-babel-config.js.map +1 -1
  25. package/src/portable-babel-launcher.js.map +1 -1
  26. package/src/portable.js.map +1 -1
  27. package/src/resolver-loader.js.map +1 -1
  28. package/src/to-broccoli-plugin.js.map +1 -1
  29. package/src/virtual-content.d.ts +6 -2
  30. package/src/virtual-content.js +104 -42
  31. package/src/virtual-content.js.map +1 -1
  32. package/src/virtual-test-support-styles.d.ts +4 -0
  33. package/src/virtual-test-support-styles.js +65 -0
  34. package/src/virtual-test-support-styles.js.map +1 -0
  35. package/src/virtual-test-support.d.ts +4 -0
  36. package/src/virtual-test-support.js +69 -0
  37. package/src/virtual-test-support.js.map +1 -0
  38. package/src/virtual-vendor-styles.d.ts +4 -0
  39. package/src/virtual-vendor-styles.js +83 -0
  40. package/src/virtual-vendor-styles.js.map +1 -0
  41. package/src/virtual-vendor.d.ts +4 -0
  42. package/src/virtual-vendor.js +73 -0
  43. package/src/virtual-vendor.js.map +1 -0
  44. package/src/wait-for-trees.js.map +1 -1
  45. package/LICENSE +0 -21
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAmD;AACnD,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAKvC,MAAa,iBAAiB;IAC5B,YACU,QAAkB,EACjB,SAAiB,EACjB,QAAgB,EAChB,SAAkB,EAClB,IAAqC,EACrC,UAAmB,EACnB,UAAyD;QAN1D,aAAQ,GAAR,QAAQ,CAAU;QACjB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAiC;QACrC,eAAU,GAAV,UAAU,CAAS;QACnB,eAAU,GAAV,UAAU,CAA+C;IACjE,CAAC;IAEJ,IAAI,SAAS;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,SAAiB;QACrB,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAS,CAAC;IACpH,CAAC;IACD,MAAM,CAAC,QAAgB;QACrB,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAS,CAAC;QACpH,CAAC;IACH,CAAC;IACD,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,QA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C;gBAED,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,YAAY,GAAG,GAAG,CAAC;gBACrB,CAAC;gBAED,SAAS;YACX,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAgB,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACrG,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;IAClD,CAAC;CACF;AAjID,8CAiIC;AAED,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAiB;IACpC,MAAM,SAAS,CAAC;IAEhB,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,GAAG,SAAS,GAAG,GAAG,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAMM,KAAK,UAAU,WAAW,CAC/B,QAAkB,EAClB,SAAiB,EACjB,QAAgB;IAEhB,IAAI,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,CACrC,IAAI,iBAAiB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CACzF,CAAC;IACF,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B,KAAK,SAAS;YACZ,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAC;QACJ;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AApBD,kCAoBC","sourcesContent":["import { virtualContent } from './virtual-content';\nimport { dirname, resolve, isAbsolute } from 'path';\nimport { explicitRelative } from '@embroider/shared-internals';\nimport assertNever from 'assert-never';\n\n// these would be circular, but they're type-only so it's fine\nimport type { ModuleRequest, Resolution, Resolver } from './module-resolver';\n\nexport class NodeModuleRequest implements ModuleRequest {\n constructor(\n private resolver: Resolver,\n readonly specifier: string,\n readonly fromFile: string,\n readonly isVirtual: boolean,\n readonly meta: Record<string, any> | undefined,\n readonly isNotFound: boolean,\n readonly resolvedTo: Resolution<NodeResolution, Error> | undefined\n ) {}\n\n get debugType() {\n return 'node';\n }\n\n alias(specifier: string): this {\n return new NodeModuleRequest(this.resolver, specifier, this.fromFile, false, this.meta, false, undefined) as this;\n }\n rehome(fromFile: string): this {\n if (this.fromFile === fromFile) {\n return this;\n } else {\n return new NodeModuleRequest(this.resolver, this.specifier, fromFile, false, this.meta, false, undefined) as this;\n }\n }\n virtualize(filename: string): this {\n return new NodeModuleRequest(this.resolver, filename, this.fromFile, true, this.meta, false, undefined) as this;\n }\n withMeta(meta: Record<string, any> | undefined): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n meta,\n this.isNotFound,\n this.resolvedTo\n ) as this;\n }\n notFound(): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n this.meta,\n true,\n undefined\n ) as this;\n }\n\n resolveTo(resolution: Resolution<NodeResolution, Error>): this {\n return new NodeModuleRequest(\n this.resolver,\n this.specifier,\n this.fromFile,\n this.isVirtual,\n this.meta,\n this.isNotFound,\n resolution\n ) as this;\n }\n\n async defaultResolve(): Promise<Resolution<NodeResolution, Error>> {\n const request = this;\n if (request.isVirtual) {\n return {\n type: 'found',\n filename: request.specifier,\n isVirtual: true,\n result: {\n type: 'virtual' as 'virtual',\n content: virtualContent(request.specifier, this.resolver).src,\n filename: request.specifier,\n },\n };\n }\n if (request.isNotFound) {\n let err = new Error(`module not found ${request.specifier}`);\n (err as any).code = 'MODULE_NOT_FOUND';\n return {\n type: 'not_found',\n err,\n };\n }\n\n // require.resolve does not like when we resolve from virtual paths.\n // That is, a request like \"../thing.js\" from\n // \"/a/real/path/VIRTUAL_SUBDIR/virtual.js\" has an unambiguous target of\n // \"/a/real/path/thing.js\", but require.resolve won't do that path\n // adjustment until after checking whether VIRTUAL_SUBDIR actually\n // exists.\n //\n // We can do the path adjustments before doing require.resolve.\n let { specifier } = request;\n let fromDir = dirname(request.fromFile);\n if (!isAbsolute(specifier) && specifier.startsWith('.')) {\n let targetPath = resolve(fromDir, specifier);\n let newFromDir = dirname(targetPath);\n if (fromDir !== newFromDir) {\n specifier = explicitRelative(newFromDir, targetPath);\n fromDir = newFromDir;\n }\n }\n\n let initialError;\n\n for (let candidate of candidates(specifier)) {\n let filename;\n try {\n filename = require.resolve(candidate, {\n paths: [fromDir],\n });\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n\n if (!initialError) {\n initialError = err;\n }\n\n continue;\n }\n return { type: 'found', filename, result: { type: 'real' as 'real', filename }, isVirtual: false };\n }\n\n return { type: 'not_found', err: initialError };\n }\n}\n\nfunction* candidates(specifier: string) {\n yield specifier;\n\n const extensions = ['.hbs.js', '.hbs'];\n\n for (let ext of extensions) {\n yield `${specifier}${ext}`;\n }\n}\n\ntype NodeResolution = { type: 'virtual'; filename: string; content: string } | { type: 'real'; filename: string };\n\ntype NodeResolutionError = { type: 'not_found'; err: Error };\n\nexport async function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string\n): Promise<NodeResolution | NodeResolutionError> {\n let resolution = await resolver.resolve(\n new NodeModuleRequest(resolver, specifier, fromFile, false, undefined, false, undefined)\n );\n switch (resolution.type) {\n case 'not_found':\n return resolution;\n case 'found':\n return resolution.result;\n case 'ignored':\n throw new Error(\n `bug: this is supposed to be impossible because NodeModuleRequest.prototype.defaultResove does not use \"ignored\"`\n );\n default:\n throw assertNever(resolution);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AA8HA,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,KAAc;KACjC,CAAC;IACF,IAAI,OAAO,EAAE;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACzC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAfD,kDAeC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all modifiers at build time. This\n // causes unused modifiers to be left out of the build (\"tree shaking\" of\n // modifiers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticModifiers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/main/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, modifier, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), modifiers\n // (which are governed by staticModifiers) or the route-specific files (routes,\n // route templates, and controllers which are governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // By default, all modules that get imported into the app go through Babel, so\n // that all code will conform with your Babel targets. This option allows you\n // to turn Babel off for a particular package. You might need this to work\n // around a transpiler bug or you might use this as a build-performance\n // optimization if you've manually verified that a particular package doesn't\n // need transpilation to be safe in your target browsers.\n skipBabel?: { package: string; semverRange?: string }[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n\n // Ember classically used a runtime AMD module loader.\n //\n // Embroider *can* locate the vast majority of modules statically, but when an\n // addon is doing something highly dynamic (like injecting AMD `define()`\n // statements directly into a <script>), we still may not be able to locate\n // them. So Embroider can emit a placeholder shim for the missing module that\n // attempts to locate it at runtime in the classic AMD loader.\n //\n // This shim can be generated as commonJS (cjs) or an ES module (es). The\n // default is cjs.\n //\n // CJS is useful when you're building in an environment that is tolerant of\n // mixed CJS and ES modules (like Webpack), because the set of exported names\n // from the module doesn't need to be known in advance. For this reason, CJS\n // shims are generated on-demand and are fully-automatic. This is the default\n // for maximum backward-compatibility.\n //\n // ES is useful when you're building in a strict ES module environment (like\n // Vite). It's fully spec-defined and doesn't suffer interoperability\n // complexities. The downside is, we can only emit a correct shim for a module\n // if you tell embroider what set of names it exports. Example:\n\n // emberExternals: {\n // es: [\n // // import { first, second } from \"my-library\";\n // ['my-library', ['first', 'second']],\n // // import Example from \"my-library/components/example\";\n // ['my-library/components/example', ['default']]\n // ];\n // }\n\n // It is not recommended to use `es` mode without also using\n // staticEmberSource, because without staticEmberSource ember itself needs\n // many external shims.\n //\n // false means we don't do any external shimming.\n amdCompatibility?:\n | false\n | 'cjs'\n | {\n es: [string, string[]][];\n };\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticModifiers: false,\n staticComponents: false,\n splitAtRoutes: [],\n staticAppPaths: [],\n skipBabel: [],\n pluginHints: [],\n amdCompatibility: 'cjs' as const,\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AA8HA,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,KAAc;KACjC,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAfD,kDAeC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all modifiers at build time. This\n // causes unused modifiers to be left out of the build (\"tree shaking\" of\n // modifiers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticModifiers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/main/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, modifier, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), modifiers\n // (which are governed by staticModifiers) or the route-specific files (routes,\n // route templates, and controllers which are governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // By default, all modules that get imported into the app go through Babel, so\n // that all code will conform with your Babel targets. This option allows you\n // to turn Babel off for a particular package. You might need this to work\n // around a transpiler bug or you might use this as a build-performance\n // optimization if you've manually verified that a particular package doesn't\n // need transpilation to be safe in your target browsers.\n skipBabel?: { package: string; semverRange?: string }[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n\n // Ember classically used a runtime AMD module loader.\n //\n // Embroider *can* locate the vast majority of modules statically, but when an\n // addon is doing something highly dynamic (like injecting AMD `define()`\n // statements directly into a <script>), we still may not be able to locate\n // them. So Embroider can emit a placeholder shim for the missing module that\n // attempts to locate it at runtime in the classic AMD loader.\n //\n // This shim can be generated as commonJS (cjs) or an ES module (es). The\n // default is cjs.\n //\n // CJS is useful when you're building in an environment that is tolerant of\n // mixed CJS and ES modules (like Webpack), because the set of exported names\n // from the module doesn't need to be known in advance. For this reason, CJS\n // shims are generated on-demand and are fully-automatic. This is the default\n // for maximum backward-compatibility.\n //\n // ES is useful when you're building in a strict ES module environment (like\n // Vite). It's fully spec-defined and doesn't suffer interoperability\n // complexities. The downside is, we can only emit a correct shim for a module\n // if you tell embroider what set of names it exports. Example:\n\n // emberExternals: {\n // es: [\n // // import { first, second } from \"my-library\";\n // ['my-library', ['first', 'second']],\n // // import Example from \"my-library/components/example\";\n // ['my-library/components/example', ['default']]\n // ];\n // }\n\n // It is not recommended to use `es` mode without also using\n // staticEmberSource, because without staticEmberSource ember itself needs\n // many external shims.\n //\n // false means we don't do any external shimming.\n amdCompatibility?:\n | false\n | 'cjs'\n | {\n es: [string, string[]][];\n };\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticModifiers: false,\n staticComponents: false,\n splitAtRoutes: [],\n staticAppPaths: [],\n skipBabel: [],\n pluginHints: [],\n amdCompatibility: 'cjs' as const,\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;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;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAFD,kDAEC","sourcesContent":["import type { AppMeta } from '@embroider/shared-internals';\nimport { tmpdir } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the app meta-data for a package\n */\nexport function getAppMeta(pathToVanillaApp: string) {\n let pkg = JSON.parse(readFileSync(join(pathToVanillaApp, 'package.json'), 'utf8'));\n return pkg as unknown as { name: string; 'ember-addon': AppMeta };\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
1
+ {"version":3,"file":"packager.js","sourceRoot":"","sources":["packager.ts"],"names":[],"mappings":";;;AACA,kEAAqD;AACrD,uCAAwC;AACxC,mCAAmC;AACnC,+BAA4B;AAoE5B,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,WAAgB;IAC1E,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CACzE,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,mBAAmB,GAAG,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;YACjD,mBAAmB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YACnE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAlBD,8DAkBC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,gBAAwB;IACjD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,gBAAgB,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnF,OAAO,GAA0D,CAAC;AACpE,CAAC;AAHD,gCAGC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAA,WAAI,EAAC,yBAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAFD,kDAEC","sourcesContent":["import type { AppMeta } from '@embroider/shared-internals';\nimport { tmpdir } from '@embroider/shared-internals';\nimport { readFileSync } from 'fs-extra';\nimport { cloneDeep } from 'lodash';\nimport { join } from 'path';\n\n// This is a collection of flags that convey what kind of build you want. They\n// are intended to be generic across Packagers, and it's up to Packager authors\n// to support each option (or not).\nexport interface Variant {\n // descriptive name that can be used by the packager to label which output\n // goes with which variant.\n name: string;\n\n // Which runtime should this build work in? Dev builds will typically be \"all\"\n // because we produce a single build that works in browser and fastboot. But\n // production builds can be divided into a browser-only variant and a\n // fastboot-only variant so that each can be separately optimized.\n //\n // Note that if you build *only* a fastboot variant, you're unlikely to end up\n // with any assets that can boot and run in the browser too, so the typical\n // thing to do is to have to two variants and for the packager to use the\n // assets from the browser build to generate browser-facing <script> tags in\n // the output of the fastboot build.\n runtime: 'all' | 'browser' | 'fastboot';\n\n // true if this build should be optimized for production, at the cost of\n // slower builds and/or worse debuggability\n optimizeForProduction: boolean;\n}\n\nexport interface PackagerConstructor<Options> {\n new (\n // where on disk the packager will find the app it's supposed to build. The\n // app and its addons will necessarily already be in v2 format, which is\n // what makes a Packager a cleanly separable stage that needs only a small\n // amount of ember-specific knowledge.\n inputPath: string,\n // where the packager should write the packaged app.\n outputPath: string,\n // list of active build variants. There is always at least one variant, but\n // there can be many.\n //\n // The main requirement for correctness is that the Packager is required to\n // apply each variant to the babel and template-compiler configs that it\n // finds in the app in order to build that variant.\n //\n // It is up to each Packager to decide how to combine the output from the\n // multiple variants. It might choose to just put them in separate\n // subdirectories of `outputPath`, or it might know how to combine them\n // correctly into one build that will run each variant under the appropriate\n // conditions.\n //\n // Not all packagers will support all arbitrary combinations of variants.\n variants: Variant[],\n // if possible, the packager should direct its console output through this\n // hook.\n consoleWrite: (message: string) => void,\n // A packager can have whatever custom options type it wants here. If the\n // packager is based on a third-party tool, this is where that tool's\n // configuration can go.\n options?: Options\n ): Packager;\n\n // a description for this packager that aids debugging & profiling\n annotation: string;\n}\n\nexport interface Packager {\n build(): Promise<void>;\n}\n\nexport function applyVariantToBabelConfig(variant: Variant, babelConfig: any) {\n if (variant.runtime === 'fastboot') {\n babelConfig = Object.assign({}, babelConfig);\n if (babelConfig.plugins) {\n babelConfig.plugins = babelConfig.plugins.slice();\n } else {\n babelConfig.plugins = [];\n }\n let macroPlugin = babelConfig.plugins.find(\n (p: any) => Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker\n );\n if (macroPlugin) {\n let modifiedMacroPlugin = cloneDeep(macroPlugin);\n modifiedMacroPlugin[1].globalConfig.fastboot = { isRunning: true };\n babelConfig.plugins.splice(babelConfig.plugins.indexOf(macroPlugin), 1, modifiedMacroPlugin);\n }\n }\n return babelConfig;\n}\n\n/**\n * Get the app meta-data for a package\n */\nexport function getAppMeta(pathToVanillaApp: string) {\n let pkg = JSON.parse(readFileSync(join(pathToVanillaApp, 'package.json'), 'utf8'));\n return pkg as unknown as { name: string; 'ember-addon': AppMeta };\n}\n\n/**\n * Get the path to a cache directory in the recommended location\n *\n * This ensures they have exactly the same lifetime as some of embroider's own caches.\n */\nexport function getPackagerCacheDir(name: string): string {\n return join(tmpdir, 'embroider', name);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"portable-babel-config.js","sourceRoot":"","sources":["portable-babel-config.ts"],"names":[],"mappings":";;;;;;AACA,+BAA4B;AAC5B,sDAA8B;AAE9B,yCAAsC;AAItC,SAAgB,YAAY,CAC1B,MAAwB,EACxB,cAA8B,EAC9B,KAAqB;IAErB,OAAO,IAAI,mBAAmB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAND,oCAMC;AAED,MAAM,mBAAmB;IAIvB,YAAY,cAA8B,EAAU,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;QACvE,IAAI,SAAS,IAAI,cAAc,EAAE;YAC/B,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;SACvC;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;YACtC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,iBAAO,C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olve';\nimport type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport type ResolveOptions = { basedir: string } | { resolve: (name: string) => any };\n\nexport function makePortable(\n config: TransformOptions,\n resolveOptions: ResolveOptions,\n hints: PortableHint[]\n): { config: TransformOptions; isParallelSafe: boolean } {\n return new PortableBabelConfig(resolveOptions, hints).convert(config);\n}\n\nclass PortableBabelConfig {\n private resolve: (name: string) => any;\n private basedir: string | undefined;\n\n constructor(resolveOptions: ResolveOptions, private hints: PortableHint[]) {\n if ('resolve' in resolveOptions) {\n this.resolve = resolveOptions.resolve;\n } else {\n this.basedir = resolveOptions.basedir;\n this.resolve = (name: string) => resolve.sync(name, { basedir: resolveOptions.basedir });\n }\n }\n\n convert(config: TransformOptions): { config: TransformOptions; isParallelSafe: boolean } {\n let portable: Portable = new Portable({\n hints: this.hints,\n dehydrate: (value: any, accessPath: string[]) => {\n // this custom dehydrate hook handles babel plugins & presets. If we're\n // not looking at plugins or presets, continue with stock Portable\n // behavior\n if (accessPath.length !== 2 || (accessPath[0] !== 'plugins' && accessPath[0] !== 'presets')) {\n return undefined;\n }\n\n // standardize to always handle an array\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n let [plugin, argument, asName] = value;\n\n // string plugins need to get resolved correctly into absolute paths,\n // so they will really be portable\n if (typeof plugin === 'string') {\n plugin = this.resolveBabelPlugin(plugin);\n }\n\n // next we deal with serializability. Our Portable system already\n // understands the protocol used by ember-cli-babel to identify plugin\n // classes and get back to their serializable forms, so this will\n // handle that case.\n let dehydrated = portable.dehydrate([plugin, argument, asName], accessPath.concat('_internal'));\n\n if (dehydrated.needsHydrate) {\n // we can eliminate the need for rehydration by going through our own\n // portable babel launcher\n return {\n value: [\n join(__dirname, 'portable-babel-launcher.js'),\n { module: dehydrated.value[0], arg: dehydrated.value[1], hints: this.hints },\n dehydrated.value[2] || `portable-babel-launcher-${accessPath[1]}`,\n ],\n needsHydrate: false,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n } else {\n // trim back down our array, because trailing undefined will get\n // converted into null via json.stringify, and babel will complain\n // about that.\n while (dehydrated.value.length > 0 && dehydrated.value[dehydrated.value.length - 1] == null) {\n dehydrated.value.pop();\n }\n if (dehydrated.value.length === 1) {\n dehydrated.value = dehydrated.value[0];\n }\n return {\n value: dehydrated.value,\n needsHydrate: dehydrated.needsHydrate,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n }\n },\n });\n let result = portable.dehydrate(config);\n if (result.needsHydrate) {\n throw new Error(`bug: portable babel configs aren't supposed to need hydration`);\n }\n return { config: result.value, isParallelSafe: result.isParallelSafe };\n }\n\n // babel lets you use relative paths, absolute paths, package names, and\n // package name shorthands.\n //\n // my-plugin -> my-plugin\n // my-plugin -> babel-plugin-my-plugin\n // @me/thing -> @me/thing\n // @me/thing -> @me/babel-plugin-thing\n // ./here -> /your/app/here\n // /tmp/there -> /tmp/there\n //\n private resolveBabelPlugin(name: string) {\n try {\n return this.resolve(name);\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n if (name.startsWith('.') || name.startsWith('/')) {\n throw err;\n }\n try {\n let expanded;\n if (name.startsWith('@')) {\n let [space, pkg, ...rest] = name.split('/');\n expanded = [space, `babel-plugin-${pkg}`, ...rest].join('/');\n } else {\n expanded = `babel-plugin-${name}`;\n }\n return this.resolve(expanded);\n } catch (err2) {\n if (err2.code !== 'MODULE_NOT_FOUND') {\n throw err2;\n }\n if (this.basedir) {\n throw new Error(`unable to resolve babel plugin ${name} from ${this.basedir}`);\n } else {\n throw new Error(`unable to resolve babel plugin ${name}`);\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"portable-babel-config.js","sourceRoot":"","sources":["portable-babel-config.ts"],"names":[],"mappings":";;;;;;AACA,+BAA4B;AAC5B,sDAA8B;AAE9B,yCAAsC;AAItC,SAAgB,YAAY,CAC1B,MAAwB,EACxB,cAA8B,EAC9B,KAAqB;IAErB,OAAO,IAAI,mBAAmB,CAAC,cAAc,EAAE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AAI,CAAC,GAAG,CAAC,CAAC;gBAC/D,CAAC;qBAAM,CAAC;oBACN,QAAQ,GAAG,gBAAgB,IAAI,EAAE,CAAC;gBACpC,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,IAAI,EAAE,CAAC;gBACd,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBACrC,MAAM,IAAI,CAAC;gBACb,CAAC;gBACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBACjF,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TransformOptions } from '@babel/core';\nimport { join } from 'path';\nimport resolve from 'resolve';\nimport type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport type ResolveOptions = { basedir: string } | { resolve: (name: string) => any };\n\nexport function makePortable(\n config: TransformOptions,\n resolveOptions: ResolveOptions,\n hints: PortableHint[]\n): { config: TransformOptions; isParallelSafe: boolean } {\n return new PortableBabelConfig(resolveOptions, hints).convert(config);\n}\n\nclass PortableBabelConfig {\n private resolve: (name: string) => any;\n private basedir: string | undefined;\n\n constructor(resolveOptions: ResolveOptions, private hints: PortableHint[]) {\n if ('resolve' in resolveOptions) {\n this.resolve = resolveOptions.resolve;\n } else {\n this.basedir = resolveOptions.basedir;\n this.resolve = (name: string) => resolve.sync(name, { basedir: resolveOptions.basedir });\n }\n }\n\n convert(config: TransformOptions): { config: TransformOptions; isParallelSafe: boolean } {\n let portable: Portable = new Portable({\n hints: this.hints,\n dehydrate: (value: any, accessPath: string[]) => {\n // this custom dehydrate hook handles babel plugins & presets. If we're\n // not looking at plugins or presets, continue with stock Portable\n // behavior\n if (accessPath.length !== 2 || (accessPath[0] !== 'plugins' && accessPath[0] !== 'presets')) {\n return undefined;\n }\n\n // standardize to always handle an array\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n let [plugin, argument, asName] = value;\n\n // string plugins need to get resolved correctly into absolute paths,\n // so they will really be portable\n if (typeof plugin === 'string') {\n plugin = this.resolveBabelPlugin(plugin);\n }\n\n // next we deal with serializability. Our Portable system already\n // understands the protocol used by ember-cli-babel to identify plugin\n // classes and get back to their serializable forms, so this will\n // handle that case.\n let dehydrated = portable.dehydrate([plugin, argument, asName], accessPath.concat('_internal'));\n\n if (dehydrated.needsHydrate) {\n // we can eliminate the need for rehydration by going through our own\n // portable babel launcher\n return {\n value: [\n join(__dirname, 'portable-babel-launcher.js'),\n { module: dehydrated.value[0], arg: dehydrated.value[1], hints: this.hints },\n dehydrated.value[2] || `portable-babel-launcher-${accessPath[1]}`,\n ],\n needsHydrate: false,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n } else {\n // trim back down our array, because trailing undefined will get\n // converted into null via json.stringify, and babel will complain\n // about that.\n while (dehydrated.value.length > 0 && dehydrated.value[dehydrated.value.length - 1] == null) {\n dehydrated.value.pop();\n }\n if (dehydrated.value.length === 1) {\n dehydrated.value = dehydrated.value[0];\n }\n return {\n value: dehydrated.value,\n needsHydrate: dehydrated.needsHydrate,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n }\n },\n });\n let result = portable.dehydrate(config);\n if (result.needsHydrate) {\n throw new Error(`bug: portable babel configs aren't supposed to need hydration`);\n }\n return { config: result.value, isParallelSafe: result.isParallelSafe };\n }\n\n // babel lets you use relative paths, absolute paths, package names, and\n // package name shorthands.\n //\n // my-plugin -> my-plugin\n // my-plugin -> babel-plugin-my-plugin\n // @me/thing -> @me/thing\n // @me/thing -> @me/babel-plugin-thing\n // ./here -> /your/app/here\n // /tmp/there -> /tmp/there\n //\n private resolveBabelPlugin(name: string) {\n try {\n return this.resolve(name);\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n if (name.startsWith('.') || name.startsWith('/')) {\n throw err;\n }\n try {\n let expanded;\n if (name.startsWith('@')) {\n let [space, pkg, ...rest] = name.split('/');\n expanded = [space, `babel-plugin-${pkg}`, ...rest].join('/');\n } else {\n expanded = `babel-plugin-${name}`;\n }\n return this.resolve(expanded);\n } catch (err2) {\n if (err2.code !== 'MODULE_NOT_FOUND') {\n throw err2;\n }\n if (this.basedir) {\n throw new Error(`unable to resolve babel plugin ${name} from ${this.basedir}`);\n } else {\n throw new Error(`unable to resolve babel plugin ${name}`);\n }\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"portable-babel-launcher.js","sourceRoot":"","sources":["portable-babel-launcher.ts"],"names":[],"mappings":";;AACA,yCAAsC;AAEtC,SAAwB,aAAa,CAEnC,KAAU,EACV,MAAwD,EACxD,GAAW;IAEX,IAAI,CAAC,GAAG,IAAI,mBAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,IAAI,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC;IACX,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE;QACvC,iEAAiE;QACjE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,MAAM,CAAC,UAAU,EAAE;YACrB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;SACzB;KACF;SAAM;QACL,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzD,IAAI,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;IAEhC,SAAS,YAAY,CAAC,KAAU;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AAK,KAAK,UAAU,EAAE;oBACxC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACvC;gBACD,OAAO,OAAO,CAAC;aAChB;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC5B,QAAQ,IAAI,EAAE;gBACZ,KAAK,KAAK,CAAC;gBACX,KAAK,MAAM;oBACT,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACzB,KAAK,SAAS;oBACZ,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;gBAC3C;oBACE,OAAO,QAAQ,CAAC;aACnB;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AA/ED,gCA+EC","sourcesContent":["import type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport default function babelLauncher(\n this: any,\n babel: any,\n launch: { module: any; arg: any; hints: PortableHint[] },\n key: string\n) {\n let p = new Portable({ hints: launch.hints });\n let hydrated = p.hydrate(launch);\n let module;\n if (typeof hydrated.module === 'string') {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n module = require(hydrated.module);\n if (module.__esModule) {\n module = module.default;\n }\n } else {\n module = hydrated.module;\n }\n\n let plugin = module.call(this, babel, hydrated.arg, key);\n let innerStates = new WeakMap();\n\n function convertState(state: any) {\n let innerState = innerStates.get(state);\n if (!innerState) {\n innerState = Object.assign({}, state, { opts: hydrated.arg });\n innerStates.set(state, innerState);\n }\n return innerState;\n }\n\n function wrap1(original: any) {\n if (typeof original === 'function') {\n return function (this: any, file: any) {\n return original.call(convertState(this), file);\n };\n }\n }\n\n function wrap2(original: Function) {\n return function (this: any, path: any, state: any) {\n return original.call(convertState(this), path, convertState(state));\n };\n }\n\n let visitorProxy = {\n get(target: any, prop: string) {\n let original = target[prop];\n if (typeof original === 'function') {\n return wrap2(original);\n }\n if (original && typeof original === 'object') {\n let wrapped: any = {};\n if (typeof original.exit === 'function') {\n wrapped.exit = wrap2(original.exit);\n }\n if (typeof original.enter === 'function') {\n wrapped.enter = wrap2(original.enter);\n }\n return wrapped;\n }\n return original;\n },\n };\n\n return new Proxy(plugin, {\n get(target, prop) {\n let original = target[prop];\n switch (prop) {\n case 'pre':\n case 'post':\n return wrap1(original);\n case 'visitor':\n return new Proxy(original, visitorProxy);\n default:\n return original;\n }\n },\n });\n}\n"]}
1
+ {"version":3,"file":"portable-babel-launcher.js","sourceRoot":"","sources":["portable-babel-launcher.ts"],"names":[],"mappings":";;AACA,yCAAsC;AAEtC,SAAwB,aAAa,CAEnC,KAAU,EACV,MAAwD,EACxD,GAAW;IAEX,IAAI,CAAC,GAAG,IAAI,mBAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,IAAI,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC;IACX,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxC,iEAAiE;QACjE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;QAC1B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzD,IAAI,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;IAEhC,SAAS,YAAY,CAAC,KAAU;QAC9B,IAAI,UAA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,CAAC;gBACD,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;oBACzC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC5B,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,KAAK,CAAC;gBACX,KAAK,MAAM;oBACT,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACzB,KAAK,SAAS;oBACZ,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;gBAC3C;oBACE,OAAO,QAAQ,CAAC;YACpB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AA/ED,gCA+EC","sourcesContent":["import type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport default function babelLauncher(\n this: any,\n babel: any,\n launch: { module: any; arg: any; hints: PortableHint[] },\n key: string\n) {\n let p = new Portable({ hints: launch.hints });\n let hydrated = p.hydrate(launch);\n let module;\n if (typeof hydrated.module === 'string') {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n module = require(hydrated.module);\n if (module.__esModule) {\n module = module.default;\n }\n } else {\n module = hydrated.module;\n }\n\n let plugin = module.call(this, babel, hydrated.arg, key);\n let innerStates = new WeakMap();\n\n function convertState(state: any) {\n let innerState = innerStates.get(state);\n if (!innerState) {\n innerState = Object.assign({}, state, { opts: hydrated.arg });\n innerStates.set(state, innerState);\n }\n return innerState;\n }\n\n function wrap1(original: any) {\n if (typeof original === 'function') {\n return function (this: any, file: any) {\n return original.call(convertState(this), file);\n };\n }\n }\n\n function wrap2(original: Function) {\n return function (this: any, path: any, state: any) {\n return original.call(convertState(this), path, convertState(state));\n };\n }\n\n let visitorProxy = {\n get(target: any, prop: string) {\n let original = target[prop];\n if (typeof original === 'function') {\n return wrap2(original);\n }\n if (original && typeof original === 'object') {\n let wrapped: any = {};\n if (typeof original.exit === 'function') {\n wrapped.exit = wrap2(original.exit);\n }\n if (typeof original.enter === 'function') {\n wrapped.enter = wrap2(original.enter);\n }\n return wrapped;\n }\n return original;\n },\n };\n\n return new Proxy(plugin, {\n get(target, prop) {\n let original = target[prop];\n switch (prop) {\n case 'pre':\n case 'post':\n return wrap1(original);\n case 'visitor':\n return new Proxy(original, visitorProxy);\n default:\n return original;\n }\n },\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"portable.js","sourceRoot":"","sources":["portable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyC;AACzC,gEAAuC;AACvC,2DAA6C;AAC7C,gFAAsD;AAEzC,QAAA,QAAQ,GAAG,+BAA+B,CAAC;AACxD,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC;AAc/C,MAAM,EAAE,iBAAiB,EAAE,GAAG,8BAAkB,CAAC;AAEjD,SAAgB,sBAAsB,CAAC,IAAY;IACjD,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,GAAG,CAAC,CAAC;KAC9D;SAAM;QACL,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,4DAA4D;KAClG;AACH,CAAC;AARD,wDAQC;AAED,MAAa,QAAQ;IACnB,YACU,OAIJ,EAAE;QAJE,SAAI,GAAJ,IAAI,CAIN;IACL,CAAC;IAEJ,SAAS,CAAC,KAAU,EAAE,aAAuB,EAAE;QAC7C,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACvB,IAA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I;YAC1B,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,KAAK;SACN;QACD,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import mapValues from 'lodash/mapValues';\nimport assertNever from 'assert-never';\nimport { Memoize } from 'typescript-memoize';\nimport resolvePackagePath from 'resolve-package-path';\n\nexport const protocol = '__embroider_portable_values__';\nconst { globalValues, nonce } = setupGlobals();\n\nexport interface PortableResult {\n value: any;\n isParallelSafe: boolean;\n needsHydrate: boolean;\n}\n\nexport interface PortableHint {\n requireFile: string;\n packageVersion: string | undefined;\n useMethod?: string;\n}\n\nconst { findUpPackagePath } = resolvePackagePath;\n\nexport function maybeNodeModuleVersion(path: string) {\n const packagePath = findUpPackagePath(path);\n\n if (packagePath === null) {\n throw new Error(`Could not find package.json for '${path}'`);\n } else {\n return require(packagePath).version; // eslint-disable-line @typescript-eslint/no-require-imports\n }\n}\n\nexport class Portable {\n constructor(\n private opts: {\n dehydrate?: (value: any, accessPath: string[]) => PortableResult | undefined;\n hydrate?: (value: any, accessPath: string[]) => { value: any } | undefined;\n hints?: PortableHint[];\n } = {}\n ) {}\n\n dehydrate(value: any, accessPath: string[] = []): PortableResult {\n if (this.opts.dehydrate) {\n let result = this.opts.dehydrate.call(this, value, accessPath);\n if (result) {\n return result;\n }\n }\n\n if (value === null) {\n return { value, isParallelSafe: true, needsHydrate: false };\n }\n\n let broccoli = maybeBroccoli(value);\n if (broccoli) {\n return { value: broccoli, isParallelSafe: true, needsHydrate: true };\n }\n\n let htmlbars = maybeHTMLBars(value);\n if (htmlbars) {\n return { value: htmlbars, isParallelSafe: true, needsHydrate: true };\n }\n\n if (Array.isArray(value)) {\n let results = value.map((element, index) => this.dehydrate(element, accessPath.concat(String(index))));\n return {\n value: results.map(r => r.value),\n isParallelSafe: results.every(r => r.isParallelSafe),\n needsHydrate: results.some(r => r.needsHydrate),\n };\n }\n\n switch (typeof value) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'undefined':\n return { value, isParallelSafe: true, needsHydrate: false };\n case 'object':\n if (Object.getPrototypeOf(value) === Object.prototype) {\n let isParallelSafe = true;\n let needsHydrate = false;\n let result = mapValues(value, (propertyValue, key) => {\n let result = this.dehydrate(propertyValue, accessPath.concat(key));\n isParallelSafe = isParallelSafe && result.isParallelSafe;\n needsHydrate = needsHydrate || result.needsHydrate;\n return result.value;\n });\n return { value: result, isParallelSafe, needsHydrate };\n }\n }\n\n let found = this.foundHints.get(value);\n if (found) {\n return {\n value: {\n embroiderPlaceholder: true,\n type: 'broccoli-parallel',\n requireFile: found.requireFile,\n packageVersion: maybeNodeModuleVersion(found.requireFile),\n useMethod: found.useMethod,\n },\n isParallelSafe: true,\n needsHydrate: true,\n };\n }\n\n return globalPlaceholder(value);\n }\n\n hydrate(input: any, accessPath: string[] = []): any {\n if (this.opts.hydrate) {\n let result = this.opts.hydrate.call(this, input, accessPath);\n if (result) {\n return result;\n }\n }\n if (Array.isArray(input)) {\n return input.map((element, index) => this.hydrate(element, accessPath.concat(String(index))));\n }\n if (input && typeof input === 'object') {\n if (input.embroiderPlaceholder) {\n let placeholder = input as Placeholder;\n switch (placeholder.type) {\n case 'global':\n if (placeholder.nonce !== nonce) {\n throw new Error(`unable to use this non-serializable babel config in this node process`);\n }\n return globalValues[placeholder.index];\n case 'broccoli-parallel':\n return buildBroccoli(placeholder);\n case 'htmlbars-parallel':\n return buildHTMLBars(placeholder);\n default:\n assertNever(placeholder);\n }\n } else {\n return mapValues(input, (value, key) => this.hydrate(value, accessPath.concat(key)));\n }\n }\n return input;\n }\n\n @Memoize()\n get foundHints(): Map<any, PortableHint> {\n let found = new Map();\n if (this.opts.hints) {\n for (let hint of this.opts.hints) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let mod = require(hint.requireFile);\n if (hint.useMethod) {\n mod = mod[hint.useMethod];\n }\n found.set(mod, hint);\n }\n }\n return found;\n }\n}\n\ninterface GlobalPlaceholder {\n embroiderPlaceholder: true;\n type: 'global';\n nonce: number;\n index: number;\n}\n\ninterface BroccoliParallelPlaceholder {\n embroiderPlaceholder: true;\n type: 'broccoli-parallel';\n requireFile: string;\n packageVersion: string | undefined;\n useMethod: string | undefined;\n buildUsing: string | undefined;\n params: any;\n}\n\ninterface HTMLBarsParallelPlaceholder {\n embroiderPlaceholder: true;\n type: 'htmlbars-parallel';\n packageVersion: string | undefined;\n requireFile: string;\n buildUsing: string;\n params: any;\n}\n\ntype Placeholder = GlobalPlaceholder | BroccoliParallelPlaceholder | HTMLBarsParallelPlaceholder;\n\nfunction setupGlobals() {\n let G = global as any as { [protocol]: { globalValues: any[]; nonce: number } };\n if (!G[protocol]) {\n G[protocol] = { globalValues: [], nonce: Math.floor(Math.random() * Math.pow(2, 32)) };\n }\n return G[protocol];\n}\n\n// === broccoli-babel-transpiler support ===\n\nfunction maybeBroccoli(object: any): BroccoliParallelPlaceholder | undefined {\n const type = typeof object;\n const hasProperties = type === 'function' || (type === 'object' && object !== null);\n\n if (\n hasProperties &&\n object._parallelBabel !== null &&\n typeof object._parallelBabel === 'object' &&\n typeof object._parallelBabel.requireFile === 'string'\n ) {\n return {\n embroiderPlaceholder: true,\n type: 'broccoli-parallel',\n requireFile: object._parallelBabel.requireFile,\n packageVersion: maybeNodeModuleVersion(object._parallelBabel.requireFile),\n buildUsing: object._parallelBabel.buildUsing,\n useMethod: object._parallelBabel.useMethod,\n params: object._parallelBabel.params,\n };\n }\n}\n\nfunction buildBroccoli(parallelApiInfo: BroccoliParallelPlaceholder) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let requiredStuff = require(parallelApiInfo.requireFile);\n\n if (parallelApiInfo.useMethod) {\n if (requiredStuff[parallelApiInfo.useMethod] === undefined) {\n throw new Error(\n \"method '\" + parallelApiInfo.useMethod + \"' does not exist in file \" + parallelApiInfo.requireFile\n );\n }\n return requiredStuff[parallelApiInfo.useMethod];\n }\n\n if (parallelApiInfo.buildUsing) {\n if (typeof requiredStuff[parallelApiInfo.buildUsing] !== 'function') {\n throw new Error(\"'\" + parallelApiInfo.buildUsing + \"' is not a function in file \" + parallelApiInfo.requireFile);\n }\n return requiredStuff[parallelApiInfo.buildUsing](parallelApiInfo.params);\n }\n\n return requiredStuff;\n}\n\n// ember-cli-htmlbars-inline-precompile support ===\nfunction maybeHTMLBars(object: any): HTMLBarsParallelPlaceholder | undefined {\n const type = typeof object;\n const hasProperties = type === 'function' || (type === 'object' && object !== null);\n\n if (\n hasProperties &&\n object.parallelBabel !== null &&\n typeof object.parallelBabel === 'object' &&\n typeof object.parallelBabel.requireFile === 'string'\n ) {\n return {\n embroiderPlaceholder: true,\n type: 'htmlbars-parallel',\n requireFile: object.parallelBabel.requireFile,\n packageVersion: maybeNodeModuleVersion(object.parallelBabel.requireFile),\n buildUsing: String(object.parallelBabel.buildUsing),\n params: object.parallelBabel.params,\n };\n }\n}\n\nfunction buildHTMLBars(parallelApiInfo: HTMLBarsParallelPlaceholder) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let requiredStuff = require(parallelApiInfo.requireFile);\n if (typeof requiredStuff[parallelApiInfo.buildUsing] !== 'function') {\n throw new Error(\"'\" + parallelApiInfo.buildUsing + \"' is not a function in file \" + parallelApiInfo.requireFile);\n }\n return requiredStuff[parallelApiInfo.buildUsing](parallelApiInfo.params);\n}\n\nfunction globalPlaceholder(value: any): { value: GlobalPlaceholder; isParallelSafe: false; needsHydrate: true } {\n let index = globalValues.length;\n globalValues.push(value);\n return {\n value: {\n embroiderPlaceholder: true,\n type: 'global',\n nonce,\n index,\n },\n isParallelSafe: false,\n needsHydrate: true,\n };\n}\n"]}
1
+ {"version":3,"file":"portable.js","sourceRoot":"","sources":["portable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyC;AACzC,gEAAuC;AACvC,2DAA6C;AAC7C,gFAAsD;AAEzC,QAAA,QAAQ,GAAG,+BAA+B,CAAC;AACxD,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,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EACpD,CAAC;QACD,OAAO;YACL,oBAAoB,EAAE,IAAI;YAC1B,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC,WAAW;YAC7C,cAAc,EAAE,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;YACxE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC;YACnD,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM;SACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,eAA4C;IACjE,iEAAiE;IACjE,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACzD,IAAI,OAAO,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,eAAe,CAAC,UAAU,GAAG,8BAA8B,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IACnH,CAAC;IACD,OAAO,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU;IACnC,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC;IAChC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO;QACL,KAAK,EAAE;YACL,oBAAoB,EAAE,IAAI;YAC1B,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,KAAK;SACN;QACD,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import mapValues from 'lodash/mapValues';\nimport assertNever from 'assert-never';\nimport { Memoize } from 'typescript-memoize';\nimport resolvePackagePath from 'resolve-package-path';\n\nexport const protocol = '__embroider_portable_values__';\nconst { globalValues, nonce } = setupGlobals();\n\nexport interface PortableResult {\n value: any;\n isParallelSafe: boolean;\n needsHydrate: boolean;\n}\n\nexport interface PortableHint {\n requireFile: string;\n packageVersion: string | undefined;\n useMethod?: string;\n}\n\nconst { findUpPackagePath } = resolvePackagePath;\n\nexport function maybeNodeModuleVersion(path: string) {\n const packagePath = findUpPackagePath(path);\n\n if (packagePath === null) {\n throw new Error(`Could not find package.json for '${path}'`);\n } else {\n return require(packagePath).version; // eslint-disable-line @typescript-eslint/no-require-imports\n }\n}\n\nexport class Portable {\n constructor(\n private opts: {\n dehydrate?: (value: any, accessPath: string[]) => PortableResult | undefined;\n hydrate?: (value: any, accessPath: string[]) => { value: any } | undefined;\n hints?: PortableHint[];\n } = {}\n ) {}\n\n dehydrate(value: any, accessPath: string[] = []): PortableResult {\n if (this.opts.dehydrate) {\n let result = this.opts.dehydrate.call(this, value, accessPath);\n if (result) {\n return result;\n }\n }\n\n if (value === null) {\n return { value, isParallelSafe: true, needsHydrate: false };\n }\n\n let broccoli = maybeBroccoli(value);\n if (broccoli) {\n return { value: broccoli, isParallelSafe: true, needsHydrate: true };\n }\n\n let htmlbars = maybeHTMLBars(value);\n if (htmlbars) {\n return { value: htmlbars, isParallelSafe: true, needsHydrate: true };\n }\n\n if (Array.isArray(value)) {\n let results = value.map((element, index) => this.dehydrate(element, accessPath.concat(String(index))));\n return {\n value: results.map(r => r.value),\n isParallelSafe: results.every(r => r.isParallelSafe),\n needsHydrate: results.some(r => r.needsHydrate),\n };\n }\n\n switch (typeof value) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'undefined':\n return { value, isParallelSafe: true, needsHydrate: false };\n case 'object':\n if (Object.getPrototypeOf(value) === Object.prototype) {\n let isParallelSafe = true;\n let needsHydrate = false;\n let result = mapValues(value, (propertyValue, key) => {\n let result = this.dehydrate(propertyValue, accessPath.concat(key));\n isParallelSafe = isParallelSafe && result.isParallelSafe;\n needsHydrate = needsHydrate || result.needsHydrate;\n return result.value;\n });\n return { value: result, isParallelSafe, needsHydrate };\n }\n }\n\n let found = this.foundHints.get(value);\n if (found) {\n return {\n value: {\n embroiderPlaceholder: true,\n type: 'broccoli-parallel',\n requireFile: found.requireFile,\n packageVersion: maybeNodeModuleVersion(found.requireFile),\n useMethod: found.useMethod,\n },\n isParallelSafe: true,\n needsHydrate: true,\n };\n }\n\n return globalPlaceholder(value);\n }\n\n hydrate(input: any, accessPath: string[] = []): any {\n if (this.opts.hydrate) {\n let result = this.opts.hydrate.call(this, input, accessPath);\n if (result) {\n return result;\n }\n }\n if (Array.isArray(input)) {\n return input.map((element, index) => this.hydrate(element, accessPath.concat(String(index))));\n }\n if (input && typeof input === 'object') {\n if (input.embroiderPlaceholder) {\n let placeholder = input as Placeholder;\n switch (placeholder.type) {\n case 'global':\n if (placeholder.nonce !== nonce) {\n throw new Error(`unable to use this non-serializable babel config in this node process`);\n }\n return globalValues[placeholder.index];\n case 'broccoli-parallel':\n return buildBroccoli(placeholder);\n case 'htmlbars-parallel':\n return buildHTMLBars(placeholder);\n default:\n assertNever(placeholder);\n }\n } else {\n return mapValues(input, (value, key) => this.hydrate(value, accessPath.concat(key)));\n }\n }\n return input;\n }\n\n @Memoize()\n get foundHints(): Map<any, PortableHint> {\n let found = new Map();\n if (this.opts.hints) {\n for (let hint of this.opts.hints) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let mod = require(hint.requireFile);\n if (hint.useMethod) {\n mod = mod[hint.useMethod];\n }\n found.set(mod, hint);\n }\n }\n return found;\n }\n}\n\ninterface GlobalPlaceholder {\n embroiderPlaceholder: true;\n type: 'global';\n nonce: number;\n index: number;\n}\n\ninterface BroccoliParallelPlaceholder {\n embroiderPlaceholder: true;\n type: 'broccoli-parallel';\n requireFile: string;\n packageVersion: string | undefined;\n useMethod: string | undefined;\n buildUsing: string | undefined;\n params: any;\n}\n\ninterface HTMLBarsParallelPlaceholder {\n embroiderPlaceholder: true;\n type: 'htmlbars-parallel';\n packageVersion: string | undefined;\n requireFile: string;\n buildUsing: string;\n params: any;\n}\n\ntype Placeholder = GlobalPlaceholder | BroccoliParallelPlaceholder | HTMLBarsParallelPlaceholder;\n\nfunction setupGlobals() {\n let G = global as any as { [protocol]: { globalValues: any[]; nonce: number } };\n if (!G[protocol]) {\n G[protocol] = { globalValues: [], nonce: Math.floor(Math.random() * Math.pow(2, 32)) };\n }\n return G[protocol];\n}\n\n// === broccoli-babel-transpiler support ===\n\nfunction maybeBroccoli(object: any): BroccoliParallelPlaceholder | undefined {\n const type = typeof object;\n const hasProperties = type === 'function' || (type === 'object' && object !== null);\n\n if (\n hasProperties &&\n object._parallelBabel !== null &&\n typeof object._parallelBabel === 'object' &&\n typeof object._parallelBabel.requireFile === 'string'\n ) {\n return {\n embroiderPlaceholder: true,\n type: 'broccoli-parallel',\n requireFile: object._parallelBabel.requireFile,\n packageVersion: maybeNodeModuleVersion(object._parallelBabel.requireFile),\n buildUsing: object._parallelBabel.buildUsing,\n useMethod: object._parallelBabel.useMethod,\n params: object._parallelBabel.params,\n };\n }\n}\n\nfunction buildBroccoli(parallelApiInfo: BroccoliParallelPlaceholder) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let requiredStuff = require(parallelApiInfo.requireFile);\n\n if (parallelApiInfo.useMethod) {\n if (requiredStuff[parallelApiInfo.useMethod] === undefined) {\n throw new Error(\n \"method '\" + parallelApiInfo.useMethod + \"' does not exist in file \" + parallelApiInfo.requireFile\n );\n }\n return requiredStuff[parallelApiInfo.useMethod];\n }\n\n if (parallelApiInfo.buildUsing) {\n if (typeof requiredStuff[parallelApiInfo.buildUsing] !== 'function') {\n throw new Error(\"'\" + parallelApiInfo.buildUsing + \"' is not a function in file \" + parallelApiInfo.requireFile);\n }\n return requiredStuff[parallelApiInfo.buildUsing](parallelApiInfo.params);\n }\n\n return requiredStuff;\n}\n\n// ember-cli-htmlbars-inline-precompile support ===\nfunction maybeHTMLBars(object: any): HTMLBarsParallelPlaceholder | undefined {\n const type = typeof object;\n const hasProperties = type === 'function' || (type === 'object' && object !== null);\n\n if (\n hasProperties &&\n object.parallelBabel !== null &&\n typeof object.parallelBabel === 'object' &&\n typeof object.parallelBabel.requireFile === 'string'\n ) {\n return {\n embroiderPlaceholder: true,\n type: 'htmlbars-parallel',\n requireFile: object.parallelBabel.requireFile,\n packageVersion: maybeNodeModuleVersion(object.parallelBabel.requireFile),\n buildUsing: String(object.parallelBabel.buildUsing),\n params: object.parallelBabel.params,\n };\n }\n}\n\nfunction buildHTMLBars(parallelApiInfo: HTMLBarsParallelPlaceholder) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let requiredStuff = require(parallelApiInfo.requireFile);\n if (typeof requiredStuff[parallelApiInfo.buildUsing] !== 'function') {\n throw new Error(\"'\" + parallelApiInfo.buildUsing + \"' is not a function in file \" + parallelApiInfo.requireFile);\n }\n return requiredStuff[parallelApiInfo.buildUsing](parallelApiInfo.params);\n}\n\nfunction globalPlaceholder(value: any): { value: GlobalPlaceholder; isParallelSafe: false; needsHydrate: true } {\n let index = globalValues.length;\n globalValues.push(value);\n return {\n value: {\n embroiderPlaceholder: true,\n type: 'global',\n nonce,\n index,\n },\n isParallelSafe: false,\n needsHydrate: true,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAwC;AAExC,uDAA6C;AAC7C,kEAAwE;AACxE,+BAA4B;AAE5B,2BAAsC;AAEtC,MAAa,cAAc;IAKzB,YAAqB,OAAe,EAAE,KAAK,GAAG,KAAK;QAA9B,YAAO,GAAP,OAAO,CAAQ;QAJpC,2CAAgC;QAChC,6CAAoB;QACpB,0CAAgC;QAG9B,uBAAA,IAAI,8BAAe,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,MAAA,CAAC;QAClF,IAAI,KAAK,EAAE;YACT,uBAAA,IAAI,2BAAY,IAAA,UAAO,EAAC,uBAAA,IAAI,kCAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE;gBACpE,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;YAC7B,CAAC,CAAC,MAAA,CAAC;SACJ;IACH,CAAC;IAED,KAAK;;QACH,MAAA,uBAAA,IAAI,+BAAS,0CAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,uBAAA,IAAI,gCAAU,EAAE;YACnB,IAAI,MAAM,GAAY,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YACnG,uBAAA,IAAI,4BAAa,IAAI,0BAAQ,CAAC,MAAM,CAAC,MAAA,CAAC;SACvC;QACD,OAAO,uBAAA,IAAI,gCAAU,CAAC;IACxB,CAAC;CACF;AAzBD,wCAyBC","sourcesContent":["import { readJSONSync } from 'fs-extra';\nimport type { Options } from './module-resolver';\nimport { Resolver } from './module-resolver';\nimport { locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport { join } from 'path';\nimport type { FSWatcher } from 'fs';\nimport { watch as fsWatch } from 'fs';\n\nexport class ResolverLoader {\n #resolver: Resolver | undefined;\n #configFile: string;\n #watcher: FSWatcher | undefined;\n\n constructor(readonly appRoot: string, watch = false) {\n this.#configFile = join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json');\n if (watch) {\n this.#watcher = fsWatch(this.#configFile, { persistent: false }, () => {\n this.#resolver = undefined;\n });\n }\n }\n\n close() {\n this.#watcher?.close();\n }\n\n get resolver(): Resolver {\n if (!this.#resolver) {\n let config: Options = readJSONSync(join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json'));\n this.#resolver = new Resolver(config);\n }\n return this.#resolver;\n }\n}\n"]}
1
+ {"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAwC;AAExC,uDAA6C;AAC7C,kEAAwE;AACxE,+BAA4B;AAE5B,2BAAsC;AAEtC,MAAa,cAAc;IAKzB,YAAqB,OAAe,EAAE,KAAK,GAAG,KAAK;QAA9B,YAAO,GAAP,OAAO,CAAQ;QAJpC,2CAAgC;QAChC,6CAAoB;QACpB,0CAAgC;QAG9B,uBAAA,IAAI,8BAAe,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,MAAA,CAAC;QAClF,IAAI,KAAK,EAAE,CAAC;YACV,uBAAA,IAAI,2BAAY,IAAA,UAAO,EAAC,uBAAA,IAAI,kCAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE;gBACpE,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;YAC7B,CAAC,CAAC,MAAA,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK;;QACH,MAAA,uBAAA,IAAI,+BAAS,0CAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,uBAAA,IAAI,gCAAU,EAAE,CAAC;YACpB,IAAI,MAAM,GAAY,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YACnG,uBAAA,IAAI,4BAAa,IAAI,0BAAQ,CAAC,MAAM,CAAC,MAAA,CAAC;QACxC,CAAC;QACD,OAAO,uBAAA,IAAI,gCAAU,CAAC;IACxB,CAAC;CACF;AAzBD,wCAyBC","sourcesContent":["import { readJSONSync } from 'fs-extra';\nimport type { Options } from './module-resolver';\nimport { Resolver } from './module-resolver';\nimport { locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport { join } from 'path';\nimport type { FSWatcher } from 'fs';\nimport { watch as fsWatch } from 'fs';\n\nexport class ResolverLoader {\n #resolver: Resolver | undefined;\n #configFile: string;\n #watcher: FSWatcher | undefined;\n\n constructor(readonly appRoot: string, watch = false) {\n this.#configFile = join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json');\n if (watch) {\n this.#watcher = fsWatch(this.#configFile, { persistent: false }, () => {\n this.#resolver = undefined;\n });\n }\n }\n\n close() {\n this.#watcher?.close();\n }\n\n get resolver(): Resolver {\n if (!this.#resolver) {\n let config: Options = readJSONSync(join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json'));\n this.#resolver = new Resolver(config);\n }\n return this.#resolver;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"to-broccoli-plugin.js","sourceRoot":"","sources":["to-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AAAA,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;gBAClB,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;aACH;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AA3BD,mCA2BC","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"]}
1
+ {"version":3,"file":"to-broccoli-plugin.js","sourceRoot":"","sources":["to-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AAAA,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;AA3BD,mCA2BC","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"]}
@@ -1,8 +1,12 @@
1
1
  import type { Resolver } from '.';
2
- export declare function virtualContent(filename: string, resolver: Resolver): string;
2
+ export interface VirtualContentResult {
3
+ src: string;
4
+ watches: string[];
5
+ }
6
+ export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
3
7
  export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
4
8
  export declare function virtualExternalCJSModule(specifier: string): string;
5
- export declare function virtualPairComponent(hbsModule: string, jsModule: string | null): string;
9
+ export declare function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string;
6
10
  export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
7
11
  export declare function decodeFastbootSwitch(filename: string): {
8
12
  names: string[];
@@ -4,6 +4,10 @@ exports.decodeImplicitModules = exports.decodeFastbootSwitch = exports.fastbootS
4
4
  const path_1 = require("path");
5
5
  const _1 = require(".");
6
6
  const js_handlebars_1 = require("./js-handlebars");
7
+ const virtual_test_support_1 = require("./virtual-test-support");
8
+ const virtual_test_support_styles_1 = require("./virtual-test-support-styles");
9
+ const virtual_vendor_1 = require("./virtual-vendor");
10
+ const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
7
11
  const externalESPrefix = '/@embroider/ext-es/';
8
12
  const externalCJSPrefix = '/@embroider/ext-cjs/';
9
13
  // Given a filename that was passed to your ModuleRequest's `virtualize()`,
@@ -25,12 +29,28 @@ function virtualContent(filename, resolver) {
25
29
  }
26
30
  let fb = decodeFastbootSwitch(filename);
27
31
  if (fb) {
28
- return fastbootSwitchTemplate(fb);
32
+ return renderFastbootSwitchTemplate(fb);
29
33
  }
30
34
  let im = decodeImplicitModules(filename);
31
35
  if (im) {
32
36
  return renderImplicitModules(im, resolver);
33
37
  }
38
+ let isVendor = (0, virtual_vendor_1.decodeVirtualVendor)(filename);
39
+ if (isVendor) {
40
+ return (0, virtual_vendor_1.renderVendor)(filename, resolver);
41
+ }
42
+ let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
43
+ if (isImplicitTestScripts) {
44
+ return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
45
+ }
46
+ let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
47
+ if (isVendorStyles) {
48
+ return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
49
+ }
50
+ let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
51
+ if (isTestSupportStyles) {
52
+ return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
53
+ }
34
54
  throw new Error(`not an @embroider/core virtual file: ${filename}`);
35
55
  }
36
56
  exports.virtualContent = virtualContent;
@@ -51,14 +71,23 @@ export { {{#each names as |name|}}{{name}}, {{/each}} }
51
71
  {{/if}}
52
72
  {{/if}}
53
73
  `);
54
- function renderESExternalShim({ moduleName, exports }) {
55
- return externalESShim({
56
- moduleName,
57
- default: exports.includes('default'),
58
- names: exports.filter(n => n !== 'default'),
59
- });
74
+ function renderESExternalShim({ moduleName, exports, }) {
75
+ return {
76
+ src: externalESShim({
77
+ moduleName,
78
+ default: exports.includes('default'),
79
+ names: exports.filter(n => n !== 'default'),
80
+ }),
81
+ watches: [],
82
+ };
60
83
  }
61
- const pairedComponentShim = (0, js_handlebars_1.compile)(`
84
+ function pairedComponentShim(params) {
85
+ return {
86
+ src: pairedComponentShimTemplate(params),
87
+ watches: [],
88
+ };
89
+ }
90
+ const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
62
91
  import { setComponentTemplate } from "@ember/component";
63
92
  import template from "{{{js-string-escape relativeHBSModule}}}";
64
93
  {{#if relativeJSModule}}
@@ -71,7 +100,7 @@ export default setComponentTemplate(template, templateOnlyComponent(undefined, "
71
100
  `);
72
101
  function virtualExternalESModule(specifier, exports) {
73
102
  if (exports) {
74
- return externalESPrefix + specifier + `?exports=${exports.join(',')}`;
103
+ return externalESPrefix + specifier + `/exports=${exports.join(',')}`;
75
104
  }
76
105
  else {
77
106
  return externalESPrefix + specifier;
@@ -85,12 +114,12 @@ exports.virtualExternalCJSModule = virtualExternalCJSModule;
85
114
  function decodeVirtualExternalESModule(filename) {
86
115
  if (filename.startsWith(externalESPrefix)) {
87
116
  let exports = [];
88
- let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');
89
- let nameString = url.searchParams.get('exports');
117
+ let components = filename.split('/exports=');
118
+ let nameString = components[1];
90
119
  if (nameString) {
91
120
  exports = nameString.split(',');
92
121
  }
93
- let moduleName = url.pathname.slice(1);
122
+ let moduleName = components[0].slice(externalESPrefix.length);
94
123
  return { moduleName, exports };
95
124
  }
96
125
  }
@@ -156,6 +185,12 @@ function decodeFastbootSwitch(filename) {
156
185
  }
157
186
  }
158
187
  exports.decodeFastbootSwitch = decodeFastbootSwitch;
188
+ function renderFastbootSwitchTemplate(params) {
189
+ return {
190
+ src: fastbootSwitchTemplate(params),
191
+ watches: [],
192
+ };
193
+ }
159
194
  const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
160
195
  import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
161
196
  let mod;
@@ -192,8 +227,8 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
192
227
  if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
193
228
  throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
194
229
  }
195
- let lazyModules = [];
196
- let eagerModules = [];
230
+ let ownModules = [];
231
+ let dependencyModules = [];
197
232
  let deps = pkg.dependencies.sort(orderAddons);
198
233
  for (let dep of deps) {
199
234
  // anything that isn't a v2 ember package by this point is not an active
@@ -226,7 +261,7 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
226
261
  runtime = renamedModules[runtimeRenameLookup];
227
262
  }
228
263
  runtime = runtime.split(path_1.sep).join('/');
229
- lazyModules.push({
264
+ ownModules.push({
230
265
  runtime,
231
266
  buildtime: path_1.posix.join(packageName, name),
232
267
  });
@@ -235,20 +270,32 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
235
270
  // we don't recurse across an engine boundary. Engines import their own
236
271
  // implicit-modules.
237
272
  if (!dep.isEngine()) {
238
- eagerModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
273
+ dependencyModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
239
274
  }
240
275
  }
241
- return implicitModulesTemplate({ lazyModules, eagerModules });
276
+ return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };
242
277
  }
243
278
  const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
244
- import { importSync as i } from '@embroider/macros';
245
- let d = window.define;
246
- {{#each lazyModules as |module|}}
247
- d("{{js-string-escape module.runtime}}", function(){ return i("{{js-string-escape module.buildtime}}");});
279
+
280
+
281
+ {{#each dependencyModules as |module index|}}
282
+ import dep{{index}} from "{{js-string-escape module}}";
248
283
  {{/each}}
249
- {{#each eagerModules as |module|}}
250
- import "{{js-string-escape module}}";
284
+
285
+ {{#each ownModules as |module index|}}
286
+ import * as own{{index}} from "{{js-string-escape module.buildtime}}";
251
287
  {{/each}}
288
+
289
+ export default Object.assign({},
290
+ {{#each dependencyModules as |module index|}}
291
+ dep{{index}},
292
+ {{/each}}
293
+ {
294
+ {{#each ownModules as |module index|}}
295
+ "{{js-string-escape module.runtime}}": own{{index}},
296
+ {{/each}}
297
+ }
298
+ );
252
299
  `);
253
300
  // meta['renamed-modules'] has mapping from classic filename to real filename.
254
301
  // This takes that and converts it to the inverst mapping from real import path
@@ -274,26 +321,41 @@ function orderAddons(depA, depB) {
274
321
  }
275
322
  return depAIdx - depBIdx;
276
323
  }
277
- const renderCJSExternalShim = (0, js_handlebars_1.compile)(`
278
- {{#if (eq moduleName "require")}}
279
- const m = window.requirejs;
280
- {{else}}
281
- const m = window.require("{{{js-string-escape moduleName}}}");
282
- {{/if}}
283
- {{!-
284
- There are plenty of hand-written AMD defines floating around
285
- that lack this, and they will break when other build systems
286
- encounter them.
324
+ function renderCJSExternalShim(params) {
325
+ return {
326
+ src: renderCJSExternalShimTemplate(params),
327
+ watches: [],
328
+ };
329
+ }
330
+ const renderCJSExternalShimTemplate = (0, js_handlebars_1.compile)(`
331
+ module.exports = new Proxy({}, {
332
+ get(target, prop) {
333
+
334
+ {{!- our proxy always presents as ES module so that we can intercept "get('default')" -}}
335
+ if (prop === '__esModule') {
336
+ return true;
337
+ }
287
338
 
288
- As far as I can tell, Ember's loader was already treating this
289
- case as a module, so in theory we aren't breaking anything by
290
- marking it as such when other packagers come looking.
339
+ {{#if (eq moduleName "require")}}
340
+ const m = window.requirejs;
341
+ {{else}}
342
+ const m = window.require("{{{js-string-escape moduleName}}}");
343
+ {{/if}}
291
344
 
292
- todo: get review on this part.
293
- -}}
294
- if (m.default && !m.__esModule) {
295
- m.__esModule = true;
296
- }
297
- module.exports = m;
345
+ {{!-
346
+ There are plenty of hand-written AMD defines floating around
347
+ that lack an __esModule declaration.
348
+
349
+ As far as I can tell, Ember's loader was already treating the Boolean(m.default)===true
350
+ case as a module, so in theory we aren't breaking anything by
351
+ treating it as such when other packagers come looking.
352
+ -}}
353
+ if (prop === 'default' && !m.__esModule && !m.default) {
354
+ return m;
355
+ }
356
+
357
+ return m[prop];
358
+ }
359
+ });
298
360
  `);
299
361
  //# sourceMappingURL=virtual-content.js.map