Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip node for which definePageMeta does not exist #1223

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/bridge/src/page-meta/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ export const PageMetaPlugin = createUnplugin(
}
})

if (!contents) {
return
}

s.prependLeft(exportDeclaration.start, contents)

if (code.includes('__nuxt_page_meta')) {
Expand Down
50 changes: 48 additions & 2 deletions packages/bridge/test/page-meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ import { defineComponent as _defineComponent } from 'vue';
export default /*#__PURE__*/_defineComponent({
__name: 'redirect',
setup: function setup(__props) {
const route = useRoute()
var route = useRoute()
definePageMeta({
middleware: ['redirect'],
layout: 'custom'
});

var obj = {
setup: {
test: 'test'
}
}
return {
__sfc: true
};
Expand All @@ -54,8 +60,14 @@ export default /*#__PURE__*/_defineComponent({
export default /*#__PURE__*/_defineComponent({
...__nuxt_page_meta,__name: 'redirect',
setup: function setup(__props) {
const route = useRoute()
var route = useRoute()
;

var obj = {
setup: {
test: 'test'
}
}
return {
__sfc: true
};
Expand All @@ -73,6 +85,12 @@ export default {
definePageMeta({
layout: 'custom'
});

var obj = {
setup: {
test: 'test'
}
}
return {
__sfc: true,
message: message
Expand All @@ -88,6 +106,12 @@ export default {
setup: function setup(__props) {
var message;
;

var obj = {
setup: {
test: 'test'
}
}
return {
__sfc: true,
message: message
Expand Down Expand Up @@ -141,6 +165,11 @@ const _sfc_main = /* @__PURE__ */ _defineComponent({
definePageMeta({
middleware: ["redirect"]
});
const obj = {
setup: {
test: "test"
}
}
return { __sfc: true };
}
});`)).toMatchInlineSnapshot(`
Expand All @@ -153,6 +182,11 @@ const _sfc_main = /* @__PURE__ */ _defineComponent({
...__nuxt_page_meta,__name: "redirect",
setup(__props) {
;
const obj = {
setup: {
test: "test"
}
}
return { __sfc: true };
}
});"
Expand All @@ -169,6 +203,12 @@ const _sfc_main = /* @__PURE__ */ _defineComponent({
definePageMeta({
layout: 'custom'
})

const obj = {
setup: {
test: 'test'
}
}

return { __sfc: true,message }
}
Expand All @@ -183,6 +223,12 @@ const _sfc_main = /* @__PURE__ */ _defineComponent({
let message



const obj = {
setup: {
test: 'test'
}
}

return { __sfc: true,message }
}
Expand Down