babel-preset-kyt-core
Advanced tools
Comparing version
/* eslint-disable global-require */ | ||
jest.setMock('babel-preset-env', 'env'); | ||
jest.setMock('babel-plugin-transform-runtime', 'runtime'); | ||
jest.setMock('babel-plugin-transform-es2015-modules-commonjs', 'commonjs'); | ||
jest.setMock('babel-plugin-syntax-dynamic-import', 'import'); | ||
jest.setMock('@babel/preset-env', 'env'); | ||
jest.setMock('@babel/plugin-transform-runtime', 'runtime'); | ||
jest.setMock('@babel/plugin-syntax-dynamic-import', 'import'); | ||
jest.setMock('babel-plugin-dynamic-import-node', 'import-node'); | ||
describe('babel-preset-kyt-core', () => { | ||
it('should load default presets and plugins', () => { | ||
const presetKytCore = require('../index.js'); | ||
const presetKytCore = require('..'); | ||
expect(presetKytCore()).toMatchSnapshot(); | ||
@@ -16,3 +16,3 @@ }); | ||
process.env.KYT_ENV_TYPE = 'server'; | ||
const presetKytCore = require('../index.js'); | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore(); | ||
@@ -24,3 +24,3 @@ expect(config.presets[0][1].targets.node).toEqual('current'); | ||
process.env.KYT_ENV_TYPE = 'client'; | ||
const presetKytCore = require('../index.js'); | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore( | ||
@@ -37,3 +37,3 @@ {}, | ||
process.env.KYT_ENV_TYPE = 'server'; | ||
const presetKytCore = require('../index.js'); | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore({}, { envOptions: { server: { targets: { node: false } } } }); | ||
@@ -44,6 +44,19 @@ expect(config.presets[0][1].targets.node).toEqual(false); | ||
it('should support an `includeRuntime` option', () => { | ||
const presetKytCore = require('../index.js'); | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore({}, { includeRuntime: true }); | ||
expect(config.plugins[0]).toEqual('runtime'); | ||
}); | ||
it('should include a dynamic import plugin', () => { | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore(); | ||
expect(config.plugins[0]).toEqual('import'); | ||
}); | ||
it('should include a import node plugin when KYT_ENV_TYPE=test', () => { | ||
process.env.KYT_ENV_TYPE = 'test'; | ||
const presetKytCore = require('..'); | ||
const config = presetKytCore(); | ||
expect(config.plugins[1]).toEqual('import-node'); | ||
}); | ||
}); |
/* eslint-disable vars-on-top */ | ||
var babelPresetEnv = require('babel-preset-env'); | ||
var babelTransformRuntime = require('babel-plugin-transform-runtime'); | ||
var babelSyntaxDynamicImport = require('babel-plugin-syntax-dynamic-import'); | ||
var babelTransformModules = require('babel-plugin-transform-es2015-modules-commonjs'); | ||
var babelPresetEnv = require('@babel/preset-env'); | ||
var babelTransformRuntime = require('@babel/plugin-transform-runtime'); | ||
var babelSyntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import'); | ||
var babelDynamicImportNode = require('babel-plugin-dynamic-import-node'); | ||
var merge = require('lodash.merge'); | ||
@@ -16,5 +16,5 @@ | ||
modules: false, | ||
useBuiltIns: true, | ||
useBuiltIns: 'entry', | ||
forceAllTransforms: true, | ||
targets: { | ||
uglify: true, | ||
browsers: ['>1%', 'last 4 versions', 'not ie < 11'], | ||
@@ -26,3 +26,4 @@ }, | ||
modules: false, | ||
useBuiltIns: true, | ||
useBuiltIns: 'entry', | ||
forceAllTransforms: true, | ||
targets: { | ||
@@ -65,11 +66,5 @@ node: 'current', | ||
opts.includeRuntime === true && babelTransformRuntime, | ||
babelSyntaxDynamicImport, | ||
process.env.KYT_ENV_TYPE === 'test' ? babelDynamicImportNode : babelSyntaxDynamicImport, | ||
].filter(Boolean), | ||
env: { | ||
test: { | ||
plugins: [[babelTransformModules, { loose: true }]], | ||
}, | ||
}, | ||
}; | ||
}; |
{ | ||
"name": "babel-preset-kyt-core", | ||
"version": "1.0.0-alpha.97d89b1e", | ||
"version": "1.0.0-alpha.9dc743a9", | ||
"description": "An opinionated babel preset, best used with kyt", | ||
@@ -12,6 +12,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"babel-plugin-syntax-dynamic-import": "6.18.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0", | ||
"babel-plugin-transform-runtime": "6.23.0", | ||
"babel-preset-env": "1.6.0" | ||
"@babel/plugin-syntax-dynamic-import": "7.2.0", | ||
"@babel/plugin-transform-runtime": "7.2.0", | ||
"@babel/preset-env": "7.2.3", | ||
"babel-plugin-dynamic-import-node": "2.2.0", | ||
"lodash.merge": "4.6.1" | ||
}, | ||
@@ -18,0 +19,0 @@ "keywords": [ |
@@ -11,15 +11,16 @@ ## babel-preset-kyt-core | ||
To install: | ||
1. `npm install babel-preset-kyt-core --save` | ||
2. In babelrc: | ||
``` | ||
{ | ||
presets: [ | ||
"babel-preset-kyt-core" | ||
] | ||
} | ||
``` | ||
``` | ||
{ | ||
presets: [ | ||
"babel-preset-kyt-core" | ||
] | ||
} | ||
``` | ||
## Options | ||
*(see [documentation](https://babeljs.io/docs/plugins/#plugin-preset-options) for Babel preset options)* | ||
_(see [documentation](https://babeljs.io/docs/plugins/#plugin-preset-options) for Babel preset options)_ | ||
@@ -31,5 +32,5 @@ - `envOptions` (`Object`) - extend the default babel-preset-env options. The type of options, `client`, `server`, and `test`, are dependent on the value of `process.env.KYT_ENV_TYPE` which, when undefined, defaults to `client`. kyt will automatically set the `KYT_ENV_TYPE` when it runs commands. For debugging purposes, use `"debug": true` to see what the plugin is targeting. The following are the default babel-preset-env configurations used by kyt-core: | ||
modules: false, | ||
useBuiltIns: true, | ||
useBuiltIns: 'entry', | ||
forceAllTransforms: true, | ||
targets: { | ||
uglify: true, | ||
browsers: ['>1%', 'last 4 versions', 'not ie < 11'], | ||
@@ -41,3 +42,4 @@ }, | ||
modules: false, | ||
useBuiltIns: true, | ||
useBuiltIns: 'entry', | ||
forceAllTransforms: true, | ||
targets: { | ||
@@ -72,2 +74,3 @@ node: 'current' | ||
``` | ||
You can find additional options to configure babel-preset-env [here](https://github.com/babel/babel/tree/master/experimental/babel-preset-env#options). | ||
@@ -74,0 +77,0 @@ |
Sorry, the diff of this file is not supported yet
9236
2.89%110
6.8%89
3.49%5
25%9
28.57%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed