UNPKG

@zohodesk/client_build_tool

Version:

A CLI tool to build web applications and client libraries

26 lines (19 loc) 1.56 kB
# I18n Split As Chunks Plugin generaly we have manage our all I18n keys and values as language specific i18n files and then we download all i18n in initial page load. Ok, what is the problem with this?. the problem is i18n file keep get's grown it will affect the the inital page load and critial rendering path. So, We have decide to create a plugin for split i18n per chunk's of js vise, Which mean we diside to create for each js chunk has its own i18n chunks, with this we already load Js chunks are on demand and now we also download i18n also ondemand with this the initial and forthere actions. Ok, How to you do this thing? we have read the js chunk and collect I18n keys what are used in that chunk and we will create i18n chunk files with only used key. Ok, How do you collect that keys? we now have two experimental stage to collect I18n keys. 1. we read jsResource.properties (or all keys I18n file) then we walk this AST of js and we collect all string which is jsResource.properties. 2. for dynamic we discide to use comment some thing like `// I18n support.tickekt.email.notvalid` ok, how do you downlowd and give to app? we have over write defualt webpack require ensure function. So every dynamic chunk requset are done by that function. So we parlarly dowload i18n files. and we ask jsonFunction, to our plugin. So we send i18nkeys , when it was download, you must store all i18n keys, we give asycrnsly by that function download in that patticular. so you must store and update (like append or assign) everytime that function call.