Skip to content

Commit

Permalink
feat: change rollup and use vite for bundling, remove unused packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Teo Wen Long committed Dec 30, 2023
1 parent 89c0052 commit 0e007c6
Show file tree
Hide file tree
Showing 8 changed files with 3,392 additions and 9,213 deletions.
27 changes: 19 additions & 8 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import type { StorybookConfig } from "@storybook/react-webpack5";
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"@storybook/addon-interactions",
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
'@storybook/blocks',
'@storybook/addon-styling',
],
framework: {
name: "@storybook/react-webpack5",
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: true,
autodocs: 'tag',
},
viteFinal: async (config) => {
config.optimizeDeps = {
...config.optimizeDeps,
include: ['@storybook/addon-styling', '@storybook/blocks'],
};

return config;
},
};
export default config;
6 changes: 3 additions & 3 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Preview } from "@storybook/react";
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
date: /Date$/i,
},
},
},
Expand Down
87 changes: 38 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "react-date-dropdown",
"version": "0.1.2",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"main": "dist/react-date-dropdown.mjs",
"module": "dist/react-date-dropdown.umd.js",
"exports": {
".": {
"import": "./dist/react-date-dropdown.mjs",
"require": "./dist/react-date-dropdown.umd.js"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/WenLonG12345/react-date-dropdown.git"
Expand All @@ -13,64 +19,47 @@
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"build": "yarn clean && rollup -c",
"storybook": "storybook dev",
"build": "yarn clean && tsc && vite build",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"serve-storybook": "serve storybook-static",
"test-storybook": "test-storybook",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"release": "release-it"
},
"dependencies": {
"react-scripts": "^5.0.1"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1",
"@storybook/addon-essentials": "7.4.6",
"@storybook/addon-interactions": "7.4.6",
"@storybook/addon-links": "7.4.6",
"@storybook/blocks": "7.4.6",
"@storybook/preset-create-react-app": "7.4.6",
"@storybook/react": "7.4.6",
"@storybook/react-webpack5": "7.4.6",
"@storybook/testing-library": "0.2.2",
"@types/jest": "^27.5.2",
"@types/node": "^18.0.6",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/webpack": "^5.28.0",
"@types/webpack-dev-server": "^4.7.2",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"@storybook/addon-essentials": "7.6.6",
"@storybook/addon-interactions": "^7.6.6",
"@storybook/addon-links": "7.6.6",
"@storybook/addon-onboarding": "^1.0.10",
"@storybook/addon-styling": "^1.3.7",
"@storybook/blocks": "7.6.6",
"@storybook/builder-vite": "^7.6.6",
"@storybook/react": "7.6.6",
"@storybook/react-vite": "^7.6.6",
"@storybook/test": "^7.6.6",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-named-exports-order": "0.0.2",
"chromatic": "^6.18.0",
"css-loader": "^6.7.1",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-storybook": "^0.6.15",
"prettier": "^2.7.1",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "^5.0.1",
"release-it": "^15.11.0",
"rollup": "^3.23.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"storybook": "7.4.6",
"ts-node": "^10.9.1",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"tslib": "^2.5.2",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4",
"webpack": "5.84.1"
"prettier": "^3.1.1",
"release-it": "^17.0.1",
"storybook": "7.6.6",
"typescript": "^5.3.3",
"vite": "5.0.10",
"vite-plugin-dts": "^3.7.0"
},
"browserslist": {
"production": [
Expand Down
46 changes: 0 additions & 46 deletions rollup.config.mjs

This file was deleted.

30 changes: 21 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"jsx": "react",
"declaration": true,
"esModuleInterop": true,
"outDir": "dist",
"target": "es6",
"module": "es6",
"moduleResolution": "node"
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"exclude": ["node_modules", "build"]
}
"exclude": ["src/stories"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
16 changes: 16 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { resolve } from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'react-date-dropdown',
fileName: 'react-date-dropdown',
},
},
plugins: [dts(), react()],
});
Loading

1 comment on commit 0e007c6

@vercel
Copy link

@vercel vercel bot commented on 0e007c6 Dec 30, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.