# cocos-babel-plugin-dynamic-import-vars **Repository Path**: mirrors_cocos-creator/cocos-babel-plugin-dynamic-import-vars ## Basic Information - **Project Name**: cocos-babel-plugin-dynamic-import-vars - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-18 - **Last Updated**: 2025-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @cocos/babel-plugin-dynamic-import-vars Inspired from [@rollup/plugin-dynamic-import-vars](https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars). This plugin transforms for example: ```js import(`./${lang}.js`) ``` into ```js ((specifier) => { switch (specifier) { case './zh-cn.js': return import('./zh-cn.js'); case './en-us.js': return import('./en-us.js'); default: return import(specifier); } })(`./${lang}.js`) ``` given `'./${lang}.js'` can be statically resolved as `'./zh-cn.js'`, `'./en-us.js'` etc. # Rules Similar with `@rollup/plugin-dynamic-import-vars` except that: - If none of the preset specifiers matches, the code won't throw but still fallback to run. - Supplied an options to resolve `.js` to others for example `.ts`.