Skip to content

Commit 15ca662

Browse files
committed
fix: rollup types to include monaco-languageclient and vscode-* types
1 parent beaef1b commit 15ca662

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "rollup --config rollup.config.ts --configPlugin typescript && npm run generate-types",
88
"prepublishOnly": "npm run build",
9-
"generate-types": "tsc --project tsconfig.types.json"
9+
"generate-types": "tsc --project tsconfig.types.json && rollup --config rollup.types.config.ts --configPlugin typescript && rm -rf ./dist/types"
1010
},
1111
"repository": {
1212
"type": "git",

rollup.types.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as rollup from 'rollup'
2+
import dts from 'rollup-plugin-dts'
3+
import pkg from './package.json'
4+
5+
const externals = [
6+
...Object.keys(pkg.dependencies),
7+
'monaco-editor'
8+
]
9+
10+
export default rollup.defineConfig({
11+
input: './dist/types/index.d.ts',
12+
output: [{ file: 'dist/index.d.ts', format: 'es' }],
13+
external: function isExternal (source, importer, isResolved) {
14+
if (isResolved) {
15+
return false
16+
}
17+
// Do not include types that rollup-plugin-dts fails to parse
18+
if (/^vscode$|proxy-polyfill/.test(source)) {
19+
return true
20+
}
21+
// Force include all types from vscode-* libs (vscode-languageclient, vscode-languageserver-protocol....)
22+
if (/^vscode-/.test(source)) {
23+
return false
24+
}
25+
return externals.some(external => source.startsWith(external))
26+
},
27+
plugins: [
28+
dts({
29+
respectExternal: true
30+
})
31+
]
32+
})

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"sourceMap": true,
2424
"target": "es5"
2525
},
26-
"include": ["src", "update-extensions.ts", "rollup.config.ts"],
26+
"include": ["src", "update-extensions.ts", "rollup.config.ts", "rollup.types.config.ts"],
2727
"exclude": [
2828
"dist",
2929
"node_modules"

tsconfig.types.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "./tsconfig",
33
"compilerOptions": {
4-
"outDir": "dist",
4+
"outDir": "dist/types",
55
"declaration": true,
66
"declarationMap": false,
77
"isolatedModules": false,

0 commit comments

Comments
 (0)