Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS] Add plugin to fix bad declaratioun output #255

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
]);
},
},
],
};
Loading