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

@nrwl/esbuild doesn't support plugins in esbuildOptions #14823

Closed
shellscape opened this issue Feb 6, 2023 · 6 comments · Fixed by #14997
Closed

@nrwl/esbuild doesn't support plugins in esbuildOptions #14823

shellscape opened this issue Feb 6, 2023 · 6 comments · Fixed by #14997
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug

Comments

@shellscape
Copy link

Current Behavior

The esbuild plugin purports to support plugins via this line:

...(esbuildOptions.plugins ?? []),

But as esbuild itself requires the plugins property to contain an array of objects, this can never be used as the code was written, as there's no way to convey what esbuild wants via project.json (and I'm not going to rant about why Nx doesn't support .js config files so don't worry, plenty of others already have)

Expected Behavior

Some ability to use plugins.

GitHub Repo

No response

Steps to Reproduce

n/a

Nx Report

n/a

Failure Logs

n/a

Additional Information

n/a

@ndcunningham
Copy link
Contributor

I am not sure I understand, could you provide a repo highlighting your expectation?

@shellscape
Copy link
Author

shellscape commented Feb 6, 2023

I'm not sure I understand what you aren't sure you understand.

To use esbuild plugins as explained here https://esbuild.github.io/plugins/#using-plugins, you have to be able to initialize them within a js file. esbuild provides no means to load plugins by name, and provides no means to load plugins via the command line (which you aren't using so that's moot). There's no reproduction to give because there's no way to create a reproduction, citing the info just given.

The gist is that the line I linked to does nothing, it has no purpose, because the user can never pass in anything via project.json that would be valid for esbuild to use there. So while the code purports to support user-provided plugins, it in fact does not, because Nx doesn't support anything but JSON in project.json.

That line of code should probably be removed.

@AgentEnder AgentEnder added the scope: bundlers Issues related to webpack, rollup label Feb 7, 2023
@jaysoo
Copy link
Member

jaysoo commented Feb 9, 2023

We discussed this, and we can get plugins to work if we support a .js config file for esbuild, just like we do for rollup, vite, and webpack.

So you can define something like:

// esbuild.config.ts
export default {
  //...
  plugins: [require('foo-plugin')]
}

or

// esbuild.config.js
module.exports = {
  // ...
  plugins: [require('foo-plugin')]
};

@shellscape
Copy link
Author

Being able to use a companion .js or .ts file would be ideal. That's up to you all if you'd like to support that, and would be cool for the community if you did. The purpose of my original issue was to highlight that there's currently code in the plugin that cannot be used, so I'm just pleased that it's getting attention.

@jaysoo
Copy link
Member

jaysoo commented Feb 9, 2023

We'll get that feature in. There shouldn't be things that can be done with plain esbuild API that cannot be done through Nx.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants