-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: support <script setup> in Vue 2.7 * refactor: remove unnecessary bindingMetadata * refactor: remove unnecessary refTransform * feat: add setup to generateSourceMap * chore: update Vue dependencies * fix: remove inline sourceMap in vue2 setup scripts * fix: update 2.x snapshot * fix: use appropriate package according to vue version * fix: rebase typo * fix: make script setup & script blocks work together * Update test.js.snap * fixing snapshots Co-authored-by: Felix Graf <git@felixgraf.dev> Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
- Loading branch information
1 parent
1cd403d
commit 7f2287c
Showing
15 changed files
with
216 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<div> | ||
<button @click="increase">Count: {{ num }}</button> | ||
<Basic /> | ||
<span>{{ msg }}</span> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import Basic from './Basic.vue' | ||
const num = ref(5) | ||
const greet = () => console.log('greet') | ||
const increase = () => { | ||
greet() | ||
num.value++ | ||
} | ||
const msg = 'hello world' | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { SourceMapGenerator, SourceMapConsumer } = require('source-map') | ||
|
||
// based on @vue/compiler-sfc mapLines | ||
module.exports = function mapLines(oldMap, newMap) { | ||
if (!oldMap) return newMap | ||
if (!newMap) return oldMap | ||
|
||
const oldMapConsumer = new SourceMapConsumer(oldMap) | ||
const newMapConsumer = new SourceMapConsumer(newMap) | ||
const mergedMapGenerator = new SourceMapGenerator() | ||
|
||
newMapConsumer.eachMapping(m => { | ||
if (m.originalLine == null) { | ||
return | ||
} | ||
|
||
const origPosInOldMap = oldMapConsumer.originalPositionFor({ | ||
line: m.originalLine, | ||
column: m.originalColumn | ||
}) | ||
|
||
if (origPosInOldMap.source == null) { | ||
return | ||
} | ||
|
||
mergedMapGenerator.addMapping({ | ||
generated: { | ||
line: m.generatedLine, | ||
column: m.generatedColumn | ||
}, | ||
original: { | ||
line: origPosInOldMap.line, // map line | ||
// use current column, since the oldMap produced by @vue/compiler-sfc | ||
// does not | ||
column: m.originalColumn | ||
}, | ||
source: origPosInOldMap.source, | ||
name: origPosInOldMap.name | ||
}) | ||
}) | ||
|
||
// source-map's type definition is incomplete | ||
const generator = mergedMapGenerator | ||
oldMapConsumer.sources.forEach(sourceFile => { | ||
generator._sources.add(sourceFile) | ||
const sourceContent = oldMapConsumer.sourceContentFor(sourceFile) | ||
if (sourceContent != null) { | ||
mergedMapGenerator.setSourceContent(sourceFile, sourceContent) | ||
} | ||
}) | ||
|
||
generator._sourceRoot = oldMap.sourceRoot | ||
generator._file = oldMap.file | ||
return generator.toJSON() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.