Skip to content

Commit

Permalink
fix: treeshaking (#2708)
Browse files Browse the repository at this point in the history
* fix: treeshaking

- migrate from microbundle to babel

* fix: removed type from package.json

- type: "module" caused errors while importing in create react app
  • Loading branch information
illiteratewriter committed Mar 16, 2023
1 parent fc539c9 commit fa46b94
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
/dist
/build
/lib
/esm
/es
.DS_Store
.idea
Expand Down
5 changes: 5 additions & 0 deletions babel.build.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

module.exports = {
extends: './babel.config.cjs',
ignore: [/\.d.ts/, /\.(stories|spec|test)\.(js|ts|jsx|tsx?)$/],
};
7 changes: 7 additions & 0 deletions babel.esm.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: './babel.build.config.cjs',
presets: [
// Dont transform modules for the esm build
['@babel/preset-env', { modules: false }],
],
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://jestjs.io/docs/configuration
*/

export default {
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@
"name": "reactstrap",
"version": "9.1.6",
"description": "React Bootstrap components",
"type": "module",
"source": "src/index.js",
"exports": {
"import": "./dist/reactstrap.modern.js",
"require": "./dist/reactstrap.cjs",
"default": "./dist/reactstrap.modern.js"
},
"main": "./dist/reactstrap.cjs",
"module": "./dist/reactstrap.module.js",
"unpkg": "./dist/reactstrap.umd.js",
"main": "lib/index.js",
"module": "esm/index.js",
"types": "types/index.d.ts",
"esnext": "src/index.js",
"sideEffects": false,
"scripts": {
"test": "jest --watch",
"test:ci": "jest",
"cover": "jest --coverage",
"start": "start-storybook -s ./static -p 8080",
"build:docs": "build-storybook -s ./static -o ./build",
"build": "microbundle --generateTypes false --jsx React.createElement --compress false",
"version": "node_modules/.bin/conventional-changelog -i CHANGELOG.md -o CHANGELOG.md -p angular && git add -A CHANGELOG.md",
"build:esm": "babel src --out-dir esm --config-file ./babel.esm.config.cjs --extensions '.js,.ts,.tsx'",
"build:lib": "babel src --out-dir lib --config-file ./babel.build.config.cjs --extensions '.js,.ts,.tsx'",
"build": "yarn clean && concurrently \"yarn:build:*(!docs)\"",
"clean": "rm -rf esm lib",
"prepublishOnly": "npm run build",
"create-release": "npm run cover && sh ./scripts/release",
"lint": "eslint src stories",
"dtslint": "dtslint types --expectOnly",
"prettier": "prettier --write src stories"
"prettier": "prettier --write src stories",
"version": "node_modules/.bin/conventional-changelog -i CHANGELOG.md -o CHANGELOG.md -p angular && git add -A CHANGELOG.md"
},
"prettier": {
"singleQuote": true,
Expand Down Expand Up @@ -273,6 +268,7 @@
"react-dom": ">=16.8.0"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.18.2",
"@babel/plugin-proposal-export-default-from": "^7.12.1",
Expand All @@ -294,6 +290,7 @@
"babel-loader": "^8.2.2",
"babel-preset-react-app": "^10.0.1",
"bootstrap": "^5.1.0",
"concurrently": "^7.6.0",
"conventional-changelog-cli": "^2.0.21",
"conventional-recommended-bump": "^4.1.1",
"cross-env": "^4.0.0",
Expand Down

0 comments on commit fa46b94

Please sign in to comment.