提交 7f435663 编写于 作者: 雪洛's avatar 雪洛

fix(uni-app-x web): 修复css内使用v-bind无效的Bug

上级 a2ffb69e
......@@ -2076,8 +2076,8 @@ function isEmpty(node) {
}
return true;
}
function hmrShouldReload(prevImports, next) {
if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
function hmrShouldReload(prevImports, next) { // fixed by xxxxxx
if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx" && next.scriptSetup.lang !== "uts") {
return false;
}
for (const key in prevImports) {
......@@ -15532,6 +15532,8 @@ class ScriptCompileContext {
const scriptSetupLang = scriptSetup && scriptSetup.lang;
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
// fixed by xxxxxx
this.isUTS = scriptLang === "uts" || scriptSetupLang === "uts"
const customElement = options.customElement;
const filename = this.descriptor.filename;
if (customElement) {
......@@ -15599,8 +15601,8 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
plugins.push("jsx");
} else if (userPlugins) {
userPlugins = userPlugins.filter((p) => p !== "jsx");
}
if (lang === "ts" || lang === "tsx") {
} // fixed by xxxxxx
if (lang === "ts" || lang === "tsx" || lang === 'uts') {
plugins.push(["typescript", { dts }], "explicitResourceManagement");
if (!userPlugins || !userPlugins.includes("decorators")) {
plugins.push("decorators-legacy");
......@@ -15708,7 +15710,7 @@ const normalScriptDefaultVar = `__default__`;
function processNormalScript(ctx, scopeId) {
var _a;
const script = ctx.descriptor.script;
if (script.lang && !ctx.isJS && !ctx.isTS) {
if (script.lang && !ctx.isJS && !ctx.isTS && !ctx.isUTS) {
return script;
}
try {
......@@ -15722,6 +15724,17 @@ function processNormalScript(ctx, scopeId) {
const defaultVar = genDefaultAs || normalScriptDefaultVar;
const s = new MagicString(content);
rewriteDefaultAST(scriptAst.body, s, defaultVar);
// fixed by xxxxxx
if(ctx.isUTS) {
scriptAst.body.forEach((node) => {
if (node.type === "ExportDefaultDeclaration") {
if (node.declaration.type === "ObjectExpression") {
s.appendLeft(node.declaration.start, `defineComponent(`);
s.appendRight (node.declaration.end, `)`);
}
}
})
}
content = s.toString();
if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
content += genNormalScriptCssVarsCode(
......@@ -19190,8 +19203,8 @@ function genModelProps(ctx) {
skipCheck && "skipCheck: true"
]);
let decl;
if (runtimeType && options) {
decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
if (runtimeType && options) { // fixed by xxxxxx
decl = ctx.isTS || ctx.isUTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
} else {
decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
}
......@@ -19859,8 +19872,8 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
throw new Error(
`[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
);
}
if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
} // fixed by xxxxxx
if (scriptSetupLang && !ctx.isJS && !ctx.isTS && !ctx.isUTS) {
return scriptSetup;
}
const scriptBindings = /* @__PURE__ */ Object.create(null);
......@@ -19888,8 +19901,8 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
ctx.s.move(start, end, 0);
}
function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
let isUsedInTemplate = needTemplateUsageCheck;
if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
let isUsedInTemplate = needTemplateUsageCheck; // fixed by xxxxxx
if (needTemplateUsageCheck && ( ctx.isTS || ctx.isUTS ) && sfc.template && !sfc.template.src && !sfc.template.lang) {
isUsedInTemplate = isImportUsed(local, sfc);
}
ctx.userImports[local] = {
......@@ -20178,7 +20191,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
node
);
}
if (ctx.isTS) {
if (ctx.isTS || ctx.isUTS) { // fixed by xxxxxx
if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
if (node.type !== "TSEnumDeclaration") {
hoistNode(node);
......@@ -20272,7 +20285,7 @@ ${genCssVarsCode(
}
}
if (hasAwait) {
const any = ctx.isTS ? `: any` : ``;
const any = (ctx.isTS || ctx.isUTS) ? `: any` : ``; // fixed by xxxxxx
ctx.s.prependLeft(startOffset, `
let __temp${any}, __restore${any}
`);
......@@ -20404,7 +20417,7 @@ return ${returned}
}
const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
`;
if (ctx.isTS) {
if (ctx.isTS || ctx.isUTS) { // fixed by xxxxxx
const def = (defaultExport ? `
...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
...${definedOptions},` : "");
......
......@@ -35,6 +35,7 @@
"@vue/compiler-core": "3.4.21",
"@vue/compiler-dom": "3.4.21",
"@vue/compiler-sfc": "3.4.21",
"@vue/compiler-ssr": "3.4.21",
"@vue/server-renderer": "3.4.21",
"@vue/shared": "3.4.21",
"autoprefixer": "^10.4.18",
......@@ -61,6 +62,7 @@
"postcss-modules": "^4.3.0",
"postcss-selector-parser": "^6.0.6",
"resolve": "^1.22.1",
"source-map-js": "^1.0.2",
"tapable": "^2.2.0",
"unplugin-auto-import": "^0.16.7",
"xregexp": "3.1.0"
......
......@@ -20,14 +20,7 @@ function rewriteCompileScriptSetupLang() {
sfc: SFCDescriptor,
options: SFCScriptCompileOptions
): SFCScriptBlock => {
const originalScriptSetupLang = sfc.scriptSetup?.lang
if (originalScriptSetupLang === 'uts') {
sfc.scriptSetup!.lang = 'ts'
}
const result = compileScript(sfc, options)
if (originalScriptSetupLang === 'uts') {
sfc.scriptSetup!.lang = 'uts'
}
return result
}
}
......@@ -613,6 +613,9 @@ importers:
'@vue/compiler-sfc':
specifier: 3.4.21
version: 3.4.21
'@vue/compiler-ssr':
specifier: 3.4.21
version: 3.4.21
'@vue/server-renderer':
specifier: 3.4.21
version: 3.4.21(vue@3.4.21)
......@@ -691,6 +694,9 @@ importers:
resolve:
specifier: ^1.22.1
version: 1.22.8
source-map-js:
specifier: ^1.0.2
version: 1.2.0
tapable:
specifier: ^2.2.0
version: 2.2.1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册