robinloeffel / esbuild-plugin-eslint

Lint your esbuild bundles with eslint. 🧐
https://npmjs.com/esbuild-plugin-eslint
MIT License
7 stars 7 forks source link

Purpose of this plugin? #9

Closed glensc closed 1 year ago

glensc commented 1 year ago

I'm looking for a way to create eslint bundle, i.e one file eslint.js with all necessary dependencies from node_modules bundled in to that file. because of dynamic imports, out of the box it does not work:


$ esbuild --platform=node --target=node14 --bundle --sourcemap --outfile=dist/eslint.js node_modules/.bin/eslint

  dist/eslint.js      3.3mb ⚠️
  dist/eslint.js.map  6.4mb

✨  Done in 0.32s.
$ node dist/eslint.js
There was a problem loading formatter: /Users/glen/work/dist/formatters/stylish
Error: Cannot find module '/Users/glen/work/dist/formatters/stylish'
Require stack:
- /Users/glen/work/dist/eslint.js

I setup your plugin into build() pipeline, and it still gave me formatters/stylish import error.

Similarly for bundling pino, there's plugin that handles the dynamic imports for bundling:

but this project, given the same project name structure, and usage, does something different. what does it mean? because these two sentences definitely doesn't explain it. to me:

Lint your esbuild bundles with eslint. 🧐

Nicely integrates the most recent version of eslint into an esbuild plugin.

please describe the actual usage of this plugin in readme, perhaps with examples, asciicast?

robinloeffel commented 1 year ago

i'm not sure i follow your question. the purpose of this plugin is to easily integrate eslint into your development workflow. this allows you to easily check for code style errors, etc., while you work on things. eslint will then pretty-print a summary of errors and warnings into your console.

this plugin however is not to bundle eslint into a chunk. which is what you were trying to do, if i understand your snippet correctly, right?

glensc commented 1 year ago

yes, I want to bundle. but why this plugin is needed? why can't I just use eslint itself?

robinloeffel commented 1 year ago

you absolutely can use eslint on its own, you don't have to use this plugin. the plugin is only to make linting your source code easier, to automatically make eslint run when esbuild starts a (re)build. but if you want to somehow integrate eslint into a bundle, this plugin won't help you with that.

glensc commented 1 year ago

i still don't understand why this plugin is useful, why would i want to use this plugin (instead of eslint directly). can you make https://asciinema.org/ recording to show it's usefulness?

i personally run eslint with lint-staged, so it's executed on every commit.