0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-04 10:39:43 +08:00
discourse/frontend/asset-processor/rollup-plugins/discourse-gjs.js
David Taylor de793bc6ed
DEV: add typescript support for core, themes and plugins (#41478)
We've been using basic type-checking via JSDoc for some time. This
commit allows us to author proper `.ts`/`.gts` files, and use the full
typescript syntax. Initially, only d-button and a single chat file are
migrated, as proof of functionality.

In future, we may migrate more files, and consider making our tsconfig
more strict.
2026-07-08 12:57:18 +01:00

26 lines
596 B
JavaScript
Vendored

import { Preprocessor } from "../content-tag";
const preprocessor = new Preprocessor();
export default function discourseGjs() {
return {
name: "discourse-gjs",
transform: {
// Enforce running the gjs transform before any others like babel that expect valid JS
order: "pre",
handler(input, id) {
if (!id.endsWith(".gjs") && !id.endsWith(".gts")) {
return null;
}
let { code, map } = preprocessor.process(input, {
filename: id,
});
return {
code,
map,
};
},
},
};
}