Skip to content

Commit

Permalink
fix: change default browser target using es6-module feature query
Browse files Browse the repository at this point in the history
BREAKING CHANGE: most modern browsers support es6-modules, it should be safe to release library code
using this target. if the user of your library targets lower browsers, they should compile your
library to support that browser target
  • Loading branch information
osdevisnot committed Jan 18, 2021
1 parent 322e094 commit 4bcc45b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,23 @@ Then use `npm run` or `yarn` to invoke npm scripts as you normally would.

`klap` uses sensible defaults for most part. However, as needed, use below properties in `package.json` to fine tune `klap`. You can also use `cli flags` to control config options for `klap`.

| option | cli flag(s) | description | default |
| ---------------- | ---------------------- | ---------------------------------------------- | --------------------------------- |
| `source` | -s --source | source file to compile and bundle | `src/index.js` |
| `cjs` | -c --cjs | the output file for common js format | pkg.main |
| `esm` | -e --esm | the output file for esm format | pkg.module |
| `umd` | -u --umd | the output file for umd format | pkg.browser |
| `types` | -t --types | the output file for type definitions | pkg.types |
| `browserslist` | -b --browserslist | browserslist compatible compilation target | `>1%, not ie 11, not op_mini all` |
| `klap.name` | -n --name | package name for `umd` bundles | sanitized `pkg.name` |
| `klap.port` | -p --port | port for development server | `1234` |
| `klap.example` | --example | location of index js/ts file for start command | `public/index.js` or `pkg.source` |
| `klap.fallback` | --fallback | location of index html file for start command | `public/index.html` |
| `klap.target` | --target | target for development server (`umd, es`) | `es` |
| `klap.sourcemap` | --no-sourcemap | sourcemaps for builds | `true` |
| `klap.minify` | --no-minify | minification for builds | `true` |
| `klap.runtime` | --runtime | the runtime for new JSX transform | `react` |
| `klap.globals` | | global names for umd bundles | `{}` |

> Note: See default [browserslist coverage](https://browserl.ist/?q=%3E1%25%2C+not+ie+11%2C+not+op_mini+all)
| option | cli flag(s) | description | default |
| ---------------- | ---------------------- | ---------------------------------------------- | ------------------------------------------------- |
| `source` | -s --source | source file to compile and bundle | `src/index.js` |
| `cjs` | -c --cjs | the output file for common js format | pkg.main |
| `esm` | -e --esm | the output file for esm format | pkg.module |
| `umd` | -u --umd | the output file for umd format | pkg.browser |
| `types` | -t --types | the output file for type definitions | pkg.types |
| `browserslist` | -b --browserslist | browserslist compatible compilation target | `>1% and supports es6-module and last 2 versions` |
| `klap.name` | -n --name | package name for `umd` bundles | sanitized `pkg.name` |
| `klap.port` | -p --port | port for development server | `1234` |
| `klap.example` | --example | location of index js/ts file for start command | `public/index.js` or `pkg.source` |
| `klap.fallback` | --fallback | location of index html file for start command | `public/index.html` |
| `klap.target` | --target | target for development server (`umd, es`) | `es` |
| `klap.sourcemap` | --no-sourcemap | sourcemaps for builds | `true` |
| `klap.minify` | --no-minify | minification for builds | `true` |
| `klap.runtime` | --runtime | the runtime for new JSX transform | `react` |
| `klap.globals` | | global names for umd bundles | `{}` |

## :clinking_glasses: License

Expand Down
10 changes: 3 additions & 7 deletions examples/react-sc-typescript/dist/index.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions examples/react-sc-typescript/dist/index.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getOptions = (pkg, command) => {
const {
klap = {},
source = 'src/index.js',
browserslist = '>1%, not ie 11, not op_mini all',
browserslist = '>1% and supports es6-module and last 2 versions',
main,
module,
browser,
Expand Down

0 comments on commit 4bcc45b

Please sign in to comment.