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

Use a more up-to-date rollup sourcemap plugin #1951

Closed
wants to merge 1 commit into from

Conversation

birkskyum
Copy link
Member

@birkskyum birkskyum commented Dec 18, 2022

We previously used: https://github.com/maxdavidson/rollup-plugin-sourcemaps

It hasn't been updated for years and is not rollup-3 compatible due to a 'peerDependency' in @rollup/pluginutils which it relies on. This PR change to a more recent fork of it.

This PR can be tested by running 'npm i' and checking that the dependency warning about conflicting rollup versions is gone.

@github-actions
Copy link
Contributor

Bundle size report:

Size Change: 0 B
Total Size Before: 207 kB
Total Size After: 207 kB

Output file Before After Change
maplibre-gl.js 197 kB 197 kB 0 B
maplibre-gl.css 9.1 kB 9.1 kB 0 B
ℹ️ View Details No major changes

@birkskyum birkskyum requested a review from wipfli December 18, 2022 10:44
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-include-sourcemaps": "^0.7.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the package very new? I am a bit scared of replacing a package with 600k weekly downloads with one which as 5...

https://www.npmjs.com/package/rollup-plugin-sourcemaps
image

https://www.npmjs.com/package/rollup-plugin-include-sourcemaps
image

Copy link
Member Author

@birkskyum birkskyum Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "big" package hasn't had a commit for years, and the new is a fork of it made with a single commit on top of it. I did create a PR on the original package as well, but it seems that other people have attempted that before. I can change back if it gets merged eventually.

Copy link
Member Author

@birkskyum birkskyum Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end of the day, this entire plugin is just one file with 73 lines of code...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@HarelM
Copy link
Collaborator

HarelM commented Dec 18, 2022

We need to decide if we want to create a pre-release before these changes get merged, just to be oh the safe side...
We also said we need to in order to see that everything is working in terms of CI.

@birkskyum
Copy link
Member Author

birkskyum commented Dec 18, 2022

I think it would be good to make a pre-release as a smoke test. We can always swap this later - my personal fork of this library has everything updated even beyond this PR, and it could help out too if we have to adjust anything.

@rotu
Copy link
Contributor

rotu commented Dec 20, 2022

What does this plugin do anyway?

Sourcemaps are already broken in CI due to an issue with @rollup/plugin-terser, so I don't know that we could really test the release process correctly right now:

https://github.com/maplibre/maplibre-gl-js/actions/runs/3724432570/jobs/6316584006#step:6:16

rollup/plugins#1371

@birkskyum
Copy link
Member Author

birkskyum commented Dec 20, 2022

@rotu it's a good point - the bundling space is changing really fast currently (I'd love to replace terser), so maybe we can wait this out a bit or remove the sourcemap plugin.

@birkskyum birkskyum closed this Dec 20, 2022
@rotu
Copy link
Contributor

rotu commented Dec 20, 2022

I still don't quite understand what this plugin supposedly does :-).

Also, I expect webapp developers to do tree-shaking and minification downstream. So maybe we can just drop terser entirely.

@birkskyum
Copy link
Member Author

birkskyum commented Dec 21, 2022

From our rollup config:

plugins: [
// Ingest the sourcemaps produced in the first step of the build.
// This is the only reason we use Rollup for this second pass
sourcemaps()
],

That is the only documentation on it I can find

@rotu
Copy link
Contributor

rotu commented Dec 21, 2022

I see that but it seems Maplibre has had defective source maps since 2.2.0-pre.4

https://unpkg.com/browse/[email protected]/dist/

https://unpkg.com/browse/[email protected]/dist/

@HarelM
Copy link
Collaborator

HarelM commented Dec 21, 2022

Not everyone is using webpack etc, maplibre can be used as is with script tag in a HTML. Although not common these days...

@rotu
Copy link
Contributor

rotu commented Dec 21, 2022

Not everyone is using webpack etc, maplibre can be used as is with script tag in a HTML. Although not common these days...

True. And those users are getting broken sourcemaps and stack traces today. I'm thinking that use case is better served with non-minified files or with an optimizing CDN like the excellent https://www.skypack.dev/

@HarelM
Copy link
Collaborator

HarelM commented Dec 21, 2022

Looking at the diff, it looks like it is related to the json assert introduction if I need to guess:
v2.2.0-pre.3...v2.2.0-pre.4
Nevertheless, I think we should find a way to fix the sourcemaps, If there isn't an issue about it, I would recommend opening one.

@rotu
Copy link
Contributor

rotu commented Dec 21, 2022

There's issue #1582 which was supposedly fixed in #1780

But I can't tell if the issue was correctly diagnosed and/or fixed. Maybe @pgoldberg knows.

@pgoldberg
Copy link
Contributor

There's issue #1582 which was supposedly fixed in #1780

But I can't tell if the issue was correctly diagnosed and/or fixed. Maybe @pgoldberg knows.

#1780 did fix #1582. Here's a gist of the bundled distribution and its source map built off of that commit: https://gist.github.com/pgoldberg/122b40f29a04d85ce3338209f6b12bed

It does look like this has since regressed due to the terser plugin issue that you pointed out

@HarelM HarelM deleted the change-rollup-plugin-for-sourcemaps branch April 19, 2023 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants