WordPress.org

Make WordPress Core

#45201 closed defect (bug) (fixed)

Exclude JavaScript source maps from build

Reported by: mcsf Owned by: SergeyBiryukov
Milestone: 5.0 Priority: normal
Severity: normal Version: 5.0
Component: Build/Test Tools Keywords: fixed-5.0
Focuses: Cc:
PR Number:

Description

The nightly build, as obtained from https://wordpress.org/nightly-builds/wordpress-latest.zip, currently contains .map files, source maps for 5.0's new JS packages. These aren't needed in the build and should be removed.

$ find . -name '*.map' | xargs du -hc
 28K	./wp-includes/js/dist/hooks.js.map
[32 more items...]
 16K	./wp-includes/js/dist/viewport.js.map
5.5M	total

Attachments (2)

45201.diff (848 bytes) - added by pento 11 months ago.
45201.2.diff (857 bytes) - added by mcsf 11 months ago.

Download all attachments as: .zip

Change History (20)

#1 @jorbin
12 months ago

  • Milestone changed from Awaiting Review to 5.0

@atimmer and @omarreiss This seems like a follow up to #45145 and something we should do to reduce the zip size.

Increased zip size can be a contributing factor to updates failing, so anything we can do to keep it lower is a good thing.

#2 @netweb
12 months ago

The recent changes in #45145 that caused this are potentially going to be reverted which will resolve this issue I believe, @mcsf can you follow that ticket also and test again once those changes are reverted please.

#3 @netweb
12 months ago

  • Keywords reporter-feedback added

@mcsf [43826] and [43824] have been reverted in [43835], could you update your local checkout when possible and test again please.

#4 @mcsf
12 months ago

confirmed that .map files are no longer present in build after running Grunt.

Last edited 12 months ago by mcsf (previous) (diff)

#5 @ocean90
12 months ago

  • Keywords reporter-feedback removed

This is related to #45156 and not #45145. The map files are still there as you can see in https://build.trac.wordpress.org/browser/branches/5.0/wp-includes/js/dist/.

#6 @pento
11 months ago

@ocean90: I seem to recall the map files being needed to extract translator comments. Is that correct? It looks like the comments are in the unminified JS files.

@pento
11 months ago

#8 follow-up: @pento
11 months ago

  • Keywords has-patch needs-testing added

45201.diff makes the build happen without the map files. Can someone please test that it doesn't have any weird side effects?

@mcsf
11 months ago

#9 in reply to: ↑ 8 @mcsf
11 months ago

Replying to pento:

45201.diff makes the build happen without the map files. Can someone please test that it doesn't have any weird side effects?

Nothing weird observed. I can confirm .map files are excluded.

The only exception can be found in the Twenty Nineteen directory:

$ find build -name '*.map'
build/wp-content/themes/twentynineteen/style.css.map

I've uploaded 45201.2.diff to cover this.

#10 @pento
11 months ago

Good catch, thanks @mcsf.

It's fine to keep that file in src, so I'll move that rule to not copy any .map files from src to build, instead.

#11 @pento
11 months ago

In 43931:

Build Tools: Don't include .map files in the build.

These files are fairly large, and while they're useful in development, they're not needed in the final build.

Props pento, mcsf.
See #45201.

#12 @pento
11 months ago

  • Keywords fixed-5.0 added; needs-testing removed

#13 @pento
11 months ago

  • Keywords has-patch fixed-5.0 removed

Turns out there was a side effect: webpack wraps the code in an eval() call when a devtool isn't specified.

#14 @pento
11 months ago

In 43932:

Build Tools: Tweak the webpack config for unminified files.

[43931] unintentionally caused the unminified files to wrap the code in an eval() call.

See #45201.

#15 @pento
11 months ago

In 43933:

Build Tools: Don't minimise CSS in the unminimised files.

See #45201.

#16 @pento
11 months ago

  • Keywords fixed-5.0 added

Okay, that reduced the nightly zip file from 18.3MB to 16.7MB. For comparison, the 4.9 nightly is 13.4MB.

I'd expect a similar size decrease in the release zip, dropping it from 13.6MB to 12MB. For comparison, the 4.9.8 release zip was 9.5MB.

I don't think there's much more space to save, the additional 3.5MB of zip is taken up by:

  • Minified package JS/CSS files: 3.4MB
  • Unminified package JS/CSS files: 7.5MB
  • The size difference between Twenty Nineteen and Twenty Fifteen (the latter is removed from the 5.0 release zip): 700KB.

#17 @SergeyBiryukov
10 months ago

In 44282:

Build Tools: Don't include .map files in the build.

These files are fairly large, and while they're useful in development, they're not needed in the final build.

Props pento, mcsf.
Merges [43931] and [43932] to trunk.
See #45201.

#18 @SergeyBiryukov
10 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 44283:

Build Tools: Don't minimise CSS in the unminimised files.

Props pento.
Merges [43933] to trunk.
Fixes #45201.

Note: See TracTickets for help on using tickets.