asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
https://kroki.io/
MIT License
146 stars 47 forks source link

Webpack: Cannot statically analyse 'require(…, …)' #317

Open lord-pendragon opened 2 years ago

lord-pendragon commented 2 years ago

image

Description: Using Asciidoctor's Kroki extension with Webpackv4 results in the following error

How to Reproduce:

  1. Make a React-App

  2. Add the following dependencies to packages.json: "asciidoctor": "^2.2.5", "asciidoctor-kroki": "^0.15.4", "highlight.js": "11.4.0", "sanitize-html": "2.6.1", "webpack": "^4.0.0"

  3. Add AsciiDoctor.jsx to your project

  4. Import AsciiDoctor into App.jsx and use it as

  5. npm start: You will see the issue

Repo: https://github.com/lord-pendragon/ascii-krokii-webpack-issue

ggrossetie commented 2 years ago

Line 29 in dist/browser/asciidoctor-kroki.js is an empty line: https://github.com/Mogztter/asciidoctor-kroki/blob/dd6b5708d87a60166fc8c0e018a12b5c026aac02/dist/browser/asciidoctor-kroki.js#L29

I can reproduce this issue using the following steps:

  1. npx create-react-app asciidoctor-kroki-react-scripts
  2. cd asciidoctor-kroki-react-scripts
  3. npm i @asciidoctor/core@2.2.5 asciidoctor-kroki@0.15.4
  4. Edit src/App.js, add the following import:
    import Asciidoctor from '@asciidoctor/core'
    import kroki from 'asciidoctor-kroki'
  5. Save and run npm start

image

Having said that, I have absolutely no idea how to solve this issue since the error message does not help. You should probably ask the Webpack team:

lord-pendragon commented 2 years ago

That's a shame, will raise this with the Web-pack Team, can close the issue if you wish to do so. Will inform on any updates from Web-pack devs.

ggrossetie commented 2 years ago

Thanks, I will keep this issue open until we found the root cause.

@lord-pendragon Feel free to link this issue if there's a corresponding GitHub issue upstream.