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

chore(): #77 export types, interfaces, and enums #90

Merged
merged 2 commits into from
Dec 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -6,7 +6,9 @@
"lint-md": "remark . --output",
"semantic-release": "semantic-release",
"dev": "vite --port 3001 --force",
"build:vite": "tsc && vite build",
"build:es": "OUTPUT_FORMAT=es vite build",
"build:umd": "OUTPUT_FORMAT=umd vite build",
"build:vite": "rm -rf ./dist && tsc && yarn run build:umd && yarn run build:es",
"build:types": "tsc --project tsconfig.types.json",
"build": "yarn run build:vite && yarn run build:types",
"lint": "tsc && eslint . --ext .ts",
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Expand Up @@ -1701,3 +1701,4 @@ class JustValidate {
}

export default JustValidate;
export * from './modules/interfaces';
3 changes: 3 additions & 0 deletions src/main.umd.ts
@@ -0,0 +1,3 @@
import JustValidate from './main';

export default JustValidate;
32 changes: 27 additions & 5 deletions vite.config.js
@@ -1,6 +1,23 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { defineConfig } from 'vite';
import path from 'path';
import { resolve } from 'path';

const config = {
es: {
entry: resolve(__dirname, 'src/main.ts'),
fileName: () => 'just-validate.es.js',
},
umd: {
entry: resolve(__dirname, 'src/main.umd.ts'),
fileName: () => 'just-validate.production.min.js',
},
};

const currentConfig = config[process.env.OUTPUT_FORMAT];

if (currentConfig === undefined) {
throw new Error('OUTPUT_FORMAT is not defined or is not valid');
}

export default defineConfig(({ command }) => {
if (command === 'serve') {
Expand All @@ -9,14 +26,19 @@ export default defineConfig(({ command }) => {
// command === 'build'
return {
build: {
outDir: 'dist',
emptyOutDir: false,
lib: {
entry: path.resolve(__dirname, 'src/main.ts'),
...currentConfig,
formats: [process.env.OUTPUT_FORMAT],
name: 'JustValidate',
fileName: (format) =>
`just-validate.${format === 'umd' ? 'production.min' : format}.js`,
},
minify: 'terser',
rollupOptions: {},
rollupOptions: {
output: {
exports: process.env.OUTPUT_FORMAT === 'es' ? 'named' : 'default',
},
},
},
};
}
Expand Down