diff --git a/package.json b/package.json index 4ad5848..4125516 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "fs-extra": "^9.1.0", "is-binary-path": "^2.1.0", "joycon": "^3.0.1", + "lodash.clonedeep": "^4.5.0", "postcss": "^8.2.10", "postcss-load-config": "^3.0.1", "resolve": "^1.20.0", @@ -49,6 +50,7 @@ "@types/fs-extra": "^8.0.0", "@types/is-binary-path": "^2.1.0", "@types/jest": "^26.0.14", + "@types/lodash.clonedeep": "^4.5.6", "@types/node-sass": "^4.11.0", "@types/stringify-attributes": "^2.0.0", "@typescript-eslint/eslint-plugin": "^4.22.0", diff --git a/src/index.ts b/src/index.ts index 5128f21..9e64827 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import isBinaryPath from 'is-binary-path' import createDebug from 'debug' import { parse } from '@vue/compiler-sfc' import glob from 'fast-glob' +import cloneDeep from 'lodash.clonedeep' import { replaceContants, cssExtensionsRe, @@ -19,7 +20,7 @@ import { writeSFC } from './writeSFC' const debug = createDebug('vue-compile:cli') -type OptionContants = Record; +type OptionContants = Record interface InputOptions { config?: boolean | string @@ -127,9 +128,11 @@ class VueCompile extends EventEmitter { ctx.transformTypeScript = !this.options.preserveTsBlock - const sfc = parse(source, { - filename: input, - }) + const sfc = cloneDeep( + parse(source, { + filename: input, + }), + ) const script = await compileScript(sfc.descriptor.script, ctx) const scriptSetup = await compileScript(sfc.descriptor.scriptSetup, ctx) @@ -159,6 +162,7 @@ class VueCompile extends EventEmitter { cwd: input, ignore: ['**/node_modules/**'].concat(exclude), }) + await Promise.all( files.map(async (file: string) => { return this.normalizeFile( diff --git a/yarn.lock b/yarn.lock index c86c5c4..2432f5c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1294,6 +1294,18 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636" integrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A== +"@types/lodash.clonedeep@^4.5.6": + version "4.5.6" + resolved "https://registry.yarnpkg.com/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.6.tgz#3b6c40a0affe0799a2ce823b440a6cf33571d32b" + integrity sha512-cE1jYr2dEg1wBImvXlNtp0xDoS79rfEdGozQVgliDZj1uERH4k+rmEMTudP9b4VQ8O6nRb5gPqft0QzEQGMQgA== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.14.172" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.172.tgz#aad774c28e7bfd7a67de25408e03ee5a8c3d028a" + integrity sha512-/BHF5HAx3em7/KkzVKm3LrsD6HZAXuXO1AJZQ3cRRBZj4oHZDviWPYu0aEplAqDFNHZPW6d3G7KN+ONcCCC7pw== + "@types/node-sass@^4.11.0": version "4.11.0" resolved "https://registry.yarnpkg.com/@types/node-sass/-/node-sass-4.11.0.tgz#b0372075546e83f39df52bd37359eab00165a04d"