@embroider/macros 1.20.0 → 1.20.2

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/README.md CHANGED
@@ -39,7 +39,6 @@ module.exports = {
39
39
  [
40
40
  "babel-plugin-ember-template-compilation",
41
41
  {
42
- compilerPath: "ember-source/dist/ember-template-compiler.js",
43
42
  transforms: [...macros.templateMacros],
44
43
  },
45
44
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/macros",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "private": false,
5
5
  "description": "Standardized build-time macros for ember apps.",
6
6
  "keywords": [
@@ -49,13 +49,13 @@
49
49
  "@types/node": "^22.9.3",
50
50
  "@types/resolve": "^1.20.0",
51
51
  "@types/semver": "^7.3.6",
52
- "babel-plugin-ember-template-compilation": "^3.0.0",
52
+ "babel-plugin-ember-template-compilation": "^3.1.0",
53
53
  "code-equality-assertions": "^1.0.1",
54
54
  "scenario-tester": "^3.0.1",
55
55
  "typescript": "^5.4.5",
56
56
  "vitest": "^3.2.4",
57
- "@embroider/test-support": "0.36.0",
58
- "@embroider/core": "4.4.4"
57
+ "@embroider/core": "4.4.7",
58
+ "@embroider/test-support": "0.36.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@glint/template": "^1.0.0"
@@ -55,7 +55,24 @@ export function setTesting(isTesting) {
55
55
  runtimeConfig.global['@embroider/macros'].isTesting = Boolean(isTesting);
56
56
  }
57
57
 
58
- const runtimeConfig = initializeRuntimeMacrosConfig();
58
+ // Welcome intrepid developer!
59
+ //
60
+ // While this data is "global", this is a private variable.
61
+ //
62
+ // do not build features based off of its contents,
63
+ // or assume it will have the same name in future releases.
64
+ const runtimeConfig = globalThis.__embroider_macros__runtime_config__ ||= {};
65
+
66
+ runtimeConfig.packages ||= {};
67
+ runtimeConfig.global ||= {};
68
+
69
+ // In the off chance there are duplicate copies of @embroider/macros in the dep graph
70
+ // (due to the package manager messing up)
71
+ // Let's try to merge them together via the above global well known variable
72
+ const localConfig = initializeRuntimeMacrosConfig();
73
+
74
+ Object.assign(runtimeConfig.packages, localConfig.packages);
75
+ Object.assign(runtimeConfig.global, localConfig.global);
59
76
 
60
77
  // this exists to be targeted by our babel plugin
61
78
  function initializeRuntimeMacrosConfig() {
package/src/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare function getOwnConfig<T>(): T;
8
8
  export declare function getGlobalConfig<T>(): T;
9
9
  export declare function isDevelopingApp(): boolean;
10
10
  export declare function isTesting(): boolean;
11
- export declare function setTesting(): boolean;
11
+ export declare function setTesting(value: boolean): boolean;
12
12
  export declare function failBuild(message: string): void;
13
13
  export declare function moduleExists(packageName: string): boolean;
14
14
  import type { HelperLike } from '@glint/template';
package/src/index.js CHANGED
@@ -62,8 +62,8 @@ function isDevelopingApp() {
62
62
  function isTesting() {
63
63
  throw new Oops();
64
64
  }
65
- function setTesting() {
66
- throw new Oops();
65
+ function setTesting(value) {
66
+ throw new Oops(value);
67
67
  }
68
68
  function failBuild(message) {
69
69
  throw new Oops(message);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,2BAA2B;;AAkB3B,kDAEC;AAED,8CAEC;AAED,wCAEC;AAED,oBAEC;AAKD,gCAEC;AAED,8BAEC;AAED,oCAEC;AAED,0CAEC;AAED,0CAEC;AAED,8BAEC;AAED,gCAEC;AAED,8BAEC;AAED,oCAEC;AArED;;;;;;;;;;;;;;EAcE;AAEF,SAAgB,mBAAmB,CAAC,WAAmB,EAAE,WAAmB;IAC1E,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,cAAc,CAAC,SAAkB;IAC/C,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,IAAI,CAAI,KAAU;IAChC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,4BAA4B;AAC5B,mFAAmF;AACnF,kDAAkD;AAClD,SAAgB,UAAU,CAAC,SAAiB;IAC1C,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,SAAS,CAAI,WAAmB;IAC9C,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,YAAY;IAC1B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,SAAS;IACvB,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,UAAU;IACxB,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,SAAS,CAAC,OAAe;IACvC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,YAAY,CAAC,WAAmB;IAC9C,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,IAAK,SAAQ,KAAK;IAEtB,YAAY,GAAG,MAAa;QAC1B,KAAK,CACH,6HAA6H,CAC9H,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF","sourcesContent":["/* Macro Type Signatures */\n\n/*\n CAUTION: this code is not necessarily what you are actually running. In\n general, the macros are implemented at build time using babel, and so calls to\n these functions get compiled away before they ever run. However, this code is\n here because it provides types to typescript users of the macros.\n\n Some macros also have runtime implementations that are useful in development\n mode, in addition to their build-time implementations in babel. You can find\n the runtime implementations in runtime.ts.\n\n Having a runtime mode lets us do things like produce a single build in\n development that works for both fastboot and browser, using the macros to\n switch between modes. For production, you would switch to the build-time macro\n implementation to get two optimized builds instead.\n*/\n\nexport function dependencySatisfies(packageName: string, semverRange: string): boolean {\n throw new Oops(packageName, semverRange);\n}\n\nexport function appEmberSatisfies(semverRange: string): boolean {\n throw new Oops(semverRange);\n}\n\nexport function macroCondition(predicate: boolean): boolean {\n throw new Oops(predicate);\n}\n\nexport function each<T>(array: T[]): T[] {\n throw new Oops(array);\n}\n\n// We would prefer to write:\n// export function importSync<T extends string>(specifier: T): typeof import(T) {\n// but TS doesn't seem to support that at present.\nexport function importSync(specifier: string): unknown {\n throw new Oops(specifier);\n}\n\nexport function getConfig<T>(packageName: string): T {\n throw new Oops(packageName);\n}\n\nexport function getOwnConfig<T>(): T {\n throw new Oops();\n}\n\nexport function getGlobalConfig<T>(): T {\n throw new Oops();\n}\n\nexport function isDevelopingApp(): boolean {\n throw new Oops();\n}\n\nexport function isTesting(): boolean {\n throw new Oops();\n}\n\nexport function setTesting(): boolean {\n throw new Oops();\n}\n\nexport function failBuild(message: string): void {\n throw new Oops(message);\n}\n\nexport function moduleExists(packageName: string): boolean {\n throw new Oops(packageName);\n}\n\nclass Oops extends Error {\n params: any[];\n constructor(...params: any[]) {\n super(\n `this method is really implemented at compile time via a babel plugin. If you're seeing this exception, something went wrong`\n );\n this.params = params;\n }\n}\n\nimport type { HelperLike } from '@glint/template';\n\nexport interface EmbroiderMacrosRegistry {\n macroGetOwnConfig: HelperLike<{\n Args: { Positional: [...keys: string[]] };\n Return: ReturnType<typeof getOwnConfig>;\n }>;\n macroGetConfig: HelperLike<{\n Args: { Positional: [packageName: string, ...keys: string[]] };\n Return: ReturnType<typeof getConfig>;\n }>;\n macroCondition: HelperLike<{\n Args: { Positional: [predicate: boolean] };\n Return: boolean;\n }>;\n macroDependencySatisfies: HelperLike<{\n Args: { Positional: Parameters<typeof dependencySatisfies> };\n Return: ReturnType<typeof dependencySatisfies>;\n }>;\n macroAppEmberSatisfies: HelperLike<{\n Args: { Positional: Parameters<typeof appEmberSatisfies> };\n Return: ReturnType<typeof appEmberSatisfies>;\n }>;\n macroMaybeAttrs: HelperLike<{\n Args: { Positional: [predicate: boolean, ...bareAttrs: unknown[]] };\n Return: void;\n }>;\n macroFailBuild: HelperLike<{\n Args: { Positional: Parameters<typeof failBuild> };\n Return: ReturnType<typeof failBuild>;\n }>;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,2BAA2B;;AAkB3B,kDAEC;AAED,8CAEC;AAED,wCAEC;AAED,oBAEC;AAKD,gCAEC;AAED,8BAEC;AAED,oCAEC;AAED,0CAEC;AAED,0CAEC;AAED,8BAEC;AAED,gCAEC;AAED,8BAEC;AAED,oCAEC;AArED;;;;;;;;;;;;;;EAcE;AAEF,SAAgB,mBAAmB,CAAC,WAAmB,EAAE,WAAmB;IAC1E,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,cAAc,CAAC,SAAkB;IAC/C,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,IAAI,CAAI,KAAU;IAChC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,4BAA4B;AAC5B,mFAAmF;AACnF,kDAAkD;AAClD,SAAgB,UAAU,CAAC,SAAiB;IAC1C,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,SAAS,CAAI,WAAmB;IAC9C,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,YAAY;IAC1B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,SAAS;IACvB,MAAM,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,UAAU,CAAC,KAAc;IACvC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,SAAS,CAAC,OAAe;IACvC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,YAAY,CAAC,WAAmB;IAC9C,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,IAAK,SAAQ,KAAK;IAEtB,YAAY,GAAG,MAAa;QAC1B,KAAK,CACH,6HAA6H,CAC9H,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF","sourcesContent":["/* Macro Type Signatures */\n\n/*\n CAUTION: this code is not necessarily what you are actually running. In\n general, the macros are implemented at build time using babel, and so calls to\n these functions get compiled away before they ever run. However, this code is\n here because it provides types to typescript users of the macros.\n\n Some macros also have runtime implementations that are useful in development\n mode, in addition to their build-time implementations in babel. You can find\n the runtime implementations in runtime.ts.\n\n Having a runtime mode lets us do things like produce a single build in\n development that works for both fastboot and browser, using the macros to\n switch between modes. For production, you would switch to the build-time macro\n implementation to get two optimized builds instead.\n*/\n\nexport function dependencySatisfies(packageName: string, semverRange: string): boolean {\n throw new Oops(packageName, semverRange);\n}\n\nexport function appEmberSatisfies(semverRange: string): boolean {\n throw new Oops(semverRange);\n}\n\nexport function macroCondition(predicate: boolean): boolean {\n throw new Oops(predicate);\n}\n\nexport function each<T>(array: T[]): T[] {\n throw new Oops(array);\n}\n\n// We would prefer to write:\n// export function importSync<T extends string>(specifier: T): typeof import(T) {\n// but TS doesn't seem to support that at present.\nexport function importSync(specifier: string): unknown {\n throw new Oops(specifier);\n}\n\nexport function getConfig<T>(packageName: string): T {\n throw new Oops(packageName);\n}\n\nexport function getOwnConfig<T>(): T {\n throw new Oops();\n}\n\nexport function getGlobalConfig<T>(): T {\n throw new Oops();\n}\n\nexport function isDevelopingApp(): boolean {\n throw new Oops();\n}\n\nexport function isTesting(): boolean {\n throw new Oops();\n}\n\nexport function setTesting(value: boolean): boolean {\n throw new Oops(value);\n}\n\nexport function failBuild(message: string): void {\n throw new Oops(message);\n}\n\nexport function moduleExists(packageName: string): boolean {\n throw new Oops(packageName);\n}\n\nclass Oops extends Error {\n params: any[];\n constructor(...params: any[]) {\n super(\n `this method is really implemented at compile time via a babel plugin. If you're seeing this exception, something went wrong`\n );\n this.params = params;\n }\n}\n\nimport type { HelperLike } from '@glint/template';\n\nexport interface EmbroiderMacrosRegistry {\n macroGetOwnConfig: HelperLike<{\n Args: { Positional: [...keys: string[]] };\n Return: ReturnType<typeof getOwnConfig>;\n }>;\n macroGetConfig: HelperLike<{\n Args: { Positional: [packageName: string, ...keys: string[]] };\n Return: ReturnType<typeof getConfig>;\n }>;\n macroCondition: HelperLike<{\n Args: { Positional: [predicate: boolean] };\n Return: boolean;\n }>;\n macroDependencySatisfies: HelperLike<{\n Args: { Positional: Parameters<typeof dependencySatisfies> };\n Return: ReturnType<typeof dependencySatisfies>;\n }>;\n macroAppEmberSatisfies: HelperLike<{\n Args: { Positional: Parameters<typeof appEmberSatisfies> };\n Return: ReturnType<typeof appEmberSatisfies>;\n }>;\n macroMaybeAttrs: HelperLike<{\n Args: { Positional: [predicate: boolean, ...bareAttrs: unknown[]] };\n Return: void;\n }>;\n macroFailBuild: HelperLike<{\n Args: { Positional: Parameters<typeof failBuild> };\n Return: ReturnType<typeof failBuild>;\n }>;\n}\n"]}