-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: DTS generation * build: fix syntax error for build --------- Co-authored-by: Richard Herman <[email protected]>
- Loading branch information
Showing
9 changed files
with
119 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules/ | |
coverage/ | ||
|
||
# Build output | ||
dist/ | ||
dist/ | ||
types/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import nodeResolve from "@rollup/plugin-node-resolve"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import { dirname, resolve } from "node:path"; | ||
import url from "node:url"; | ||
|
||
const isWatching = !!process.env.ROLLUP_WATCH; | ||
const external = ["ws", "@elgato/schemas/streamdeck/plugins"]; | ||
|
||
const output = { | ||
banner: `/**! | ||
* @author Elgato | ||
* @module elgato/streamdeck | ||
* @license MIT | ||
* @copyright Copyright (c) Corsair Memory Inc. | ||
*/`, | ||
sourcemap: isWatching, | ||
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => { | ||
return url.pathToFileURL(resolve(dirname(sourcemapPath), relativeSourcePath)).href; | ||
} | ||
}; | ||
|
||
/** | ||
* Generates a wrapped DTS file. | ||
* @param {string} index File path to the index.d.ts file. | ||
* @returns The wrapped DTS file. | ||
*/ | ||
function dts(index) { | ||
return `import streamDeck from "${index}"; | ||
export * from "${index}"; | ||
export default streamDeck;`; | ||
} | ||
|
||
/** | ||
* Rollup configuration. | ||
*/ | ||
export default [ | ||
/** | ||
* Main build. | ||
*/ | ||
{ | ||
input: "src/plugin/index.ts", | ||
output: { | ||
...output, | ||
file: `dist/index.js` | ||
}, | ||
external, | ||
plugins: [ | ||
typescript({ | ||
tsconfig: "src/plugin/tsconfig.build.json", | ||
mapRoot: isWatching ? "./" : undefined | ||
}), | ||
nodeResolve(), | ||
{ | ||
name: "emit-dts", | ||
generateBundle() { | ||
this.emitFile({ | ||
fileName: "index.d.ts", | ||
source: dts("../types/plugin"), | ||
type: "asset" | ||
}); | ||
} | ||
} | ||
] | ||
}, | ||
|
||
/** | ||
* Browser build. | ||
*/ | ||
{ | ||
input: "src/ui/index.ts", | ||
output: { | ||
...output, | ||
file: `dist/browser.js` | ||
}, | ||
external, | ||
plugins: [ | ||
typescript({ | ||
tsconfig: "src/ui/tsconfig.build.json", | ||
mapRoot: isWatching ? "./" : undefined | ||
}), | ||
nodeResolve(), | ||
{ | ||
name: "emit-dts", | ||
generateBundle() { | ||
this.emitFile({ | ||
fileName: "browser.d.ts", | ||
source: dts("../types/ui"), | ||
type: "asset" | ||
}); | ||
} | ||
} | ||
] | ||
} | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationDir": "../../dist/types" | ||
}, | ||
"exclude": [ | ||
"**/__mocks__/", | ||
"**/__tests__/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
}, | ||
"include": [ | ||
"src/", | ||
"rollup.config.ts", | ||
"tests/" | ||
], | ||
"exclude": [ | ||
|