formily icon indicating copy to clipboard operation
formily copied to clipboard

[Bug Report] @formify/element-plus with vite-plugin-imp failed in Nuxt3

Open NexZhu opened this issue 3 years ago • 0 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

git clone -b formily https://github.com/daotl/nuxt-starter.git
cd nuxt-starter
npm install
npm run dev

What is expected?

I'm following this guid to use Formily with Element Plus + Nuxt3 + Vite https://element-plus.formilyjs.org/guide/#%E6%8C%89%E9%9C%80%E6%89%93%E5%8C%85

Expected to work.

What is actually happening?

I just modified nuxt.config.ts, I haven't use the Form component in .vue file yet, but Nuxt already failed to startup.

nuxt.config.ts (related part):

export default defineNuxtConfig({
  ...
  vite: {
    plugins: [
      vitePluginImp({
        libList: [
          {
            libName: '@formily/element-plus',
            style(name): string {
              return `@formily/element-plus/esm/${name}/style.js`
            },
          },
        ],
      }),
    ],
  ...
}

npm run dev error, then go to http://localhost:3000/, error log:

 ERROR  Unexpected token, expected "}" (5:7)    

 ERROR  4:17:55 PM [vite] Internal server error: Unexpected token, expected "}" (5:7)                                                                                                                                                             16:17:55
  Plugin: vite-plugin-imp
  File: /root/dev/web/daotl-nuxt-starter/app.vue
  3  |  
  4  |  useHead({
  5  |    title: 'Vitesse Nuxt 3',
     |         ^
  6  |    link: [
  7  |      {
    at instantiate (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:72:29)
      at constructor (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:367:12)
      at JSXParserMixin.raise (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3678:19)
      at JSXParserMixin.unexpected (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3716:16)
      at JSXParserMixin.expect (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:4129:28)
      at JSXParserMixin.jsxParseExpressionContainer (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:8009:10)
      at JSXParserMixin.jsxParseElementAt (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:8103:36)
      at JSXParserMixin.jsxParseElement (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:8156:17)
      at JSXParserMixin.parseExprAtom (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:8170:19)
      at JSXParserMixin.parseExprSubscripts (/root/dev/web/daotl-nuxt-starter/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:12790:23)

image

Package

@formily/[email protected]


Node version v18.8.0

NexZhu avatar Sep 21 '22 08:09 NexZhu