@embroider/compat 0.47.2 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/compat",
3
- "version": "0.47.2",
3
+ "version": "0.48.0",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
30
30
  "@babel/preset-env": "^7.14.5",
31
31
  "@babel/traverse": "^7.14.5",
32
- "@embroider/macros": "0.47.2",
33
- "@embroider/shared-internals": "0.47.2",
32
+ "@embroider/macros": "0.48.0",
33
+ "@embroider/shared-internals": "0.48.0",
34
34
  "@types/babel__code-frame": "^7.0.2",
35
35
  "@types/yargs": "^17.0.3",
36
36
  "assert-never": "^1.1.0",
@@ -85,7 +85,7 @@
85
85
  "typescript": "*"
86
86
  },
87
87
  "peerDependencies": {
88
- "@embroider/core": "0.47.2"
88
+ "@embroider/core": "0.48.0"
89
89
  },
90
90
  "engines": {
91
91
  "node": "12.* || 14.* || >= 16"
package/src/audit-cli.js CHANGED
File without changes
@@ -0,0 +1,5 @@
1
+ import V1Addon from '../v1-addon';
2
+ export default class EmberCliBabel extends V1Addon {
3
+ hasAnyTrees(): boolean;
4
+ get v2Tree(): import("broccoli-node-api").Node;
5
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const broccoli_file_creator_1 = __importDefault(require("broccoli-file-creator"));
7
+ const v1_addon_1 = __importDefault(require("../v1-addon"));
8
+ // Because almost every addon depends on ember-cli-babel, and because ember-cli
9
+ // instantiates a separate instance of Addon per consumer, approximately *half*
10
+ // of all Addon instances in a typical app will be copies of ember-cli-babel.
11
+ //
12
+ // Under embroider, *all* of them should be contributing no files to the build.
13
+ class EmberCliBabel extends v1_addon_1.default {
14
+ // this ensures we don't bother smooshing together a large number of useless
15
+ // copies of the addon.
16
+ hasAnyTrees() {
17
+ return false;
18
+ }
19
+ // and the one copy that we do emit should just be an empty valid package. We
20
+ // don't want the babel helpers it emits, they're not even used under
21
+ // Embroider anyway.
22
+ get v2Tree() {
23
+ return (0, broccoli_file_creator_1.default)('package.json', JSON.stringify(this.newPackageJSON, null, 2));
24
+ }
25
+ }
26
+ exports.default = EmberCliBabel;
27
+ //# sourceMappingURL=ember-cli-babel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ember-cli-babel.js","sourceRoot":"","sources":["ember-cli-babel.ts"],"names":[],"mappings":";;;;;AAAA,kFAA8C;AAC9C,2DAAkC;AAElC,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,EAAE;AACF,+EAA+E;AAC/E,MAAqB,aAAc,SAAQ,kBAAO;IAChD,4EAA4E;IAC5E,uBAAuB;IACvB,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6EAA6E;IAC7E,qEAAqE;IACrE,oBAAoB;IACpB,IAAI,MAAM;QACR,OAAO,IAAA,+BAAS,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;CACF;AAbD,gCAaC","sourcesContent":["import writeFile from 'broccoli-file-creator';\nimport V1Addon from '../v1-addon';\n\n// Because almost every addon depends on ember-cli-babel, and because ember-cli\n// instantiates a separate instance of Addon per consumer, approximately *half*\n// of all Addon instances in a typical app will be copies of ember-cli-babel.\n//\n// Under embroider, *all* of them should be contributing no files to the build.\nexport default class EmberCliBabel extends V1Addon {\n // this ensures we don't bother smooshing together a large number of useless\n // copies of the addon.\n hasAnyTrees() {\n return false;\n }\n\n // and the one copy that we do emit should just be an empty valid package. We\n // don't want the babel helpers it emits, they're not even used under\n // Embroider anyway.\n get v2Tree() {\n return writeFile('package.json', JSON.stringify(this.newPackageJSON, null, 2));\n }\n}\n"]}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const v1_addon_1 = __importDefault(require("../v1-addon"));
7
7
  const broccoli_file_creator_1 = __importDefault(require("broccoli-file-creator"));
8
+ const broccoli_merge_trees_1 = __importDefault(require("broccoli-merge-trees"));
8
9
  function createIndexContents(config) {
9
10
  return `export default ${JSON.stringify(config)};`;
10
11
  }
@@ -24,7 +25,10 @@ class default_1 extends v1_addon_1.default {
24
25
  // eslint-disable-next-line @typescript-eslint/no-require-imports
25
26
  const configModule = require(this.app.configPath());
26
27
  const appEnvironmentConfig = configModule(this.app.env);
27
- return (0, broccoli_file_creator_1.default)('index.js', createIndexContents(appEnvironmentConfig));
28
+ return (0, broccoli_merge_trees_1.default)([
29
+ (0, broccoli_file_creator_1.default)('index.js', createIndexContents(appEnvironmentConfig)),
30
+ (0, broccoli_file_creator_1.default)('package.json', JSON.stringify(this.newPackageJSON, null, 2)),
31
+ ]);
28
32
  }
29
33
  }
30
34
  exports.default = default_1;
@@ -1 +1 @@
1
- {"version":3,"file":"ember-get-config.js","sourceRoot":"","sources":["ember-get-config.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAClC,kFAA8C;AAE9C,SAAS,mBAAmB,CAAC,MAAW;IACtC,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,iEAAiE;QACjE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExD,OAAO,IAAA,+BAAS,EAAC,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC1E,CAAC;CACF;AARD,4BAQC","sourcesContent":["import V1Addon from '../v1-addon';\nimport writeFile from 'broccoli-file-creator';\n\nfunction createIndexContents(config: any): string {\n return `export default ${JSON.stringify(config)};`;\n}\n\n/**\n * The `ember-get-config` addon conceptually does just one thing: re-exports the `config/environment` runtime module\n * from the host app so that addons can import it themseles. It handles the \"hard part\" of knowing what the host app's\n * module name is, since that's not something an addon can normally know ahead of time.\n *\n * From a dependency graph perspective though, declaring all of the dependencies correctly would require a circular\n * dependency from the addon back to the host app itself, which we don't want to introduce.\n *\n * We need to basically re-implement the entire addon's behavior so that it still exports the app's\n * `config/environment` runtime value, but without needing it to actually export from the host app's module.\n */\nexport default class extends V1Addon {\n get v2Tree() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const configModule = require(this.app.configPath());\n const appEnvironmentConfig = configModule(this.app.env);\n\n return writeFile('index.js', createIndexContents(appEnvironmentConfig));\n }\n}\n"]}
1
+ {"version":3,"file":"ember-get-config.js","sourceRoot":"","sources":["ember-get-config.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAClC,kFAA8C;AAC9C,gFAA8C;AAE9C,SAAS,mBAAmB,CAAC,MAAW;IACtC,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,iEAAiE;QACjE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACpD,MAAM,oBAAoB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExD,OAAO,IAAA,8BAAU,EAAC;YAChB,IAAA,+BAAS,EAAC,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YAChE,IAAA,+BAAS,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;CACF;AAXD,4BAWC","sourcesContent":["import V1Addon from '../v1-addon';\nimport writeFile from 'broccoli-file-creator';\nimport mergeTrees from 'broccoli-merge-trees';\n\nfunction createIndexContents(config: any): string {\n return `export default ${JSON.stringify(config)};`;\n}\n\n/**\n * The `ember-get-config` addon conceptually does just one thing: re-exports the `config/environment` runtime module\n * from the host app so that addons can import it themseles. It handles the \"hard part\" of knowing what the host app's\n * module name is, since that's not something an addon can normally know ahead of time.\n *\n * From a dependency graph perspective though, declaring all of the dependencies correctly would require a circular\n * dependency from the addon back to the host app itself, which we don't want to introduce.\n *\n * We need to basically re-implement the entire addon's behavior so that it still exports the app's\n * `config/environment` runtime value, but without needing it to actually export from the host app's module.\n */\nexport default class extends V1Addon {\n get v2Tree() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const configModule = require(this.app.configPath());\n const appEnvironmentConfig = configModule(this.app.env);\n\n return mergeTrees([\n writeFile('index.js', createIndexContents(appEnvironmentConfig)),\n writeFile('package.json', JSON.stringify(this.newPackageJSON, null, 2)),\n ]);\n }\n}\n"]}
package/src/options.js CHANGED
@@ -26,6 +26,7 @@ exports.recommendedOptions = Object.freeze({
26
26
  staticAddonTrees: true,
27
27
  staticAddonTestSupportTrees: true,
28
28
  staticHelpers: true,
29
+ staticModifiers: true,
29
30
  staticComponents: true,
30
31
  allowUnsafeDynamicComponents: false,
31
32
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAEA,0CAAkG;AA0FlG,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,kBAAkB,EAAE,EAAE;IACtB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;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,gBAAgB,EAAE,IAAI;QACtB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { V1AddonConstructor } from './v1-addon';\nimport { Node } from 'broccoli-node-api';\nimport { Options as CoreOptions, optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport { 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 // temporary directory where we will work when we're rewriting your addons\n // and/or app to v2-compatible formats.\n workspaceDir?: string | null;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\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\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n optionalComponents: [],\n packageRules: [],\n allowUnsafeDynamicComponents: false,\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 staticComponents: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAEA,0CAAkG;AA0FlG,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,kBAAkB,EAAE,EAAE;IACtB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;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 { V1AddonConstructor } from './v1-addon';\nimport { Node } from 'broccoli-node-api';\nimport { Options as CoreOptions, optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport { 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 // temporary directory where we will work when we're rewriting your addons\n // and/or app to v2-compatible formats.\n workspaceDir?: string | null;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\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\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n optionalComponents: [],\n packageRules: [],\n allowUnsafeDynamicComponents: false,\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"]}
@@ -13,6 +13,7 @@ export declare function makeResolverTransform(resolver: Resolver): {
13
13
  BlockStatement(node: ASTv1.BlockStatement): void;
14
14
  SubExpression(node: ASTv1.SubExpression): void;
15
15
  MustacheStatement(node: ASTv1.MustacheStatement): void;
16
+ ElementModifierStatement(node: ASTv1.ElementModifierStatement): void;
16
17
  ElementNode: {
17
18
  enter(node: ASTv1.ElementNode): void;
18
19
  exit(): void;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeResolverTransform = void 0;
7
7
  const resolver_1 = __importDefault(require("./resolver"));
8
- // This is the AST transform that resolves components and helpers at build time
8
+ // This is the AST transform that resolves components, helpers and modifiers at build time
9
9
  // and puts them into `dependencies`.
10
10
  function makeResolverTransform(resolver) {
11
11
  function resolverTransform({ filename }) {
@@ -112,6 +112,29 @@ function makeResolverTransform(resolver) {
112
112
  }
113
113
  }
114
114
  },
115
+ ElementModifierStatement(node) {
116
+ if (node.path.type !== 'PathExpression') {
117
+ return;
118
+ }
119
+ if (scopeStack.inScope(node.path.parts[0])) {
120
+ return;
121
+ }
122
+ if (node.path.this === true) {
123
+ return;
124
+ }
125
+ if (node.path.data === true) {
126
+ return;
127
+ }
128
+ if (node.path.parts.length > 1) {
129
+ // paths with a dot in them (which therefore split into more than
130
+ // one "part") are classically understood by ember to be contextual
131
+ // components. With the introduction of `Template strict mode` in Ember 3.25
132
+ // it is also possible to pass modifiers this way which means there's nothing
133
+ // to resolve at this location.
134
+ return;
135
+ }
136
+ resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);
137
+ },
115
138
  ElementNode: {
116
139
  enter(node) {
117
140
  if (!scopeStack.inScope(node.tag.split('.')[0])) {
@@ -1 +1 @@
1
- {"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAwF;AAGxF,+EAA+E;AAC/E,qCAAqC;AACrC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAwB;QAC3D,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,+BAA+B;YAErC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAmB;wBACvB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,CAAC;oBACD,IAAI;wBACF,UAAU,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC;iBACF;gBACD,cAAc,CAAC,IAA0B;oBACvC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;wBACvC,OAAO;qBACR;oBACD,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBAC1C,OAAO;qBACR;oBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;wBAC3B,OAAO;qBACR;oBACD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;wBAC9B,iEAAiE;wBACjE,mEAAmE;wBACnE,6DAA6D;wBAC7D,YAAY;wBACZ,OAAO;qBACR;oBACD,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;wBAChE,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAA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AAI,KAAK,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5E,OAAO;KACR;IAED,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEhF,OAAO;IACP,0CAA0C;IAC1C,qCAAqC;IACrC,iCAAiC;IACjC,wEAAwE;IACxE,MAAM;IACN,YAAY;IACZ,IAAI;IAEJ,OAAO;IACP,0CAA0C;IAC1C,4CAA4C;IAC5C,wCAAwC;IACxC,MAAM;IACN,sFAAsF;IACtF,YAAY;IACZ,IAAI;IAEJ,mCAAmC;IACnC,oGAAoG;IACpG,YAAY;IACZ,IAAI;IAEJ,uHAAuH;IACvH,yFAAyF;IACzF,YAAY;IACZ,IAAI;IAEJ,8FAA8F;AAChG,CAAC","sourcesContent":["import { default as Resolver, ComponentResolution, ComponentLocator } from './resolver';\nimport type { ASTv1 } from '@glimmer/syntax';\n\n// This is the AST transform that resolves components and helpers at build time\n// and puts them into `dependencies`.\nexport function makeResolverTransform(resolver: Resolver) {\n function resolverTransform({ filename }: { filename: string }) {\n resolver.enter(filename);\n\n let scopeStack = new ScopeStack();\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node: ASTv1.Program) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node: ASTv1.BlockStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n const resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n }\n }\n });\n }\n },\n SubExpression(node: ASTv1.SubExpression) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n },\n MustacheStatement(node: ASTv1.MustacheStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n for (let name of resolution.argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n }\n }\n }\n },\n ElementNode: {\n enter(node: ASTv1.ElementNode) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let attr = node.attributes.find((attr: ASTv1.AttrNode) => attr.name === '@' + name);\n if (attr) {\n handleComponentHelper(attr.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n }\n resolverTransform.parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): void {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n return;\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return;\n }\n\n resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.hash.pairs.length === 0 &&\n // param.params.length === 0 &&\n // handleComponentHelper(param.path, resolver, moduleName, scopeStack)\n // ) {\n // return;\n // }\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.path.type === 'PathExpression' &&\n // param.path.original === 'component'\n // ) {\n // // safe because we will handle this inner `{{component ...}}` mustache on its own\n // return;\n // }\n\n // if (param.type === 'TextNode') {\n // resolver.resolveComponentHelper({ type: 'literal', path: param.chars }, moduleName, param.loc);\n // return;\n // }\n\n // if (param.type === 'SubExpression' && param.path.type === 'PathExpression' && param.path.original === 'component') {\n // // safe because we will handle this inner `(component ...)` subexpression on its own\n // return;\n // }\n\n // resolver.unresolvableComponentArgument(componentName, argumentName, moduleName, param.loc);\n}\n"]}
1
+ {"version":3,"file":"resolver-transform.js","sourceRoot":"","sources":["resolver-transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAwF;AAGxF,0FAA0F;AAC1F,qCAAqC;AACrC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,SAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAwB;QAC3D,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,+BAA+B;YAErC,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAmB;wBACvB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,CAAC;oBACD,IAAI;wBACF,UAAU,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC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EAAE,CAAC;YAC5B,MAAM;QACR;YACE,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC/B;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5E,OAAO;KACR;IAED,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEhF,OAAO;IACP,0CAA0C;IAC1C,qCAAqC;IACrC,iCAAiC;IACjC,wEAAwE;IACxE,MAAM;IACN,YAAY;IACZ,IAAI;IAEJ,OAAO;IACP,0CAA0C;IAC1C,4CAA4C;IAC5C,wCAAwC;IACxC,MAAM;IACN,sFAAsF;IACtF,YAAY;IACZ,IAAI;IAEJ,mCAAmC;IACnC,oGAAoG;IACpG,YAAY;IACZ,IAAI;IAEJ,uHAAuH;IACvH,yFAAyF;IACzF,YAAY;IACZ,IAAI;IAEJ,8FAA8F;AAChG,CAAC","sourcesContent":["import { default as Resolver, ComponentResolution, ComponentLocator } from './resolver';\nimport type { ASTv1 } from '@glimmer/syntax';\n\n// This is the AST transform that resolves components, helpers and modifiers at build time\n// and puts them into `dependencies`.\nexport function makeResolverTransform(resolver: Resolver) {\n function resolverTransform({ filename }: { filename: string }) {\n resolver.enter(filename);\n\n let scopeStack = new ScopeStack();\n\n return {\n name: 'embroider-build-time-resolver',\n\n visitor: {\n Program: {\n enter(node: ASTv1.Program) {\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n BlockStatement(node: ASTv1.BlockStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n // a block counts as args from our perpsective (it's enough to prove\n // this thing must be a component, not content)\n let hasArgs = true;\n const resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: (node.path as ASTv1.PathExpression).original,\n argumentName: name,\n });\n }\n }\n });\n }\n },\n SubExpression(node: ASTv1.SubExpression) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n resolver.resolveSubExpression(node.path.original, filename, node.path.loc);\n },\n MustacheStatement(node: ASTv1.MustacheStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components, which means there's nothing to resolve at this\n // location.\n return;\n }\n if (node.path.original === 'component' && node.params.length > 0) {\n handleComponentHelper(node.params[0], resolver, filename, scopeStack);\n return;\n }\n let hasArgs = node.params.length > 0 || node.hash.pairs.length > 0;\n let resolution = resolver.resolveMustache(node.path.original, hasArgs, filename, node.path.loc);\n if (resolution && resolution.type === 'component') {\n for (let name of resolution.argumentsAreComponents) {\n let pair = node.hash.pairs.find((pair: ASTv1.HashPair) => pair.key === name);\n if (pair) {\n handleComponentHelper(pair.value, resolver, filename, scopeStack, {\n componentName: node.path.original,\n argumentName: name,\n });\n }\n }\n }\n },\n ElementModifierStatement(node: ASTv1.ElementModifierStatement) {\n if (node.path.type !== 'PathExpression') {\n return;\n }\n if (scopeStack.inScope(node.path.parts[0])) {\n return;\n }\n if (node.path.this === true) {\n return;\n }\n if (node.path.data === true) {\n return;\n }\n if (node.path.parts.length > 1) {\n // paths with a dot in them (which therefore split into more than\n // one \"part\") are classically understood by ember to be contextual\n // components. With the introduction of `Template strict mode` in Ember 3.25\n // it is also possible to pass modifiers this way which means there's nothing\n // to resolve at this location.\n return;\n }\n\n resolver.resolveElementModifierStatement(node.path.original, filename, node.path.loc);\n },\n ElementNode: {\n enter(node: ASTv1.ElementNode) {\n if (!scopeStack.inScope(node.tag.split('.')[0])) {\n const resolution = resolver.resolveElement(node.tag, filename, node.loc);\n if (resolution && resolution.type === 'component') {\n scopeStack.enteringComponentBlock(resolution, ({ argumentsAreComponents }) => {\n for (let name of argumentsAreComponents) {\n let attr = node.attributes.find((attr: ASTv1.AttrNode) => attr.name === '@' + name);\n if (attr) {\n handleComponentHelper(attr.value, resolver, filename, scopeStack, {\n componentName: node.tag,\n argumentName: name,\n });\n }\n }\n });\n }\n }\n scopeStack.push(node.blockParams);\n },\n exit() {\n scopeStack.pop();\n },\n },\n },\n };\n }\n resolverTransform.parallelBabel = {\n requireFile: __filename,\n buildUsing: 'makeResolverTransform',\n params: Resolver,\n };\n return resolverTransform;\n}\n\ninterface ComponentBlockMarker {\n type: 'componentBlockMarker';\n resolution: ComponentResolution;\n argumentsAreComponents: string[];\n exit: (marker: ComponentBlockMarker) => void;\n}\n\ntype ScopeEntry = { type: 'blockParams'; blockParams: string[] } | ComponentBlockMarker;\n\nclass ScopeStack {\n private stack: ScopeEntry[] = [];\n\n // as we enter a block, we push the block params onto here to mark them as\n // being in scope\n push(blockParams: string[]) {\n this.stack.unshift({ type: 'blockParams', blockParams });\n }\n\n // and when we leave the block they go out of scope. If this block was tagged\n // by a safe component marker, we also clear that.\n pop() {\n this.stack.shift();\n let next = this.stack[0];\n if (next && next.type === 'componentBlockMarker') {\n next.exit(next);\n this.stack.shift();\n }\n }\n\n // right before we enter a block, we might determine that some of the values\n // that will be yielded as marked (by a rule) as safe to be used with the\n // {{component}} helper.\n enteringComponentBlock(resolution: ComponentResolution, exit: ComponentBlockMarker['exit']) {\n this.stack.unshift({\n type: 'componentBlockMarker',\n resolution,\n argumentsAreComponents: resolution.argumentsAreComponents.slice(),\n exit,\n });\n }\n\n inScope(name: string) {\n for (let scope of this.stack) {\n if (scope.type === 'blockParams' && scope.blockParams.includes(name)) {\n return true;\n }\n }\n return false;\n }\n\n safeComponentInScope(name: string): boolean {\n let parts = name.split('.');\n if (parts.length > 2) {\n // we let component rules specify that they yield components or objects\n // containing components. But not deeper than that. So the max path length\n // that can refer to a marked-safe component is two segments.\n return false;\n }\n for (let i = 0; i < this.stack.length - 1; i++) {\n let here = this.stack[i];\n let next = this.stack[i + 1];\n if (here.type === 'blockParams' && next.type === 'componentBlockMarker') {\n let positionalIndex = here.blockParams.indexOf(parts[0]);\n if (positionalIndex === -1) {\n continue;\n }\n\n if (parts.length === 1) {\n if (next.resolution.yieldsComponents[positionalIndex] === true) {\n return true;\n }\n let sourceArg = next.resolution.yieldsArguments[positionalIndex];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n } else {\n let entry = next.resolution.yieldsComponents[positionalIndex];\n if (entry && typeof entry === 'object') {\n return entry[parts[1]] === true;\n }\n\n let argsEntry = next.resolution.yieldsArguments[positionalIndex];\n if (argsEntry && typeof argsEntry === 'object') {\n let sourceArg = argsEntry[parts[1]];\n if (typeof sourceArg === 'string') {\n next.argumentsAreComponents.push(sourceArg);\n return true;\n }\n }\n }\n // we found the source of the name, but there were no rules to cover it.\n // Don't keep searching higher, those are different names.\n return false;\n }\n }\n return false;\n }\n}\n\nfunction handleComponentHelper(\n param: ASTv1.Node,\n resolver: Resolver,\n moduleName: string,\n scopeStack: ScopeStack,\n impliedBecause?: { componentName: string; argumentName: string }\n): void {\n let locator: ComponentLocator;\n switch (param.type) {\n case 'StringLiteral':\n locator = { type: 'literal', path: param.value };\n break;\n case 'PathExpression':\n locator = { type: 'path', path: param.original };\n break;\n case 'MustacheStatement':\n if (param.hash.pairs.length === 0 && param.params.length === 0) {\n handleComponentHelper(param.path, resolver, moduleName, scopeStack, impliedBecause);\n return;\n } else if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `{{component ...}}` mustache on its own\n return;\n } else {\n locator = { type: 'other' };\n }\n break;\n case 'TextNode':\n locator = { type: 'literal', path: param.chars };\n break;\n case 'SubExpression':\n if (param.path.type === 'PathExpression' && param.path.original === 'component') {\n // safe because we will handle this inner `(component ...)` subexpression on its own\n return;\n }\n if (param.path.type === 'PathExpression' && param.path.original === 'ensure-safe-component') {\n // safe because we trust ensure-safe-component\n return;\n }\n locator = { type: 'other' };\n break;\n default:\n locator = { type: 'other' };\n }\n\n if (locator.type === 'path' && scopeStack.safeComponentInScope(locator.path)) {\n return;\n }\n\n resolver.resolveComponentHelper(locator, moduleName, param.loc, impliedBecause);\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.hash.pairs.length === 0 &&\n // param.params.length === 0 &&\n // handleComponentHelper(param.path, resolver, moduleName, scopeStack)\n // ) {\n // return;\n // }\n\n // if (\n // param.type === 'MustacheStatement' &&\n // param.path.type === 'PathExpression' &&\n // param.path.original === 'component'\n // ) {\n // // safe because we will handle this inner `{{component ...}}` mustache on its own\n // return;\n // }\n\n // if (param.type === 'TextNode') {\n // resolver.resolveComponentHelper({ type: 'literal', path: param.chars }, moduleName, param.loc);\n // return;\n // }\n\n // if (param.type === 'SubExpression' && param.path.type === 'PathExpression' && param.path.original === 'component') {\n // // safe because we will handle this inner `(component ...)` subexpression on its own\n // return;\n // }\n\n // resolver.unresolvableComponentArgument(componentName, argumentName, moduleName, param.loc);\n}\n"]}
package/src/resolver.d.ts CHANGED
@@ -14,7 +14,11 @@ export interface HelperResolution {
14
14
  type: 'helper';
15
15
  modules: ResolvedDep[];
16
16
  }
17
- export declare type ResolutionResult = ComponentResolution | HelperResolution;
17
+ export interface ModifierResolution {
18
+ type: 'modifier';
19
+ modules: ResolvedDep[];
20
+ }
21
+ export declare type ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;
18
22
  export interface ResolutionFail {
19
23
  type: 'error';
20
24
  message: string;
@@ -32,7 +36,7 @@ export interface Loc {
32
36
  column: number;
33
37
  };
34
38
  }
35
- declare type ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
39
+ declare type ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
36
40
  interface RehydrationParamsBase {
37
41
  root: string;
38
42
  modulePrefix: string;
@@ -88,13 +92,17 @@ export default class CompatResolver implements Resolver {
88
92
  }): string;
89
93
  private get staticComponentsEnabled();
90
94
  private get staticHelpersEnabled();
95
+ private get staticModifiersEnabled();
91
96
  private tryHelper;
92
97
  private _tryHelper;
98
+ private tryModifier;
99
+ private _tryModifier;
93
100
  private get appPackage();
94
101
  private tryComponent;
95
102
  private _tryComponent;
96
103
  resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null;
97
104
  resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null;
105
+ resolveElementModifierStatement(path: string, from: string, loc: Loc): Resolution | null;
98
106
  resolveElement(tagName: string, from: string, loc: Loc): Resolution | null;
99
107
  resolveComponentHelper(component: ComponentLocator, from: string, loc: Loc, impliedBecause?: {
100
108
  componentName: string;
package/src/resolver.js CHANGED
@@ -59,9 +59,11 @@ const builtInHelpers = [
59
59
  'yield',
60
60
  ];
61
61
  const builtInComponents = ['input', 'link-to', 'textarea'];
62
+ const builtInModifiers = ['action', 'on'];
62
63
  function extractOptions(options) {
63
64
  return {
64
65
  staticHelpers: options.staticHelpers,
66
+ staticModifiers: options.staticModifiers,
65
67
  staticComponents: options.staticComponents,
66
68
  allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,
67
69
  };
@@ -231,12 +233,12 @@ class CompatResolver {
231
233
  }
232
234
  astTransformer(templateCompiler) {
233
235
  this.templateCompiler = templateCompiler;
234
- if (this.staticComponentsEnabled || this.staticHelpersEnabled) {
236
+ if (this.staticComponentsEnabled || this.staticHelpersEnabled || this.staticModifiersEnabled) {
235
237
  return (0, resolver_transform_1.makeResolverTransform)(this);
236
238
  }
237
239
  }
238
- // called by our audit tool. Forces staticComponents and staticHelpers to
239
- // activate so we can audit their behavior, while making their errors silent
240
+ // called by our audit tool. Forces staticComponents, staticHelpers and staticModifiers
241
+ // to activate so we can audit their behavior, while making their errors silent
240
242
  // until we can gather them up at the end of the build for the audit results.
241
243
  enableAuditMode() {
242
244
  this.auditMode = true;
@@ -325,6 +327,9 @@ class CompatResolver {
325
327
  get staticHelpersEnabled() {
326
328
  return this.params.options.staticHelpers || this.auditMode;
327
329
  }
330
+ get staticModifiersEnabled() {
331
+ return this.params.options.staticModifiers || this.auditMode;
332
+ }
328
333
  tryHelper(path, from) {
329
334
  let parts = path.split('@');
330
335
  if (parts.length > 1 && parts[0].length > 0) {
@@ -358,6 +363,39 @@ class CompatResolver {
358
363
  }
359
364
  return null;
360
365
  }
366
+ tryModifier(path, from) {
367
+ let parts = path.split('@');
368
+ if (parts.length > 1 && parts[0].length > 0) {
369
+ let cache = core_1.PackageCache.shared('embroider-stage3');
370
+ let packageName = parts[0];
371
+ let renamed = this.adjustImportsOptions.renamePackages[packageName];
372
+ if (renamed) {
373
+ packageName = renamed;
374
+ }
375
+ return this._tryModifier(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)));
376
+ }
377
+ else {
378
+ return this._tryModifier(path, from, this.appPackage);
379
+ }
380
+ }
381
+ _tryModifier(path, from, targetPackage) {
382
+ for (let extension of this.adjustImportsOptions.resolvableExtensions) {
383
+ let absPath = (0, path_1.join)(targetPackage.root, 'modifiers', path) + extension;
384
+ if ((0, fs_extra_1.pathExistsSync)(absPath)) {
385
+ return {
386
+ type: 'modifier',
387
+ modules: [
388
+ {
389
+ runtimeName: this.absPathToRuntimeName(absPath, targetPackage),
390
+ path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
391
+ absPath,
392
+ },
393
+ ],
394
+ };
395
+ }
396
+ }
397
+ return null;
398
+ }
361
399
  get appPackage() {
362
400
  return { root: this.params.root, name: this.params.modulePrefix };
363
401
  }
@@ -504,6 +542,24 @@ class CompatResolver {
504
542
  return null;
505
543
  }
506
544
  }
545
+ resolveElementModifierStatement(path, from, loc) {
546
+ if (!this.staticModifiersEnabled) {
547
+ return null;
548
+ }
549
+ let found = this.tryModifier(path, from);
550
+ if (found) {
551
+ return this.add(found, from);
552
+ }
553
+ if (builtInModifiers.includes(path)) {
554
+ return null;
555
+ }
556
+ return this.add({
557
+ type: 'error',
558
+ message: `Missing modifier`,
559
+ detail: path,
560
+ loc,
561
+ }, from);
562
+ }
507
563
  resolveElement(tagName, from, loc) {
508
564
  if (!this.staticComponentsEnabled) {
509
565
  return null;
@@ -562,6 +618,9 @@ class CompatResolver {
562
618
  loc,
563
619
  }, from);
564
620
  }
621
+ if (builtInComponents.includes(component.path)) {
622
+ return null;
623
+ }
565
624
  let found = this.tryComponent(component.path, from);
566
625
  if (found) {
567
626
  return this.add(found, from);
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAO4B;AAC5B,0CAOyB;AACzB,+BAAoD;AAGpD,2DAA6C;AAG7C,yEAAuD;AACvD,6DAA6D;AAC7D,uCAA0C;AAC1C,sDAA8B;AAsC9B,0EAA0E;AAC1E,2BAA2B;AAC3B,MAAM,cAAc,GAAG;IACrB,kBAAkB;IAClB,aAAa;IACb,YAAY;IACZ,oBAAoB;IACpB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,QAAQ;IACR,UAAU;IACV,MAAM;IACN,S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AS,CAAC,IAAI;gBACtB,GAAG;aACJ,EACD,IAAI,CACL,CAAC;SACH;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,GAAG,CACb;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,SAAS,CAAC,IAAI;YACtB,GAAG;SACJ,EACD,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AA3hBC;IADC,IAAA,4BAAO,GAAE;0DAOT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAoET;AAsHD;IADC,IAAA,4BAAO,GAAE;iEAGT;AAqED;IADC,IAAA,4BAAO,GAAE;gDAGT;AA9UH,iCA8lBC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACvB,IAAI,IAAI,GAAG,CAAC;KACb;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n ActivePackageRules,\n ComponentRules,\n ModuleRules,\n PackageRules,\n PreprocessedComponentRule,\n preprocessComponentRule,\n} from './dependency-rules';\nimport {\n Package,\n PackageCache,\n Resolver,\n TemplateCompiler,\n explicitRelative,\n extensionsPattern,\n} from '@embroider/core';\nimport { dirname, join, relative, sep } from 'path';\n\nimport { Options as AdjustImportsOptions } from '@embroider/core/src/babel-plugin-adjust-imports';\nimport { Memoize } from 'typescript-memoize';\nimport Options from './options';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport { dasherize } from './dasherize-component-name';\nimport { makeResolverTransform } from './resolver-transform';\nimport { pathExistsSync } from 'fs-extra';\nimport resolve from 'resolve';\nimport type { ASTv1 } from '@glimmer/syntax';\n\nexport interface ComponentResolution {\n type: 'component';\n modules: ResolvedDep[];\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n}\n\nexport interface HelperResolution {\n type: 'helper';\n modules: ResolvedDep[];\n}\n\nexport type ResolutionResult = ComponentResolution | HelperResolution;\n\nexport interface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ninterface ResolverDependencyError extends Error {\n isTemplateResolverError?: boolean;\n loc?: Loc;\n moduleName?: string;\n}\n\nexport type Resolution = ResolutionResult | ResolutionFail;\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\n// TODO: this depends on the ember version. And it's probably missing some\n// private-but-used values.\nconst builtInHelpers = [\n '-get-dynamic-var',\n '-in-element',\n 'in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each',\n 'each-in',\n 'fn',\n 'get',\n 'has-block',\n 'has-block-params',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'if',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unless',\n 'with',\n 'yield',\n];\n\nconst builtInComponents = ['input', 'link-to', 'textarea'];\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype ResolverOptions = Pick<Required<Options>, 'staticHelpers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;\n\nfunction extractOptions(options: Required<Options> | ResolverOptions): ResolverOptions {\n return {\n staticHelpers: options.staticHelpers,\n staticComponents: options.staticComponents,\n allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,\n };\n}\n\ninterface RehydrationParamsBase {\n root: string;\n modulePrefix: string;\n podModulePrefix?: string;\n options: ResolverOptions;\n activePackageRules: ActivePackageRules[];\n}\n\ninterface RehydrationParamsWithFile extends RehydrationParamsBase {\n adjustImportsOptionsPath: string;\n}\n\ninterface RehydrationParamsWithOptions extends RehydrationParamsBase {\n adjustImportsOptions: AdjustImportsOptions;\n}\n\ntype RehydrationParams = RehydrationParamsWithFile | RehydrationParamsWithOptions;\n\nexport function rehydrate(params: RehydrationParams) {\n return new CompatResolver(params);\n}\n\nexport default class CompatResolver implements Resolver {\n private dependencies: Map<string, Resolution[]> = new Map();\n private templateCompiler: TemplateCompiler | undefined;\n private auditMode = false;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: RehydrationParams;\n };\n\n constructor(private params: RehydrationParams) {\n this.params.options = extractOptions(this.params.options);\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'rehydrate',\n params,\n };\n }\n\n enter(moduleName: string) {\n let rules = this.findComponentRules(moduleName);\n let deps: Resolution[];\n if (rules?.dependsOnComponents) {\n deps = rules.dependsOnComponents.map(snippet => this.resolveComponentSnippet(snippet, rules!, moduleName));\n } else {\n deps = [];\n }\n this.dependencies.set(moduleName, deps);\n }\n\n private add(resolution: Resolution, from: string) {\n // this \"!\" is safe because we always `enter()` a module before hitting this\n this.dependencies.get(from)!.push(resolution);\n return resolution;\n }\n\n private findComponentRules(absPath: string): PreprocessedComponentRule | undefined {\n let rules = this.rules.components.get(absPath);\n if (rules) {\n return rules;\n }\n\n // co-located templates aren't visible to the resolver, because they never\n // get resolved from a template (they are always handled directly by the\n // corresponding JS module, which the resolver *does* see). This means their\n // paths won't ever be in `this.rules.components`. But we do want them to\n // \"inherit\" the rules that are attached to their corresonding JS module.\n if (absPath.endsWith('.hbs')) {\n let stem = absPath.slice(0, -4);\n for (let ext of this.adjustImportsOptions.resolvableExtensions) {\n if (ext !== '.hbs') {\n let rules = this.rules.components.get(stem + ext);\n if (rules) {\n return rules;\n }\n }\n }\n }\n return undefined;\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.ignoredComponents.includes(dasherizedName);\n }\n\n @Memoize()\n get adjustImportsOptions(): AdjustImportsOptions {\n const { params } = this;\n return 'adjustImportsOptionsPath' in params\n ? // eslint-disable-next-line @typescript-eslint/no-require-imports\n require(params.adjustImportsOptionsPath)\n : params.adjustImportsOptions;\n }\n\n @Memoize()\n private get rules() {\n if (!this.templateCompiler) {\n throw new Error(\n `Bug: Resolver needs to get linked into a TemplateCompiler before it can understand packageRules`\n );\n }\n\n // keyed by their first resolved dependency's runtimeName.\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // keyed by our own dasherized interpretation of the component's name.\n let ignoredComponents: string[] = [];\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.params.activePackageRules) {\n if (rule.components) {\n for (let [snippet, componentRules] of Object.entries(rule.components)) {\n if (componentRules.safeToIgnore) {\n ignoredComponents.push(this.standardDasherize(snippet, rule));\n continue;\n }\n let resolvedDep = this.resolveComponentSnippet(snippet, rule).modules[0];\n let processedRules = preprocessComponentRule(componentRules);\n\n // we always register our rules on the component's own first resolved\n // module, which must be a module in the app's module namespace.\n components.set(resolvedDep.absPath, processedRules);\n\n // if there's a custom layout, we also need to register our rules on\n // those templates.\n if (componentRules.layout) {\n if (componentRules.layout.appPath) {\n components.set(join(this.params.root, componentRules.layout.appPath), processedRules);\n } else if (componentRules.layout.addonPath) {\n for (let root of rule.roots) {\n components.set(join(root, componentRules.layout.addonPath), processedRules);\n }\n } else {\n throw new Error(\n `layout property in component rule must contain either appPath or addonPath: ${JSON.stringify(\n rule,\n null,\n 2\n )}`\n );\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n components.set(join(this.params.root, path), processedRules);\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n components.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { components, ignoredComponents };\n }\n\n resolveComponentSnippet(\n snippet: string,\n rule: PackageRules | ModuleRules,\n from = 'rule-snippet.hbs'\n ): ResolutionResult & { type: 'component' } {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let name = this.standardDasherize(snippet, rule);\n let found = this.tryComponent(name, from, false);\n if (found && found.type === 'component') {\n return found;\n }\n throw new Error(`unable to locate component ${snippet} referred to in rule ${JSON.stringify(rule, null, 2)}`);\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let ast: ASTv1.Template | ASTv1.Program;\n try {\n ast = this.templateCompiler.parse('snippet.hbs', snippet) as unknown as ASTv1.Template | ASTv1.Program;\n } catch (err) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n if ((ast.type === 'Program' || ast.type === 'Template') && ast.body.length > 0) {\n let first = ast.body[0];\n const isMustachePath = first.type === 'MustacheStatement' && first.path.type === 'PathExpression';\n const isComponent =\n isMustachePath && ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original === 'component';\n const hasStringParam =\n isComponent &&\n Array.isArray((first as ASTv1.MustacheStatement).params) &&\n (first as ASTv1.MustacheStatement).params[0].type === 'StringLiteral';\n if (isMustachePath && isComponent && hasStringParam) {\n return ((first as ASTv1.MustacheStatement).params[0] as ASTv1.StringLiteral).value;\n }\n if (isMustachePath) {\n return ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original;\n }\n if (first.type === 'ElementNode') {\n return dasherize(first.tag);\n }\n }\n throw new Error(`cannot identify a component in rule snippet: \"${snippet}\"`);\n }\n\n astTransformer(templateCompiler: TemplateCompiler): unknown {\n this.templateCompiler = templateCompiler;\n if (this.staticComponentsEnabled || this.staticHelpersEnabled) {\n return makeResolverTransform(this);\n }\n }\n\n // called by our audit tool. Forces staticComponents and staticHelpers to\n // activate so we can audit their behavior, while making their errors silent\n // until we can gather them up at the end of the build for the audit results.\n enableAuditMode() {\n this.auditMode = true;\n }\n\n errorsIn(moduleName: string): ResolutionFail[] {\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n return deps.filter(d => d.type === 'error') as ResolutionFail[];\n } else {\n return [];\n }\n }\n\n dependenciesOf(moduleName: string): ResolvedDep[] {\n let flatDeps: Map<string, ResolvedDep> = new Map();\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n for (let dep of deps) {\n if (dep.type === 'error') {\n if (!this.auditMode && !this.params.options.allowUnsafeDynamicComponents) {\n let e: ResolverDependencyError = new Error(\n `${dep.message}: ${dep.detail} in ${humanReadableFile(this.params.root, moduleName)}`\n );\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = moduleName;\n throw e;\n }\n } else {\n for (let entry of dep.modules) {\n let { runtimeName } = entry;\n flatDeps.set(runtimeName, entry);\n }\n }\n }\n }\n return [...flatDeps.values()];\n }\n\n resolveImport(path: string, from: string): { runtimeName: string; absPath: string } | undefined {\n let absPath;\n try {\n absPath = resolve.sync(path, {\n basedir: dirname(from),\n extensions: this.adjustImportsOptions.resolvableExtensions,\n });\n } catch (err) {\n return;\n }\n if (absPath) {\n let runtimeName = this.absPathToRuntimeName(absPath);\n if (runtimeName) {\n return { runtimeName, absPath };\n }\n }\n }\n\n @Memoize()\n private get resolvableExtensionsPattern() {\n return extensionsPattern(this.adjustImportsOptions.resolvableExtensions);\n }\n\n absPathToRuntimePath(absPath: string, owningPackage?: { root: string; name: string }) {\n let pkg = owningPackage || PackageCache.shared('embroider-stage3').ownerOfFile(absPath);\n if (pkg) {\n let packageRuntimeName = pkg.name;\n for (let [runtimeName, realName] of Object.entries(this.adjustImportsOptions.renamePackages)) {\n if (realName === packageRuntimeName) {\n packageRuntimeName = runtimeName;\n break;\n }\n }\n return join(packageRuntimeName, relative(pkg.root, absPath)).split(sep).join('/');\n } else if (absPath.startsWith(this.params.root)) {\n return join(this.params.modulePrefix, relative(this.params.root, absPath)).split(sep).join('/');\n } else {\n throw new Error(`bug: can't figure out the runtime name for ${absPath}`);\n }\n }\n\n absPathToRuntimeName(absPath: string, owningPackage?: { root: string; name: string }) {\n return this.absPathToRuntimePath(absPath, owningPackage)\n .replace(this.resolvableExtensionsPattern, '')\n .replace(/\\/index$/, '');\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.params.options.staticComponents || this.auditMode;\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.params.options.staticHelpers || this.auditMode;\n }\n\n private tryHelper(path: string, from: string): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryHelper(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryHelper(path, from, this.appPackage);\n }\n }\n\n private _tryHelper(path: string, from: string, targetPackage: Package | AppPackagePlaceholder): Resolution | null {\n for (let extension of this.adjustImportsOptions.resolvableExtensions) {\n let absPath = join(targetPackage.root, 'helpers', path) + extension;\n if (pathExistsSync(absPath)) {\n return {\n type: 'helper',\n modules: [\n {\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n path: explicitRelative(dirname(from), absPath),\n absPath,\n },\n ],\n };\n }\n }\n return null;\n }\n\n @Memoize()\n private get appPackage(): AppPackagePlaceholder {\n return { root: this.params.root, name: this.params.modulePrefix };\n }\n\n private tryComponent(path: string, from: string, withRuleLookup = true): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryComponent(parts[1], from, withRuleLookup, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryComponent(path, from, withRuleLookup, this.appPackage);\n }\n }\n\n private _tryComponent(\n path: string,\n from: string,\n withRuleLookup: boolean,\n targetPackage: Package | AppPackagePlaceholder\n ): Resolution | null {\n // The order here is important! We always put our .hbs paths first here, so\n // that if we have an hbs file of our own, that will be the first resolved\n // dependency. The first resolved dependency is special because we use that\n // as a key into the rules, and we want to be able to find our rules when\n // checking from our own template (among other times).\n\n let extensions = ['.hbs', ...this.adjustImportsOptions.resolvableExtensions.filter((e: string) => e !== '.hbs')];\n\n let componentModules = [] as string[];\n\n // first, the various places our template might be\n for (let extension of extensions) {\n let absPath = join(targetPackage.root, 'templates', 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n // then the various places our javascript might be\n for (let extension of extensions) {\n if (extension === '.hbs') {\n continue;\n }\n\n let absPath = join(targetPackage.root, 'components', path, 'index') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n if (componentModules.length > 0) {\n let componentRules;\n if (withRuleLookup) {\n componentRules = this.findComponentRules(componentModules[0]);\n }\n return {\n type: 'component',\n modules: componentModules.map(absPath => ({\n path: explicitRelative(dirname(from), absPath),\n absPath,\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n })),\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n };\n }\n\n return null;\n }\n\n resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n if (builtInHelpers.includes(path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message: `Missing helper`,\n detail: path,\n loc,\n },\n from\n );\n }\n\n resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null {\n if (this.staticHelpersEnabled) {\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (this.staticComponentsEnabled) {\n let found = this.tryComponent(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (\n hasArgs &&\n this.staticComponentsEnabled &&\n this.staticHelpersEnabled &&\n !builtInHelpers.includes(path) &&\n !this.isIgnoredComponent(path)\n ) {\n return this.add(\n {\n type: 'error',\n message: `Missing component or helper`,\n detail: path,\n loc,\n },\n from\n );\n } else {\n return null;\n }\n }\n\n resolveElement(tagName: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n if (tagName[0] === tagName[0].toLowerCase()) {\n // starts with lower case, so this can't be a component we need to\n // globally resolve\n return null;\n }\n\n let dName = dasherize(tagName);\n\n if (builtInComponents.includes(dName)) {\n return null;\n }\n\n let found = this.tryComponent(dName, from);\n if (found) {\n return this.add(found, from);\n }\n\n if (this.isIgnoredComponent(dName)) {\n return null;\n }\n\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: tagName,\n loc,\n },\n from\n );\n }\n\n resolveComponentHelper(\n component: ComponentLocator,\n from: string,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return this.add(\n {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n },\n from\n );\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findComponentRules(from);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message,\n detail: component.path,\n loc,\n },\n from\n );\n }\n let found = this.tryComponent(component.path, from);\n if (found) {\n return this.add(found, from);\n }\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: component.path,\n loc,\n },\n from\n );\n }\n}\n\nfunction humanReadableFile(root: string, file: string) {\n if (!root.endsWith('/')) {\n root += '/';\n }\n if (file.startsWith(root)) {\n return file.slice(root.length);\n }\n return file;\n}\n\n// we don't have a real Package for the app itself because the resolver has work\n// to do before we have even written out the app's own package.json and\n// therefore made it into a fully functional Package.\ninterface AppPackagePlaceholder {\n root: string;\n name: string;\n}\n\nexport type ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n"]}
1
+ {"version":3,"file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ACb,OAAO;gBACP,MAAM,EAAE,SAAS,CAAC,IAAI;gBACtB,GAAG;aACJ,EACD,IAAI,CACL,CAAC;SACH;QAED,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC9C,OAAO,IAAI,CAAC;SACb;QAED,IAAI,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,GAAG,CACb;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,SAAS,CAAC,IAAI;YACtB,GAAG;SACJ,EACD,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AA5lBC;IADC,IAAA,4BAAO,GAAE;0DAOT;AAGD;IADC,IAAA,4BAAO,GAAE;2CAoET;AAsHD;IADC,IAAA,4BAAO,GAAE;iEAGT;AA2GD;IADC,IAAA,4BAAO,GAAE;gDAGT;AApXH,iCA+pBC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACvB,IAAI,IAAI,GAAG,CAAC;KACb;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAChC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n ActivePackageRules,\n ComponentRules,\n ModuleRules,\n PackageRules,\n PreprocessedComponentRule,\n preprocessComponentRule,\n} from './dependency-rules';\nimport {\n Package,\n PackageCache,\n Resolver,\n TemplateCompiler,\n explicitRelative,\n extensionsPattern,\n} from '@embroider/core';\nimport { dirname, join, relative, sep } from 'path';\n\nimport { Options as AdjustImportsOptions } from '@embroider/core/src/babel-plugin-adjust-imports';\nimport { Memoize } from 'typescript-memoize';\nimport Options from './options';\nimport { ResolvedDep } from '@embroider/core/src/resolver';\nimport { dasherize } from './dasherize-component-name';\nimport { makeResolverTransform } from './resolver-transform';\nimport { pathExistsSync } from 'fs-extra';\nimport resolve from 'resolve';\nimport type { ASTv1 } from '@glimmer/syntax';\n\nexport interface ComponentResolution {\n type: 'component';\n modules: ResolvedDep[];\n yieldsComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n}\n\nexport interface HelperResolution {\n type: 'helper';\n modules: ResolvedDep[];\n}\n\nexport interface ModifierResolution {\n type: 'modifier';\n modules: ResolvedDep[];\n}\n\nexport type ResolutionResult = ComponentResolution | HelperResolution | ModifierResolution;\n\nexport interface ResolutionFail {\n type: 'error';\n message: string;\n detail: string;\n loc: Loc;\n}\n\ninterface ResolverDependencyError extends Error {\n isTemplateResolverError?: boolean;\n loc?: Loc;\n moduleName?: string;\n}\n\nexport type Resolution = ResolutionResult | ResolutionFail;\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\n// TODO: this depends on the ember version. And it's probably missing some\n// private-but-used values.\nconst builtInHelpers = [\n '-get-dynamic-var',\n '-in-element',\n 'in-element',\n '-with-dynamic-vars',\n 'action',\n 'array',\n 'component',\n 'concat',\n 'debugger',\n 'each',\n 'each-in',\n 'fn',\n 'get',\n 'has-block',\n 'has-block-params',\n 'hasBlock',\n 'hasBlockParams',\n 'hash',\n 'if',\n 'input',\n 'let',\n 'link-to',\n 'loc',\n 'log',\n 'mount',\n 'mut',\n 'on',\n 'outlet',\n 'partial',\n 'query-params',\n 'readonly',\n 'textarea',\n 'unbound',\n 'unless',\n 'with',\n 'yield',\n];\n\nconst builtInComponents = ['input', 'link-to', 'textarea'];\n\nconst builtInModifiers = ['action', 'on'];\n\n// this is a subset of the full Options. We care about serializability, and we\n// only needs parts that are easily serializable, which is why we don't keep the\n// whole thing.\ntype ResolverOptions = Pick<\n Required<Options>,\n 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'\n>;\n\nfunction extractOptions(options: Required<Options> | ResolverOptions): ResolverOptions {\n return {\n staticHelpers: options.staticHelpers,\n staticModifiers: options.staticModifiers,\n staticComponents: options.staticComponents,\n allowUnsafeDynamicComponents: options.allowUnsafeDynamicComponents,\n };\n}\n\ninterface RehydrationParamsBase {\n root: string;\n modulePrefix: string;\n podModulePrefix?: string;\n options: ResolverOptions;\n activePackageRules: ActivePackageRules[];\n}\n\ninterface RehydrationParamsWithFile extends RehydrationParamsBase {\n adjustImportsOptionsPath: string;\n}\n\ninterface RehydrationParamsWithOptions extends RehydrationParamsBase {\n adjustImportsOptions: AdjustImportsOptions;\n}\n\ntype RehydrationParams = RehydrationParamsWithFile | RehydrationParamsWithOptions;\n\nexport function rehydrate(params: RehydrationParams) {\n return new CompatResolver(params);\n}\n\nexport default class CompatResolver implements Resolver {\n private dependencies: Map<string, Resolution[]> = new Map();\n private templateCompiler: TemplateCompiler | undefined;\n private auditMode = false;\n\n _parallelBabel: {\n requireFile: string;\n buildUsing: string;\n params: RehydrationParams;\n };\n\n constructor(private params: RehydrationParams) {\n this.params.options = extractOptions(this.params.options);\n this._parallelBabel = {\n requireFile: __filename,\n buildUsing: 'rehydrate',\n params,\n };\n }\n\n enter(moduleName: string) {\n let rules = this.findComponentRules(moduleName);\n let deps: Resolution[];\n if (rules?.dependsOnComponents) {\n deps = rules.dependsOnComponents.map(snippet => this.resolveComponentSnippet(snippet, rules!, moduleName));\n } else {\n deps = [];\n }\n this.dependencies.set(moduleName, deps);\n }\n\n private add(resolution: Resolution, from: string) {\n // this \"!\" is safe because we always `enter()` a module before hitting this\n this.dependencies.get(from)!.push(resolution);\n return resolution;\n }\n\n private findComponentRules(absPath: string): PreprocessedComponentRule | undefined {\n let rules = this.rules.components.get(absPath);\n if (rules) {\n return rules;\n }\n\n // co-located templates aren't visible to the resolver, because they never\n // get resolved from a template (they are always handled directly by the\n // corresponding JS module, which the resolver *does* see). This means their\n // paths won't ever be in `this.rules.components`. But we do want them to\n // \"inherit\" the rules that are attached to their corresonding JS module.\n if (absPath.endsWith('.hbs')) {\n let stem = absPath.slice(0, -4);\n for (let ext of this.adjustImportsOptions.resolvableExtensions) {\n if (ext !== '.hbs') {\n let rules = this.rules.components.get(stem + ext);\n if (rules) {\n return rules;\n }\n }\n }\n }\n return undefined;\n }\n\n private isIgnoredComponent(dasherizedName: string) {\n return this.rules.ignoredComponents.includes(dasherizedName);\n }\n\n @Memoize()\n get adjustImportsOptions(): AdjustImportsOptions {\n const { params } = this;\n return 'adjustImportsOptionsPath' in params\n ? // eslint-disable-next-line @typescript-eslint/no-require-imports\n require(params.adjustImportsOptionsPath)\n : params.adjustImportsOptions;\n }\n\n @Memoize()\n private get rules() {\n if (!this.templateCompiler) {\n throw new Error(\n `Bug: Resolver needs to get linked into a TemplateCompiler before it can understand packageRules`\n );\n }\n\n // keyed by their first resolved dependency's runtimeName.\n let components: Map<string, PreprocessedComponentRule> = new Map();\n\n // keyed by our own dasherized interpretation of the component's name.\n let ignoredComponents: string[] = [];\n\n // we're not responsible for filtering out rules for inactive packages here,\n // that is done before getting to us. So we should assume these are all in\n // force.\n for (let rule of this.params.activePackageRules) {\n if (rule.components) {\n for (let [snippet, componentRules] of Object.entries(rule.components)) {\n if (componentRules.safeToIgnore) {\n ignoredComponents.push(this.standardDasherize(snippet, rule));\n continue;\n }\n let resolvedDep = this.resolveComponentSnippet(snippet, rule).modules[0];\n let processedRules = preprocessComponentRule(componentRules);\n\n // we always register our rules on the component's own first resolved\n // module, which must be a module in the app's module namespace.\n components.set(resolvedDep.absPath, processedRules);\n\n // if there's a custom layout, we also need to register our rules on\n // those templates.\n if (componentRules.layout) {\n if (componentRules.layout.appPath) {\n components.set(join(this.params.root, componentRules.layout.appPath), processedRules);\n } else if (componentRules.layout.addonPath) {\n for (let root of rule.roots) {\n components.set(join(root, componentRules.layout.addonPath), processedRules);\n }\n } else {\n throw new Error(\n `layout property in component rule must contain either appPath or addonPath: ${JSON.stringify(\n rule,\n null,\n 2\n )}`\n );\n }\n }\n }\n }\n if (rule.appTemplates) {\n for (let [path, templateRules] of Object.entries(rule.appTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n components.set(join(this.params.root, path), processedRules);\n }\n }\n if (rule.addonTemplates) {\n for (let [path, templateRules] of Object.entries(rule.addonTemplates)) {\n let processedRules = preprocessComponentRule(templateRules);\n for (let root of rule.roots) {\n components.set(join(root, path), processedRules);\n }\n }\n }\n }\n return { components, ignoredComponents };\n }\n\n resolveComponentSnippet(\n snippet: string,\n rule: PackageRules | ModuleRules,\n from = 'rule-snippet.hbs'\n ): ResolutionResult & { type: 'component' } {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let name = this.standardDasherize(snippet, rule);\n let found = this.tryComponent(name, from, false);\n if (found && found.type === 'component') {\n return found;\n }\n throw new Error(`unable to locate component ${snippet} referred to in rule ${JSON.stringify(rule, null, 2)}`);\n }\n\n private standardDasherize(snippet: string, rule: PackageRules | ModuleRules): string {\n if (!this.templateCompiler) {\n throw new Error(`bug: tried to use resolveComponentSnippet without a templateCompiler`);\n }\n let ast: ASTv1.Template | ASTv1.Program;\n try {\n ast = this.templateCompiler.parse('snippet.hbs', snippet) as unknown as ASTv1.Template | ASTv1.Program;\n } catch (err) {\n throw new Error(`unable to parse component snippet \"${snippet}\" from rule ${JSON.stringify(rule, null, 2)}`);\n }\n if ((ast.type === 'Program' || ast.type === 'Template') && ast.body.length > 0) {\n let first = ast.body[0];\n const isMustachePath = first.type === 'MustacheStatement' && first.path.type === 'PathExpression';\n const isComponent =\n isMustachePath && ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original === 'component';\n const hasStringParam =\n isComponent &&\n Array.isArray((first as ASTv1.MustacheStatement).params) &&\n (first as ASTv1.MustacheStatement).params[0].type === 'StringLiteral';\n if (isMustachePath && isComponent && hasStringParam) {\n return ((first as ASTv1.MustacheStatement).params[0] as ASTv1.StringLiteral).value;\n }\n if (isMustachePath) {\n return ((first as ASTv1.MustacheStatement).path as ASTv1.PathExpression).original;\n }\n if (first.type === 'ElementNode') {\n return dasherize(first.tag);\n }\n }\n throw new Error(`cannot identify a component in rule snippet: \"${snippet}\"`);\n }\n\n astTransformer(templateCompiler: TemplateCompiler): unknown {\n this.templateCompiler = templateCompiler;\n if (this.staticComponentsEnabled || this.staticHelpersEnabled || this.staticModifiersEnabled) {\n return makeResolverTransform(this);\n }\n }\n\n // called by our audit tool. Forces staticComponents, staticHelpers and staticModifiers\n // to activate so we can audit their behavior, while making their errors silent\n // until we can gather them up at the end of the build for the audit results.\n enableAuditMode() {\n this.auditMode = true;\n }\n\n errorsIn(moduleName: string): ResolutionFail[] {\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n return deps.filter(d => d.type === 'error') as ResolutionFail[];\n } else {\n return [];\n }\n }\n\n dependenciesOf(moduleName: string): ResolvedDep[] {\n let flatDeps: Map<string, ResolvedDep> = new Map();\n let deps = this.dependencies.get(moduleName);\n if (deps) {\n for (let dep of deps) {\n if (dep.type === 'error') {\n if (!this.auditMode && !this.params.options.allowUnsafeDynamicComponents) {\n let e: ResolverDependencyError = new Error(\n `${dep.message}: ${dep.detail} in ${humanReadableFile(this.params.root, moduleName)}`\n );\n e.isTemplateResolverError = true;\n e.loc = dep.loc;\n e.moduleName = moduleName;\n throw e;\n }\n } else {\n for (let entry of dep.modules) {\n let { runtimeName } = entry;\n flatDeps.set(runtimeName, entry);\n }\n }\n }\n }\n return [...flatDeps.values()];\n }\n\n resolveImport(path: string, from: string): { runtimeName: string; absPath: string } | undefined {\n let absPath;\n try {\n absPath = resolve.sync(path, {\n basedir: dirname(from),\n extensions: this.adjustImportsOptions.resolvableExtensions,\n });\n } catch (err) {\n return;\n }\n if (absPath) {\n let runtimeName = this.absPathToRuntimeName(absPath);\n if (runtimeName) {\n return { runtimeName, absPath };\n }\n }\n }\n\n @Memoize()\n private get resolvableExtensionsPattern() {\n return extensionsPattern(this.adjustImportsOptions.resolvableExtensions);\n }\n\n absPathToRuntimePath(absPath: string, owningPackage?: { root: string; name: string }) {\n let pkg = owningPackage || PackageCache.shared('embroider-stage3').ownerOfFile(absPath);\n if (pkg) {\n let packageRuntimeName = pkg.name;\n for (let [runtimeName, realName] of Object.entries(this.adjustImportsOptions.renamePackages)) {\n if (realName === packageRuntimeName) {\n packageRuntimeName = runtimeName;\n break;\n }\n }\n return join(packageRuntimeName, relative(pkg.root, absPath)).split(sep).join('/');\n } else if (absPath.startsWith(this.params.root)) {\n return join(this.params.modulePrefix, relative(this.params.root, absPath)).split(sep).join('/');\n } else {\n throw new Error(`bug: can't figure out the runtime name for ${absPath}`);\n }\n }\n\n absPathToRuntimeName(absPath: string, owningPackage?: { root: string; name: string }) {\n return this.absPathToRuntimePath(absPath, owningPackage)\n .replace(this.resolvableExtensionsPattern, '')\n .replace(/\\/index$/, '');\n }\n\n private get staticComponentsEnabled(): boolean {\n return this.params.options.staticComponents || this.auditMode;\n }\n\n private get staticHelpersEnabled(): boolean {\n return this.params.options.staticHelpers || this.auditMode;\n }\n\n private get staticModifiersEnabled(): boolean {\n return this.params.options.staticModifiers || this.auditMode;\n }\n\n private tryHelper(path: string, from: string): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryHelper(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryHelper(path, from, this.appPackage);\n }\n }\n\n private _tryHelper(path: string, from: string, targetPackage: Package | AppPackagePlaceholder): Resolution | null {\n for (let extension of this.adjustImportsOptions.resolvableExtensions) {\n let absPath = join(targetPackage.root, 'helpers', path) + extension;\n if (pathExistsSync(absPath)) {\n return {\n type: 'helper',\n modules: [\n {\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n path: explicitRelative(dirname(from), absPath),\n absPath,\n },\n ],\n };\n }\n }\n return null;\n }\n\n private tryModifier(path: string, from: string): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryModifier(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryModifier(path, from, this.appPackage);\n }\n }\n\n private _tryModifier(path: string, from: string, targetPackage: Package | AppPackagePlaceholder): Resolution | null {\n for (let extension of this.adjustImportsOptions.resolvableExtensions) {\n let absPath = join(targetPackage.root, 'modifiers', path) + extension;\n if (pathExistsSync(absPath)) {\n return {\n type: 'modifier',\n modules: [\n {\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n path: explicitRelative(dirname(from), absPath),\n absPath,\n },\n ],\n };\n }\n }\n return null;\n }\n\n @Memoize()\n private get appPackage(): AppPackagePlaceholder {\n return { root: this.params.root, name: this.params.modulePrefix };\n }\n\n private tryComponent(path: string, from: string, withRuleLookup = true): Resolution | null {\n let parts = path.split('@');\n if (parts.length > 1 && parts[0].length > 0) {\n let cache = PackageCache.shared('embroider-stage3');\n let packageName = parts[0];\n let renamed = this.adjustImportsOptions.renamePackages[packageName];\n if (renamed) {\n packageName = renamed;\n }\n return this._tryComponent(parts[1], from, withRuleLookup, cache.resolve(packageName, cache.ownerOfFile(from)!));\n } else {\n return this._tryComponent(path, from, withRuleLookup, this.appPackage);\n }\n }\n\n private _tryComponent(\n path: string,\n from: string,\n withRuleLookup: boolean,\n targetPackage: Package | AppPackagePlaceholder\n ): Resolution | null {\n // The order here is important! We always put our .hbs paths first here, so\n // that if we have an hbs file of our own, that will be the first resolved\n // dependency. The first resolved dependency is special because we use that\n // as a key into the rules, and we want to be able to find our rules when\n // checking from our own template (among other times).\n\n let extensions = ['.hbs', ...this.adjustImportsOptions.resolvableExtensions.filter((e: string) => e !== '.hbs')];\n\n let componentModules = [] as string[];\n\n // first, the various places our template might be\n for (let extension of extensions) {\n let absPath = join(targetPackage.root, 'templates', 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'template') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n // then the various places our javascript might be\n for (let extension of extensions) {\n if (extension === '.hbs') {\n continue;\n }\n\n let absPath = join(targetPackage.root, 'components', path, 'index') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path) + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n absPath = join(targetPackage.root, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n\n if (\n typeof this.params.podModulePrefix !== 'undefined' &&\n this.params.podModulePrefix !== '' &&\n targetPackage === this.appPackage\n ) {\n let podPrefix = this.params.podModulePrefix.replace(this.params.modulePrefix, '');\n\n absPath = join(targetPackage.root, podPrefix, 'components', path, 'component') + extension;\n if (pathExistsSync(absPath)) {\n componentModules.push(absPath);\n break;\n }\n }\n }\n\n if (componentModules.length > 0) {\n let componentRules;\n if (withRuleLookup) {\n componentRules = this.findComponentRules(componentModules[0]);\n }\n return {\n type: 'component',\n modules: componentModules.map(absPath => ({\n path: explicitRelative(dirname(from), absPath),\n absPath,\n runtimeName: this.absPathToRuntimeName(absPath, targetPackage),\n })),\n yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],\n yieldsArguments: componentRules ? componentRules.yieldsArguments : [],\n argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],\n };\n }\n\n return null;\n }\n\n resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticHelpersEnabled) {\n return null;\n }\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n if (builtInHelpers.includes(path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message: `Missing helper`,\n detail: path,\n loc,\n },\n from\n );\n }\n\n resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null {\n if (this.staticHelpersEnabled) {\n let found = this.tryHelper(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (this.staticComponentsEnabled) {\n let found = this.tryComponent(path, from);\n if (found) {\n return this.add(found, from);\n }\n }\n if (\n hasArgs &&\n this.staticComponentsEnabled &&\n this.staticHelpersEnabled &&\n !builtInHelpers.includes(path) &&\n !this.isIgnoredComponent(path)\n ) {\n return this.add(\n {\n type: 'error',\n message: `Missing component or helper`,\n detail: path,\n loc,\n },\n from\n );\n } else {\n return null;\n }\n }\n\n resolveElementModifierStatement(path: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticModifiersEnabled) {\n return null;\n }\n let found = this.tryModifier(path, from);\n if (found) {\n return this.add(found, from);\n }\n if (builtInModifiers.includes(path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message: `Missing modifier`,\n detail: path,\n loc,\n },\n from\n );\n }\n\n resolveElement(tagName: string, from: string, loc: Loc): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n if (tagName[0] === tagName[0].toLowerCase()) {\n // starts with lower case, so this can't be a component we need to\n // globally resolve\n return null;\n }\n\n let dName = dasherize(tagName);\n\n if (builtInComponents.includes(dName)) {\n return null;\n }\n\n let found = this.tryComponent(dName, from);\n if (found) {\n return this.add(found, from);\n }\n\n if (this.isIgnoredComponent(dName)) {\n return null;\n }\n\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: tagName,\n loc,\n },\n from\n );\n }\n\n resolveComponentHelper(\n component: ComponentLocator,\n from: string,\n loc: Loc,\n impliedBecause?: { componentName: string; argumentName: string }\n ): Resolution | null {\n if (!this.staticComponentsEnabled) {\n return null;\n }\n\n let message;\n if (impliedBecause) {\n message = `argument \"${impliedBecause.argumentName}\" to component \"${impliedBecause.componentName}\" is treated as a component, but the value you're passing is dynamic`;\n } else {\n message = `Unsafe dynamic component`;\n }\n\n if (component.type === 'other') {\n return this.add(\n {\n type: 'error',\n message,\n detail: `cannot statically analyze this expression`,\n loc,\n },\n from\n );\n }\n if (component.type === 'path') {\n let ownComponentRules = this.findComponentRules(from);\n if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {\n return null;\n }\n return this.add(\n {\n type: 'error',\n message,\n detail: component.path,\n loc,\n },\n from\n );\n }\n\n if (builtInComponents.includes(component.path)) {\n return null;\n }\n\n let found = this.tryComponent(component.path, from);\n if (found) {\n return this.add(found, from);\n }\n return this.add(\n {\n type: 'error',\n message: `Missing component`,\n detail: component.path,\n loc,\n },\n from\n );\n }\n}\n\nfunction humanReadableFile(root: string, file: string) {\n if (!root.endsWith('/')) {\n root += '/';\n }\n if (file.startsWith(root)) {\n return file.slice(root.length);\n }\n return file;\n}\n\n// we don't have a real Package for the app itself because the resolver has work\n// to do before we have even written out the app's own package.json and\n// therefore made it into a fully functional Package.\ninterface AppPackagePlaceholder {\n root: string;\n name: string;\n}\n\nexport type ComponentLocator =\n | {\n type: 'literal';\n path: string;\n }\n | {\n type: 'path';\n path: string;\n }\n | {\n type: 'other';\n };\n"]}