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

fix(webpack): enable SourceMaps in releases #9877

Merged
merged 6 commits into from
Apr 30, 2024
Merged

fix(webpack): enable SourceMaps in releases #9877

merged 6 commits into from
Apr 30, 2024

Conversation

glowcloud
Copy link
Contributor

Refs #9101

From the official Webpack documentation for devtool:

Screenshot 2024-04-26 at 11 16 27

and guide for production:

Screenshot 2024-04-26 at 11 18 44

Testing the options with the static HTML page in the dist folder:

  • source-map (PR):
source-map
  • nosources-source-map (current):
nosources-source-map
  • hidden-source-map:
hidden-source-map

After building with the source-map option, the size of the dist folder went from 10 439 023 bytes (10,5 MB on disk) to 19 239 017 bytes (19,3 MB on disk)

@char0n
Copy link
Member

char0n commented Apr 29, 2024

TODO:

  • we need to limit source map generation to certain build fragments (exports/browser only)
  • we need to return sourceMap setting for Terser plugin
  • we need to refactor the logic of determining if source map is to be generated
  • we need to test on Safari
  • ideally close all the source map related issues as resolved
  • we always was source maps in dev environment because of direct chrome debugging capability
  • ?? possibility to ignore vendor source maps ??

We decided that only certain build fragments that can/may be used in development env will contain source maps. Other will not as we're assuming nobody debugs in production and on production bundles (debugging in mostly done in development).

webpack/_config-builder.js Outdated Show resolved Hide resolved
@glowcloud
Copy link
Contributor Author

glowcloud commented Apr 30, 2024

dist size after building: 11 804 809 bytes (11,9 MB on disk) with source maps included for core, es-bundle-core, dev and standalone.

Tested with a React application in Chrome:

Screenshot 2024-04-29 at 15 27 20

Firefox:

Screenshot 2024-04-29 at 15 28 39

and Safari:

Screenshot 2024-04-29 at 15 30 54

@glowcloud
Copy link
Contributor Author

glowcloud commented Apr 30, 2024

There's also this line in es-bundle-core:

devtool: sourcemaps && minimize ? "source-map" : false,

perhaps it was to bypass the previous nosources-source-map setting?

@char0n
Copy link
Member

char0n commented Apr 30, 2024

We don't want to generate source maps for standalone build UMD fragment because of:

We decided that only certain build fragments that can/may be used in development env will contain source maps. Other will not as we're assuming nobody debugs in production and on production bundles (debugging in mostly done in development).

@char0n
Copy link
Member

char0n commented Apr 30, 2024

There's also this line in es-bundle-core
perhaps it was to bypass the previous nosources-source-map setting?

We'll use new reusable helper for this one to align it with swagger-ui.js build fragment. This one always worked and generated properly working source map, but now we utilize some optimization on top of it.

@char0n
Copy link
Member

char0n commented Apr 30, 2024

Please also modify

cp ../../../dist/swagger-ui-es-bundle-core.js ../dist

@char0n
Copy link
Member

char0n commented Apr 30, 2024

Another references in

!dist/swagger-ui-bundle.js

@char0n char0n merged commit 8c90d5d into master Apr 30, 2024
8 checks passed
@char0n char0n deleted the issue-9101 branch May 13, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants