Skip to content

Commit

Permalink
Add plugin to fix bad declaratioun output
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Feb 9, 2024
1 parent ba0e97d commit 3d35a9b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions files/__addonLocation__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"prettier-plugin-ember-template-tag": "^1.1.0",
"rollup": "^4.9.1"<% if (!isExistingMonorepo) { %>,
"rollup-plugin-copy": "^3.5.0"<% } %><% if (typescript) { %>,
"execa": '^8.0.1",
"fix-bad-declaration-output": "^1.1.2",
"typescript": "^5.3.3"<% } %>
},
"publishConfig": {
Expand Down
31 changes: 30 additions & 1 deletion files/__addonLocation__/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -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 { execaCommand } from 'execa';
import { fixBadDeclarationOutput } from 'fix-bad-declaration-output';
<% } %>

const addon = new Addon({
srcDir: 'src',
Expand Down Expand Up @@ -67,5 +71,30 @@ export default {
<% filesToCopyFromRootToAddon.forEach((file) => { %> { src: '<%= pathFromAddonToRoot %>/<%= file %>', dest: '.' },
<% }); %> ],
}),
<% } %> ],
<% } %>

{
name: 'generate-types',
closeBundle: async () => {
/**
* We generate the types here as an inline rollup plugin
* so that we can have the correct timing for fixing the types
* after they are generated.
*
* This also provides better CLI output, as Glint and Rollup don't fight
* each other to clear the terminal.
*/
console.log('Building types');
await execaCommand(`pnpm glint --declaration`, { stdio: 'inherit' });

console.log('Fixing types');
await fixBadDeclarationOutput('declarations/**/*.d.ts', [
// https://github.com/microsoft/TypeScript/issues/56571
'TypeScript#56571',
// https://github.com/typed-ember/glint/issues/628
'Glint#628',
]);
},
},
],
};

0 comments on commit 3d35a9b

Please sign in to comment.