Skip to content

Pass normalized options from rust to js #2906

@hyf0

Description

@hyf0

If you are interested in some tasks, please first claim them in the comments, then raise a PR.

This is a follow up of #1041.

So far we are passing the normalize options(done in rust side) from rust to js. I have already build the basic infra for this requirement and consider this as good chance to involve contributors.

Task are

Pass normalized options itself from rust to js for hooks Solved

There are some plugin hooks that require to access normalized options and I just pass faked to them as an workaround to pass type-check.

For guidance, you could see how I did this to generateBundle hook in #2902.

  • renderChunk hook

// TODO(hyf0): pass `BindingNormalizedOptions` in `renderChunk` hook
{} as NormalizedOutputOptions,

  • writeBundle hook

// TODO(hyf0): pass `BindingNormalizedOptions` in `renderChunk` hook
{} as NormalizedOutputOptions,

Pass normalized fields from rust to js

For guidance, you could see how I did this in #2900.

export interface NormalizedOutputOptions {
	assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
	banner: AddonFunction;
	chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
	dir: string | undefined; // solved
	entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
	esModule: boolean | 'if-default-prop';
	exports: 'default' | 'named' | 'none' | 'auto'
	externalLiveBindings: boolean;
	file: string | undefined;
	footer: AddonFunction;
	format: InternalModuleFormat; // Supported by rolldown already
	inlineDynamicImports: boolean; // solved
	name: string | undefined;
	outro: AddonFunction;
	sourcemap: boolean | 'inline' | 'hidden'; // solved
	sourcemapBaseUrl: string | undefined;
	sourcemapExcludeSources: boolean;
	sourcemapFile: string | undefined;
	sourcemapFileNames: string | ((chunkInfo: PreRenderedChunk) => string) | undefined;
}

This is current supported options

export interface NormalizedOutputOptions {
entryFileNames: string | ChunkFileNamesFunction
format: InternalModuleFormat
}

For input options, I don't feel there are fields need to support so I didn't list them here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions