Skip to content

Commit aafffb4

Browse files
committed
Add and differentiate between tsconfig.publish and tsconfig
1 parent 2bda45e commit aafffb4

4 files changed

Lines changed: 50 additions & 23 deletions

File tree

files/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@glint/environment-ember-loose": "^1.4.0",
5050
"@glint/environment-ember-template-imports": "^1.4.0",
5151
"@glint/template": "^1.4.0",
52+
"@ember/app-tsconfig": "^1.0.0",
5253
"@ember/library-tsconfig": "^1.0.0",<% } %>
5354
"@rollup/plugin-babel": "^6.0.4",
5455
"babel-plugin-ember-template-compilation": "^2.2.5",

files/rollup.config.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const addon = new Addon({
88
destDir: 'dist',
99
});
1010

11+
const rootDirectory = dirname(fileURLToPath(import.meta.url));
12+
const configs = {
13+
babel: resolve(rootDirectory, './babel.pubish.config.cjs'),<% if (typescript) { %>
14+
ts: resolve(rootDirectory, './tsconfig.publish.json'),<% } %>
15+
};
16+
1117
export default {
1218
// This provides defaults that work well alongside `publicEntrypoints` below.
1319
// You can augment this if you need to.
@@ -47,10 +53,7 @@ export default {
4753
babel({
4854
extensions: ['.js', '.gjs'<% if (typescript) { %>, '.ts', '.gts'<% } %>],
4955
babelHelpers: 'bundled',
50-
configFile: resolve(
51-
dirname(fileURLToPath(import.meta.url)),
52-
'./babel.publish.config.cjs',
53-
),
56+
configFile: configs.babel
5457
}),
5558

5659
// Ensure that standalone .hbs files are properly integrated as Javascript.
@@ -60,7 +63,7 @@ export default {
6063
addon.gjs(),<% if (typescript) { %>
6164

6265
// Emit .d.ts declaration files
63-
addon.declarations('declarations'),<% } %>
66+
addon.declarations('declarations', `<%= packageManager %> exec glint --project ${configs.ts}`),<% } %>
6467

6568
// addons are allowed to contain imports of .css files, which we want rollup
6669
// to leave alone and keep in the published output.

files/tsconfig.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1+
/**
2+
* This tsconfig is not used for publishing.
3+
* It's only for the local editing experience
4+
* (and linting)
5+
*/
16
{
2-
"extends": "@ember/library-tsconfig",
3-
"include": ["src/**/*", "unpublished-development-types/**/*"],
7+
"extends": "@ember/app-tsconfig",
48
"glint": {
59
"environment": ["ember-loose", "ember-template-imports"]
610
},
11+
"include": ["src", "tests", "unpublished-development-types"],
712
"compilerOptions": {
8-
"allowJs": true,
9-
"declarationDir": "declarations",
10-
11-
/**
12-
https://www.typescriptlang.org/tsconfig#rootDir
13-
"Default: The longest common path of all non-declaration input files."
14-
15-
Because we want our declarations' structure to match our rollup output,
16-
we need this "rootDir" to match the "srcDir" in the rollup.config.mjs.
17-
18-
This way, we can have simpler `package.json#exports` that matches
19-
imports to files on disk
20-
*/
21-
"rootDir": "./src",
22-
23-
"types": ["ember-source/types"]
13+
"rootDir": ".",
14+
"types": [
15+
"ember-source/types",
16+
"vite/client",
17+
"kolay/virtual",
18+
"@embroider/core/virtual",
19+
"unplugin-info/client"
20+
],
21+
"paths": {}
2422
}
2523
}

files/tsconfig.publish.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "@ember/library-tsconfig",
3+
"include": ["src", "unpublished-development-types"],
4+
"glint": {
5+
"environment": ["ember-loose", "ember-template-imports"]
6+
},
7+
"compilerOptions": {
8+
"allowJs": true,
9+
"declarationDir": "declarations",
10+
11+
/**
12+
https://www.typescriptlang.org/tsconfig#rootDir
13+
"Default: The longest common path of all non-declaration input files."
14+
15+
Because we want our declarations' structure to match our rollup output,
16+
we need this "rootDir" to match the "srcDir" in the rollup.config.mjs.
17+
18+
This way, we can have simpler `package.json#exports` that matches
19+
imports to files on disk
20+
*/
21+
"rootDir": "./src",
22+
23+
"types": ["ember-source/types"]
24+
}
25+
}

0 commit comments

Comments
 (0)