Giter Site home page Giter Site logo

vite-plugin-imp's Introduction

vite-plugin-imp

  • A vite plugin for import ui library component style automatic.
  • It can also import library like lodash on demand.
import { forEach } from 'lodash'

forEach([1,2], console.log)

to

import forEach from 'lodash/forEach'

forEach([1,2], console.log)

import { Progress } from 'vant'

to

import { Progress } from 'vant'
import 'vant/es/progress/style/index.js'

install

npm i vite-plugin-imp -D

or

yarn add vite-plugin-imp -D

Usage

import { defineConfig } from 'vite'
import vitePluginImp from 'vite-plugin-imp'
export default defineConfig({
  plugins: [vitePluginImp(config)]
})

config interface is ImpConfig:

export interface LibItem {
  /**
   * library name
   */
  libName: string
  /**
   * component style file path
   */
  style: (name: string) => string | string[] | boolean
  /**
   * default `es`
   */
  libDirectory?: string
  /**
   * whether convert component name from camel to dash
   */
  camel2DashComponentName?: boolean
  /**
   * whether replace old import statement, default `command === 'build'`,
   * that means in vite serve default to `false`, in vite build default to `ture`
   */
  replaceOldImport?: boolean
}

interface ImpConfig {
  libList: libItem[]
  /**
   * exclude the library from defaultLibList
   */
  exclude?: string[]
  /**
   * when a style path is not found, don’t show error and give a warning. 
   * Default: command === 'serve'
   */
  ignoreStylePathNotFound?: boolean
  /**
   * By default `vite-plugin-imp` ignores all files inside node_modules. 
   * You can enable this option to avoid unexpected untranspiled code from third-party dependencies.
   * 
   * Transpiling all the dependencies could slow down the build process, though. 
   * If build performance is a concern, you can explicitly transpile only some of the dependencies 
   * by passing an array of package names or name patterns to this option.
   * 
   * Default: false
   */
  transpileDependencies?: boolean | Array<string | RegExp>
}

More libraries usage

// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginImp from 'vite-plugin-imp'

export default defineConfig({
  plugins: [
    // ...
    vitePluginImp({
      libList: [
        {
          libName: 'lodash',
          libDirectory: '',
          camel2DashComponentName: false
        },
        {
          libName: 'antd',
          style(name) {
            // use less
            return `antd/es/${name}/style/index.js`
          }
        },
      ]
    })
  ]
})

Built-in Support popular library

You should put these built-in supported libraries in your dependencies field in package.json.

If your project is using libraries that mentioned above, you just need use it like:

export default defineConfig({
  plugins: [
    // ...
    vitePluginImp()
  ]
})

If you want to support a library built-in, feel free to open a issue.

just use the component like below, component style will be auto injected.

import { defineComponent } from 'vue'
import { Progress } from 'vant'
import { ElButton } from 'element-plus'

export default defineComponent({
  setup() {
    return () => {
      return (
        <div>
          <Progress percentage={3} />
          <ElButton>element-plus button</ElButton>
        </div>
      )
    }
  }
})

You can set camel2DashComponentName to false to disable transfer from camel to dash:

vitePluginImp({
  libList: [
    {
      libName: 'custom-lib',
      camel2DashComponentName: false, // default true
      style: (name) => {
        return`custom-lib/lib/${name}/index.css`
      }
    }
  ]
})

plugin V1.x (No more updates) Usage

// vite.config.js
const vitePluginImpCreator = require('vite-plugin-imp')

const vitePluginImp = vitePluginImpCreator({
  optimize: true,
  libList: [
    {
      libraryName: 'vant',
      style: (name) => {
        return `vant/es/${name}/index.css`
      }
    },
    {
      libraryName: 'element-plus',
      style: (name) => {
        return`element-plus/lib/theme-chalk/${name}.css`
      }
    }
  ]
})

module.exports = {
  plugins: [vitePluginImp]
}

vite-plugin-imp's People

Contributors

adalinesimonian avatar choysen avatar dependabot[bot] avatar hangsman avatar mrcljx avatar psaren avatar richex-cn avatar zheeeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vite-plugin-imp's Issues

React antd-mobile libDirectory 的bug

Describe the bug

源码中 libDirectory 没有填写, 默认是es,
而antd-mobile的真正目录因该是es/components

Libarary Info(please complete the following information):

"antd-mobile": "^5.10.3",
"vite-plugin-imp": "^2.1.7",

To Reproduce
随便使用一个antd-mobile 组件 , 然后 vite build

Expected behavior
无需自定义配置 , 即可正常build

Error message

antd-mobile/es/dialog 正确的路径应该是 antd-mobile/es/components/dialog

[vite]: Rollup failed to resolve import "antd-mobile/es/dialog" from "src/pages/product/index.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

Additional context

我这样自定义libDirectory 后, 解决了该问题..
方案来自于 antd-mobile官网地址

vitePluginImp({ 
      libList: [        
        {
          libName: "antd-mobile",
          libDirectory:"es/components",

          // 下面这个style可能不需要,  需要在 main.tsx 中 引入 import "antd-mobile/es/global";
          //style: (name) => {
          //  return `antd-mobile/es/components/${name}/${name}.css`            
          //}

        }
      ],
    }),

Support to transform imports into different formats (esm and cjs)

Describe the feature

If I use it in a library and want to output two formats (esm and cjs), I can transform an import into only one format.

import { Button } from '@arco-design/mobile-react';
import Button from '@arco-design/mobile-react/esm/Button'; // in esm format
import Button from '@arco-design/mobile-react/cjs/Button'; // in cjs format

Can this plugin support this case?

Discuss: an idea to make this plugin easier

I have an idea to make this plugin easier , like below:

import { defineConfig } from 'vite'
import vitePluginImp from 'vite-plugin-imp'
export default defineConfig({
  plugins: [vitePluginImp()]
})

Implementation:
we collect a default libList from frequently used libraries.

defaultLibList: [
  {
    libName: 'lodash',
    libDirectory: '',
    camel2DashComponentName: false,
    style: () => {
      return false;
    },
  },
  {
    libName: 'antd',
    style: (name) => `antd/es/${name}/style`
  },
  // other frequently used libraries.
  ...
]
  1. defaultLibList will be filter by dependencies of package.json(for better prefomance).
  2. Combined libList and defaultLibList into one list(combinedLibList), if libList has a lib duplicate with defaultLibList, use the one in libList.
  3. Add a option exclude: string[] options to exclude the lib in combinedLibList.

Last but not least, ensure that the changes are compatible with the previous version.

Please feel free to comment, and I look for to having deeper discussion with you.

Cannot work with vite.config.ts

TS 的定义和实际的 JS 输出不一致,当我在 vite.config.ts 中使用时,只能通过 vitePluginImp.default 配合 @ts-ignore 使用。

Reproduce: https://stackblitz.com/edit/vitejs-vite-wkqurd?file=vite.config.ts

目前我只能这样用:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginImp from 'vite-plugin-imp'

export default defineConfig(({ mode }) => {
  const IS_DEV = mode === 'development'

  return {
    plugins: [
      vue(),
      // @ts-ignore: conflicting type define with default export
      vitePluginImp.default({})
    ]
  }
})

why i set console.log in line 13 but the chrome console.log show the line is 28 ?

Describe the bug
A clear and concise description of what the bug is.
your bug should start with lib, like:

[vant] get error xxx

Libarary Info(please complete the following information):
Libarary: [name]

  • Version [e.g. 22]

To Reproduce
Steps to reproduce the behavior:
Paste your code here or provide a minimal reproduce repo link.

Expected behavior
A clear and concise description of what you expected to happen.

** Error message**
Paste the error message here.

Additional context
Add any other context about the problem here.

React + antd +vite 按需引入antd 样式,一些组件样式存在问题,比如 Select、DatePicker、Menu

Describe the bug
React + antd +vite 按需引入antd 样式,一些组件样式存在问题,比如 Select、DatePicker、Menu

Libarary Info
"antd": "^4.15.4",
"vite": "^2.3.4",
"vite-plugin-imp": "^2.0.7",

To Reproduce

import { Select } from 'antd';
// ...
    <Select defaultValue="lucy" style={{ width: 120 }}>
      <Option value="jack">Jack</Option>
      <Option value="lucy">Lucy</Option>
      <Option value="Yiminghe">yiminghe</Option>
    </Select>
    vitePluginImp({
      libList: [
        {
          libName: 'antd',
          style: (name) => `antd/lib/${name}/style/index.less`,
        }
      ]
    })

Expected behavior
点击 Select 显示 Option,失去焦点隐藏 Option

** Error message**
点击 Select 显示 Option,失去焦点没有隐藏 Option 如图

2uu238.png

Doesn't compatible with antd-mobile 5.0

Describe the bug
A clear and concise description of what the bug is.
your bug should start with lib, like:

[antd-mobile] build failed

Libarary Info(please complete the following information):
Libarary: "antd-mobile": "^5.4.0"

To Reproduce
Steps to reproduce the behavior:
Paste your code here or provide a minimal reproduce repo link.
https://stackblitz.com/edit/vitejs-vite-ixsqtt?file=vite.config.ts

Expected behavior
A clear and concise description of what you expected to happen.

Error message
Paste the error message here.
[vite]: Rollup failed to resolve import "antd-mobile/es/pull-to-refresh/style/css.js" from "src/App.tsx". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.externalerror during build: Error: [vite]: Rollup failed to resolve import "antd-mobile/es/pull-to-refresh/style/css.js" from "src/App.tsx". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it tobuild.rollupOptions.external at onRollupWarning (/home/projects/vitejs-vite-ixsqtt/node_modules/vite/dist/node/chunks/dep-9c153816.js:39242:19) at onwarn (/home/projects/vitejs-vite-ixsqtt/node_modules/vite/dist/node/chunks/dep-9c153816.js:39020:13) at Object.eval [as onwarn] (/home/projects/vitejs-vite-ixsqtt/node_modules/rollup/dist/shared/rollup.js:23129:13) at ModuleLoader.handleResolveId (/home/projects/vitejs-vite-ixsqtt/node_modules/rollup/dist/shared/rollup.js:22419:26) at eval (/home/projects/vitejs-vite-ixsqtt/node_modules/rollup/dist/shared/rollup.js:22380:26)

Additional context
Add any other context about the problem here.

Debug sourcemap line error with antd.

Confirm sourcemap line error with antd.
使用antd按需加载样式的时候断点行错误.

Libarary Info:

  • vite: 2.6.13
  • vite-plugin-imp: 2.0.9
  • antd: 4.16.13

Minimal To Reproduce
package.json

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "vite",
  },
  "dependencies": {
    "antd": "^4.16.13",
    "prop-types": "15.7.2",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@vitejs/plugin-react-refresh": "^1.3.1",
    "less": "^4.1.2",
    "vite": "^2.6.13",
    "vite-plugin-imp": "^2.0.9"
  }
}

vite.config.js

import reactRefresh from "@vitejs/plugin-react-refresh";
import { defineConfig } from "vite";
import vitePluginImp from "vite-plugin-imp";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    reactRefresh(),
    vitePluginImp({
      libList: [
        {
          libName: "antd",
          style: (name) => `antd/es/${name}/style`,
        },
      ],
    }),
  ],
  css: {
    preprocessorOptions: {
      less: {
        // 支持内联 JavaScript
        javascriptEnabled: true,
      },
    },
  },
});

index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Test</title>
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
  <script type="module" src="/src/index.jsx"></script>
</body>

</html>

src/index.jsx

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";

ReactDOM.render(
  <App />, document.getElementById("root")
);

src/App.jsx

import { Row, Col, Button, Modal } from 'antd';
import React from 'react';

export default class App extends React.Component {
  state = {
    visible: false,
  }

  componentDidMount() {
    console.log(this)
  }

  show = () => {
    this.setState({ visible: true })
  }

  hide = () => {
    this.setState({ visible: false })
  }

  ok = () => {
    console.log(this.state) // set debug here.
  }

  render() {
    return (
      <>
        <Row gutter={8}>
          <Col span={6}>
            <Button className="mt_8" onClick={this.show}>as</Button>
          </Col>
        </Row>
        <Modal
          title="Modal"
          visible={this.state.visible}
          onCancel={this.hide}
          onOk={this.ok}
        ></Modal>
      </>
    )
  }
}

Expected behavior
debug break at given line src/App.jsx#24

Error message
debug report break at src/App.jsx#32

QQ20211028175847

I also found that whcih is Modal causes this bug but cannot step further due to prior js/ts knowledge.
Maybe there have more other antd compoments will cause this bug.

type error

export default function vitePluginImp(userConfig: Partial<ImpConfig>): Plugin {

userConfig?: Partial<ImpConfig>

this line should have a ?. when we set plugin [vitePluginImp()]

parse importmap in index.html failed

Describe the bug

image

image

        <script type="importmap">
            {
                "imports": {
                    "date-fns": "https://esm.dancf.com/npm:[email protected]/index.js",
                    "lodash": "https://esm.dancf.com/npm:[email protected]/lodash.js",
                    "nativebird": "https://esm.dancf.com/npm:[email protected]/promise.mjs",
                    "path-to-regexp": "https://esm.dancf.com/npm:[email protected]/index.js",
                    "pinia": "https://esm.dancf.com/npm:[email protected]/dist/pinia.mjs",
                    "qs": "https://esm.dancf.com/npm:[email protected]/dist/qs.js",
                    "vue": "https://esm.dancf.com/npm:[email protected]/dist/vue.runtime.esm.js",
                    "vue-demi": "https://esm.dancf.com/npm:[email protected]/lib/index.mjs",
                    "vue-router": "https://esm.dancf.com/npm:[email protected]/dist/vue-router.esm.js",
                    "vuedraggable": "https://esm.dancf.com/npm:[email protected]/dist/vuedraggable.umd.js"
                },
                "scopes": {
                    "https://esm.dancf.com/": {
                        "@vue/devtools-api": "https://esm.dancf.com/npm:@vue/[email protected]/lib/esm/index.js",
                        "@vue/reactivity": "https://esm.dancf.com/npm:@vue/[email protected]/dist/reactivity.esm-bundler.js",
                        "@vue/runtime-core": "https://esm.dancf.com/npm:@vue/[email protected]/dist/runtime-core.esm-bundler.js",
                        "@vue/runtime-dom": "https://esm.dancf.com/npm:@vue/[email protected]/dist/runtime-dom.esm-bundler.js",
                        "@vue/shared": "https://esm.dancf.com/npm:@vue/[email protected]/dist/shared.esm-bundler.js",
                        "sortablejs": "https://esm.dancf.com/npm:[email protected]/modular/sortable.esm.js",
                        "vue": "https://esm.dancf.com/npm:[email protected]/dist/vue.runtime.esm-bundler.js"
                    }
                }
            }
        </script>

Libarary Info(please complete the following information):

  • "vite": "^3.2.5",
  • "vite-plugin-imp": "^2.3.1"

To Reproduce

  1. add importmap to index.html
  2. vite build

Expected behavior

No error when build.

** Error message**
Paste the error message here.

Additional context

What is importmaps: https://github.com/WICG/import-maps

antd 3.x 版本 配置问题

3.20.16 版本的antd 引index.js 不生效 antd/es/${name}/style/index.js;

改成css.js 反倒生效了 - -

vite 5.0.2 版本

Sourcemap is likely to be incorrect

When run build script, the command line displays as follows:

Sourcemap is likely to be incorrect: a plugin (vite-plugin-imp) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

name undefined in shared.js

Describe the bug

[ant-design-vue] get error [vite] Internal server error: Cannot read property 'name' of undefined
error in node_modules/vite-plugin-imp/dist/shared.js:55:95
const name = (_a = item) === null || _a === void 0 ? void 0 : _a.imported.name;

Libarary Info(please complete the following information):
Libarary: [vite]

  • Version [2.3.0]
    Libarary: [ant-design-vue]
  • Version [2.1.6]
    Libarary: [vite-plugin-imp]
  • Version [2.0.7]

Does the library not support Ant-design !!!

Rollup failed to resolve import "antd/Slider" from "xxx/xx/xx/xx.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

构建出错

Describe the bug
使用vant的时候,vite build构建报错

[vite]: Rollup failed to resolve import "vant/es/lazyload" from "src/main.ts".

Libarary Info(please complete the following information):
Libarary: vant

  • Version [e.g. 22]

To Reproduce

viteImp({
      libList: [
        {
          libName: 'vant',
          // replaceOldImport: false,
          style: name => `vant/es/${name}/style/index.js`,
        },
      ],
    }),

Expected behavior
build right , when i set replaceOldImport false. it will success

** Error message**

Additional context

有一些疑问想和大家讨论

1.使用该插件和直接在main.ts引用相比,有哪些好处?
2.作者身体状况如何,是否打算长期维护这个项目?

Missing semicolon causes build to fail

v2.1.4 just upgrade and build fail, the semicolon is missing?
source code at src/shared.ts line 68

newImportStatement += `import ${localName} from '${libName}/${libDir}${finalName}'`

antd v5

error with antd v5
Error: [vite]: Rollup failed to resolve import "antd/es/grid/style/css.js" from "/Users/sayjeyhi/Desktop/Projects/newHoory/common-frontend/hooks/useResponsive/index.ts".

where I used:

import { Grid } from "antd";

Option to only add extra styles without rewriting the JS imports?

Describe the bug

Can't build my vite app using vite-plugin-imp as it tries to rewrite both style and js imports. In my use case, I only want to add extra less imports and do not touch the JS imports (and let rollup do the tree shaking).

        {
          libName: '@mgcrea/antd-extended',
          // libDirectory: 'lib/esm',
          // camel2DashComponentName: false,
          style: (name) => {
            return [`antd/es/${name}/style/index.less`, `@mgcrea/antd-extended/lib/esm/${name}/style/index.less`];
          },
        },

[vite]: Rollup failed to resolve import "@mgcrea/antd-extended/es/button" from "src/screens/LoginScreen.tsx".

Library Info(please complete the following information):

  • "@mgcrea/antd-extended": "^0.4.0",

To Reproduce

npx vite build

Looks like replaceOldImport might be a possible fix if it did work for the build command as well.

antd-vue, Popconfirm, throw 'Failed to resolve import "ant-design-vue/es/popconfirm/style/index.css". Does the file exist?'

whole error msg

12:09:55 PM [vite] Internal server error: Failed to resolve import "ant-design-vue/es/popconfirm/style/index.css". Does the file exist?
Plugin: vite:import-analysis
File: /Users/zbf/workspace/web/project/vue3-admin/src/views/Login/index.tsx
2 | import 'ant-design-vue/es/checkbox/style/index.css'
3 | import 'ant-design-vue/es/button/style/index.css'
4 | import 'ant-design-vue/es/popconfirm/style/index.css'
| ^
5 | import { isVNode as _isVNode, createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
6 | import { reactive, defineComponent } from 'vue';
at formatError (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:53624:46)
at TransformContext.error (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:53620:19)
at normalizeUrl (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:46462:26)
at async TransformContext.transform (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:46599:57)
at async Object.transform (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:53840:30)
at async transformRequest (/Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:60394:29)
at async /Users/zbf/workspace/web/project/vue3-admin/node_modules/vite/dist/node/chunks/dep-dee4e734.js:60484:32

vant/es/default/style/index.js is not found! 报错

[vite-plugin-imp] vant/es/default/style/index.js is not found!
[vite-plugin-imp] If you think this is a bug, feel free to open an issue on https://github.com/onebay/vite-plugin-imp/issues
[vite-plugin-imp] vant/es/toast/style/index.js is not found!
[vite-plugin-imp] If you think this is a bug, feel free to open an issue on https://github.com/onebay/vite-plugin-imp/issues
[vite-plugin-imp] vant/es/toast/style/index.js is not found!
[vite-plugin-imp] If you think this is a bug, feel free to open an issue on https://github.com/onebay/vite-plugin-imp/issues

Can't transform import "lodash"

Describe the bug

image

Can't transform import "lodash"

vitePluginImp({
    libList: [
        {
            libName: '@xxx/yyy-antd',
            libDirectory: 'es',
            style: (name) => `@xxx/yyy-antd/es/${name}/style/css.js`,
        },
    ],
}),

Libarary Info(please complete the following information):

"vite-plugin-imp": "^2.3.1",
"lodash": "4.17.21"

To Reproduce

This happen in my company project, which is a large vite + vu2 project.
Two package will use this plugin to tramsform import:

  1. lodash
  2. @xxx/yyy-antd

Expected behavior
No this warning, or provide an option to supress this warning.

What about always transform no matter "serve" or "build"

Describe the bug

Thanks your work, it is a helpful package

Does this plugin only work under "build"? It maybe useful under development, Or we can add a option, to let user whether always transform the import declaration

Libarary Info(please complete the following information):
Libarary: [name]

  • Version [e.g. 22]

To Reproduce
Steps to reproduce the behavior:
Paste your code here or provide a minimal reproduce repo link.

Expected behavior
A clear and concise description of what you expected to happen.

** Error message**
Paste the error message here.

Additional context
Add any other context about the problem here.

支持处理node_modules中的文件

Describe the bug

有些封装的库没有做打包处理,就是要和项目一起编译,比如我基于 ant-design-vue封装了一些高级组件,就是以 tsx文件发布的,项目中引用这个库直接被项目的编译工具编译,此时插件未处理按需加载的情况

Libarary Info(please complete the following information):
Libarary: ant-design-vue

  • Version 3

To Reproduce
...

Expected behavior
支持编译node_modules中的文件

fusion design in vite project that can't be built

Describe the bug

[@alifd/next] vite project import fusion design UI framework,then get mistake node_modules/@alifd/next/types/drawer/index.d.ts:13:18 - error TS2430: Interface 'DrawerProps' incorrectly extends interface 'HTMLAttributesWeak'.
Types of property 'onVisibleChange' are incompatible.
Type '((visible: boolean, reason: string) => void) | undefined' is not assignable to type '((visible: boolean, type: string | object, e?: {} | undefined) => void) | undefined'.

Libarary Info(please complete the following information):
Libarary: [@alifd/next]

  • Version [1.25.19]

To Reproduce
Steps to reproduce the behavior:
1、pls. take a look at this online demo https://stackblitz.com/edit/vitejs-vite-ajpyen?file=src%2FApp.tsx
2、open a new terminal to run "npm run build",then you will see the mistake info

Expected behavior
when run "npm run build",there is no mistake and can packaged ok

** Error message**
Paste the error message here.

Additional context
Add any other context about the problem here.

How about icon components import ? like arcod

@arco-design/web-react/icon do not support dynamic import out of box with this plugin.

And we should add extra libList to support it, if this plugin support every modern UI frameworks. (antd, arcod, element, etc.)

Why not support icon components ?

vitePluginImp({
    libList: [
      {
        libName: '@arco-design/web-react/icon',
        libDirectory: 'react-icon',
        camel2DashComponentName: false,
      }
    ],
  }),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.