Skip to content

Commit

Permalink
fix(macros): move plugin order
Browse files Browse the repository at this point in the history
closes #233
  • Loading branch information
sxzz committed Jan 25, 2023
1 parent d3b7427 commit 72de51f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-plants-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'unplugin-vue-macros': patch
---

move plugin order
2 changes: 1 addition & 1 deletion packages/macros/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export default createCombinePlugin((userOptions: Options = {}, meta) => {
resolvePlugin(VueSetupSFC, framework, options.setupSFC),
setupComponentPlugins?.[0],
resolvePlugin(VueSetupBlock, framework, options.setupBlock),
resolvePlugin(VueHoistStatic, framework, options.hoistStatic),
namedTemplatePlugins?.[0],
resolvePlugin(VueDefineProps, framework, options.defineProps),
resolvePlugin(VueExportProps, framework, options.exportProps),
Expand All @@ -193,6 +192,7 @@ export default createCombinePlugin((userOptions: Options = {}, meta) => {
options.reactivityTransformVue2
),
resolvePlugin(VueBetterDefine, framework, options.betterDefine),
resolvePlugin(VueHoistStatic, framework, options.hoistStatic),
resolvePlugin(VueDefineOptions, framework, options.defineOptions),
options.plugins.vue,
options.plugins.vueJsx,
Expand Down
33 changes: 31 additions & 2 deletions packages/macros/tests/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const __default__ = defineComponent({
var _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: {
modelValue: { type: String, required: true },
title: { type: String, required: true }
\\"modelValue\\": { type: String, required: true },
\\"title\\": { type: String, required: true }
},
emits: [\\"update:modelValue\\", \\"change\\"],
setup(__props, { emit }) {
Expand Down Expand Up @@ -62,6 +62,35 @@ export { basic as default };
"
`;
exports[`fixtures > tests/fixtures/case-233.vue 1`] = `
"import { defineComponent } from 'vue';
const msg = \\"Hello\\";
var _sfc_main = /* @__PURE__ */ defineComponent({
__name: \\"case-233\\",
props: {
\\"msg\\": { type: String, required: true, default: msg }
},
setup(__props) {
return () => {
};
}
});
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
var case233 = /* @__PURE__ */ _export_sfc(_sfc_main, [__FILE__]);
export { case233 as default };
"
`;
exports[`fixtures > tests/fixtures/hoist-static.vue 1`] = `
"import { defineComponent } from 'vue';
Expand Down
2 changes: 1 addition & 1 deletion packages/macros/tests/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import VueMacros from '../src/rollup'

describe('fixtures', async () => {
await testFixtures(
'tests/fixtures/**/*.{vue,js,jsx,ts,tsx}',
['tests/fixtures/**/*.{vue,js,jsx,ts,tsx}', '!tests/fixtures/types.ts'],
(args, id) => {
const version = id.includes('vue2') ? 2 : 3
return rollupBuild(id, [
Expand Down
8 changes: 8 additions & 0 deletions packages/macros/tests/fixtures/case-233.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script setup lang="ts">
import type { HelloWorldProps } from './types'
const msg = 'Hello'
withDefaults(defineProps<HelloWorldProps>(), {
msg,
})
</script>
3 changes: 3 additions & 0 deletions packages/macros/tests/fixtures/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface HelloWorldProps {
msg: string;
}

0 comments on commit 72de51f

Please sign in to comment.