Closed twavv closed 6 months ago
@travigd Can you use a dynamic import instead?
export async function getServerSideProps() {
const crypto = await import('crypto');
}
Yes, but this should still be fixed. :)
I'm currently just using the webpack workaround described above.
Could probably integrate this into PR #200 tbh. Will here shortly
Probably best not to conflate multiple things in the same PR.
Would it be best to rather make a separate PR after #200 is pushed to have this fixed?
I'd think so.
PR #201 will fix this issue
Fixed in b638139cc86e560ce65533c00e5f72b95926ff59
See title.
Allows for deadcode elimination when not the module is imported but not actually used.
This comes up for me when using NextJS where one frequently writes server side code as a
getServerSideProps
function. I want to import Node's crypto module but don't need it for the browser -- but webpack is unable to remove the import even though Next does remove thegetServerSideProps
function).The workaround is to add
to the webpack config.