Skip to content

Commit

Permalink
Strip reference comments from the declaration files
Browse files Browse the repository at this point in the history
This copies the setup from ember-page-title: ember-cli/ember-page-title#283
  • Loading branch information
Windvis committed Aug 9, 2024
1 parent 2dd081b commit 4083642
Show file tree
Hide file tree
Showing 3 changed files with 399 additions and 6 deletions.
10 changes: 4 additions & 6 deletions addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
"dist"
],
"scripts": {
"build": "concurrently 'npm:build:*'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"build": "rollup --config",
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
Expand All @@ -43,9 +41,7 @@
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"prepack": "rollup --config",
"start": "concurrently 'npm:start:*'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"start": "rollup --config --watch --no-watch.clearScreen",
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
},
"dependencies": {
Expand Down Expand Up @@ -74,6 +70,8 @@
"eslint-plugin-ember": "^11.12.0",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-prettier": "^5.0.1",
"execa": "^8.0.1",
"fix-bad-declaration-output": "^1.1.0",
"prettier": "^3.1.1",
"prettier-plugin-ember-template-tag": "^1.1.0",
"rollup": "^4.9.1",
Expand Down
28 changes: 28 additions & 0 deletions addon/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { babel } from '@rollup/plugin-babel';
import copy from 'rollup-plugin-copy';
import { Addon } from '@embroider/addon-dev/rollup';
import { execaCommand } from 'execa';

const addon = new Addon({
srcDir: 'src',
Expand Down Expand Up @@ -61,6 +62,33 @@ export default {
// Remove leftover build artifacts when starting a new build.
addon.clean(),

// Copied from: https://github.com/ember-cli/ember-page-title/pull/283
{
name: 'fix-bad-declaration-output',
closeBundle: async () => {
/**
* Generate the types (these include /// <reference types="ember-source/types"
* but our consumers may not be using those, or have a new enough ember-source that provides them.
*/
console.log('Building types');
await execaCommand(`pnpm glint --declaration`, { stdio: 'inherit' });
/**
* https://github.com/microsoft/TypeScript/issues/56571#
* README: https://github.com/NullVoxPopuli/fix-bad-declaration-output
*/
console.log('Fixing types');
await execaCommand(
`pnpm fix-bad-declaration-output declarations/**/*.d.ts`,
{
stdio: 'inherit',
},
);
console.log(
'⚠️ Dangerously (but neededly) fixed bad declaration output from typescript',
);
},
},

// Copy Readme and License into published package
copy({
targets: [
Expand Down
Loading

0 comments on commit 4083642

Please sign in to comment.