0.2.1 • Published 11 months ago

rspack-dts-plugin v0.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

ts.d文件自动生成

使用

const { RspackDtsPlugin } = require('rspack-dts-plugin');

// rspack.config.js
module.exports = {
        plugins: [new RspackDtsPlugin()],
        entry: './src/index.ts',
        devtool: false,
        resolve: {
            extensions: [".ts", ".js", ".json", ".wasm"],
        },
        externals: {
            
        },
        module: {
            rules: [
                {
                    test: /\.ts$/,
                    exclude: [/node_modules/],
                    loader: 'builtin:swc-loader',
                    options: {
                        jsc: {
                            parser: {
                                syntax: 'typescript',
                            },
                        },
                    },
                    type: 'javascript/auto',
                },
            ],
        },
    }

API

  • 触发编译 dts
declare function buildDts(options: RspackDtsPluginOptions): void;

RspackDtsPluginOptions

/**
 * @des 相同字段tsconfig.json优先级最高
 */
type RspackDtsPluginOptions = {
    /**
     * 是否生成ts
     * @default true
     */
    dts?: boolean;
    /**
      * 是否生成一个.d文件
      * @default true
      */
    only?: boolean;
    /**
     * ts 输出目录
     * @default ./dist/types
     */
    outputDir?: string;
    /**
     * ts 输出文件
     * @default ./dist/types/index
     */
    outFile?: string;
    /**
     * ts rootDir
     */
    rootDir?: 'src';
    /**
     * library.name和only同时成立的时候生成namespace
     * 优先级 this => output.library.name
     * @default undefined;
     */
    name?: string;
};
0.2.1

11 months ago

0.2.0

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago