-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Reduce built library size #277
Conversation
✅ Deploy Preview for anchor-position-wpt canceled.
|
✅ Deploy Preview for anchor-polyfill ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
vite.config.ts
Outdated
}, | ||
plugins: [bundleStats()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have multiple outputs, this is just giving us the stats for the last build, but I don't think there's a benefit for auditing the builds separately.
I'm leaning towards leaving this installed, as it can help us keep an eye on the bundle size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I moved it to devDependencies
and made it less verbose, but the generated reports are still there.
@@ -37,7 +38,12 @@ export default defineConfig({ | |||
emptyOutDir: !process.env.BUILD_FN, | |||
target: 'es6', | |||
sourcemap: true, | |||
rollupOptions: { | |||
external: [/source-map-js/], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to provide a name in output.globals? There's a warning message emitted-
`No name was provided for external module "source-map-js/lib/source-map-generator.js" in "output.globals". We don't really need to expose it, I don't think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't think it really matters. I added it just to silence the warning, since I don't love getting used to "ignore these warnings" if we don't have to.
Description
This reduces the size of the built library from 223.72KiB to 105.54KiB by:
source-map-js
from the built library. Source maps are still generated, but the module itself isn't needed.Pre-merge cleanup:
Related Issue(s)
#276
Steps to test/reproduce
import polyfill from '/dist/css-anchor-positioning-fn.js';
npm run build; open dist/bundle-stats.html
to check the results. (You can compare with the current build on theprev-stats
branch, which has the bundle-stats plugin installed with no modifications to main.Show me
Before
After