microsoft / PowerBI-visuals-tools

Contains tools for building/packaging Power BI visuals
https://www.powerbi.com
MIT License
336 stars 152 forks source link

pbiviz package -> [ERR_REQUIRE_ESM]: require() of ES Module #505

Closed PlastMan420 closed 7 months ago

PlastMan420 commented 9 months ago

using latest v 5.4.1 Running pbiviz package will throw this error. it complains .eslintrc.js

Another issue is replacing .eslintc.js with .eslintrc (json config). it would throw that error instead -> Error: Failed to load plugin 'powerbi-visuals' declared in 'CLIOptions': Cannot find module 'eslint-plugin-powerbi-visuals'

tools v5.3.0 works fine.

AleksSavelev commented 9 months ago

Thank you for creating this issue. I'll investigate the problem.

For now, look like you can use second approach and install the eslint-plugin-powerbi-visuals if you didn't do it before.

PlastMan420 commented 9 months ago

Hello, I do have it installed and I got it included in .eslintrc.js. I also made sure to have it included in .eslinrc.

I'd like to add that my custom visual was generated using tools v5.3.0

PlastMan420 commented 9 months ago

Hello, I've resolved my problem by

  1. Rename .exlintrc.js to .eslintrc.cjs. didn't end up using .eslintrc in the end.
  2. Install both eslint-plugin-powerbi-visuals and @typescript-eslint/eslint-plugin globally. has to be the 2 of em.
  3. Make sure both plugins are included in .eslintrc.cjs.
  4. Make sure that .eslintrc.cjs is included in tsconfig.
glasshalfasleep commented 8 months ago

Hello, I've resolved my problem by

  1. Rename .exlintrc.js to .eslintrc.cjs. didn't end up using .eslintrc in the end.
  2. Install both eslint-plugin-powerbi-visuals and @typescript-eslint/eslint-plugin globally. has to be the 2 of em.
  3. Make sure both plugins are included in .eslintrc.cjs.
  4. Make sure that .eslintrc.cjs is included in tsconfig.

Where are the files located for 1 above? How do I install globally for 2? How for 3 and 4?

I am very new to all this stuff and I am simply trying to modify a power BI visual with a minor edit to the visual.ts file and that took me like 10 minutes and I have spent hours trying to figure out how to package the visual back up to actually test the change.

PlastMan420 commented 8 months ago
  1. All files are in the root directory of your visual project.
  2. run npm i -g eslint-plugin-powerbi-visuals @typescript-eslint/eslint-plugin
  3. https://eslint.org/docs/latest/use/configure/plugins#use-a-plugin add under "plugins" and then under "extends"
  4. add "eslintrc.cjs" under "files" in tsconfig.
AleksSavelev commented 8 months ago

Hello @PlastMan420. Is it possible to share with me the source code to reproduce this issue?

AleksSavelev commented 8 months ago

Thank you for the information you provided in this topic. I was able to reproduce it and fix the issue!

The new version will be available in a few upcoming days.