Skip to content

Commit

Permalink
build(pkg)!: export cjs and module format (#59)
Browse files Browse the repository at this point in the history
Help supporting treeshaking

BREAKING CHANGE: export cjs format as main

As most build tools can tree shake commonjs format, I would argue that we should provide the cjs format as default.
The previous bundle is available under the `browser` entry.
  • Loading branch information
douglasduteil authored Mar 19, 2020
1 parent 669c7db commit 3f82e4d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
23 changes: 14 additions & 9 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@

{
"presets": [
["@babel/preset-react"],
["@babel/preset-env"]
],
"plugins": [

]
}
"presets": [["@babel/preset-react"], ["@babel/preset-env"]],
"env": {
"esm": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.cache
cjs
coverage
dist
esm
example/dist
node_modules
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"name": "@socialgouv/react-departements",
"description": "Une carte de France où certains departements peuvent être colorés.",
"version": "2.1.1",
"main": "dist/index.js",
"module": "src/index.js",
"main": "cjs/index.js",
"module": "esm/index.js",
"browser": "dist/index.js",
"license": "Apache-2.0",
"files": [
"README.md",
"cjs",
"dist",
"src"
"esm"
],
"dependencies": {
"react-svgmt": "^1.1.9"
Expand Down Expand Up @@ -41,8 +43,11 @@
"clean:demo": "rm -rf ./example/dist",
"start": "parcel watch ./src/index.js --out-dir ./dist",
"start:demo": "parcel ./example/src/index.html --out-dir ./example/dist",
"build": "parcel build ./src/index.js --global minimum-parcel-lib",
"build": "yarn run build:browser && yarn run build:cjs && yarn run build:esm",
"build:browser": "parcel build ./src/index.js --global minimum-parcel-lib",
"build:cjs": "BABEL_ENV=cjs babel src --out-dir cjs",
"build:demo": "parcel build ./example/src/index.html --out-dir ./example/dist --public-url ./",
"build:esm": "BABEL_ENV=esm babel src --out-dir esm",
"deploy": "gh-pages -d ./example/dist -r https://gitlab-ci-token:$GH_TOKEN@github.com/SocialGouv/react-departements.git"
}
}

0 comments on commit 3f82e4d

Please sign in to comment.