1.0.2 • Published 2 years ago
@videojs/babel-config v1.0.2
@videojs/babel-config
Currently babel configs are the same for most plugins, and most of them are built using this babel config via babel. We have some libraries though that are should not be built using rollup for nodejs consumption, that are currently doing so. So this config while still consumed by videojs-generate-rollup-config can also be used standalone with babel-cli.
Lead Maintainer: Brandon Casey @brandonocasey
Maintenance Status: Stable
Table of Contents
Installation
$ npm install --save-dev @babel/cli @videojs/babel-configUsage
- In your rollup config add a line to delete module builds:
if (config.builds.module) {
delete config.builds.module;
}- Add a npm scripts for cjs/es dists to your package.json:
{
"build:cjs": "babel-config-cjs -d ./cjs ./src",
"build:es": "babel-config-es -d ./es ./src",
"watch:cjs": "npm run build:cjs -- -w",
"watch:es": "npm run build:es -- -w"
}- verify that
maininpackage.jsonis set to the cjs dist. Something likecjs/index.js - verify that
moduleinpackage.jsonis set to the es dist. Something likees/index.js - verify that
browserinpackage.jsonis set to the browser dist. Something likedist/project-name.js - Add
esandcjstovjsstandard.ignoreinpackage.json - Make sure that
es/andcjs/are infilesinpackage.json - Add
/esand/cjsto.gitignore. - Add
./esand./cjsto the npm script forcleanaftermkdir -pandrm -rf.
shx rm -rf ./dist ./test/dist ./cjs ./es && shx mkdir -p ./dist ./test/dist ./cjs ./esImportant things
- When running through
babel-config-cjs,babel-config-es, orbabel-config-runif theTEST_BUNDLE_ONLYenvironment variable is set nothing will run! This is to maintain parity withvideojs-generate-rollup-config. - The
babel-config-cjsbinary runs babel cli with--verboseand--config-fileset to the cjs config exported here. - The
babel-config-esbinary runs babel cli with--verboseand--config-fileset to the es config exported here. - The
babel-config-runbinary runs babel cli with--verbosebut no config file.
Changing configuration
- require the configuration you want to use
const config = require('@videojs/babel-config/cjs.js'); - Make changes to it and export:
module.export = config. - Change the build scripts to
babel-config-run --config-file <new-config> ...