babel-preset-codecademy
Advanced tools
Comparing version 3.0.0 to 3.0.1
15
index.js
@@ -10,7 +10,6 @@ const path = require("path"); | ||
const PACKAGE_APPLICATION = "application"; | ||
const packageTypes = [PACKAGE_LIBRARY, PACKAGE_APPLICATION]; | ||
module.exports = (api, opts) => { | ||
const packageType = opts.type || PACKAGE_APPLICATION; | ||
if (!packageTypes.includes(packageType)) { | ||
module.exports = (api, { type = PACKAGE_LIBRARY } = {}) => { | ||
if (!packageTypes.includes(type)) { | ||
throw new Error( | ||
@@ -20,8 +19,8 @@ `babel-preset-codecademy: option 'type' should be one of: ${[ | ||
PACKAGE_APPLICATION, | ||
].join(", ")}, received ${packageType}` | ||
].join(", ")}, received ${type}` | ||
); | ||
} | ||
let absoluteRuntimePath = undefined; | ||
if (packageType === PACKAGE_APPLICATION) { | ||
let absoluteRuntimePath; | ||
if (type === PACKAGE_APPLICATION) { | ||
absoluteRuntimePath = path.dirname( | ||
@@ -78,3 +77,3 @@ require.resolve("@babel/runtime/package.json") | ||
regenerator: true, | ||
helpers: packageType === PACKAGE_APPLICATION, | ||
helpers: type === PACKAGE_APPLICATION, | ||
regenerator: true, | ||
@@ -81,0 +80,0 @@ useESModules: isEnvDevelopment || isEnvProduction, |
{ | ||
"name": "babel-preset-codecademy", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A collection of babel plugins and presets used at codecademy.com", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,10 +29,26 @@ # babel-preset-codecademy | ||
### Via Node API | ||
### Options | ||
```javascript | ||
require('babel-core').transform('code', { | ||
presets: ['codecademy'] | ||
}); | ||
#### Type | ||
default: 'library' | ||
Certain options can be turned on and off depending on what you're using babel for. | ||
For applications, we enable runtime helpers and `@babel/runtime` becomes a required dependency. | ||
```json | ||
{ | ||
"presets": ["codecademy", { "type": "application" }] | ||
} | ||
``` | ||
For libraries (default), we don't enable runtime helpers because then the resulting package would need `@babel/runtime` as a dependency, which should be handled by the consumer of the package. | ||
```json | ||
{ | ||
"presets": ["codecademy", { "type": "library" }] | ||
} | ||
``` | ||
## Publishing this package | ||
@@ -42,5 +58,5 @@ | ||
* merge your PR into `main` | ||
* create a new PR that updates the version of the package in package.json. Base the version bump on all of the changes that will be added in this version. | ||
* merge the version PR into `main` | ||
* check the [actions](https://github.com/Codecademy/babel-preset-codecademy/actions) to see when the package is published | ||
- merge your PR into `main` | ||
- create a new PR that updates the version of the package in package.json. Base the version bump on all of the changes that will be added in this version. | ||
- merge the version PR into `main` | ||
- check the [actions](https://github.com/Codecademy/babel-preset-codecademy/actions) to see when the package is published |
17693
61