indooorsman / esbuild-css-modules-plugin

A esbuild plugin to bundle css modules into js(x)/ts(x)
MIT License
91 stars 16 forks source link

Incompatibility with tsup #48

Closed moishinetzer closed 9 months ago

moishinetzer commented 1 year ago
// tsup.config.ts
import { defineConfig } from "tsup";
import cssModulesPlugin from "esbuild-css-modules-plugin";

export default defineConfig({
  esbuildPlugins: [cssModulesPlugin()],
});

For some reason typescript really hates this, do you know why this is happening? I believe that it still works correctly, it seems that one of the type definitions aren't the same as what tsup has.

indooorsman commented 1 year ago

could u post the error or screenshot here ?

moishinetzer commented 1 year ago

It's a pretty long call stack but here you go:

Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin'.
  Types of property 'setup' are incompatible.
    Type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>' is not assignable to type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>'.
      Types of parameters 'build' and 'build' are incompatible.
        Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild'.
          The types of 'initialOptions.plugins' are incompatible between these types.
            Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin[] | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin[] | undefined'.
              Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin[]' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin[]'.
                Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin'.
                  Types of property 'setup' are incompatible.
                    Type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>' is not assignable to type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>'.
                      Types of parameters 'build' and 'build' are incompatible.
                        Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild'.
                          Types of property 'onEnd' are incompatible.
                            Type '(callback: (result: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildResult) => void | Promise<void>) => void' is not assignable to type '(callback: (result: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildResult) => void | Promise<void>) => void'.
                              Types of parameters 'callback' and 'callback' are incompatible.
                                Types of parameters 'result' and 'result' are incompatible.
                                  Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildResult' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildResult'.
                                    Types of property 'rebuild' are incompatible.
                                      Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildInvalidate | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildInvalidate | undefined'.
                                        Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildInvalidate' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildInvalidate'.
                                          Type 'Promise<import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildIncremental>' is not assignable to type 'Promise<import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildIncremental>'.
                                            Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildIncremental' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildIncremental'.
                                              Types of property 'metafile' are incompatible.
                                                Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Metafile | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Metafile | undefined'.
                                                  Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Metafile' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Metafile'.
                                                    Types of property 'outputs' are incompatible.
                                                      Type '{ [path: string]: { bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }; }' is not assignable to type '{ [path: string]: { bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }; }'.
                                                        'string' index signatures are incompatible.
                                                          Type '{ bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }' is not assignable to type '{ bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }'.
                                                            Types of property 'imports' are incompatible.
                                                              Type '{ path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]' is not assignable to type '{ path: string; kind: ImportKind; }[]'.
                                                                Type '{ path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }' is not assignable to type '{ path: string; kind: ImportKind; }'.
                                                                  Types of property 'kind' are incompatible.
                                                                    Type 'ImportKind | "file-loader"' is not assignable to type 'ImportKind'.
                                                                      Type '"file-loader"' is not assignable to type 'ImportKind'.ts(2322)
indooorsman commented 1 year ago

it seems that you have 2 different versions of esbuild installed, try to resolve them to 1 version(if you're using yarn then you could add a resolution item to your package.json )


发件人: Moishi Netzer @.> 发送时间: Friday, February 3, 2023 7:11:00 PM 收件人: indooorsman/esbuild-css-modules-plugin @.> 抄送: indooorsman @.>; Comment @.> 主题: Re: [indooorsman/esbuild-css-modules-plugin] Incompatibility with tsup (Issue #48)

It's a pretty long call stack but here you go:

Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin'. Types of property 'setup' are incompatible. Type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild) => void | Promise' is not assignable to type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild) => void | Promise'. Types of parameters 'build' and 'build' are incompatible. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild'. The types of 'initialOptions.plugins' are incompatible between these types. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin[] | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin[] | undefined'. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin[]' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin[]'. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Plugin'. Types of property 'setup' are incompatible. Type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild) => void | Promise' is not assignable to type '(build: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild) => void | Promise'. Types of parameters 'build' and 'build' are incompatible. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").PluginBuild' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").PluginBuild'. Types of property 'onEnd' are incompatible. Type '(callback: (result: import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildResult) => void | Promise) => void' is not assignable to type '(callback: (result: import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildResult) => void | Promise) => void'. Types of parameters 'callback' and 'callback' are incompatible. Types of parameters 'result' and 'result' are incompatible. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildResult' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildResult'. Types of property 'rebuild' are incompatible. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildInvalidate | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildInvalidate | undefined'. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildInvalidate' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildInvalidate'. Type 'Promise<import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildIncremental>' is not assignable to type 'Promise<import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildIncremental>'. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").BuildIncremental' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").BuildIncremental'. Types of property 'metafile' are incompatible. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Metafile | undefined' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Metafile | undefined'. Type 'import("c:/Users/moish/Documents/Repos/Pbandj/node_modules/esbuild/lib/main").Metafile' is not assignable to type 'import("c:/Users/moish/Documents/Repos/Pbandj/playground/node_modules/esbuild/lib/main").Metafile'. Types of property 'outputs' are incompatible. Type '{ [path: string]: { bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }; }' is not assignable to type '{ [path: string]: { bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }; }'. 'string' index signatures are incompatible. Type '{ bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }' is not assignable to type '{ bytes: number; inputs: { [path: string]: { bytesInOutput: number; }; }; imports: { path: string; kind: ImportKind; }[]; exports: string[]; entryPoint?: string | undefined; cssBundle?: string | undefined; }'. Types of property 'imports' are incompatible. Type '{ path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }[]' is not assignable to type '{ path: string; kind: ImportKind; }[]'. Type '{ path: string; kind: ImportKind | "file-loader"; external?: boolean | undefined; }' is not assignable to type '{ path: string; kind: ImportKind; }'. Types of property 'kind' are incompatible. Type 'ImportKind | "file-loader"' is not assignable to type 'ImportKind'. Type '"file-loader"' is not assignable to type 'ImportKind'.ts(2322)

― Reply to this email directly, view it on GitHubhttps://github.com/indooorsman/esbuild-css-modules-plugin/issues/48#issuecomment-1415723024, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABFRA3P65O624QI6BOA2DU3WVTRUJANCNFSM6AAAAAAUPOUBKQ. You are receiving this because you commented.Message ID: @.***>

indooorsman commented 9 months ago

closed as no feedback for long time