istanbuljs / babel-plugin-istanbul

A babel plugin that adds istanbul instrumentation to ES6 code
BSD 3-Clause "New" or "Revised" License
616 stars 72 forks source link

"Don't know how to turn this value into node" error when paired with Vue3 and script setup #276

Open scaricopax8 opened 2 years ago

scaricopax8 commented 2 years ago

Description When using babel-plugin-instanbul for a Vue 3 app that is using script setup, there is a flood of transpilation errors reading don't know how to turn this value into a node at transformFile.next for each Vue component that uses <script setup> when extending .vue files in your babel.config.js.

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
  ],
  plugins: [
    ['babel-plugin-istanbul', {
      extension: ['.js', '.vue']
    }]
  ],
};
Screen Shot 2022-05-02 at 3 15 41 PM

Steps to Reproduce

  1. Create a new Vue 3 application using the vue-cli
  2. Install babel-plugin-istanbul in your dev dependencies
  3. Configure your babel.config.js as shown above
  4. Update your App.vue to use <script setup>
  5. Run npm run serve

Expected Behavior The app is traspiled with no errors

Actual Behavior A don't know how to turn this value into a node at transformFile.next error populates for every Vue file that uses <script setup>


If you were to revise the script in your Vue files to use export default the transpilation errors disappear.

✅ Works

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

❌ Fails

<script setup>
import HelloWorld from './components/HelloWorld.vue'
</script>
yilihjy commented 1 year ago

I use https://github.com/istanbuljs/babel-plugin-istanbul/pull/272 to fix this