-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: support package exports and custom paths #52
base: master
Are you sure you want to change the base?
Conversation
@@ -28,7 +28,7 @@ server({ port: PORT }, [ | |||
}) | |||
} | |||
}), | |||
get('/export-sizes', async ctx => { | |||
get('/exports-sizes', async ctx => { |
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.
Not sure what's going on here, this is the path the frontend is using.
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.
This is only a dev server — the frontend uses its own routes and server. But makes sense to synchronize here.
const mainSizes = mainAssets.reduce((acc, asset) => { | ||
acc.size += asset.size | ||
acc.gzip += asset.gzip | ||
if (asset.parse) { | ||
acc.parse = acc.parse || {baseParseTime: 0, scriptParseTime: 0} | ||
acc.parse.baseParseTime += asset.parse.baseParseTime || 0 | ||
acc.parse.scriptParseTime += asset.parse.scriptParseTime || 0 | ||
} | ||
return acc | ||
}, { size: 0, gzip: 0, parse: null as null | { baseParseTime: number, scriptParseTime: number } }) |
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.
I maintain a component library (Vuetify) that imports its own stylesheets. The way this was before would only include the size of the CSS instead of CSS + JS.
console.log(${options.customImports.join(', ')}) | ||
` | ||
} else { | ||
importStatement = `const p = require('${packageName}'); console.log(p)` | ||
importStatement = `const p = await import(/* webpackMode: 'eager' */'${importPath}'); console.log(p)` |
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.
.mjs
can't be .require()
d
options, | ||
}: BuildPackageArgs) { | ||
const buildStartTime = performance.now() | ||
let buildIteration = 1 | ||
|
||
importPath = await resolve(installPath, importPath) |
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.
We're still using webpack 4, but have webpack 5's enhanced-resolve
. This resolves imports to an absolute path so webpack 4 can load them.
Thanks for taking time out to contribute. Support for alternate entry points to a package that was definitely on my radar. |
That's fair enough, I don't really know how all the caching and historical stats works. |
Frontend PR: pastelsky/bundlephobia#679
Supports the following formats: