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

[rollup-plugin] Specify that Rollup 3 is required for this plugin to work #1060

Closed
joekrump opened this issue Apr 27, 2023 · 3 comments
Closed
Assignees
Labels
rollup/vite @honeybadger-io/rollup-plugin

Comments

@joekrump
Copy link

What are the steps to reproduce this issue?

  1. Install Vite version 3.*
  2. Install @honeybadger-io/rollup-plugin and configure as per docs
  3. Run build vite build

What happens?

  • No sourcemaps are found by the plugin and so none are uploaded even though (as you can see from the logged output, the sourcemaps are created).

Partial logged build output in the terminal:

../../public/vite/assets/EditorTextInput.fa2b8ea2.js                          2.12 KiB / gzip: 1.11 KiB
../../public/vite/assets/EditorTextInput.fa2b8ea2.js.map                      6.33 KiB
../../public/vite/assets/errors.95c27f84.css                                  0.78 KiB / gzip: 0.30 KiB
../../public/vite/assets/DropdownQuestion.a74ad556.css                        0.06 KiB / gzip: 0.08 KiB
../../public/vite/assets/users_search.147fa1db.css                            0.74 KiB / gzip: 0.33 KiB
../../public/vite/assets/quill.595782a5.css                                   21.52 KiB / gzip: 3.42 KiB
../../public/vite/assets/application.f2d44d81.css                             37.57 KiB / gzip: 8.18 KiB
../../public/vite/assets/TimePicker.96926bd6.js                               221.00 KiB / gzip: 48.28 KiB
../../public/vite/assets/TimePicker.96926bd6.js.map                           840.77 KiB
../../public/vite/assets/quill.f2f08b2e.js                                    259.15 KiB / gzip: 69.25 KiB
../../public/vite/assets/quill.f2f08b2e.js.map                                826.38 KiB
../../public/vite/assets/application.7993a2c1.css                             378.11 KiB / gzip: 49.00 KiB
../../public/vite/assets/application.50e6d8de.js                              1299.85 KiB / gzip: 366.58 KiB
../../public/vite/assets/application.50e6d8de.js.map                          4967.96 KiB
Build with Vite complete: /Users/username/code/projects/some_project/public/vite
Could not find any sourcemaps in the bundle. Nothing will be uploaded.

What were you expecting to happen?

The sourcemap files would be found and uploaded

Any logs, error output, etc?

See above

Any other comments?

When adding some logging to this plugins code and running the build, I could see that none of the sourcemap files were showing up in the bundle object.

Basic logging I added to the isSourcemap function:

function isSourcemap(file: OutputAsset | OutputChunk): file is OutputAsset {
  // added logging for debugging
  console.log('a bundled file name: ', file.fileName)
  if (file.type !== 'asset' || !file.fileName.endsWith('.js.map') || !file.source) {
    return false
  }

  const source = typeof file.source === 'string' ? file.source : file.source.toString()
  const json = JSON.parse(source)

  return !!json.sourcesContent && json.sourcesContent.length > 0
}

What versions are you using?

Operating System: macOS 13.3.1
Package Name: @honeybadger-io/rollup-plugin
Package Version: 5.4.0
Browser Version: N/A

@joekrump
Copy link
Author

I suggest adding a peerDependency of rollup >= 3 in package.json and specifying something in the README as well.

@joekrump
Copy link
Author

In my case I was using the latest version of Vite 3 but because Vite 3 depended on rollup v2: https://github.com/vitejs/vite/blob/eba9b423ff92c01e52b5e73a69eeded3b608293d/packages/vite/package.json#L64

And looks like @honeybadger-io/rollup-plugin requires rollup v3, which adds this breaking change which looks like it allows reading sourcemaps from the in-memory bundle object: rollup/rollup#4605 (comment)

While sourcemaps were written to disk when using bundle.write, they would not appear as files in the in-memory bundle. Again this has been changed: If the sourcemaps are not inline, they are emitted as regular assets directly before generateBundle has run. This allows you to manually remove some sourcemaps in that hook (or re-emit them with changed content). In any case, this very much improves the in-memory experience when running Rollup.

@subzero10 subzero10 added the rollup/vite @honeybadger-io/rollup-plugin label Apr 28, 2023
@BethanyBerkowitz BethanyBerkowitz self-assigned this May 1, 2023
@BethanyBerkowitz
Copy link
Contributor

Thank you so much, @joekrump! PR is open to add the peer dependency and a note in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup/vite @honeybadger-io/rollup-plugin
Projects
None yet
Development

No branches or pull requests

3 participants