@vue/compiler-sfc 3.5.5 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-sfc.cjs.js +29 -17
- package/dist/compiler-sfc.d.ts +1 -0
- package/dist/compiler-sfc.esm-browser.js +4022 -1057
- package/package.json +6 -6
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.5.
|
|
2
|
+
* @vue/compiler-sfc v3.5.6
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -15723,20 +15723,26 @@ ${shared.generateCodeFrame(
|
|
|
15723
15723
|
const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
|
|
15724
15724
|
return block.content.slice(node.start, node.end);
|
|
15725
15725
|
}
|
|
15726
|
+
warn(msg, node, scope) {
|
|
15727
|
+
warn(generateError(msg, node, this, scope));
|
|
15728
|
+
}
|
|
15726
15729
|
error(msg, node, scope) {
|
|
15727
|
-
const offset = scope ? scope.offset : this.startOffset;
|
|
15728
15730
|
throw new Error(
|
|
15729
|
-
`[@vue/compiler-sfc] ${msg}
|
|
15730
|
-
|
|
15731
|
-
${(scope || this.descriptor).filename}
|
|
15732
|
-
${shared.generateCodeFrame(
|
|
15733
|
-
(scope || this.descriptor).source,
|
|
15734
|
-
node.start + offset,
|
|
15735
|
-
node.end + offset
|
|
15736
|
-
)}`
|
|
15731
|
+
`[@vue/compiler-sfc] ${generateError(msg, node, this, scope)}`
|
|
15737
15732
|
);
|
|
15738
15733
|
}
|
|
15739
15734
|
}
|
|
15735
|
+
function generateError(msg, node, ctx, scope) {
|
|
15736
|
+
const offset = scope ? scope.offset : ctx.startOffset;
|
|
15737
|
+
return `${msg}
|
|
15738
|
+
|
|
15739
|
+
${(scope || ctx.descriptor).filename}
|
|
15740
|
+
${shared.generateCodeFrame(
|
|
15741
|
+
(scope || ctx.descriptor).source,
|
|
15742
|
+
node.start + offset,
|
|
15743
|
+
node.end + offset
|
|
15744
|
+
)}`;
|
|
15745
|
+
}
|
|
15740
15746
|
function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
15741
15747
|
const plugins = [];
|
|
15742
15748
|
if (!userPlugins || !userPlugins.some(
|
|
@@ -19468,7 +19474,7 @@ function genModelProps(ctx) {
|
|
|
19468
19474
|
|
|
19469
19475
|
const DEFINE_PROPS = "defineProps";
|
|
19470
19476
|
const WITH_DEFAULTS = "withDefaults";
|
|
19471
|
-
function processDefineProps(ctx, node, declId) {
|
|
19477
|
+
function processDefineProps(ctx, node, declId, isWithDefaults = false) {
|
|
19472
19478
|
if (!isCallOf(node, DEFINE_PROPS)) {
|
|
19473
19479
|
return processWithDefaults(ctx, node, declId);
|
|
19474
19480
|
}
|
|
@@ -19493,7 +19499,7 @@ function processDefineProps(ctx, node, declId) {
|
|
|
19493
19499
|
}
|
|
19494
19500
|
ctx.propsTypeDecl = node.typeParameters.params[0];
|
|
19495
19501
|
}
|
|
19496
|
-
if (declId && declId.type === "ObjectPattern") {
|
|
19502
|
+
if (!isWithDefaults && declId && declId.type === "ObjectPattern") {
|
|
19497
19503
|
processPropsDestructure(ctx, declId);
|
|
19498
19504
|
}
|
|
19499
19505
|
ctx.propsCall = node;
|
|
@@ -19504,7 +19510,12 @@ function processWithDefaults(ctx, node, declId) {
|
|
|
19504
19510
|
if (!isCallOf(node, WITH_DEFAULTS)) {
|
|
19505
19511
|
return false;
|
|
19506
19512
|
}
|
|
19507
|
-
if (!processDefineProps(
|
|
19513
|
+
if (!processDefineProps(
|
|
19514
|
+
ctx,
|
|
19515
|
+
node.arguments[0],
|
|
19516
|
+
declId,
|
|
19517
|
+
true
|
|
19518
|
+
)) {
|
|
19508
19519
|
ctx.error(
|
|
19509
19520
|
`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
|
|
19510
19521
|
node.arguments[0] || node
|
|
@@ -19516,10 +19527,11 @@ function processWithDefaults(ctx, node, declId) {
|
|
|
19516
19527
|
node
|
|
19517
19528
|
);
|
|
19518
19529
|
}
|
|
19519
|
-
if (
|
|
19520
|
-
ctx.
|
|
19530
|
+
if (declId && declId.type === "ObjectPattern") {
|
|
19531
|
+
ctx.warn(
|
|
19521
19532
|
`${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
|
|
19522
|
-
|
|
19533
|
+
Reactive destructure will be disabled when using withDefaults().
|
|
19534
|
+
Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...). `,
|
|
19523
19535
|
node.callee
|
|
19524
19536
|
);
|
|
19525
19537
|
}
|
|
@@ -20894,7 +20906,7 @@ function isStaticNode(node) {
|
|
|
20894
20906
|
return false;
|
|
20895
20907
|
}
|
|
20896
20908
|
|
|
20897
|
-
const version = "3.5.
|
|
20909
|
+
const version = "3.5.6";
|
|
20898
20910
|
const parseCache = parseCache$1;
|
|
20899
20911
|
const errorMessages = {
|
|
20900
20912
|
...CompilerDOM.errorMessages,
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -395,6 +395,7 @@ export declare class ScriptCompileContext {
|
|
|
395
395
|
fs?: NonNullable<SFCScriptCompileOptions['fs']>;
|
|
396
396
|
constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
|
|
397
397
|
getString(node: Node, scriptSetup?: boolean): string;
|
|
398
|
+
warn(msg: string, node: Node, scope?: TypeScope): void;
|
|
398
399
|
error(msg: string, node: Node, scope?: TypeScope): never;
|
|
399
400
|
}
|
|
400
401
|
|