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

TypeError: ifdefPlugin is not a function #1

Open
helm100 opened this issue Nov 2, 2022 · 1 comment
Open

TypeError: ifdefPlugin is not a function #1

helm100 opened this issue Nov 2, 2022 · 1 comment

Comments

@helm100
Copy link

helm100 commented Nov 2, 2022

First of all, I'm extremely happy this plugin exists. It really extends the possibilities of building a client.

I could be wrong, but I think I stumbled upon a bug. My setup:

const esbuild = require("esbuild");
const ifdefPlugin = require("esbuild-ifdef");

esbuild.build({
    entryPoints: ["./app.ts"],
    bundle: true,
    outfile: "./out/bundle.js",
    minify: false,
    sourcemap: true,
    plugins: [
        ifdefPlugin({
            variables: {
                Client: "DESKTOP"
            },
            requireTripleSlash: false
        })
    ]
}).catch(() => process.exit(1));

I have esbuild v0.15.11 and esbuild-ifdef v0.2.0

Executing this code with node gives the error:
TypeError: ifdefPlugin is not a function

This is fixed by changing the first line into
const ifdefPlugin = require("esbuild-ifdef").default;

I'm not sure whether that is the expected behavior. I did not stumble upon it when searching the README.

@zziger
Copy link
Owner

zziger commented Nov 2, 2022

Hi! I'll have a look at the this issue shortly, there's probably some problem with separating esmodules and commonjs versions in built package.

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