Closed sirreal closed 1 year ago
Fix the generated type declarations.
By using TypeScript's special export = we're able to author source that mostly looks like ESM but generates our desired declaration and js output.
export =
The published type declarations are currently export {}, which makes it hard to use this package in typechecked files.
export {}
After this change, the generated JS file is mostly the same, but the declaration file has the expected output:
import { JsMinifyOptions } from '@swc/core'; import webpack from 'webpack'; declare class SwcMinifyWebpackPlugin { private readonly options; constructor(options?: JsMinifyOptions); apply(compiler: webpack.Compiler): void; private transformAssets; private processAssets; } export = SwcMinifyWebpackPlugin;
Another change that may be helpful to use a shared tsconfig designed for node, for example:
https://github.com/tsconfig/bases#node-lts--strictest-tsconfigjson
That will likely improve the build result and save generating compatibility code that's not necessary for targeting Node.
I'd be happy to push that here or in another PR.
Released in 1.1.1
The new releases have the same problem, the published declarations are an empty export. At 1e03fee111c36abd05646d6b99cc31536b053130 (merge commit) this generated the expected declarations.
Fix the generated type declarations.
By using TypeScript's special
export =
we're able to author source that mostly looks like ESM but generates our desired declaration and js output.The published type declarations are currently
export {}
, which makes it hard to use this package in typechecked files.After this change, the generated JS file is mostly the same, but the declaration file has the expected output:
Another change that may be helpful to use a shared tsconfig designed for node, for example:
https://github.com/tsconfig/bases#node-lts--strictest-tsconfigjson
That will likely improve the build result and save generating compatibility code that's not necessary for targeting Node.
I'd be happy to push that here or in another PR.