Skip to content

Commit

Permalink
fix(core): compile down to commonjs (#29)
Browse files Browse the repository at this point in the history
Fixes: #28
  • Loading branch information
André Neves authored and Andrew T. Poe committed May 28, 2019
1 parent 24ffb82 commit 8e8cc0b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// https://www.wisdomgeek.com/development/web-development/how-to-setup-jest-typescript-babel-webpack-project/
module.exports = (api) => {
// Testing if babel is being run in test mode
const isTest = api.env('test');

/**
* Cache the returned value forever and don't call this function again. This is the default behavior but since we
* are reading the env value above, we need to explicitly set it after we are done doing that, else we get a
* caching was left unconfigured error.
*/
api.cache(true);

return {
presets: [
[
Expand All @@ -17,12 +15,8 @@ module.exports = (api) => {
{
// Specifying which browser versions you want to transpile down to
targets: '> 0.25%, not dead',
/**
* Specifying what module type should the output be in.
* For test cases, we transpile all the way down to commonjs since jest does not understand TypeScript.
* For all other cases, we don't transform since we want Webpack to do that in order for it to do
* dead code elimination (tree shaking) and intelligently select what all to add to the bundle.
*/ modules: isTest ? 'commonjs' : false,

modules: 'commonjs',
},
],
// Enabling Babel to understand TypeScript
Expand Down

0 comments on commit 8e8cc0b

Please sign in to comment.