Skip to content

Commit

Permalink
fix: no default value for propsDestructure
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Sep 5, 2024
1 parent afd956e commit 97ea214
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 170 deletions.
1 change: 0 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function resolveOptions(rawOptions: Options): ResolvedOptions {
optionsAPI: true,
prodDevtools: false,
prodHydrationMismatchDetails: false,
propsDestructure: false,
...rawOptions.features,
customElement:
(rawOptions.features?.customElement || rawOptions.customElement) ??
Expand Down
142 changes: 60 additions & 82 deletions tests/__snapshots__/esbuild.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ var export_helper_default = (sfc, props) => {
// tests/fixtures/basic.vue
console.log("Hello world");
var _sfc_main = {};
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return _openBlock(), _createElementBlock("div", null, [..._hoisted_2]);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
}
var basic_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "#FILE#"]]);
export {
Expand All @@ -54,18 +52,16 @@ var export_helper_default = (sfc, props) => {
// tests/fixtures/basic.vue
console.log("Hello world");
var _sfc_main = {};
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return _openBlock(), _createElementBlock("div", null, _hoisted_2);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
}
var basic_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render]]);
export {
Expand Down Expand Up @@ -191,18 +187,16 @@ var _sfc_main = {
return __returned__;
}
};
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return _openBlock(), _createElementBlock("div", null, [..._hoisted_2]);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
}
var script_setup_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "#FILE#"]]);
export {
Expand All @@ -216,21 +210,19 @@ exports[`esbuild > tests/fixtures/script-setup.vue > isProduction = false 2`] =
exports[`esbuild > tests/fixtures/script-setup.vue > isProduction = true 1`] = `
"// tests/fixtures/script-setup.vue
import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
var _sfc_main = {
__name: "script-setup",
setup(__props) {
return (_ctx, _cache) => {
return _openBlock(), _createElementBlock("div", null, _hoisted_2);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
};
}
};
Expand Down Expand Up @@ -262,16 +254,11 @@ var str = "bar";
var _sfc_main = /* @__PURE__ */ _defineComponent({
__name: "script-setup-ts",
props: {
foo: { type: String, required: true },
bar: { type: Number, required: true },
baz: { type: Boolean, required: true }
foo: { type: String, required: true, default: "123" },
bar: { type: Number, required: true, default: 123 },
baz: { type: Boolean, required: true, default: true }
},
setup(__props, { expose: __expose }) {
const {
foo = "123",
bar = 123,
baz = true
} = __props;
__expose({
str
});
Expand All @@ -280,18 +267,16 @@ var _sfc_main = /* @__PURE__ */ _defineComponent({
return __returned__;
}
});
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return _openBlock(), _createElementBlock("div", null, [..._hoisted_2]);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
}
var script_setup_ts_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "#FILE#"]]);
export {
Expand All @@ -306,35 +291,28 @@ exports[`esbuild > tests/fixtures/script-setup-ts.vue > isProduction = true 1`]
"// tests/fixtures/script-setup-ts.vue
import { defineComponent as _defineComponent } from "vue";
import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
var _hoisted_1 = /* @__PURE__ */ _createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
);
var _hoisted_2 = [
_hoisted_1
];
var str = "bar";
var _sfc_main = /* @__PURE__ */ _defineComponent({
__name: "script-setup-ts",
props: {
foo: {},
bar: {},
baz: { type: Boolean }
foo: { default: "123" },
bar: { default: 123 },
baz: { type: Boolean, default: true }
},
setup(__props, { expose: __expose }) {
const {
foo = "123",
bar = 123,
baz = true
} = __props;
__expose({
str
});
return (_ctx, _cache) => {
return _openBlock(), _createElementBlock("div", null, _hoisted_2);
return _openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
_createElementVNode(
"h1",
null,
"Hello World",
-1
/* HOISTED */
)
]));
};
}
});
Expand Down
Loading

0 comments on commit 97ea214

Please sign in to comment.