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

WIP feat: support vue #628

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,3 +12,5 @@
/tests/fixtures/build/*/node_modules
/tests/fixtures/prebundle/*/compiled
/tests/fixtures/prebundle/*/modules
/suites/**/dist
/suites/**/node_modules
3 changes: 2 additions & 1 deletion .prettierignore
@@ -1,3 +1,4 @@
dist
compiled
*.yaml
*.yaml
node_modules
2 changes: 1 addition & 1 deletion bin/father.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node

require('v8-compile-cache');
// require('v8-compile-cache');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删了吧,引这个会有其他异常

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的 昨晚被坑了 1个小时

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

具体是啥问题?看 Umi 也把这个去掉了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无法使用 esm 的包 比如 vite 使用会有问题

Copy link
Member

@xiaohuoni xiaohuoni Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umi 非 dev 的时候,这代码进不去
const { build } = await import("./build.js");

require('../dist/cli/cli')
.run()
.catch((e) => {
Expand Down
17 changes: 17 additions & 0 deletions examples/with-vue/.fatherrc.ts
@@ -0,0 +1,17 @@
import { defineConfig } from 'father';
import path from 'path';

export default defineConfig({
esm: {},
// cjs: {},
// umd: {
// externals: {
// vue: 'vue',
// },
// },
alias: {
'@': path.resolve(__dirname, './src'),
},
platform: 'browser',
plugins: ['@fatherjs/plugin-vue'],
});
16 changes: 16 additions & 0 deletions examples/with-vue/package.json
@@ -0,0 +1,16 @@
{
"scripts": {
"build": "rm -rf ./node_modules/.cache && father build",
"build:no-clean": "father build --no-clean",
"dev": "father dev",
"doctor": "father doctor",
"version": "father version"
},
"dependencies": {
"father": "workspace:*",
"vue": "^3.2.47"
},
"devDependencies": {
"@fatherjs/plugin-vue": "workspace:*"
}
}
19 changes: 19 additions & 0 deletions examples/with-vue/src/A.tsx
@@ -0,0 +1,19 @@
import ElEmpty from './Empty.vue.b';
import type { CSSProperties, FunctionalComponent } from 'vue';

type EmptyRendererProps = {
class?: JSX.IntrinsicAttributes['class'];
style?: CSSProperties;
};

const Footer: FunctionalComponent<EmptyRendererProps> = (props, { slots }) => {
return (
<div class={props.class} style={props.style}>
{slots.default ? slots.default() : <ElEmpty />}
</div>
);
};

Footer.displayName = 'ElTableV2Empty';

export default Footer;
7 changes: 7 additions & 0 deletions examples/with-vue/src/Content.tsx
@@ -0,0 +1,7 @@
class Content {
say() {
return 'Hello father 3';
}
}

export default new Content().say();
41 changes: 41 additions & 0 deletions examples/with-vue/src/Empty.vue
@@ -0,0 +1,41 @@
<template>
<div :class="ns.b()">
<div :class="ns.e('image')" :style="imageStyle">
<img v-if="image" :src="image" ondragstart="return false" />
<slot v-else name="image">
<img-empty />
</slot>
</div>
<div :class="ns.e('description')">
<slot v-if="$slots.description" name="description" />
<p v-else>{{ emptyDescription }}</p>
</div>
<div v-if="$slots.default" :class="ns.e('bottom')">
<slot />
</div>
</div>
</template>

<script lang="ts" setup>
import { computed } from 'vue';
// import { emptyProps } from './empty';

import type { CSSProperties } from 'vue';

const props = defineProps({
image: {
type: String,
default: '',
},
imageSize: Number,
description: {
type: String,
default: '',
},
});

const emptyDescription = computed(() => props.description);
const imageStyle = computed<CSSProperties>(() => ({
width: props.imageSize,
}));
</script>
8 changes: 8 additions & 0 deletions examples/with-vue/src/Hello.vue
@@ -0,0 +1,8 @@
<template>
<div>{{ hello }}</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';

const hello = ref('hello vue');
</script>
16 changes: 16 additions & 0 deletions examples/with-vue/src/empty.ts
@@ -0,0 +1,16 @@
import { buildProps } from '@/utils/buildProps';
import type { ExtractPropTypes } from 'vue';

export const emptyProps = buildProps({
image: {
type: String,
default: '',
},
imageSize: Number,
description: {
type: String,
default: '',
},
} as const);

export type EmptyProps = ExtractPropTypes<typeof emptyProps>;
1 change: 1 addition & 0 deletions examples/with-vue/src/foo.ts
@@ -0,0 +1 @@
console.log('foo here');
11 changes: 11 additions & 0 deletions examples/with-vue/src/index.ts
@@ -0,0 +1,11 @@
import Hello from './Hello.vue';
import Empty from './Empty.vue';
import A from '@/A';
import Content from '@/Content';

export default {
Hello,
Empty,
A,
Content,
};
1 change: 1 addition & 0 deletions examples/with-vue/src/utils/buildProps.ts
@@ -0,0 +1 @@
export const buildProps = (props: any) => props;
21 changes: 21 additions & 0 deletions examples/with-vue/tsconfig.json
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true,
"paths": {
"@/*": ["./src/*"]
},
"baseUrl": "."
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}