Skip to content

Commit 0091a2f

Browse files
refactor: ♻️ move to babel
1 parent d4858a1 commit 0091a2f

File tree

5 files changed

+321
-616
lines changed

5 files changed

+321
-616
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ For every release changelog/migration-guide will be available in [releases](http
9090

9191
- This project gets inspiration and several pieces of logical code from [react-multiple-select](https://github.com/Khan/react-multi-select/)
9292
- [TypeScript](https://github.com/microsoft/typescript)
93-
- [microbundle](https://github.com/developit/microbundle)
9493

9594
## 📜 License
9695

babel.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const BABEL_ENV = process.env.BABEL_ENV;
2+
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === "cjs";
3+
const isESM = BABEL_ENV !== undefined && BABEL_ENV === "esm";
4+
5+
module.exports = function (api) {
6+
api.cache(true);
7+
8+
const presets = [
9+
[
10+
"@babel/env",
11+
{
12+
loose: true,
13+
modules: isCommonJS ? "commonjs" : false,
14+
targets: {
15+
esmodules: isESM ? true : undefined,
16+
},
17+
},
18+
],
19+
"@babel/preset-typescript",
20+
"@babel/preset-react",
21+
];
22+
23+
const plugins = [["transform-css-import-to-string"]];
24+
25+
return {
26+
presets,
27+
plugins,
28+
};
29+
};

package.json

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
{
22
"name": "react-multi-select-component",
3-
"version": "4.1.10",
3+
"version": "4.1.11",
44
"description": "Simple and lightweight multiple selection dropdown component with checkboxes, search and select-all",
55
"author": "harshzalavadiya",
66
"license": "MIT",
77
"repository": "https://github.com/hc-oss/react-multi-select-component",
8-
"type": "module",
9-
"source": "src/index.tsx",
10-
"exports": "./dist/react-multi-select-component.modern.js",
11-
"main": "./dist/react-multi-select-component.cjs",
12-
"module": "./dist/react-multi-select-component.module.js",
13-
"unpkg": "./dist/react-multi-select-component.umd.js",
14-
"types": "./dist/index.d.ts",
8+
"main": "dist/cjs/index.js",
9+
"module": "dist/esm/index.js",
10+
"types": "dist/types/index.d.ts",
11+
"typings": "dist/types/index.d.ts",
12+
"exports": {
13+
".": {
14+
"require": "./dist/cjs/index.js",
15+
"default": "./dist/esm/index.js"
16+
}
17+
},
1518
"scripts": {
1619
"analyze": "size-limit --why",
1720
"build-storybook": "build-storybook",
18-
"build": "microbundle --css inline --sourcemap false --jsx React.createElement",
21+
"prebuild": "rimraf dist",
22+
"build": "concurrently yarn:build:*",
23+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps",
24+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps",
25+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
1926
"format": "prettier --write src/**/*",
2027
"lint": "eslint src/**/*.{ts,tsx}",
2128
"size": "size-limit",
@@ -26,7 +33,10 @@
2633
},
2734
"dependencies": {},
2835
"devDependencies": {
36+
"@babel/cli": "^7.15.4",
2937
"@babel/core": "^7.15.5",
38+
"@babel/preset-react": "^7.14.5",
39+
"@babel/preset-typescript": "^7.15.0",
3040
"@size-limit/preset-small-lib": "^5.0.3",
3141
"@storybook/addon-actions": "^6.3.8",
3242
"@storybook/addon-essentials": "^6.3.8",
@@ -35,32 +45,34 @@
3545
"@storybook/react": "^6.3.8",
3646
"@types/react": "^17.0.20",
3747
"@types/react-dom": "^17.0.9",
38-
"@typescript-eslint/eslint-plugin": "^4.31.0",
39-
"@typescript-eslint/parser": "^4.31.0",
48+
"@typescript-eslint/eslint-plugin": "^4.31.1",
49+
"@typescript-eslint/parser": "^4.31.1",
4050
"babel-loader": "^8.2.2",
51+
"babel-plugin-transform-css-import-to-string": "^0.0.2",
52+
"concurrently": "^6.2.1",
53+
"cross-env": "^7.0.3",
4154
"eslint": "^7.32.0",
4255
"eslint-config-prettier": "^8.3.0",
4356
"eslint-plugin-prettier": "^4.0.0",
4457
"eslint-plugin-react": "^7.25.1",
4558
"eslint-plugin-simple-import-sort": "^7.0.0",
4659
"husky": "^7.0.2",
47-
"microbundle": "^0.13.3",
48-
"prettier": "^2.3.2",
60+
"prettier": "^2.4.0",
4961
"react": "^17.0.1",
50-
"react-dom": "^17.0.2"
62+
"react-dom": "^17.0.2",
63+
"typescript": "^4.4.3"
5164
},
5265
"browserslist": [
5366
"defaults",
5467
"not IE 11",
5568
"maintained node versions"
5669
],
5770
"files": [
58-
"dist",
59-
"src"
71+
"dist"
6072
],
6173
"size-limit": [
6274
{
63-
"path": "dist/react-multi-select-component.cjs",
75+
"path": "dist/cjs/index.js",
6476
"limit": "10 KB"
6577
}
6678
],

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"skipLibCheck": true,
55
"module": "ESNext",
6-
"target": "ESNext",
6+
"target": "es5",
77
"lib": ["dom", "esnext"],
88
"importHelpers": true,
99
"declaration": true,

0 commit comments

Comments
 (0)