Skip to content

Commit 2eeef32

Browse files
committed
fix vue package
1 parent 23acf9e commit 2eeef32

13 files changed

+329
-113
lines changed

package-lock.json

+111-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+63-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,80 @@
11
{
22
"name": "g-motion",
3-
"private": true,
3+
"private": false,
44
"version": "0.0.0",
55
"type": "module",
6+
"description": "A Vue and React Gsap Motion Library",
7+
"author": {
8+
"name": "Ebraheem Alhetari",
9+
"email": "hetari4all@gmail.com",
10+
"url": "https://github.com/hetari"
11+
},
12+
"license": "MIT",
13+
"repository": {
14+
"type": "git",
15+
"url": ""
16+
},
17+
"homepage": "",
18+
"bugs": {
19+
"url": ""},
20+
"keywords": [
21+
"gsap",
22+
"motion",
23+
"vue",
24+
"react",
25+
"gsap-motion",
26+
"vue-gsap",
27+
"react-gsap"
28+
],
29+
"exports": {
30+
"./vue": {
31+
"types": "./dist/vue/index.d.ts",
32+
"import": "./dist/vue/index.es.js",
33+
"require": "./dist/vue/index.umd.js"
34+
},
35+
"./react": {
36+
"types": "./dist/react/index.d.ts",
37+
"import": "./dist/react/index.es.js",
38+
"require": "./dist/react/index.umd.js"
39+
}
40+
},
41+
"main": "./dist/vue/index.umd.js",
42+
"module": "./dist/vue/index.es.js",
43+
"types": "./dist/vue/index.d.ts",
44+
"files": [
45+
"dist",
46+
"README.md",
47+
"src/types/*.ts"
48+
],
49+
"typesVersions": {
50+
"*": {
51+
"vue": ["./dist/vue/index.d.ts"],
52+
"react": ["./dist/react/index.d.ts"]
53+
}
54+
},
655
"scripts": {
756
"dev": "vite",
8-
"build": "tsc && vite build",
9-
"preview": "vite preview"
57+
"preview": "vite preview",
58+
"build:vue": "vite build --mode vue",
59+
"build:react": "vite build --mode react",
60+
"build": "npm run build:vue && npm run build:react",
61+
"dev:vue": "vite --mode vue",
62+
"dev:react": "vite --mode react"
1063
},
1164
"devDependencies": {
1265
"@types/node": "^22.9.0",
1366
"@types/react": "^18.3.12",
1467
"@vitejs/plugin-react": "^4.3.3",
1568
"@vitejs/plugin-vue": "^5.1.4",
1669
"typescript": "~5.6.2",
17-
"vite": "^5.4.10"
70+
"vite": "^5.4.10",
71+
"vite-plugin-dts": "^4.3.0"
1872
},
1973
"dependencies": {
20-
"vite-plugin-dts": "^4.3.0"
74+
"react": "^18.3.1",
75+
"vue": "^3.5.12"
76+
},
77+
"publishConfig": {
78+
"access": "public"
2179
}
2280
}

src/index.ts

-19
This file was deleted.

src/react-entry.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './react/index';

src/react/Button.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
export function Button(props: React.ButtonHTMLAttributes<HTMLButtonElement>) {
2-
return <button {...props} />;
1+
interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement> {
2+
label: string;
3+
children?: React.ReactNode;
34
}
5+
6+
function Button(props: Props) {
7+
const { className, label, ...restProps } = props;
8+
return (
9+
<button
10+
className={`${className}`}
11+
{...restProps}>
12+
{label}
13+
</button>
14+
);
15+
}
16+
17+
export default Button;

src/react/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Button from './Button';
2+
3+
export { Button };

src/vue-entry.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './vue/index';

src/vue/Button.vue

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
<!-- src/vue/Button.vue -->
21
<template>
32
<button>{{ label }}</button>
43
</template>
54

65
<script setup lang="ts">
7-
import { defineComponent } from 'vue';
8-
9-
defineComponent({
10-
name: 'Button',
11-
props: {
12-
label: String
13-
}
14-
});
15-
16-
defineProps<{
17-
label: string;
18-
}>();
6+
defineProps<{ label: string }>();
197
</script>

src/vue/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Button from './Button.vue';
2+
3+
export { Button };

tsconfig.json

+66-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,74 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"useDefineForClassFields": true,
3+
"declaration": true,
4+
"declarationDir": "./dist/types",
5+
"emitDeclarationOnly": true,
56
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"moduleResolution": "node",
8+
"esModuleInterop": true,
79
"skipLibCheck": true,
8-
"jsx": "react-jsxdev",
910

10-
/* Bundler mode */
11-
"moduleResolution": "Bundler",
12-
"allowImportingTsExtensions": true,
13-
"isolatedModules": true,
14-
"moduleDetection": "force",
15-
"noEmit": true,
16-
17-
/* Linting */
11+
"baseUrl": ".",
12+
"paths": {
13+
"@vue/*": ["src/vue/*"],
14+
"@react/*": ["src/react/*"]
15+
},
1816
"strict": true,
19-
"noUnusedLocals": true,
20-
"noUnusedParameters": true,
21-
"noFallthroughCasesInSwitch": true,
22-
"noUncheckedSideEffectImports": true
17+
"jsx": "react-jsx",
18+
"lib": ["dom", "esnext"],
19+
"allowSyntheticDefaultImports": true
2320
},
24-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
21+
"include": [
22+
"src/**/*.ts",
23+
"src/**/*.tsx",
24+
"types/**/*.tsx",
25+
"src/**/*.vue",
26+
"types/**/*.ts",
27+
"types/**/*.vue"
28+
],
29+
"exclude": ["node_modules", "dist"]
2530
}
31+
32+
// {
33+
// "compilerOptions": {
34+
// "target": "ES2020",
35+
// "useDefineForClassFields": true,
36+
// "module": "ESNext",
37+
// "lib": ["ES2020", "DOM", "DOM.Iterable"],
38+
// "skipLibCheck": true,
39+
// "jsx": "react-jsxdev",
40+
// "types": ["vite/client"],
41+
// "allowSyntheticDefaultImports": true,
42+
// "outDir": "dist",
43+
// "declaration": true,
44+
// "declarationDir": "dist/types",
45+
// "emitDeclarationOnly": true,
46+
// "baseUrl": ".",
47+
48+
// /* Bundler mode */
49+
// "moduleResolution": "Bundler",
50+
// "allowImportingTsExtensions": true,
51+
// "isolatedModules": true,
52+
// "moduleDetection": "force",
53+
// "noEmit": true,
54+
55+
// /* Linting */
56+
// "strict": true,
57+
// "noUnusedLocals": true,
58+
// "noUnusedParameters": true,
59+
// "noFallthroughCasesInSwitch": true,
60+
// "paths": {
61+
// "vue": ["./src/vue"],
62+
// "react": ["./src/react"]
63+
// }
64+
// },
65+
// "include": [
66+
// "src/index.ts",
67+
// "src/**/*.ts",
68+
// "src/**/*.d.ts",
69+
// "src/**/*.tsx",
70+
// "src/**/*.vue",
71+
// "vite.config.ts"
72+
// ],
73+
// "exclude": ["node_modules", "dist"]
74+
// }

tsconfig.react.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist/react"
5+
},
6+
"include": ["src/react/**/*", "src/react-entry.ts"],
7+
"exclude": ["src/vue/**/*"]
8+
}

tsconfig.vue.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist/vue"
5+
},
6+
"include": ["src/vue/**/*", "src/vue-entry.ts"],
7+
"exclude": ["src/react/**/*"]
8+
}

vite.config.ts

+48-31
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,56 @@ import react from '@vitejs/plugin-react';
44
import dts from 'vite-plugin-dts';
55
import { resolve } from 'path';
66
// import libCss from 'vite-plugin-libcss';
7+
// import { libInjectCss } from 'vite-plugin-lib-inject-css';
78

8-
export default defineConfig({
9-
plugins: [
10-
vue(), // Enables Vue SFC support
11-
react(), // Enables React JSX support
12-
dts({
13-
insertTypesEntry: true,
14-
tsconfigPath: './tsconfig.json'
15-
})
16-
],
17-
build: {
18-
copyPublicDir: false,
19-
lib: {
20-
entry: resolve(__dirname, 'src/index.ts'),
21-
name: 'G-Motion',
22-
formats: ['es', 'umd'],
23-
fileName: (format) => `g-motion.${format}.js`
24-
},
25-
rollupOptions: {
26-
external: [
27-
'vue',
28-
'react',
29-
'react-dom',
30-
'react/jsx-runtime' // <-- Add this line to externalize react/jsx-runtime
31-
],
32-
output: {
33-
globals: {
34-
vue: 'Vue',
35-
react: 'React',
36-
'react-dom': 'ReactDOM',
37-
'react/jsx-runtime': 'jsxRuntime'
9+
export default defineConfig(({ mode }) => {
10+
const isVue = mode === 'vue';
11+
const framework = isVue ? 'vue' : 'react';
12+
13+
return {
14+
plugins: [
15+
isVue ? vue() : react(),
16+
dts({
17+
tsconfigPath: `./tsconfig.${framework}.json`,
18+
outDir: `dist/${framework}`,
19+
include: [`src/${framework}/**/*`, `src/${framework}-entry.ts`],
20+
insertTypesEntry: true,
21+
cleanVueFileName: true,
22+
rollupTypes: true
23+
})
24+
].filter(Boolean),
25+
build: {
26+
target: 'es2015',
27+
28+
copyPublicDir: false,
29+
outDir: `dist/${framework}`,
30+
31+
lib: {
32+
entry: resolve(__dirname, `src/${framework}-entry.ts`),
33+
// name: isVue ? 'GMotionVue' : 'GMotionReact',
34+
name: 'G-Motion',
35+
formats: ['es', 'umd'],
36+
fileName: 'index'
37+
// fileName: (format) => `index.${format}.js`
38+
},
39+
rollupOptions: {
40+
external: ['vue', 'react', 'react/jsx-runtime'],
41+
output: {
42+
assetFileNames: 'assets/[name][extname]',
43+
entryFileNames: '[name].js',
44+
globals: {
45+
vue: 'Vue',
46+
react: 'React'
47+
},
48+
exports: 'named'
3849
}
3950
}
51+
},
52+
resolve: {
53+
alias: {
54+
'@vue': resolve(__dirname, 'src/vue'),
55+
'@react': resolve(__dirname, 'src/react')
56+
}
4057
}
41-
}
58+
};
4259
});

0 commit comments

Comments
 (0)