https://hokify-data.s3.eu-central-1.amazonaws.com/empty-app-shared-components.zip
core-js should not be included, or at least only the minimum stuff that is somehow still needed in modern builds? are there any though?

i'm not sure if this is maybe expected, but couldn't find any valid reason. according to esmodule babel documentation, promise is definitely supported in this case (https://www.ecma-international.org/ecma-262/6.0/#sec-promise-constructor) and therefore I see no reason why e.g. this one is included. I guess this is true also for the other includes.
In copmarison to the client build, there a are a lot less modules included already, but shouldn't it actually be gone at all?
Hi @simllll , thanks for the issue reporting.
For modern build, modern browsers is decided by targets.esmodules of @babel/preset-env, but even for some modern browsers, es.promise in core-js is still needed as some of the modern browsers are not fully supporting promise specifications, like https://github.com/zloirock/core-js/issues/565#issuecomment-495987453 described.
NOTE(Dangerous): This may break some unfully supported functionalities in modern browsers, if you're 100% sure that you don't need the polyfills, you can use exclude to exclude them:
export default {
modern: 'server',
build: {
babel: {
presets({ envName }, [preset, options]) {
options.corejs = { version: 3 }
if (envName === 'modern') {
options.exclude = ['es.promise']
}
}
}
}
}
More details if you're interested
esmodules: From babel compat-data, we can see that esmodules corresponding browsers are https://github.com/babel/babel/blob/master/packages/babel-compat-data/data/native-modules.json#L4 which includes firefox >= 60promise: From core-js comapt data, we can see that promise corresponding browsers are https://github.com/zloirock/core-js/blob/master/packages/core-js-compat/src/data.js#L705 which includes firefox >= 69That's the reason why promise is included, so the app may be lack of fully promise support in firefox 60-69 if you exclude the polyfill manually.
For other included core-js polyfills, you can use the same way to check if it should be included.
Thank you for the great insights! Makes totally sense now, perfect summary of what's going on! Closing this now, should we link this issue from @nuxt/babel-preset-app as further explanation for polyfills and modern build?
just for reference, this could be something to look into to as well:
https://github.com/nuxt/nuxt.js/issues/6784
@babel/preset-modules for modern build
Most helpful comment
Hi @simllll , thanks for the issue reporting.
For modern build, modern browsers is decided by
targets.esmodulesof@babel/preset-env, but even for some modern browsers,es.promiseincore-jsis still needed as some of the modern browsers are not fully supportingpromisespecifications, like https://github.com/zloirock/core-js/issues/565#issuecomment-495987453 described.NOTE(Dangerous): This may break some unfully supported functionalities in modern browsers, if you're 100% sure that you don't need the polyfills, you can use
excludeto exclude them:More details if you're interested
esmodules: From babel compat-data, we can see thatesmodulescorresponding browsers are https://github.com/babel/babel/blob/master/packages/babel-compat-data/data/native-modules.json#L4 which includesfirefox >= 60promise: From core-js comapt data, we can see thatpromisecorresponding browsers are https://github.com/zloirock/core-js/blob/master/packages/core-js-compat/src/data.js#L705 which includesfirefox >= 69That's the reason why
promiseis included, so the app may be lack of fully promise support infirefox60-69 if you exclude the polyfill manually.For other included core-js polyfills, you can use the same way to check if it should be included.