https://github.com/mat3e/polyfill
Babel + core-js example
https://github.com/mat3e/polyfill
Last synced: 6 months ago
JSON representation
Babel + core-js example
- Host: GitHub
- URL: https://github.com/mat3e/polyfill
- Owner: mat3e
- License: mit
- Created: 2019-10-26T19:56:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:31:25.000Z (over 3 years ago)
- Last Synced: 2024-04-14T07:38:52.752Z (over 2 years ago)
- Language: JavaScript
- Size: 383 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Babel + core-js
1. `npm run babel`
* Creates `babel/code.js` from `src/code.js` with Babel transformations
* Uses just `@babel/preset-env`, with no additional configuration
* `@babel/preset-env` uses `.browserslistrc` to decide what to transform and how
2. `npm run babel-core-js`
* Creates `babel-core-js/code.js`
* Uses `cross-env` to change `NODE_ENV`
* Then, `@babel/preset-env` uses `core-js` (see `.babelrc.js`)
* `@babel/preset-env` uses `.browserslistrc` to decide what to transform and **polyfill** and how
3. `npm run docs`
* Creates `docs` folder with
* polyfill.html
* babel-core-js.js
* original.html
* original.js
* Executes webpack 2 times - with the original file (default configuration) and with the Babel + core-js version (`webpack-babel-core-js.js` webpack configuration)
## Example in action
* [Original script](https://mat3e.github.io/polyfill/original.html)
* [Babel + core-js](https://mat3e.github.io/polyfill/polyfill.html)
## Why not using Babel inside Webpack?
The idea is to show Babel and core-js. It's simpler with Babel CLI.
Webpack is just for creating the example webpages with the code got from Babel.