iam-medvedev / esbuild-plugin-less

esbuild plugin for less files
https://npmjs.com/package/esbuild-plugin-less
Do What The F*ck You Want To Public License
43 stars 12 forks source link

Show full less error #11

Closed tannerkrewson closed 3 years ago

tannerkrewson commented 3 years ago

Thanks for this! Works great!

If there is an error in my less, I get just one line, like "Operation on an invalid type", and an unhelpful trace. Could you log the full error? 😄

iam-medvedev commented 3 years ago

@tannerkrewson Can you provide a code? In my example, errors are shown.

I tried this:

.style-2-less {
  color: red;
  background: @some-undefined-var; // this variable is undefined
}

And got this:

 > example/index.ts:1:7: error: [less-loader] variable @some-undefined-var is undefined
     1 │ import './styles/style.less';
       ╵        ~~~~~~~~~~~~~~~~~~~~~
   src/index.ts:23:12: note: This error came from the "onLoad" callback registered here
    23 │       build.onLoad({ filter: /\.less$/, namespace: 'file' }, async (args) => {
       ╵             ~~~~~~
    at setup (/Users/imedvedev/projects/esbuild-plugin-less/src/index.ts:23:13)
    at handlePlugins (/Users/imedvedev/projects/esbuild-plugin-less/node_modules/esbuild/lib/main.js:700:7)
    at Object.buildOrServe (/Users/imedvedev/projects/esbuild-plugin-less/node_modules/esbuild/lib/main.js:929:44)
    at /Users/imedvedev/projects/esbuild-plugin-less/node_modules/esbuild/lib/main.js:1529:17
    at new Promise (<anonymous>)
    at Object.build (/Users/imedvedev/projects/esbuild-plugin-less/node_modules/esbuild/lib/main.js:1528:14)
    at Object.build (/Users/imedvedev/projects/esbuild-plugin-less/node_modules/esbuild/lib/main.js:1404:51)
    at Object.<anonymous> (/Users/imedvedev/projects/esbuild-plugin-less/example/build.ts:8:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)

Anyway, I will look for options to make the better error output.

iam-medvedev commented 3 years ago

Errors will now become more readable:

 > example/styles/style-2.less:4:9: error: [less-loader] variable @some-undefined-var is undefined
    4 │   color: @some-undefined-var;
      ╵          ^
   example/index.ts:1:7: note: The plugin "less-loader" was triggered by this import
    1 │ import './styles/style.less';
      ╵        ~~~~~~~~~~~~~~~~~~~~~

Build failed with 1 error:
example/styles/style-2.less:4:9: error: [less-loader] variable @some-undefined-var is undefined
github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tannerkrewson commented 3 years ago

That is perfect! Thank you!!!!!

On Fri, Apr 2, 2021, 2:04 AM github-actions[bot] @.***> wrote:

🎉 This issue has been resolved in version 1.0.4 🎉

The release is available on:

Your semantic-release https://github.com/semantic-release/semantic-release bot 📦🚀

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iam-medvedev/esbuild-plugin-less/issues/11#issuecomment-812361639, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACANVM6FEKZDYHLTTQ4O7D3TGVUBNANCNFSM42H6HV6Q .