From 5bcc2018a462b7340d371205b25c70b42fb849f6 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:16:31 -0400 Subject: [PATCH 1/3] Provide TS workarounds for both TS and Glint issues --- files/__addonLocation__/package.json | 9 +++--- files/__addonLocation__/rollup.config.mjs | 34 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/files/__addonLocation__/package.json b/files/__addonLocation__/package.json index 762892f9..450cdf70 100644 --- a/files/__addonLocation__/package.json +++ b/files/__addonLocation__/package.json @@ -13,11 +13,8 @@ "declarations", "dist" ], - "scripts": {<% if (typescript) { %> - "build": "concurrently '<%= packageManager %>:build:*'", - "build:js": "rollup --config", - "build:types": "glint --declaration",<% } else { %> - "build": "rollup --config",<% } %> + "scripts": { + "build": "rollup --config", "lint": "concurrently '<%= packageManager %>:lint:*(!fix)' --names 'lint:'", "lint:fix": "concurrently '<%= packageManager %>:lint:*:fix' --names 'fix:'", "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern", @@ -84,6 +81,8 @@ "prettier-plugin-ember-template-tag": "^2.0.2", "rollup": "^4.16.4"<% if (!isExistingMonorepo) { %>, "rollup-plugin-copy": "^3.5.0"<% } %><% if (typescript) { %>, + "execa": "9.2.0", + "fix-bad-declaration-output": "1.1.4", "typescript": "^5.4.5"<% } %> }, "publishConfig": { diff --git a/files/__addonLocation__/rollup.config.mjs b/files/__addonLocation__/rollup.config.mjs index 2a49ed1a..8163db9b 100644 --- a/files/__addonLocation__/rollup.config.mjs +++ b/files/__addonLocation__/rollup.config.mjs @@ -1,6 +1,10 @@ import { babel } from '@rollup/plugin-babel'; <% if (!isExistingMonorepo) { %>import copy from 'rollup-plugin-copy'; <% } %>import { Addon } from '@embroider/addon-dev/rollup'; +<% if (typescript) { %> +import { $ } from "execa"; +import { fixBadDeclarationOutput } from "fix-bad-declaration-output"; +<% } %> const addon = new Addon({ srcDir: 'src', @@ -67,5 +71,33 @@ export default { <% filesToCopyFromRootToAddon.forEach((file) => { %> { src: '<%= pathFromAddonToRoot %>/<%= file %>', dest: '.' }, <% }); %> ], }), -<% } %> ], +<% } %> + +<% if (typescript) { %> + { + name: "Build Declarations", + closeBundle: async () => { + /** + * Generate the types (these include /// + ], }; From a6763df33c6100510cdb38951f830329aab8f12a Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:32:11 -0400 Subject: [PATCH 2/3] Accomodate NPM --- files/__addonLocation__/rollup.config.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/__addonLocation__/rollup.config.mjs b/files/__addonLocation__/rollup.config.mjs index 8163db9b..cbd6eeab 100644 --- a/files/__addonLocation__/rollup.config.mjs +++ b/files/__addonLocation__/rollup.config.mjs @@ -82,7 +82,9 @@ export default { * but our consumers may not be using those, or have a new enough ember-source that provides them. */ console.log("Building types"); - await $({ stdio: 'inherit' })`./node_modules/.bin/glint --declaration`; + let command = npm ? 'npm exec glint -- --declaration' : `${packageManager} glint --declaration`; + + await $({ stdio: 'inherit' })`${command}`; /** * https://github.com/microsoft/TypeScript/issues/56571# From 72e13904f0a4b06d8fbcaa91f957d322eb6135d5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:37:57 -0400 Subject: [PATCH 3/3] Momentary lapse in how templating works --- files/__addonLocation__/rollup.config.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/__addonLocation__/rollup.config.mjs b/files/__addonLocation__/rollup.config.mjs index cbd6eeab..8a895b0a 100644 --- a/files/__addonLocation__/rollup.config.mjs +++ b/files/__addonLocation__/rollup.config.mjs @@ -82,9 +82,11 @@ export default { * but our consumers may not be using those, or have a new enough ember-source that provides them. */ console.log("Building types"); - let command = npm ? 'npm exec glint -- --declaration' : `${packageManager} glint --declaration`; - - await $({ stdio: 'inherit' })`${command}`; + <% if (npm) { %> + await $({ stdio: 'inherit' })`npm exec glint -- --declaration`; + <% } else { %> + await $({ stdio: 'inherit' })`<%= packageManager %> glint --declaration`; + <% } %> /** * https://github.com/microsoft/TypeScript/issues/56571#