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

Make esbuild an optional peer dependency #1232

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Make esbuild an optional peer dependency #1232

merged 2 commits into from
Nov 15, 2023

Conversation

mrm007
Copy link
Contributor

@mrm007 mrm007 commented Nov 15, 2023

Prior art and discussions: #1018, #1171

esbuild is now a peer dependency in esbuild-plugin and esbuild-plugin-next.
Why make it a peer dependency? Because our script to bundle types bundles the Plugin type from esbuild into the output, which can cause a type error when consumers try to use it.
It's marked as optional, so it won't crash on install when consumers don't have esbuild in their dependencies.

I believe this is a better solution than both #1018 and #1171.
#1171 is too intrusive and adds esbuild everywhere, and consumers have to include it in their dependencies.
Relevant xkcd: https://xkcd.com/927/

Before

https://unpkg.com/browse/@vanilla-extract/[email protected]/dist/vanilla-extract-esbuild-plugin.cjs.d.ts (Plugin type is inlined)

After

import { IdentifierOption, CompileOptions } from '@vanilla-extract/integration';
import { Plugin } from 'esbuild';

interface VanillaExtractPluginOptions {
    outputCss?: boolean;
    /**
     * @deprecated Use `esbuildOptions.external` instead.
     */
    externals?: Array<string>;
    runtime?: boolean;
    processCss?: (css: string) => Promise<string>;
    identifiers?: IdentifierOption;
    esbuildOptions?: CompileOptions['esbuildOptions'];
}
declare function vanillaExtractPlugin({ outputCss, externals, runtime, processCss, identifiers, esbuildOptions, }?: VanillaExtractPluginOptions): Plugin;

export { vanillaExtractPlugin };

Copy link

changeset-bot bot commented Nov 15, 2023

🦋 Changeset detected

Latest commit: 74c37ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vanilla-extract/esbuild-plugin-next Patch
@vanilla-extract/esbuild-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@askoufis askoufis enabled auto-merge (squash) November 15, 2023 04:23
@askoufis askoufis merged commit ca68a90 into master Nov 15, 2023
11 checks passed
@askoufis askoufis deleted the esbuild-peer-deps branch November 15, 2023 04:25
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

Successfully merging this pull request may close these issues.

2 participants