From 31a3573aca18e73bfb179563eec46c8b2b254c8f Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Sun, 2 Feb 2025 10:36:40 +0000 Subject: [PATCH 1/3] deprecate staticEmberSource: false --- packages/compat/src/options.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/compat/src/options.ts b/packages/compat/src/options.ts index bef7d60a0..b9a8c8ebb 100644 --- a/packages/compat/src/options.ts +++ b/packages/compat/src/options.ts @@ -44,14 +44,19 @@ export default interface Options extends CoreOptions { // apply. staticAddonTestSupportTrees?: boolean; - // when true, we will load ember-source as ES modules. This means unused parts - // of ember-source won't be included. But it also means that addons using old - // APIs to try to `require()` things from Ember -- particularly from within - // vendor.js -- cannot do that anymore. - // - // When false (the default) we load ember-source the traditional way, which is - // that a big ol' script gets smooshed into vendor.js, and none of ember's - // public module API actually exists as modules at build time. + /** + * When true, we will load ember-source as ES modules. This means unused parts + * of ember-source won't be included. But it also means that addons using old + * APIs to try to `require()` things from Ember -- particularly from within + * vendor.js -- cannot do that anymore. + * + * When false (the default) we load ember-source the traditional way, which is + * that a big ol' script gets smooshed into vendor.js, and none of ember's + * public module API actually exists as modules at build time. + * + * Note: This setting will be removed in the next version of Embroider and + * will effectively default to true + */ staticEmberSource?: boolean; // Allows you to override how specific addons will build. Like: @@ -114,6 +119,11 @@ export type CompatOptionsType = Required< Pick; export function optionsWithDefaults(options?: Options): CompatOptionsType { + if (!options?.staticEmberSource) { + 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.` + ); + } return Object.assign({}, defaults, options); } From d25291a95ec24f2d6ec442bf25e2161b81bbb3d7 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Sat, 1 Feb 2025 10:23:48 +0000 Subject: [PATCH 2/3] add a simple deprecation for staticAddonTrees and staticAddonTestSupportTrees --- packages/compat/src/options.ts | 56 ++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/packages/compat/src/options.ts b/packages/compat/src/options.ts index b9a8c8ebb..1923ff19f 100644 --- a/packages/compat/src/options.ts +++ b/packages/compat/src/options.ts @@ -9,25 +9,30 @@ import type { PackageRules } from './dependency-rules'; // the cost of slower or bigger builds. As you eliminate sources of legacy // behavior you can benefit from the more aggressive modes. export default interface Options extends CoreOptions { - // Controls whether your addon's "addon" trees should be resolved statically - // at build time. - // - // false (the default): implies maximum backward compatibility at the cost - // of bigger builds. In this mode, we force every file into the Ember app, - // which is the legacy behavior. - // - // true: produces smaller builds. The addon files must be imported from - // somewhere we can statically see during the build. In this mode, your app - // will only include files that are actually imported from somewhere. - // - // Commentary: most v1 addons already work well with this set to true, because - // they tend to either offer Javascript that users are supposed to directly - // `import` or components / helpers / services that get directly imported and - // re-exported by code in App Javascript. The exceptions are addons that do - // runtime shenanigans with `require` or scoped runtime resolutions. - // - // To workaround an addon that is preventing you from enabling this flag, you - // can use addonDependencyRules. + /** + * Controls whether your addon's "addon" trees should be resolved statically + * at build time. + * + * Note: This setting will be removed in the next version of Embroider and + * will effectively default to true + * + * false (the current default): implies maximum backward compatibility at + * the cost of bigger builds. In this mode, we force every file into the + * Ember app, which is the legacy behavior. + * + * true: produces smaller builds. The addon files must be imported from + * somewhere we can statically see during the build. In this mode, your app + * will only include files that are actually imported from somewhere. + * + * Commentary: most v1 addons already work well with this set to true, because + * they tend to either offer Javascript that users are supposed to directly + * `import` or components / helpers / services that get directly imported and + * re-exported by code in App Javascript. The exceptions are addons that do + * runtime shenanigans with `require` or scoped runtime resolutions. + * + * To workaround an addon that is preventing you from enabling this flag, you + * can use addonDependencyRules. + */ staticAddonTrees?: boolean; // Controls whether your addon's "addonTestSupport" trees should be resolved @@ -124,6 +129,19 @@ export function optionsWithDefaults(options?: Options): CompatOptionsType { `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.` ); } + + if (!options?.staticAddonTrees) { + 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.` + ); + } + + if (!options?.staticAddonTestSupportTrees) { + 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.` + ); + } + return Object.assign({}, defaults, options); } From 45af919137b86655d236a44adb16c01cb51af61f Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Sat, 8 Feb 2025 10:23:19 +0000 Subject: [PATCH 3/3] fix type error since staticEmberSource was removed --- packages/compat/src/options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compat/src/options.ts b/packages/compat/src/options.ts index 0f20a1c27..498503950 100644 --- a/packages/compat/src/options.ts +++ b/packages/compat/src/options.ts @@ -123,7 +123,7 @@ export type CompatOptionsType = Required< Pick; export function optionsWithDefaults(options?: Options): CompatOptionsType { - if (!options?.staticEmberSource) { + if (!(options as any)?.staticEmberSource) { 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.` );