@embroider/compat 3.7.1-unstable.3e8dbe3 → 3.7.1-unstable.57e628d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,42 +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.stableWorkspaceDir = stableWorkspaceDir;
7
- exports.default = defaultPipeline;
8
6
  exports.prebuild = prebuild;
9
7
  const options_1 = require("./options");
10
8
  const _1 = require(".");
11
- const core_1 = require("@embroider/core");
12
- const core_2 = require("@embroider/core");
13
9
  const broccoli_file_creator_1 = __importDefault(require("broccoli-file-creator"));
14
10
  const broccoli_merge_trees_1 = __importDefault(require("broccoli-merge-trees"));
15
- const crypto_1 = require("crypto");
16
- const path_1 = require("path");
17
- const pkg_up_1 = require("pkg-up");
18
- function stableWorkspaceDir(appRoot, environment) {
19
- let hash = (0, crypto_1.createHash)('md5');
20
- hash.update((0, path_1.dirname)((0, pkg_up_1.sync)({ cwd: appRoot })));
21
- hash.update(environment);
22
- return (0, path_1.join)(core_2.tmpdir, 'embroider', hash.digest('hex').slice(0, 6));
23
- }
24
- function defaultPipeline(emberApp, packager, options = {}) {
25
- let outputPath;
26
- let addons;
27
- let embroiderApp = new _1.App(emberApp, options);
28
- addons = new _1.Addons(embroiderApp);
29
- addons.ready().then(result => {
30
- outputPath = result.outputPath;
31
- });
32
- if (process.env.STAGE1_ONLY) {
33
- return (0, broccoli_merge_trees_1.default)([addons.tree, (0, broccoli_file_creator_1.default)('.stage1-output', () => outputPath)]);
34
- }
35
- if (process.env.STAGE2_ONLY || !packager) {
36
- return (0, broccoli_merge_trees_1.default)([embroiderApp.asStage(addons).tree, (0, broccoli_file_creator_1.default)('.stage2-output', () => outputPath)]);
37
- }
38
- let BroccoliPackager = (0, core_1.toBroccoliPlugin)(packager);
39
- let variants = (options && options.variants) || defaultVariants(emberApp);
40
- return new BroccoliPackager(embroiderApp.asStage(addons), variants, options && options.packagerOptions);
41
- }
42
11
  const defaultPrebuildOptions = {
43
12
  ...options_1.recommendedOptions.optimized,
44
13
  amdCompatibility: {
@@ -58,32 +27,4 @@ function prebuild(emberApp, options) {
58
27
  }
59
28
  return (0, broccoli_merge_trees_1.default)([embroiderApp.asStage(addons).tree, (0, broccoli_file_creator_1.default)('.stage2-output', () => outputPath)]);
60
29
  }
61
- function hasFastboot(emberApp) {
62
- return emberApp.project.addons.find(a => a.name === 'ember-cli-fastboot');
63
- }
64
- function defaultVariants(emberApp) {
65
- let variants = [];
66
- if (emberApp.env === 'production') {
67
- variants.push({
68
- name: 'browser',
69
- runtime: 'browser',
70
- optimizeForProduction: true,
71
- });
72
- if (hasFastboot(emberApp)) {
73
- variants.push({
74
- name: 'fastboot',
75
- runtime: 'fastboot',
76
- optimizeForProduction: true,
77
- });
78
- }
79
- }
80
- else {
81
- variants.push({
82
- name: 'dev',
83
- runtime: hasFastboot(emberApp) ? 'all' : 'browser',
84
- optimizeForProduction: false,
85
- });
86
- }
87
- return variants;
88
- }
89
30
  //# sourceMappingURL=default-pipeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-pipeline.js","sourceRoot":"","sources":["default-pipeline.ts"],"names":[],"mappings":";;;;;AAkBA,gDAKC;AAED,kCA0BC;AASD,4BAgBC;AA3ED,uCAA+C;AAC/C,wBAAgD;AAEhD,0CAAmD;AACnD,0CAAyC;AAEzC,kFAA8C;AAC9C,gFAA8C;AAC9C,mCAAoC;AACpC,+BAAqC;AACrC,mCAA2C;AAO3C,SAAgB,kBAAkB,CAAC,OAAe,EAAE,WAAmB;IACrE,IAAI,IAAI,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,IAAA,cAAO,EAAC,IAAA,aAAS,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAE,CAAC,CAAC,CAA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,eAAe,CAAC,QAA0B;IACjD,IAAI,QAAQ,GAAc,EAAE,CAAC;IAC7B,IAAI,QAAQ,CAAC,GAAG,KAAK,YAAY,EAAE,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,SAAS;YAClB,qBAAqB,EAAE,IAAI;SAC5B,CAAC,CAAC;QACH,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,UAAU;gBACnB,qBAAqB,EAAE,IAAI;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAClD,qBAAqB,EAAE,KAAK;SAC7B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type Options from './options';\nimport { recommendedOptions } from './options';\nimport { App, Addons as CompatAddons } from '.';\nimport type { PackagerConstructor, Variant, EmberAppInstance } from '@embroider/core';\nimport { toBroccoliPlugin } from '@embroider/core';\nimport { tmpdir } from '@embroider/core';\nimport type { Node } from 'broccoli-node-api';\nimport writeFile from 'broccoli-file-creator';\nimport mergeTrees from 'broccoli-merge-trees';\nimport { createHash } from 'crypto';\nimport { join, dirname } from 'path';\nimport { sync as pkgUpSync } from 'pkg-up';\n\nexport interface PipelineOptions<PackagerOptions> extends Options {\n packagerOptions?: PackagerOptions;\n variants?: Variant[];\n}\n\nexport function stableWorkspaceDir(appRoot: string, environment: string) {\n let hash = createHash('md5');\n hash.update(dirname(pkgUpSync({ cwd: appRoot })!));\n hash.update(environment);\n return join(tmpdir, 'embroider', hash.digest('hex').slice(0, 6));\n}\n\nexport default function defaultPipeline<PackagerOptions>(\n emberApp: EmberAppInstance,\n packager?: PackagerConstructor<PackagerOptions>,\n options: PipelineOptions<PackagerOptions> = {}\n): Node {\n let outputPath: string;\n let addons;\n\n let embroiderApp = new App(emberApp, options);\n\n addons = new CompatAddons(embroiderApp);\n addons.ready().then(result => {\n outputPath = result.outputPath;\n });\n\n if (process.env.STAGE1_ONLY) {\n return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);\n }\n\n if (process.env.STAGE2_ONLY || !packager) {\n return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);\n }\n\n let BroccoliPackager = toBroccoliPlugin(packager);\n let variants = (options && options.variants) || defaultVariants(emberApp);\n return new BroccoliPackager(embroiderApp.asStage(addons), variants, options && options.packagerOptions);\n}\n\nconst defaultPrebuildOptions = {\n ...recommendedOptions.optimized,\n amdCompatibility: {\n es: [],\n },\n};\n\nexport function prebuild(emberApp: EmberAppInstance, options?: Options): Node {\n let outputPath: string;\n let addons;\n\n let embroiderApp = new App(emberApp, { ...defaultPrebuildOptions, ...options });\n\n addons = new CompatAddons(embroiderApp);\n addons.ready().then(result => {\n outputPath = result.outputPath;\n });\n\n if (process.env.STAGE1_ONLY) {\n return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);\n }\n\n return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);\n}\n\nfunction hasFastboot(emberApp: EmberAppInstance | EmberAppInstance) {\n return emberApp.project.addons.find(a => a.name === 'ember-cli-fastboot');\n}\n\nfunction defaultVariants(emberApp: EmberAppInstance): Variant[] {\n let variants: Variant[] = [];\n if (emberApp.env === 'production') {\n variants.push({\n name: 'browser',\n runtime: 'browser',\n optimizeForProduction: true,\n });\n if (hasFastboot(emberApp)) {\n variants.push({\n name: 'fastboot',\n runtime: 'fastboot',\n optimizeForProduction: true,\n });\n }\n } else {\n variants.push({\n name: 'dev',\n runtime: hasFastboot(emberApp) ? 'all' : 'browser',\n optimizeForProduction: false,\n });\n }\n return variants;\n}\n"]}
1
+ {"version":3,"file":"default-pipeline.js","sourceRoot":"","sources":["default-pipeline.ts"],"names":[],"mappings":";;;;;AAoBA,4BAgBC;AAnCD,uCAA+C;AAC/C,wBAAgD;AAGhD,kFAA8C;AAC9C,gFAA8C;AAO9C,MAAM,sBAAsB,GAAG;IAC7B,GAAG,4BAAkB,CAAC,SAAS;IAC/B,gBAAgB,EAAE;QAChB,EAAE,EAAE,EAAE;KACP;CACF,CAAC;AAEF,SAAgB,QAAQ,CAAC,QAA0B,EAAE,OAAiB;IACpE,IAAI,UAAkB,CAAC;IACvB,IAAI,MAAM,CAAC;IAEX,IAAI,YAAY,GAAG,IAAI,MAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,sBAAsB,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEhF,MAAM,GAAG,IAAI,SAAY,CAAC,YAAY,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC3B,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,IAAA,8BAAU,EAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAA,+BAAS,EAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,IAAA,8BAAU,EAAC,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAA,+BAAS,EAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC","sourcesContent":["import type Options from './options';\nimport { recommendedOptions } from './options';\nimport { App, Addons as CompatAddons } from '.';\nimport type { Variant, EmberAppInstance } from '@embroider/core';\nimport type { Node } from 'broccoli-node-api';\nimport writeFile from 'broccoli-file-creator';\nimport mergeTrees from 'broccoli-merge-trees';\n\nexport interface PipelineOptions<PackagerOptions> extends Options {\n packagerOptions?: PackagerOptions;\n variants?: Variant[];\n}\n\nconst defaultPrebuildOptions = {\n ...recommendedOptions.optimized,\n amdCompatibility: {\n es: [],\n },\n};\n\nexport function prebuild(emberApp: EmberAppInstance, options?: Options): Node {\n let outputPath: string;\n let addons;\n\n let embroiderApp = new App(emberApp, { ...defaultPrebuildOptions, ...options });\n\n addons = new CompatAddons(embroiderApp);\n addons.ready().then(result => {\n outputPath = result.outputPath;\n });\n\n if (process.env.STAGE1_ONLY) {\n return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);\n }\n\n return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);\n}\n"]}
@@ -59,6 +59,7 @@ export interface PreprocessedComponentRule {
59
59
  safeToIgnore: boolean;
60
60
  safeInteriorPaths: string[];
61
61
  disambiguate: Record<string, 'component' | 'helper' | 'data'>;
62
+ invokes: Required<ComponentRules>['invokes'];
62
63
  }
63
64
  export declare function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule;
64
65
  export declare function activePackageRules(packageRules: PackageRules[], activePackages: {
@@ -10,7 +10,7 @@ const resolve_exports_1 = require("resolve.exports");
10
10
  // take a component rule from the authoring format to a format more optimized
11
11
  // for consumption in the resolver
12
12
  function preprocessComponentRule(componentRules) {
13
- var _a;
13
+ var _a, _b;
14
14
  let argumentsAreComponents = [];
15
15
  let safeInteriorPaths = [];
16
16
  if (componentRules.acceptsComponentArguments) {
@@ -44,6 +44,7 @@ function preprocessComponentRule(componentRules) {
44
44
  yieldsSafeComponents: componentRules.yieldsSafeComponents || [],
45
45
  yieldsArguments: componentRules.yieldsArguments || [],
46
46
  disambiguate: (_a = componentRules === null || componentRules === void 0 ? void 0 : componentRules.disambiguate) !== null && _a !== void 0 ? _a : {},
47
+ invokes: (_b = componentRules === null || componentRules === void 0 ? void 0 : componentRules.invokes) !== null && _b !== void 0 ? _b : {},
47
48
  };
48
49
  }
49
50
  function activePackageRules(packageRules, activePackages) {
@@ -1 +1 @@
1
- {"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;AA8KA,0DAkCC;AAED,gDAqBC;AAED,0CAkBC;AA1PD,0CAA8C;AAC9C,+BAAuD;AACvD,mCAAmC;AACnC,qDAA4D;AAwK5D,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;QAC7C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;YAC3D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;YAC3B,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;YAC3C,iBAAiB,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,I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C,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,QAAkB;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC;YACpB,0EAA0E;YAC1E,8EAA8E;YAC9E,6EAA6E;YAC7E,wCAAwC;YACxC,OAAO,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,iBAAiB;YACjB,IAAI,OAAO,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5D,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,IAAA,cAAO,EAAC,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { getOrCreate } from '@embroider/core';\nimport { resolve as pathResolve, dirname } from 'path';\nimport { satisfies } from 'semver';\nimport { resolve as resolveExports } from 'resolve.exports';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(\n packageRules: PackageRules[],\n activePackages: { name: string; root: string; version: string }[]\n): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function appTreeRulesDir(root: string, resolver: Resolver) {\n let pkg = resolver.packageCache.ownerOfFile(root);\n if (pkg) {\n if (pkg.isV2Addon()) {\n // in general v2 addons can keep their app tree stuff in other places than\n // \"_app_\" and we would need to check their package.json to see. But this code\n // is only for applying packageRules to auto-upgraded v1 addons and apps, and\n // those we always organize predictably.\n return pathResolve(root, '_app_');\n } else {\n // this is an app\n let matched = resolveExports(pkg.packageJSON, './index.js');\n if (matched) {\n return dirname(pathResolve(root, matched[0]));\n }\n }\n }\n return root;\n}\n"]}
1
+ {"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;AA+KA,0DAmCC;AAED,gDAqBC;AAED,0CAkBC;AA5PD,0CAA8C;AAC9C,+BAAuD;AACvD,mCAAmC;AACnC,qDAA4D;AAyK5D,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;QAC7C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC;YAC3D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;YAC3B,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;YAC3C,iBAAiB,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,IAAI,cAAc,CAAC,O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IAChB,KAAK,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,QAAkB;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC;YACpB,0EAA0E;YAC1E,8EAA8E;YAC9E,6EAA6E;YAC7E,wCAAwC;YACxC,OAAO,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,iBAAiB;YACjB,IAAI,OAAO,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5D,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,IAAA,cAAO,EAAC,IAAA,cAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { getOrCreate } from '@embroider/core';\nimport { resolve as pathResolve, dirname } from 'path';\nimport { satisfies } from 'semver';\nimport { resolve as resolveExports } from 'resolve.exports';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n invokes: Required<ComponentRules>['invokes'];\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n invokes: componentRules?.invokes ?? {},\n };\n}\n\nexport function activePackageRules(\n packageRules: PackageRules[],\n activePackages: { name: string; root: string; version: string }[]\n): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function appTreeRulesDir(root: string, resolver: Resolver) {\n let pkg = resolver.packageCache.ownerOfFile(root);\n if (pkg) {\n if (pkg.isV2Addon()) {\n // in general v2 addons can keep their app tree stuff in other places than\n // \"_app_\" and we would need to check their package.json to see. But this code\n // is only for applying packageRules to auto-upgraded v1 addons and apps, and\n // those we always organize predictably.\n return pathResolve(root, '_app_');\n } else {\n // this is an app\n let matched = resolveExports(pkg.packageJSON, './index.js');\n if (matched) {\n return dirname(pathResolve(root, matched[0]));\n }\n }\n }\n return root;\n}\n"]}
package/src/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export { default as App } from './compat-app';
2
2
  export { default as Addons } from './compat-addons';
3
3
  export { default as Options, recommendedOptions } from './options';
4
4
  export { default as V1Addon } from './v1-addon';
5
- export { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';
5
+ export { prebuild, PipelineOptions } from './default-pipeline';
6
6
  export { PackageRules, ModuleRules } from './dependency-rules';
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ 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.prebuild = exports.compatBuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
6
+ exports.prebuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
7
7
  var compat_app_1 = require("./compat-app");
8
8
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(compat_app_1).default; } });
9
9
  var compat_addons_1 = require("./compat-addons");
@@ -13,6 +13,5 @@ Object.defineProperty(exports, "recommendedOptions", { enumerable: true, get: fu
13
13
  var v1_addon_1 = require("./v1-addon");
14
14
  Object.defineProperty(exports, "V1Addon", { enumerable: true, get: function () { return __importDefault(v1_addon_1).default; } });
15
15
  var default_pipeline_1 = require("./default-pipeline");
16
- Object.defineProperty(exports, "compatBuild", { enumerable: true, get: function () { return __importDefault(default_pipeline_1).default; } });
17
16
  Object.defineProperty(exports, "prebuild", { enumerable: true, get: function () { return default_pipeline_1.prebuild; } });
18
17
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAAuF;AAA9E,gIAAA,OAAO,OAAe;AAAE,4GAAA,QAAQ,OAAA","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAA+D;AAAtD,4GAAA,QAAQ,OAAA","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { prebuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
package/src/options.d.ts CHANGED
@@ -4,7 +4,6 @@ import type { PackageRules } from './dependency-rules';
4
4
  export default interface Options extends CoreOptions {
5
5
  staticAddonTrees?: boolean;
6
6
  staticAddonTestSupportTrees?: boolean;
7
- staticEmberSource?: boolean;
8
7
  compatAdapters?: Map<string, V1AddonConstructor | null>;
9
8
  packageRules?: PackageRules[];
10
9
  allowUnsafeDynamicComponents?: boolean;
package/src/options.js CHANGED
@@ -6,7 +6,6 @@ const core_1 = require("@embroider/core");
6
6
  const defaults = Object.assign((0, core_1.optionsWithDefaults)(), {
7
7
  staticAddonTrees: false,
8
8
  staticAddonTestSupportTrees: false,
9
- staticEmberSource: false,
10
9
  compatAdapters: new Map(),
11
10
  extraPublicTrees: [],
12
11
  workspaceDir: null,
@@ -31,7 +30,6 @@ exports.recommendedOptions = Object.freeze({
31
30
  staticHelpers: true,
32
31
  staticModifiers: true,
33
32
  staticComponents: true,
34
- staticEmberSource: true,
35
33
  allowUnsafeDynamicComponents: false,
36
34
  }),
37
35
  });
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AA6HA,kDAEC;AA7HD,0CAA0E;AA6G1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;IACnC,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,IAAI;IACrB,oBAAoB,EAAE,IAAI;CAC3B,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,IAAI;QACtB,iBAAiB,EAAE,IAAI;QACvB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // when true, we will load ember-source as ES modules. This means unused parts\n // of ember-source won't be included. But it also means that addons using old\n // APIs to try to `require()` things from Ember -- particularly from within\n // vendor.js -- cannot do that anymore.\n //\n // When false (the default) we load ember-source the traditional way, which is\n // that a big ol' script gets smooshed into vendor.js, and none of ember's\n // public module API actually exists as modules at build time.\n staticEmberSource?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n\n // Allows you to customize the list of content types addons use to provide HTML\n // to {{content-for}}. By default, the following content types are expected:\n // 'head', 'test-head', 'head-footer', 'test-head-footer', 'body', 'test-body',\n // 'body-footer', 'test-body-footer'. You need to use this config only to extend\n // this list.\n availableContentForTypes?: string[];\n\n // Allows you to cancel the warning that at least one classic addon provides\n // content-for 'app-boot'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'app-boot' code has been properly moved to the app-side.\n useAddonAppBoot?: boolean;\n\n // content-for 'config-module'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'config-module' code has been properly moved to the app-side.\n useAddonConfigModule?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n staticEmberSource: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n availableContentForTypes: [],\n useAddonAppBoot: true,\n useAddonConfigModule: true,\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticModifiers: true,\n staticComponents: true,\n staticEmberSource: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAkHA,kDAEC;AAlHD,0CAA0E;AAmG1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;IACnC,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,IAAI;IACrB,oBAAoB,EAAE,IAAI;CAC3B,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,IAAI;QACtB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n\n // Allows you to customize the list of content types addons use to provide HTML\n // to {{content-for}}. By default, the following content types are expected:\n // 'head', 'test-head', 'head-footer', 'test-head-footer', 'body', 'test-body',\n // 'body-footer', 'test-body-footer'. You need to use this config only to extend\n // this list.\n availableContentForTypes?: string[];\n\n // Allows you to cancel the warning that at least one classic addon provides\n // content-for 'app-boot'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'app-boot' code has been properly moved to the app-side.\n useAddonAppBoot?: boolean;\n\n // content-for 'config-module'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'config-module' code has been properly moved to the app-side.\n useAddonConfigModule?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n availableContentForTypes: [],\n useAddonAppBoot: true,\n useAddonConfigModule: true,\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticModifiers: true,\n staticComponents: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
@@ -95,7 +95,9 @@ class TemplateResolver {
95
95
  this.scopeStack = new ScopeStack();
96
96
  this.visitor = {
97
97
  Template: {
98
- enter: () => {
98
+ enter: (node, path) => {
99
+ this.ownRules = this.findRules(this.env.filename);
100
+ this.implementInvokesRule(node, path);
99
101
  if (this.env.locals) {
100
102
  this.scopeStack.pushMustacheBlock(this.env.locals);
101
103
  }
@@ -536,6 +538,7 @@ class TemplateResolver {
536
538
  };
537
539
  }
538
540
  targetComponentHelper(component, loc, impliedBecause) {
541
+ var _a;
539
542
  if (!this.staticComponentsEnabled) {
540
543
  return null;
541
544
  }
@@ -555,8 +558,7 @@ class TemplateResolver {
555
558
  };
556
559
  }
557
560
  if (component.type === 'path') {
558
- let ownComponentRules = this.findRules(this.env.filename);
559
- if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {
561
+ if ((_a = this.ownRules) === null || _a === void 0 ? void 0 : _a.safeInteriorPaths.includes(component.path)) {
560
562
  return null;
561
563
  }
562
564
  return {
@@ -801,6 +803,28 @@ class TemplateResolver {
801
803
  }
802
804
  return null;
803
805
  }
806
+ implementInvokesRule(node, path) {
807
+ var _a;
808
+ if (!((_a = this.ownRules) === null || _a === void 0 ? void 0 : _a.invokes)) {
809
+ return;
810
+ }
811
+ let registrations = [];
812
+ for (let snippets of Object.values(this.ownRules.invokes)) {
813
+ for (let snippet of snippets) {
814
+ let dasherizedName = (0, dasherize_component_name_1.snippetToDasherizedName)(snippet);
815
+ if (!dasherizedName) {
816
+ throw new Error(`Package rule contains unparseable component snippet: ${snippet}`);
817
+ }
818
+ let resolution = this.targetComponentHelper({ type: 'literal', path: dasherizedName }, node.loc);
819
+ this.emit(path, resolution, (_target, id) => {
820
+ registrations.push(this.env.syntax.builders.pair(dasherizedName, id));
821
+ });
822
+ }
823
+ }
824
+ if (registrations.length > 0) {
825
+ node.body.unshift(this.env.syntax.builders.mustache(this.env.meta.jsutils.bindExpression(registrationHelper, path, { nameHint: 'registerComponents' }), [], this.env.syntax.builders.hash(registrations)));
826
+ }
827
+ }
804
828
  }
805
829
  __decorate([
806
830
  (0, typescript_memoize_1.Memoize)()
@@ -988,4 +1012,18 @@ function parts(path) {
988
1012
  return;
989
1013
  return 'original' in path ? path.original.split('.') : path.parts;
990
1014
  }
1015
+ function registrationHelper(context) {
1016
+ let Helper = context.import('@ember/component/helper', 'default', 'Helper');
1017
+ let getOwner = context.import('@ember/owner', 'getOwner');
1018
+ return `
1019
+ (class extends ${Helper} {
1020
+ compute(_positional, registrations) {
1021
+ let owner = ${getOwner}(this);
1022
+ for (let [name, definition] of Object.entries(registrations)) {
1023
+ owner.register(\`component:\${name}\`, definition);
1024
+ }
1025
+ }
1026
+ })
1027
+ `;
1028
+ }
991
1029
  //# sourceMappingURL=resolver-transform.js.map