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

need pad when parsing script #1778

Open
l1shu opened this issue Dec 22, 2020 · 1 comment
Open

need pad when parsing script #1778

l1shu opened this issue Dec 22, 2020 · 1 comment

Comments

@l1shu
Copy link

l1shu commented Dec 22, 2020

Version

16.0.0

Reproduction link

https://codepen.io/l1shu/pen/ExgwjbM

Steps to reproduce

In vue-loader@16

source code:

<template>
  <div />
</template>
<script>
export default {}
</script>

What is expected?

//
//
//
//
export default {}

What is actually happening?

export default {}

add param pad: 'line'
https://github.com/vuejs/vue-loader/blob/next/src/index.ts#L96

const { descriptor, errors } = parse(source, {
    filename,
    sourceMap,
    pad: 'line',
});

That's because the parser of @vue/compiler-sfc use pad=false as default.
see https://github.com/vuejs/vue-next/blob/master/packages/compiler-sfc/src/parse.ts#L84

@andrewmackrodt
Copy link

andrewmackrodt commented Feb 24, 2021

+1 for this, IDE debugger support is not functional without setting pad: 'line' | true. If pad is not desired for production builds, could it be supported as a vue-loader option which defaults to true in non-production environments?

Presently, it is required to override compiler-sfc's parse method with something like:

const CompilerSfc = require('@vue/compiler-sfc')
const parse = CompilerSfc.parse
CompilerSfc.parse = (source, options) => {
  return parse(source, Object.assign({ pad: true }, options))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants