@cocos/babel-plugin-dynamic-import-vars
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@cocos/babel-plugin-dynamic-import-vars

Inspired from @rollup/plugin-dynamic-import-vars.

This plugin transforms for example:

import(`./${lang}.js`)

into

((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.

Readme

Keywords

none

Package Sidebar

Install

npm i @cocos/babel-plugin-dynamic-import-vars

Weekly Downloads

528

Version

1.0.2

License

MIT

Unpacked Size

19.3 kB

Total Files

11

Last publish

Collaborators

  • cocos-creator
  • pp_pro
  • shrinktofit
  • devhacker520