Skip to content

Commit efa3950

Browse files
committed
refactor: remove dependency on @vue/compiler-sfc
So that users won't be bothered by the peer dependency warning even if npm did the wrong hoisting Fixes vuejs/vue-cli#5940
1 parent ea7fe31 commit efa3950

File tree

6 files changed

+1930
-1953
lines changed

6 files changed

+1930
-1953
lines changed

Diff for: bin/vue-codemod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const { _: files, transformation: transformationName, params } = yargs
3131

3232
// TODO: port the `Runner` interface of jscodeshift
3333
async function main() {
34-
const resolvedPaths = globby.sync(files)
34+
const resolvedPaths = globby.sync(files as string[])
3535
const transformationModule = loadTransformationModule(transformationName)
3636

3737
log(`Processing ${resolvedPaths.length} files…`)

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
"dependencies": {
2424
"@babel/core": "^7.10.3",
2525
"@babel/preset-env": "^7.10.3",
26+
"@babel/types": "^7.12.12",
2627
"@types/jscodeshift": "^0.7.1",
27-
"@vue/compiler-sfc": "^3.0.0-beta.15",
28+
"@vue/compiler-core": "^3.0.4",
29+
"@vue/compiler-dom": "^3.0.4",
2830
"debug": "^4.1.1",
2931
"globby": "^10.0.2",
3032
"inquirer": "^7.0.3",
3133
"jscodeshift": "^0.10.0",
32-
"vue": "^3.0.0-beta.15",
34+
"lru-cache": "^6.0.0",
35+
"source-map": "^0.6.1",
3336
"yargs": "^15.3.1"
3437
},
3538
"devDependencies": {

Diff for: src/runTransformation.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import jscodeshift, { Transform, Parser } from 'jscodeshift'
22
// @ts-ignore
33
import getParser from 'jscodeshift/src/getParser'
4-
import { parse as parseSFC, SFCDescriptor } from '@vue/compiler-sfc'
5-
import stringifySFCDescriptor from './stringify-sfc-descriptor'
64
import createDebug from 'debug'
75

6+
import { parse as parseSFC, stringify as stringifySFC } from './sfcUtils'
7+
import type { SFCDescriptor } from './sfcUtils'
8+
89
import VueTransformation from './VueTransformation'
910

1011
const debug = createDebug('vue-codemod')
@@ -105,7 +106,7 @@ export default function runTransformation(
105106
}
106107

107108
descriptor!.script!.content = out
108-
return stringifySFCDescriptor(descriptor!)
109+
return stringifySFC(descriptor!)
109110
}
110111

111112
return out

0 commit comments

Comments
 (0)