@embroider/compat 3.8.1-unstable.fc482ba → 3.8.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.
Files changed (97) hide show
  1. package/package.json +17 -15
  2. package/src/audit/babel-visitor.js +1 -7
  3. package/src/audit/babel-visitor.js.map +1 -1
  4. package/src/audit/build.js.map +1 -1
  5. package/src/audit/options.d.ts +1 -2
  6. package/src/audit/options.js.map +1 -1
  7. package/src/audit-cli.d.ts +2 -0
  8. package/src/audit-cli.js +150 -0
  9. package/src/audit-cli.js.map +1 -0
  10. package/src/audit.d.ts +57 -7
  11. package/src/audit.js +301 -101
  12. package/src/audit.js.map +1 -1
  13. package/src/babel-plugin-adjust-imports.js +18 -19
  14. package/src/babel-plugin-adjust-imports.js.map +1 -1
  15. package/src/compat-adapters/@ember-data/debug.d.ts +6 -0
  16. package/src/compat-adapters/@ember-data/debug.js +22 -0
  17. package/src/compat-adapters/@ember-data/debug.js.map +1 -0
  18. package/src/compat-adapters/@ember-data/store.d.ts +5 -1
  19. package/src/compat-adapters/@ember-data/store.js +15 -3
  20. package/src/compat-adapters/@ember-data/store.js.map +1 -1
  21. package/src/compat-adapters/active-model-adapter.d.ts +1 -1
  22. package/src/compat-adapters/ember-asset-loader.d.ts +1 -1
  23. package/src/compat-adapters/ember-cli-addon-docs.d.ts +1 -1
  24. package/src/compat-adapters/ember-cli-fastboot.js +1 -0
  25. package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
  26. package/src/compat-adapters/ember-cli-mirage.js +1 -0
  27. package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
  28. package/src/compat-adapters/ember-decorators.d.ts +1 -1
  29. package/src/compat-adapters/ember-macro-helpers.d.ts +4 -0
  30. package/src/compat-adapters/{ember-fetch.js → ember-macro-helpers.js} +4 -5
  31. package/src/compat-adapters/ember-macro-helpers.js.map +1 -0
  32. package/src/compat-adapters/ember-percy.d.ts +1 -1
  33. package/src/compat-adapters/ember-scroll-modifiers.d.ts +1 -1
  34. package/src/compat-adapters/ember-source.d.ts +6 -3
  35. package/src/compat-adapters/ember-source.js +41 -26
  36. package/src/compat-adapters/ember-source.js.map +1 -1
  37. package/src/compat-adapters/ember-test-selectors.d.ts +1 -1
  38. package/src/compat-addons.js +1 -1
  39. package/src/compat-addons.js.map +1 -1
  40. package/src/compat-app-builder.d.ts +64 -9
  41. package/src/compat-app-builder.js +1272 -110
  42. package/src/compat-app-builder.js.map +1 -1
  43. package/src/compat-app.d.ts +22 -4
  44. package/src/compat-app.js +218 -77
  45. package/src/compat-app.js.map +1 -1
  46. package/src/default-pipeline.d.ts +5 -4
  47. package/src/default-pipeline.js +46 -21
  48. package/src/default-pipeline.js.map +1 -1
  49. package/src/dependency-rules.d.ts +0 -1
  50. package/src/dependency-rules.js +11 -19
  51. package/src/dependency-rules.js.map +1 -1
  52. package/src/detect-babel-plugins.d.ts +0 -1
  53. package/src/detect-babel-plugins.js +0 -14
  54. package/src/detect-babel-plugins.js.map +1 -1
  55. package/src/index.d.ts +2 -2
  56. package/src/index.js +4 -3
  57. package/src/index.js.map +1 -1
  58. package/src/options.d.ts +40 -3
  59. package/src/options.js +11 -3
  60. package/src/options.js.map +1 -1
  61. package/src/rename-require-plugin.d.ts +1 -0
  62. package/src/rename-require-plugin.js +15 -0
  63. package/src/rename-require-plugin.js.map +1 -0
  64. package/src/resolver-transform.js +15 -56
  65. package/src/resolver-transform.js.map +1 -1
  66. package/src/standalone-addon-build.js +15 -6
  67. package/src/standalone-addon-build.js.map +1 -1
  68. package/src/sync-dir.d.ts +8 -0
  69. package/src/sync-dir.js +68 -0
  70. package/src/sync-dir.js.map +1 -0
  71. package/src/template-tag-codemod.d.ts +13 -0
  72. package/src/template-tag-codemod.js +302 -0
  73. package/src/template-tag-codemod.js.map +1 -0
  74. package/src/v1-appboot.d.ts +14 -0
  75. package/src/v1-appboot.js +47 -0
  76. package/src/v1-appboot.js.map +1 -0
  77. package/src/v1-config.d.ts +8 -0
  78. package/src/v1-config.js +51 -1
  79. package/src/v1-config.js.map +1 -1
  80. package/babel.js +0 -1
  81. package/src/babel.d.ts +0 -17
  82. package/src/babel.js +0 -146
  83. package/src/babel.js.map +0 -1
  84. package/src/compat-adapters/ember-fetch.d.ts +0 -5
  85. package/src/compat-adapters/ember-fetch.js.map +0 -1
  86. package/src/compat-adapters/ember-resolver.d.ts +0 -4
  87. package/src/compat-adapters/ember-resolver.js +0 -21
  88. package/src/compat-adapters/ember-resolver.js.map +0 -1
  89. package/src/content-for-config.d.ts +0 -11
  90. package/src/content-for-config.js +0 -66
  91. package/src/content-for-config.js.map +0 -1
  92. package/src/http-audit.d.ts +0 -13
  93. package/src/http-audit.js +0 -60
  94. package/src/http-audit.js.map +0 -1
  95. package/src/module-visitor.d.ts +0 -52
  96. package/src/module-visitor.js +0 -285
  97. package/src/module-visitor.js.map +0 -1
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compatBuild = exports.prebuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
6
+ exports.templateTagCodemod = exports.compatBuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
7
7
  var compat_app_1 = require("./compat-app");
8
8
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(compat_app_1).default; } });
9
9
  var compat_addons_1 = require("./compat-addons");
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "recommendedOptions", { enumerable: true, get: fu
13
13
  var v1_addon_1 = require("./v1-addon");
14
14
  Object.defineProperty(exports, "V1Addon", { enumerable: true, get: function () { return __importDefault(v1_addon_1).default; } });
15
15
  var default_pipeline_1 = require("./default-pipeline");
16
- Object.defineProperty(exports, "prebuild", { enumerable: true, get: function () { return default_pipeline_1.prebuild; } });
17
- Object.defineProperty(exports, "compatBuild", { enumerable: true, get: function () { return default_pipeline_1.compatBuild; } });
16
+ Object.defineProperty(exports, "compatBuild", { enumerable: true, get: function () { return __importDefault(default_pipeline_1).default; } });
17
+ var template_tag_codemod_1 = require("./template-tag-codemod");
18
+ Object.defineProperty(exports, "templateTagCodemod", { enumerable: true, get: function () { return __importDefault(template_tag_codemod_1).default; } });
18
19
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAA4E;AAAnE,4GAAA,QAAQ,OAAA;AAAE,+GAAA,WAAW,OAAA","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { prebuild, compatBuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\nexport type { Options as ResolverTransformOptions } from './resolver-transform';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAA6E;AAApE,gIAAA,OAAO,OAAe;AAC/B,+DAAuE;AAA9D,2IAAA,OAAO,OAAsB","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { default as compatBuild, PipelineOptions } from './default-pipeline';\nexport { default as templateTagCodemod } from './template-tag-codemod';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
package/src/options.d.ts CHANGED
@@ -1,15 +1,52 @@
1
1
  import type { V1AddonConstructor } from './v1-addon';
2
+ import type { Node } from 'broccoli-node-api';
2
3
  import type { Options as CoreOptions } from '@embroider/core';
3
4
  import type { PackageRules } from './dependency-rules';
4
5
  export default interface Options extends CoreOptions {
6
+ /**
7
+ * Controls whether your addon's "addon" trees should be resolved statically
8
+ * at build time.
9
+ *
10
+ * Note: This setting will be removed in the next version of Embroider and
11
+ * will effectively default to true
12
+ *
13
+ * false (the current default): implies maximum backward compatibility at
14
+ * the cost of bigger builds. In this mode, we force every file into the
15
+ * Ember app, which is the legacy behavior.
16
+ *
17
+ * true: produces smaller builds. The addon files must be imported from
18
+ * somewhere we can statically see during the build. In this mode, your app
19
+ * will only include files that are actually imported from somewhere.
20
+ *
21
+ * Commentary: most v1 addons already work well with this set to true, because
22
+ * they tend to either offer Javascript that users are supposed to directly
23
+ * `import` or components / helpers / services that get directly imported and
24
+ * re-exported by code in App Javascript. The exceptions are addons that do
25
+ * runtime shenanigans with `require` or scoped runtime resolutions.
26
+ *
27
+ * To workaround an addon that is preventing you from enabling this flag, you
28
+ * can use addonDependencyRules.
29
+ */
5
30
  staticAddonTrees?: boolean;
6
31
  staticAddonTestSupportTrees?: boolean;
32
+ /**
33
+ * When true, we will load ember-source as ES modules. This means unused parts
34
+ * of ember-source won't be included. But it also means that addons using old
35
+ * APIs to try to `require()` things from Ember -- particularly from within
36
+ * vendor.js -- cannot do that anymore.
37
+ *
38
+ * When false (the default) we load ember-source the traditional way, which is
39
+ * that a big ol' script gets smooshed into vendor.js, and none of ember's
40
+ * public module API actually exists as modules at build time.
41
+ *
42
+ * Note: This setting will be removed in the next version of Embroider and
43
+ * will effectively default to true
44
+ */
45
+ staticEmberSource?: boolean;
7
46
  compatAdapters?: Map<string, V1AddonConstructor | null>;
47
+ extraPublicTrees?: Node[];
8
48
  packageRules?: PackageRules[];
9
49
  allowUnsafeDynamicComponents?: boolean;
10
- availableContentForTypes?: string[];
11
- useAddonAppBoot?: boolean;
12
- useAddonConfigModule?: boolean;
13
50
  }
14
51
  export type CompatOptionsType = Required<Omit<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>> & Pick<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>;
15
52
  export declare function optionsWithDefaults(options?: Options): CompatOptionsType;
package/src/options.js CHANGED
@@ -6,16 +6,23 @@ const core_1 = require("@embroider/core");
6
6
  const defaults = Object.assign((0, core_1.optionsWithDefaults)(), {
7
7
  staticAddonTrees: false,
8
8
  staticAddonTestSupportTrees: false,
9
+ staticEmberSource: false,
9
10
  compatAdapters: new Map(),
10
11
  extraPublicTrees: [],
11
12
  workspaceDir: null,
12
13
  packageRules: [],
13
14
  allowUnsafeDynamicComponents: false,
14
- availableContentForTypes: [],
15
- useAddonAppBoot: true,
16
- useAddonConfigModule: true,
17
15
  });
18
16
  function optionsWithDefaults(options) {
17
+ if (!(options === null || options === void 0 ? void 0 : options.staticEmberSource)) {
18
+ console.log(`The setting 'staticEmberSource' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticEmberSource: true' in your Embroider config.`);
19
+ }
20
+ if (!(options === null || options === void 0 ? void 0 : options.staticAddonTrees)) {
21
+ console.log(`The setting 'staticAddonTrees' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticAddonTrees: true' in your Embroider config.`);
22
+ }
23
+ if (!(options === null || options === void 0 ? void 0 : options.staticAddonTestSupportTrees)) {
24
+ console.log(`The setting 'staticAddonTestSupportTrees' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticAddonTestSupportTrees: true' in your Embroider config.`);
25
+ }
19
26
  return Object.assign({}, defaults, options);
20
27
  }
21
28
  // These are recommended configurations for addons to test themselves under. By
@@ -27,6 +34,7 @@ exports.recommendedOptions = Object.freeze({
27
34
  optimized: Object.freeze({
28
35
  staticAddonTrees: true,
29
36
  staticAddonTestSupportTrees: true,
37
+ staticEmberSource: true,
30
38
  allowUnsafeDynamicComponents: false,
31
39
  staticInvokables: true,
32
40
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAuHA,kDAEC;AAvHD,0CAA0E;AAmG1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;IACnC,wBAAwB,EAAE,EAAE;IAC5B,eAAe,EAAE,IAAI;IACrB,oBAAoB,EAAE,IAAI;CAC3B,CAAC,CAAC;AAOH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,4BAA4B,EAAE,KAAK;QACnC,gBAAgB,EAAE,IAAI;KACvB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n\n // Allows you to customize the list of content types addons use to provide HTML\n // to {{content-for}}. By default, the following content types are expected:\n // 'head', 'test-head', 'head-footer', 'test-head-footer', 'body', 'test-body',\n // 'body-footer', 'test-body-footer'. You need to use this config only to extend\n // this list.\n availableContentForTypes?: string[];\n\n // Allows you to cancel the warning that at least one classic addon provides\n // content-for 'app-boot'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'app-boot' code has been properly moved to the app-side.\n useAddonAppBoot?: boolean;\n\n // content-for 'config-module'. This warning brings awareness for developers\n // switching to Embroider, but is no longer necessary once content-for\n // 'config-module' code has been properly moved to the app-side.\n useAddonConfigModule?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n availableContentForTypes: [],\n useAddonAppBoot: true,\n useAddonConfigModule: true,\n});\n\nexport type CompatOptionsType = Required<\n Omit<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>\n> &\n Pick<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>;\n\nexport function optionsWithDefaults(options?: Options): CompatOptionsType {\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 allowUnsafeDynamicComponents: false,\n staticInvokables: true,\n }),\n});\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AA6HA,kDAoBC;AA9ID,0CAA0E;AA0G1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAOH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,CAAA,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CACT,uMAAuM,CACxM,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAA,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CACT,qMAAqM,CACtM,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,2BAA2B,CAAA,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CACT,2NAA2N,CAC5N,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,iBAAiB,EAAE,IAAI;QACvB,4BAA4B,EAAE,KAAK;QACnC,gBAAgB,EAAE,IAAI;KACvB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Node } from 'broccoli-node-api';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n /**\n * Controls whether your addon's \"addon\" trees should be resolved statically\n * at build time.\n *\n * Note: This setting will be removed in the next version of Embroider and\n * will effectively default to true\n *\n * false (the current default): implies maximum backward compatibility at\n * the cost of bigger builds. In this mode, we force every file into the\n * Ember app, 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 */\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 /**\n * When true, we will load ember-source as ES modules. This means unused parts\n * of ember-source won't be included. But it also means that addons using old\n * APIs to try to `require()` things from Ember -- particularly from within\n * vendor.js -- cannot do that anymore.\n *\n * When false (the default) we load ember-source the traditional way, which is\n * that a big ol' script gets smooshed into vendor.js, and none of ember's\n * public module API actually exists as modules at build time.\n *\n * Note: This setting will be removed in the next version of Embroider and\n * will effectively default to true\n */\n staticEmberSource?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // 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 staticEmberSource: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n});\n\nexport type CompatOptionsType = Required<\n Omit<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>\n> &\n Pick<Options, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'staticInvokables'>;\n\nexport function optionsWithDefaults(options?: Options): CompatOptionsType {\n if (!options?.staticEmberSource) {\n console.log(\n `The setting 'staticEmberSource' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticEmberSource: true' in your Embroider config.`\n );\n }\n\n if (!options?.staticAddonTrees) {\n console.log(\n `The setting 'staticAddonTrees' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticAddonTrees: true' in your Embroider config.`\n );\n }\n\n if (!options?.staticAddonTestSupportTrees) {\n console.log(\n `The setting 'staticAddonTestSupportTrees' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticAddonTestSupportTrees: true' in your Embroider config.`\n );\n }\n\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 staticEmberSource: true,\n allowUnsafeDynamicComponents: false,\n staticInvokables: true,\n }),\n});\n"]}
@@ -0,0 +1 @@
1
+ export default function inlineHBSTransform(): unknown;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = inlineHBSTransform;
4
+ function inlineHBSTransform() {
5
+ return {
6
+ visitor: {
7
+ ImportDefaultSpecifier(path) {
8
+ if (path.node.local.name === 'require') {
9
+ path.scope.rename('require');
10
+ }
11
+ },
12
+ },
13
+ };
14
+ }
15
+ //# sourceMappingURL=rename-require-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,qCAUC;AAVD,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
@@ -14,6 +14,7 @@ const dependency_rules_1 = require("./dependency-rules");
14
14
  const typescript_memoize_1 = require("typescript-memoize");
15
15
  const assert_never_1 = __importDefault(require("assert-never"));
16
16
  const path_1 = require("path");
17
+ const fs_extra_1 = require("fs-extra");
17
18
  const dasherize_component_name_1 = require("./dasherize-component-name");
18
19
  const core_1 = require("@embroider/core");
19
20
  const lodash_1 = require("lodash");
@@ -95,9 +96,7 @@ class TemplateResolver {
95
96
  this.scopeStack = new ScopeStack();
96
97
  this.visitor = {
97
98
  Template: {
98
- enter: (node, path) => {
99
- this.ownRules = this.findRules(this.env.filename);
100
- this.implementInvokesRule(node, path);
99
+ enter: () => {
101
100
  if (this.env.locals) {
102
101
  this.scopeStack.pushMustacheBlock(this.env.locals);
103
102
  }
@@ -141,7 +140,7 @@ class TemplateResolver {
141
140
  });
142
141
  return;
143
142
  }
144
- let resolution = this.targetComponent(node.path.original, node.path.original);
143
+ let resolution = this.targetComponent(node.path.original);
145
144
  this.emit(path, resolution, (node, newId) => {
146
145
  node.path = newId;
147
146
  });
@@ -283,7 +282,7 @@ class TemplateResolver {
283
282
  // if it starts with lower case, it can't be a component we need to
284
283
  // globally resolve
285
284
  if (node.tag[0] !== node.tag[0].toLowerCase()) {
286
- resolution = this.targetComponent((0, dasherize_component_name_1.dasherize)(node.tag), node.tag);
285
+ resolution = this.targetComponent((0, dasherize_component_name_1.dasherize)(node.tag));
287
286
  }
288
287
  this.emit(path, resolution, (node, newId) => {
289
288
  node.tag = newId.original;
@@ -482,9 +481,6 @@ class TemplateResolver {
482
481
  return { files, components };
483
482
  }
484
483
  findRules(absPath) {
485
- // when babel is invoked by vite our filenames can have query params still
486
- // hanging off them. That would break rule matching.
487
- absPath = (0, core_1.cleanUrl)(absPath);
488
484
  let fileRules = this.rules.files.get(absPath);
489
485
  let componentRules;
490
486
  let componentName = this.moduleResolver.reverseComponentLookup(absPath);
@@ -503,7 +499,7 @@ class TemplateResolver {
503
499
  }
504
500
  return name;
505
501
  }
506
- targetComponent(name, nameHint) {
502
+ targetComponent(name) {
507
503
  if (!this.staticComponentsEnabled) {
508
504
  return null;
509
505
  }
@@ -529,16 +525,15 @@ class TemplateResolver {
529
525
  let componentRules = this.rules.components.get(name);
530
526
  return {
531
527
  type: 'component',
532
- specifier: `@embroider/virtual/components/${name}`,
528
+ specifier: `#embroider_compat/components/${name}`,
533
529
  importedName: 'default',
534
530
  yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],
535
531
  yieldsArguments: componentRules ? componentRules.yieldsArguments : [],
536
532
  argumentsAreComponents: componentRules ? componentRules.argumentsAreComponents : [],
537
- nameHint: this.nameHint(nameHint),
533
+ nameHint: this.nameHint(name),
538
534
  };
539
535
  }
540
536
  targetComponentHelper(component, loc, impliedBecause) {
541
- var _a;
542
537
  if (!this.staticComponentsEnabled) {
543
538
  return null;
544
539
  }
@@ -558,7 +553,8 @@ class TemplateResolver {
558
553
  };
559
554
  }
560
555
  if (component.type === 'path') {
561
- if ((_a = this.ownRules) === null || _a === void 0 ? void 0 : _a.safeInteriorPaths.includes(component.path)) {
556
+ let ownComponentRules = this.findRules(this.env.filename);
557
+ if (ownComponentRules && ownComponentRules.safeInteriorPaths.includes(component.path)) {
562
558
  return null;
563
559
  }
564
560
  return {
@@ -568,7 +564,7 @@ class TemplateResolver {
568
564
  loc,
569
565
  };
570
566
  }
571
- return this.targetComponent(component.path, component.path);
567
+ return this.targetComponent(component.path);
572
568
  }
573
569
  targetHelper(path) {
574
570
  if (!this.staticHelpersEnabled) {
@@ -593,7 +589,7 @@ class TemplateResolver {
593
589
  }
594
590
  return {
595
591
  type: 'helper',
596
- specifier: `@embroider/virtual/helpers/${path}`,
592
+ specifier: `#embroider_compat/helpers/${path}`,
597
593
  importedName: 'default',
598
594
  nameHint: this.nameHint(path),
599
595
  };
@@ -682,7 +678,7 @@ class TemplateResolver {
682
678
  if (ownComponentRules === null || ownComponentRules === void 0 ? void 0 : ownComponentRules.disambiguate[path]) {
683
679
  switch (ownComponentRules.disambiguate[path]) {
684
680
  case 'component':
685
- return this.targetComponent(path, path);
681
+ return this.targetComponent(path);
686
682
  case 'helper':
687
683
  return this.targetHelper(path);
688
684
  case 'data':
@@ -717,7 +713,7 @@ class TemplateResolver {
717
713
  let componentRules = this.rules.components.get(path);
718
714
  return {
719
715
  type: 'component',
720
- specifier: `@embroider/virtual/ambiguous/${path}`,
716
+ specifier: `#embroider_compat/ambiguous/${path}`,
721
717
  importedName: 'default',
722
718
  yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],
723
719
  yieldsArguments: componentRules ? componentRules.yieldsArguments : [],
@@ -744,7 +740,7 @@ class TemplateResolver {
744
740
  }
745
741
  return {
746
742
  type: 'modifier',
747
- specifier: `@embroider/virtual/modifiers/${path}`,
743
+ specifier: `#embroider_compat/modifiers/${path}`,
748
744
  importedName: 'default',
749
745
  nameHint: this.nameHint(path),
750
746
  };
@@ -803,36 +799,13 @@ class TemplateResolver {
803
799
  }
804
800
  return null;
805
801
  }
806
- implementInvokesRule(node, path) {
807
- var _a;
808
- if (!((_a = this.ownRules) === null || _a === void 0 ? void 0 : _a.invokes)) {
809
- return;
810
- }
811
- let registrations = [];
812
- for (let snippets of Object.values(this.ownRules.invokes)) {
813
- for (let snippet of snippets) {
814
- let dasherizedName = (0, dasherize_component_name_1.snippetToDasherizedName)(snippet);
815
- if (!dasherizedName) {
816
- throw new Error(`Package rule contains unparseable component snippet: ${snippet}`);
817
- }
818
- let resolution = this.targetComponentHelper({ type: 'literal', path: dasherizedName }, node.loc);
819
- this.emit(path, resolution, (_target, id) => {
820
- registrations.push(this.env.syntax.builders.pair(dasherizedName, id));
821
- });
822
- }
823
- }
824
- if (registrations.length > 0) {
825
- node.body.unshift(this.env.syntax.builders.mustache(this.env.meta.jsutils.bindExpression(registrationHelper, path, { nameHint: 'registerComponents' }), [], this.env.syntax.builders.hash(registrations)));
826
- }
827
- }
828
802
  }
829
803
  __decorate([
830
804
  (0, typescript_memoize_1.Memoize)()
831
805
  ], TemplateResolver.prototype, "rules", null);
832
806
  // This is the AST transform that resolves components, helpers and modifiers at build time
833
807
  function makeResolverTransform({ appRoot, emberVersion, externalNameHint }) {
834
- let loader = new core_1.ResolverLoader(appRoot);
835
- let config = loader.resolver.options;
808
+ let config = (0, fs_extra_1.readJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(appRoot), 'resolver.json'));
836
809
  const resolverTransform = env => {
837
810
  if (env.strictMode) {
838
811
  return {
@@ -1012,18 +985,4 @@ function parts(path) {
1012
985
  return;
1013
986
  return 'original' in path ? path.original.split('.') : path.parts;
1014
987
  }
1015
- function registrationHelper(context) {
1016
- let Helper = context.import('@ember/component/helper', 'default', 'Helper');
1017
- let getOwner = context.import('@ember/owner', 'getOwner');
1018
- return `
1019
- (class extends ${Helper} {
1020
- compute(_positional, registrations) {
1021
- let owner = ${getOwner}(this);
1022
- for (let [name, definition] of Object.entries(registrations)) {
1023
- owner.register(\`component:\${name}\`, definition);
1024
- }
1025
- }
1026
- })
1027
- `;
1028
- }
1029
988
  //# sourceMappingURL=resolver-transform.js.map