Skip to content

Commit

Permalink
fix: fix proposed type generation
Browse files Browse the repository at this point in the history
now that typescript emit triple-slash reference directives
  • Loading branch information
Loïc Mangeonjean committed Dec 4, 2023
1 parent 97c1b87 commit 9c01b98
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions rollup/rollup.types.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
return chunkInfo.name.replace('node_modules', 'external') + '.ts'
}
return '[name].ts'
},
// the extension file exposes a way to get the vscode API, so we should reference the proposed vscode types here too
banner: (chunk) => chunk.fileName === 'extensions.d.ts' ? '/// <reference path="vscode.proposed.d.ts" />' : ''
}
},
external: (id) => isExternal(id, main),
plugins: [
Expand Down Expand Up @@ -216,6 +214,23 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
return code.replace('export import Severity = BaseSeverity;', 'type Severity = BaseSeverity; export { Severity }')
}
},
{
name: 'resolve-vscode-proposed-types',
transform (code) {
return code.replace(/\/\/\/ <reference types="vscode\/src\/vscode-dts\/(vscode\.proposed\..*)" \/>/g, '/// <reference path="./vscode-dts/$1.d.ts" />')
},
async generateBundle () {
const types = await fastGlob('vscode.proposed.*.d.ts', {
cwd: VSCODE_SRC_DTS_DIR
})
await Promise.all(types.map(async file => this.emitFile({
type: 'asset',
needsCodeReference: false,
fileName: `vscode-dts/${file}`,
source: await fsPromise.readFile(path.resolve(VSCODE_SRC_DTS_DIR, file))
})))
}
},
{
name: 'replace-interfaces',
load (id) {
Expand Down Expand Up @@ -280,21 +295,6 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
return undefined
}
},
{
name: 'vscode-proposed',
async generateBundle () {
const types = await fastGlob('vscode.proposed.*.d.ts', {
cwd: VSCODE_SRC_DTS_DIR
})
const contents = await Promise.all(types.map(file => fsPromise.readFile(path.resolve(VSCODE_SRC_DTS_DIR, file))))
this.emitFile({
type: 'asset',
needsCodeReference: false,
fileName: 'vscode.proposed.d.ts',
source: contents.join('\n\n')
})
}
},
dts({
respectExternal: true
})
Expand Down

0 comments on commit 9c01b98

Please sign in to comment.