@embroider/compat 0.47.0 → 0.48.1

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.0",
3
+ "version": "0.48.1",
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.0",
33
- "@embroider/shared-internals": "0.47.0",
32
+ "@embroider/macros": "0.48.1",
33
+ "@embroider/shared-internals": "0.48.1",
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.0"
88
+ "@embroider/core": "0.48.1"
89
89
  },
90
90
  "engines": {
91
91
  "node": "12.* || 14.* || >= 16"
package/src/audit-cli.js CHANGED
File without changes
@@ -26,6 +26,12 @@ function buildCompatAddon(originalPackage, v1Cache) {
26
26
  return withoutNodeModules(originalPackage);
27
27
  }
28
28
  let oldPackages = v1Cache.getAddons(originalPackage.root);
29
+ if (oldPackages.length > 1) {
30
+ // extensibility hook that allows a compat adapter to optimize its own
31
+ // smooshing. We do it early so that if it reduces all the way to zero, the
32
+ // next check will handle that.
33
+ oldPackages = oldPackages[0].reduceInstances(oldPackages);
34
+ }
29
35
  if (oldPackages.length === 0) {
30
36
  // this happens when the v1 addon wasn't actually getting instantiated at
31
37
  // all, which can happen if the app uses `addons.blacklist` or another addon
@@ -37,7 +43,7 @@ function buildCompatAddon(originalPackage, v1Cache) {
37
43
  // up unused at this point.
38
44
  return new empty_package_tree_1.default(originalPackage.name);
39
45
  }
40
- let needsSmooshing = oldPackages[0].hasAnyTrees();
46
+ let needsSmooshing = oldPackages.length > 1 && oldPackages[0].hasAnyTrees();
41
47
  if (needsSmooshing) {
42
48
  let trees = oldPackages.map(pkg => pkg.v2Tree).reverse();
43
49
  let smoosher = new smoosh_package_json_1.default(trees, { annotation: originalPackage.name });
@@ -1 +1 @@
1
- {"version":3,"file":"build-compat-addon.js","sourceRoot":"","sources":["build-compat-addon.ts"],"names":[],"mappings":";;;;;AAEA,gFAAsD;AACtD,gFAAsD;AAEtD,0DAAiC;AACjC,sEAA0C;AAC1C,qDAA2D;AAC3D,8EAAoD;AAEpD,SAAwB,sBAAsB,CAAC,eAAwB,EAAE,OAAwB;IAC/F,IAAI,IAAI,GAAG,gBAAgB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;QAC/B,IAAI,GAAG,IAAI,kBAAO,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;KAChD;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,yCAMC;AAED,SAAS,gBAAgB,CAAC,eAAwB,EAAE,OAAwB;IAC1E,IAAI,eAAe,CAAC,SAAS,EAAE,EAAE;QAC/B,0DAA0D;QAC1D,kEAAkE;QAClE,0EAA0E;QAC1E,aAAa;QACb,OAAO,kBAAkB,CAAC,eAAe,CAAC,CAAC;KAC5C;IAED,IAAI,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAE1D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,yEAAyE;QACzE,4EAA4E;QAC5E,kCAAkC;QAClC,EAAE;QACF,yEAAyE;QACzE,gEAAgE;QAChE,0EAA0E;QAC1E,2BAA2B;QAC3B,OAAO,IAAI,4BAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;KACnD;IAED,IAAI,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAClD,IAAI,cAAc,EAAE;QAClB,IAAI,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QACzD,IAAI,QAAQ,GAAG,IAAI,6BAAiB,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;QAClF,OAAO,IAAA,8BAAkB,EAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACtE;SAAM;QACL,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KAC9B;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,eAAwB;IAClD,IAAI,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,4BAAU,CAAC,CAAC,CAAC,8BAAY,CAAC;IACnE,OAAO,IAAA,yBAAW,EAAC,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAClD,OAAO,EAAE,CAAC,cAAc,CAAC;KAC1B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import V1InstanceCache from './v1-instance-cache';\nimport { Package } from '@embroider/core';\nimport SmooshPackageJSON from './smoosh-package-json';\nimport broccoliMergeTrees from 'broccoli-merge-trees';\nimport { Node } from 'broccoli-node-api';\nimport OneShot from './one-shot';\nimport buildFunnel from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport EmptyPackageTree from './empty-package-tree';\n\nexport default function cachedBuildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {\n let tree = buildCompatAddon(originalPackage, v1Cache);\n if (!originalPackage.mayRebuild) {\n tree = new OneShot(tree, originalPackage.name);\n }\n return tree;\n}\n\nfunction buildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {\n if (originalPackage.isV2Addon()) {\n // this case is needed when a native-v2 addon depends on a\n // non-native-v2 addon. (The non-native one will get rewritten and\n // therefore moved, so to continue depending on it the native one needs to\n // move too.)\n return withoutNodeModules(originalPackage);\n }\n\n let oldPackages = v1Cache.getAddons(originalPackage.root);\n\n if (oldPackages.length === 0) {\n // this happens when the v1 addon wasn't actually getting instantiated at\n // all, which can happen if the app uses `addons.blacklist` or another addon\n // uses `shouldIncludeChildAddon`.\n //\n // we still keep a place for this addon in the rewritten addon workspace,\n // because that whole process only depends on looking at all the\n // package.json files on disk -- it can't know which ones are going to end\n // up unused at this point.\n return new EmptyPackageTree(originalPackage.name);\n }\n\n let needsSmooshing = oldPackages[0].hasAnyTrees();\n if (needsSmooshing) {\n let trees = oldPackages.map(pkg => pkg.v2Tree).reverse();\n let smoosher = new SmooshPackageJSON(trees, { annotation: originalPackage.name });\n return broccoliMergeTrees([...trees, smoosher], { overwrite: true });\n } else {\n return oldPackages[0].v2Tree;\n }\n}\n\nfunction withoutNodeModules(originalPackage: Package): Node {\n let Klass = originalPackage.mayRebuild ? WatchedDir : UnwatchedDir;\n return buildFunnel(new Klass(originalPackage.root), {\n exclude: ['node_modules'],\n });\n}\n"]}
1
+ {"version":3,"file":"build-compat-addon.js","sourceRoot":"","sources":["build-compat-addon.ts"],"names":[],"mappings":";;;;;AAEA,gFAAsD;AACtD,gFAAsD;AAEtD,0DAAiC;AACjC,sEAA0C;AAC1C,qDAA2D;AAC3D,8EAAoD;AAEpD,SAAwB,sBAAsB,CAAC,eAAwB,EAAE,OAAwB;IAC/F,IAAI,IAAI,GAAG,gBAAgB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;QAC/B,IAAI,GAAG,IAAI,kBAAO,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;KAChD;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,yCAMC;AAED,SAAS,gBAAgB,CAAC,eA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SAAS,kBAAkB,CAAC,eAAwB;IAClD,IAAI,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,4BAAU,CAAC,CAAC,CAAC,8BAAY,CAAC;IACnE,OAAO,IAAA,yBAAW,EAAC,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAClD,OAAO,EAAE,CAAC,cAAc,CAAC;KAC1B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import V1InstanceCache from './v1-instance-cache';\nimport { Package } from '@embroider/core';\nimport SmooshPackageJSON from './smoosh-package-json';\nimport broccoliMergeTrees from 'broccoli-merge-trees';\nimport { Node } from 'broccoli-node-api';\nimport OneShot from './one-shot';\nimport buildFunnel from 'broccoli-funnel';\nimport { UnwatchedDir, WatchedDir } from 'broccoli-source';\nimport EmptyPackageTree from './empty-package-tree';\n\nexport default function cachedBuildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {\n let tree = buildCompatAddon(originalPackage, v1Cache);\n if (!originalPackage.mayRebuild) {\n tree = new OneShot(tree, originalPackage.name);\n }\n return tree;\n}\n\nfunction buildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {\n if (originalPackage.isV2Addon()) {\n // this case is needed when a native-v2 addon depends on a\n // non-native-v2 addon. (The non-native one will get rewritten and\n // therefore moved, so to continue depending on it the native one needs to\n // move too.)\n return withoutNodeModules(originalPackage);\n }\n\n let oldPackages = v1Cache.getAddons(originalPackage.root);\n\n if (oldPackages.length > 1) {\n // extensibility hook that allows a compat adapter to optimize its own\n // smooshing. We do it early so that if it reduces all the way to zero, the\n // next check will handle that.\n oldPackages = oldPackages[0].reduceInstances(oldPackages);\n }\n\n if (oldPackages.length === 0) {\n // this happens when the v1 addon wasn't actually getting instantiated at\n // all, which can happen if the app uses `addons.blacklist` or another addon\n // uses `shouldIncludeChildAddon`.\n //\n // we still keep a place for this addon in the rewritten addon workspace,\n // because that whole process only depends on looking at all the\n // package.json files on disk -- it can't know which ones are going to end\n // up unused at this point.\n return new EmptyPackageTree(originalPackage.name);\n }\n\n let needsSmooshing = oldPackages.length > 1 && oldPackages[0].hasAnyTrees();\n if (needsSmooshing) {\n let trees = oldPackages.map(pkg => pkg.v2Tree).reverse();\n let smoosher = new SmooshPackageJSON(trees, { annotation: originalPackage.name });\n return broccoliMergeTrees([...trees, smoosher], { overwrite: true });\n } else {\n return oldPackages[0].v2Tree;\n }\n}\n\nfunction withoutNodeModules(originalPackage: Package): Node {\n let Klass = originalPackage.mayRebuild ? WatchedDir : UnwatchedDir;\n return buildFunnel(new Klass(originalPackage.root), {\n exclude: ['node_modules'],\n });\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import V1Addon from '../v1-addon';
2
+ export default class EmberCliBabel extends V1Addon {
3
+ reduceInstances(copies: EmberCliBabel[]): EmberCliBabel[];
4
+ }
@@ -0,0 +1,25 @@
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 v1_addon_1 = __importDefault(require("../v1-addon"));
7
+ class EmberCliBabel extends v1_addon_1.default {
8
+ // the only copy of ember-cli-babel that might need to do something is the
9
+ // first one that wants to emit babel polyfills. No other copy is allowed to
10
+ // emit anything into the build.
11
+ reduceInstances(copies) {
12
+ let polyfillCopy = copies.find(c => {
13
+ let instance = c.addonInstance;
14
+ return typeof instance._shouldIncludePolyfill === 'function' && instance._shouldIncludePolyfill();
15
+ });
16
+ if (polyfillCopy) {
17
+ return [polyfillCopy];
18
+ }
19
+ else {
20
+ return [];
21
+ }
22
+ }
23
+ }
24
+ exports.default = EmberCliBabel;
25
+ //# 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,2DAAkC;AAElC,MAAqB,aAAc,SAAQ,kBAAO;IAChD,0EAA0E;IAC1E,4EAA4E;IAC5E,gCAAgC;IAChC,eAAe,CAAC,MAAuB;QACrC,IAAI,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACjC,IAAI,QAAQ,GAAG,CAAC,CAAC,aAAoB,CAAC;YACtC,OAAO,OAAO,QAAQ,CAAC,sBAAsB,KAAK,UAAU,IAAI,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QACpG,CAAC,CAAC,CAAC;QACH,IAAI,YAAY,EAAE;YAChB,OAAO,CAAC,YAAY,CAAC,CAAC;SACvB;aAAM;YACL,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import V1Addon from '../v1-addon';\n\nexport default class EmberCliBabel extends V1Addon {\n // the only copy of ember-cli-babel that might need to do something is the\n // first one that wants to emit babel polyfills. No other copy is allowed to\n // emit anything into the build.\n reduceInstances(copies: EmberCliBabel[]): EmberCliBabel[] {\n let polyfillCopy = copies.find(c => {\n let instance = c.addonInstance as any;\n return typeof instance._shouldIncludePolyfill === 'function' && instance._shouldIncludePolyfill();\n });\n if (polyfillCopy) {\n return [polyfillCopy];\n } else {\n return [];\n }\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAyE;AACzE,mCAAmC;AAEnC,+BAA+B;AA8J/B,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,mBAAmB,GAAG,EAAE,CAAC;IAC7B,IAAI,cAAc,CAAC,yBAAyB,EAAE;QAC5C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE;YAC1D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAClC;KACF;IACD,IAAI,cAAc,CAAC,OAAO,EAAE;QAC1B,KAAK,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAA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ompatResolver from './resolver';\nimport { dirname } from 'path';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your temlate says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n dependsOnComponents: ComponentSnippet[];\n argumentsAreComponents: string[];\n safeInteriorPaths: string[];\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n let dependsOnComponents = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n }\n }\n if (componentRules.invokes) {\n for (let [path, snippets] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n for (let snippet of snippets) {\n dependsOnComponents.push(snippet);\n }\n }\n }\n return {\n argumentsAreComponents,\n safeInteriorPaths,\n dependsOnComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n };\n}\n\nexport function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {\n let output: { absPath: string; target: string; runtimeName: string }[] = [];\n if (moduleRules.dependsOnModules) {\n for (let path of moduleRules.dependsOnModules) {\n let found = resolver.resolveImport(path, absPath);\n if (!found) {\n throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);\n }\n output.push({\n absPath,\n target: explicitRelative(dirname(absPath), found.absPath),\n runtimeName: found.runtimeName,\n });\n }\n }\n if (moduleRules.dependsOnComponents) {\n for (let snippet of moduleRules.dependsOnComponents) {\n let found = resolver.resolveComponentSnippet(snippet, moduleRules);\n for (let { absPath: target, runtimeName } of found.modules) {\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n }\n }\n return output;\n}\n"]}
1
+ {"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAyE;AACzE,mCAAmC;AAEnC,+BAA+B;AA8J/B,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,mBAAmB,GAAG,EAAE,CAAC;IAC7B,IAAI,cAAc,CAAC,yBAAyB,EAAE;QAC5C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE;YAC1D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ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IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAxBD,8CAwBC","sourcesContent":["import { Package, explicitRelative, getOrCreate } from '@embroider/core';\nimport { satisfies } from 'semver';\nimport CompatResolver from './resolver';\nimport { dirname } from 'path';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n dependsOnComponents: ComponentSnippet[];\n argumentsAreComponents: string[];\n safeInteriorPaths: string[];\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n let dependsOnComponents = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n }\n }\n if (componentRules.invokes) {\n for (let [path, snippets] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n for (let snippet of snippets) {\n dependsOnComponents.push(snippet);\n }\n }\n }\n return {\n argumentsAreComponents,\n safeInteriorPaths,\n dependsOnComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n };\n}\n\nexport function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {\n let output: { absPath: string; target: string; runtimeName: string }[] = [];\n if (moduleRules.dependsOnModules) {\n for (let path of moduleRules.dependsOnModules) {\n let found = resolver.resolveImport(path, absPath);\n if (!found) {\n throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);\n }\n output.push({\n absPath,\n target: explicitRelative(dirname(absPath), found.absPath),\n runtimeName: found.runtimeName,\n });\n }\n }\n if (moduleRules.dependsOnComponents) {\n for (let snippet of moduleRules.dependsOnComponents) {\n let found = resolver.resolveComponentSnippet(snippet, moduleRules);\n for (let { absPath: target, runtimeName } of found.modules) {\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n }\n }\n return output;\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 }) {
@@ -29,6 +29,9 @@ function makeResolverTransform(resolver) {
29
29
  if (scopeStack.inScope(node.path.parts[0])) {
30
30
  return;
31
31
  }
32
+ if (node.path.this === true) {
33
+ return;
34
+ }
32
35
  if (node.path.parts.length > 1) {
33
36
  // paths with a dot in them (which therefore split into more than
34
37
  // one "part") are classically understood by ember to be contextual
@@ -81,6 +84,9 @@ function makeResolverTransform(resolver) {
81
84
  if (scopeStack.inScope(node.path.parts[0])) {
82
85
  return;
83
86
  }
87
+ if (node.path.this === true) {
88
+ return;
89
+ }
84
90
  if (node.path.parts.length > 1) {
85
91
  // paths with a dot in them (which therefore split into more than
86
92
  // one "part") are classically understood by ember to be contextual
@@ -106,6 +112,29 @@ function makeResolverTransform(resolver) {
106
112
  }
107
113
  }
108
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
+ },
109
138
  ElementNode: {
110
139
  enter(node) {
111
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,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,CAA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AC,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.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.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;iBACF;gBACD,cAAc,CAAC,IAA0B;oBACvC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;wBACvC,OAAO;qBACR;oB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,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,12 +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;
97
+ private _tryHelper;
98
+ private tryModifier;
99
+ private _tryModifier;
92
100
  private get appPackage();
93
101
  private tryComponent;
94
102
  private _tryComponent;
95
103
  resolveSubExpression(path: string, from: string, loc: Loc): Resolution | null;
96
104
  resolveMustache(path: string, hasArgs: boolean, from: string, loc: Loc): Resolution | null;
105
+ resolveElementModifierStatement(path: string, from: string, loc: Loc): Resolution | null;
97
106
  resolveElement(tagName: string, from: string, loc: Loc): Resolution | null;
98
107
  resolveComponentHelper(component: ComponentLocator, from: string, loc: Loc, impliedBecause?: {
99
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,15 +327,66 @@ 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) {
334
+ let parts = path.split('@');
335
+ if (parts.length > 1 && parts[0].length > 0) {
336
+ let cache = core_1.PackageCache.shared('embroider-stage3');
337
+ let packageName = parts[0];
338
+ let renamed = this.adjustImportsOptions.renamePackages[packageName];
339
+ if (renamed) {
340
+ packageName = renamed;
341
+ }
342
+ return this._tryHelper(parts[1], from, cache.resolve(packageName, cache.ownerOfFile(from)));
343
+ }
344
+ else {
345
+ return this._tryHelper(path, from, this.appPackage);
346
+ }
347
+ }
348
+ _tryHelper(path, from, targetPackage) {
329
349
  for (let extension of this.adjustImportsOptions.resolvableExtensions) {
330
- let absPath = (0, path_1.join)(this.params.root, 'helpers', path) + extension;
350
+ let absPath = (0, path_1.join)(targetPackage.root, 'helpers', path) + extension;
331
351
  if ((0, fs_extra_1.pathExistsSync)(absPath)) {
332
352
  return {
333
353
  type: 'helper',
334
354
  modules: [
335
355
  {
336
- runtimeName: `${this.params.modulePrefix}/helpers/${path}`,
356
+ runtimeName: this.absPathToRuntimeName(absPath, targetPackage),
357
+ path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
358
+ absPath,
359
+ },
360
+ ],
361
+ };
362
+ }
363
+ }
364
+ return null;
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),
337
390
  path: (0, core_1.explicitRelative)((0, path_1.dirname)(from), absPath),
338
391
  absPath,
339
392
  },
@@ -489,6 +542,24 @@ class CompatResolver {
489
542
  return null;
490
543
  }
491
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
+ }
492
563
  resolveElement(tagName, from, loc) {
493
564
  if (!this.staticComponentsEnabled) {
494
565
  return null;
@@ -547,6 +618,9 @@ class CompatResolver {
547
618
  loc,
548
619
  }, from);
549
620
  }
621
+ if (builtInComponents.includes(component.path)) {
622
+ return null;
623
+ }
550
624
  let found = this.tryComponent(component.path, from);
551
625
  if (found) {
552
626
  return this.add(found, from);