Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend esbuild types #332

Closed
panoply opened this issue Mar 31, 2022 · 1 comment
Closed

Extend esbuild types #332

panoply opened this issue Mar 31, 2022 · 1 comment

Comments

@panoply
Copy link

panoply commented Mar 31, 2022

Hey @egoist,

Thanks for your all your OS work and bringing support for esbuild to Rollup. Looking over the code the way in which types are applied could be improved. Folks tend to rely heavily on Intellisense capabilities within editors and as we see in #331 devs will assume something it not supported when an option is not made available in completions.

We only need to omit the CommonOptions that this plugin does not support. Here is a refined approach you could leverage that will extend the ESBuild types, opposed to the interface used in index.ts

Let me know if you need a PR and I try get around to it.

import type { CommonOptions, Loader } from 'esbuild';

type OmitOptions = Omit<CommonOptions, (
  | 'sourcesContent'
  | 'sourcemap'
  | 'sourceRoot'
  | 'color'
  | 'logLevel'
  | 'logLimit'
)>

type MinifyOptions = Omit<OmitOptions, (
  | 'format'
  | 'sourcesContent'
  | 'globalName'
  | 'define'
  | 'pure'
  | 'jsx'
  | 'jsxFactory'
  | 'jsxFragment'
)>

export interface ESBuildOptions extends OmitOptions {
  sourceMap?: boolean;
  optimizeDeps?: MarkOptional<OptimizeDepsOptions, 'cwd' | 'sourceMap'>
  /**
   * Use this tsconfig file instead
   * Disable it by setting to `false`
   */
  tsconfig?: string | false;
  /**
   * Map extension to esbuild loader
   * Note that each entry (the extension) needs to start with a dot
   */
  loaders?: {
    [ext: string]: Loader | false;
  };
}
@sxzz
Copy link
Collaborator

sxzz commented Sep 20, 2023

Closing due to resolved.

@sxzz sxzz closed this as completed Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants