Fix broken UTC plugin due to rollup #1453
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was playing around with using dayjs from the
dev
branch with #1450 and Node.JS, and I noticed that thedayjs/plugin/utc
was broken, as the plugin was instead exported under thedefault
key.It looks like Rollup does not like mixing together named exports and default exports: https://rollupjs.org/guide/en/#default-export
Updating Rollup
I updated Rollup to the latest version, which fixed an error with running
npm install --dev
on NPM@v7, and also added the following warning:The new rollup is create a
gzip
file that is 31 bytes larger than the oldgzip
size. It seems like it's mainly due to the addition ofglobalThis
, so this should also fix #1060, but I haven't tested it.I also changed
build/index.js
to run rollup sequentially, since otherwise it uses up more than 16 GB of RAM on my computer, which makes it freeze.Fixing
plugins/utc
Finally, to fix plugins/utc, I moved the two regex named exports to the
constant.js
file. Normally this would be a breaking change, but since there hasn't been a release since the PR that added these exports (#1395), it should be fine.New bundle sizes
Created by running
for file in {plugin/*.js,dayjs.min.js}; do echo "$file: $(npx gzip-size --raw "$file")"; done
As can be seen, all the bundles have increased in size by about 15-30 bytes (mainly due to adding
globalThis
), except for the utc plugin, which decreases in size since it no longer has the extra exports.I think it's still worth it though, since the old
rollup
version that is being used is from 2018-03-17, so it is quite out-of-date.