How to generate css module TS declaration using @modernjs/module-tools #5486
-
Hi, I'm maintaining a large monorepo with many private libraries (react component or ts only packages) and a few apps. Currently, the packages are built using heft, which is working fine but is quite slow. I'm experimenting with various alternatives including modernjs. I didn't find, however, how to generate the TS strong declaration for css modules. I found How I can enable emitting these declarations? As an alternative, I tried to use PostCSS modules Typescript definitions generator and this config: import { moduleTools, defineConfig } from "@modern-js/module-tools";
import postcssDTS from "postcss-typescript-d-ts";
import packageJson from "./package.json";
const banner = `/*
${packageJson.name}@${packageJson.version}
© ${packageJson.author} ${new Date().getFullYear()}
*/`;
export default defineConfig({
plugins: [moduleTools()],
buildPreset: "npm-component",
buildConfig: {
style: {
postcss: {
plugins: [
postcssDTS({
extra: {
header: banner,
},
}),
],
},
},
},
}); Unfortunately, it works "sometimes". If I delete the css.d.ts file, it works. Subsequent build won't work with some obscure message:
I wonder if multiple concurrent builds (the Thanks in advance for help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sorry I miss this discussion. Here is the solution |
Beta Was this translation helpful? Give feedback.
Sorry I miss this discussion. Here is the solution