rollup#RollupOutput TypeScript Examples

The following examples show how to use rollup#RollupOutput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: report.ts    From reskript with MIT License 6 votes vote down vote up
drawBuildReport = (outputs: RollupOutput[]) => {
    const toAsset = (value: OutputAsset | OutputChunk): Asset => {
        return {
            name: value.fileName,
            size: Buffer.byteLength(value.type === 'asset' ? value.source : value.code),
            initial: value.type === 'chunk' && value.isEntry,
        };
    };
    const assets = outputs.flatMap(v => v.output.map(toAsset));
    drawAssetReport(assets);
}
Example #2
Source File: index.test.ts    From reskript with MIT License 6 votes vote down vote up
build = async (classNamesModule: string) => {
    const config: InlineConfig = {
        root: path.join(currentDirectory, 'fixtures'),
        logLevel: 'warn',
        plugins: [
            cssBind({classNamesModule}),
        ],
    };
    const bundle = await vite.build(config) as RollupOutput;
    return bundle.output[0].code;
}
Example #3
Source File: index.test.ts    From reskript with MIT License 6 votes vote down vote up
build = async () => {
    const config: InlineConfig = {
        root: path.join(currentDirectory, 'fixtures'),
        logLevel: 'warn',
        plugins: [
            cssForceModules(),
        ],
    };
    const bundle = await vite.build(config) as RollupOutput;
    const cssAsset = bundle.output.find(v => path.extname(v.fileName) === '.css');
    return cssAsset?.type === 'asset' ? cssAsset.source.toString() : '';
}
Example #4
Source File: index.test.ts    From reskript with MIT License 6 votes vote down vote up
build = async (options?: Options) => {
    const config: InlineConfig = {
        root: path.join(currentDirectory, 'fixtures'),
        logLevel: 'warn',
        plugins: [
            svgToComponent(options),
        ],
    };
    const bundle = await vite.build(config) as RollupOutput;
    return bundle;
}
Example #5
Source File: index.test.ts    From reskript with MIT License 6 votes vote down vote up
build = async (options: Pick<VirtualEntryOptions, 'favicon'>) => {
    const entries = [
        createEntry('index'),
        createEntry('about'),
    ];
    const entryOptions: VirtualEntryOptions = {
        ...options,
        entries,
        publicPath: '/',
        defaultEntry: entries[0],
        buildTarget: 'stable',
        customizeMiddleware: () => {},
    };
    const config: InlineConfig = {
        root: path.join(currentDirectory, 'fixtures'),
        logLevel: 'warn',
        build: {
            rollupOptions: {
                input: Object.entries(entries).reduce(
                    (input, [name, {entry}]) => Object.assign(input, {[name]: entry}),
                    {} as Record<string, string>
                ),
            },
        },
        plugins: [
            virtualEntry(entryOptions),
        ],
    };
    const bundle = await vite.build(config) as RollupOutput;
    return {
        assets: bundle.output.filter((v: any): v is OutputAsset => v.type === 'asset'),
        chunks: bundle.output.filter((v: any): v is OutputChunk => v.type === 'chunk'),
    };
}
Example #6
Source File: index.ts    From reskript with MIT License 5 votes vote down vote up
isBuildOutput = (value: any): value is RollupOutput => 'output' in value