Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using babel transforms with vue plugin #1450

Closed
lmiller1990 opened this issue Jan 9, 2021 · 0 comments
Closed

Using babel transforms with vue plugin #1450

lmiller1990 opened this issue Jan 9, 2021 · 0 comments

Comments

@lmiller1990
Copy link

lmiller1990 commented Jan 9, 2021

Describe the bug

Vue SFC compilerOptions do not appear to be respected.

I tried https://github.com/wingsico/vite-babel-plugin. No luck. This seems to only work for js files, not anything in SFCs.

This is definitely something that should work, we have tests for it in core: https://github.com/vuejs/vue-next/blob/master/packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts#L444

Reproduction

Create a minimal project with these two files:

vite.config.ts

import vue from '@vitejs/plugin-vue'
import { babel } from '@rollup/plugin-babel'
import { UserConfig } from 'vite'

export default {
  plugins: [
    babel({
      plugins: [
        ['@babel/plugin-proposal-pipeline-operator', { proposal: 'fsharp' }],
      ]
    }),
    vue({
      template: {
        compilerOptions: {
          expressionPlugins: [
            ['pipelineOperator', { proposal: 'fsharp' }]
          ]
        },
      },
      script: {
        babelParserPlugins: [
          ['pipelineOperator', { proposal: 'fsharp' }],
          'partialApplication'
        ] 
      }
    }),
  ]
} as UserConfig

app.vue

<template>
  {{ bar |> up }}
  {{ foo }}
</template>

<script>
export default {
  setup() {

    const up = x => x.toUpperCase()
    const foo = 'foo' |> up

    return {
      bar: 'ok',
      up,
      foo
    }
  }
}

</script>

Should work, but fails on "unexpected token" since it does not understand |>.

System Info

  • vite version: ^2.0.0-beta.12"
  • Operating System: macos
  • Node version:12
  • Package manager (npm/yarn/pnpm) and version: yarn, 1.2x

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
[rollup-plugin-dynamic-import-variables] Unexpected token (6:23)
file: /Users/lachlan/code/dump/reader/src/App.vue:6:23
error during build:
SyntaxError: Unexpected token (6:23)
    at Object.pp$4.raise (/Users/lachlan/code/dump/reader/node_modules/rollup/dist/shared/rollup.js:15589:13)
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant