Skip to content

Commit

Permalink
Default to Babel stage 1 when testing React component/library and web…
Browse files Browse the repository at this point in the history
… module projects

Fixes #364
  • Loading branch information
insin committed Dec 12, 2017
1 parent 6b9bb31 commit 0f2434e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

- Deprecated the `webpack.compat.sinon` flag for Sinon 1.x compatibility settings, as subsequent major versions since July 2017 support Webpack out of the box.

## Fixed

- Fixed testing React component/library and web module projects when using [export extensions](http://babeljs.io/docs/plugins/transform-export-extensions/) - the Babel stage preset wasn't being defaulted to preset-stage-1, which includes the export extensions plugin [[#364](https://github.com/insin/nwb/issues/364)]

## Added

- You can now provide a [`babel.config()` function](https://github.com/insin/nwb/blob/master/docs/Configuration.md#config-function) which will be given the generated Babel config to do whatever it wants with.
Expand Down
15 changes: 15 additions & 0 deletions src/commands/test-react-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow
import merge from 'webpack-merge'

import karmaServer from '../karmaServer'
import reactConfig from '../react'

import type {ErrBack} from '../types'

export default function testReactComponent(args: Object, cb: ErrBack) {
karmaServer(args, merge(reactConfig(args).getKarmaTestConfig(), {
babel: {
stage: 1
}
}), cb)
}
12 changes: 12 additions & 0 deletions src/commands/test-web-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow
import karmaServer from '../karmaServer'

import type {ErrBack} from '../types'

export default function testWebModule(args: Object, cb: ErrBack) {
karmaServer(args, {
babel: {
stage: 1
}
}, cb)
}
7 changes: 5 additions & 2 deletions src/commands/test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// @flow
import {getProjectType} from '../config'
import {INFERNO_APP, PREACT_APP, REACT_APP, REACT_COMPONENT} from '../constants'
import {INFERNO_APP, PREACT_APP, REACT_APP, REACT_COMPONENT, WEB_MODULE} from '../constants'
import karmaServer from '../karmaServer'
import testInferno from './test-inferno'
import testPreact from './test-preact'
import testReact from './test-react'
import testReactComponent from './test-react-component'
import testWebModule from './test-web-module'

import type {ErrBack} from '../types'

const TEST_COMMANDS = {
[INFERNO_APP]: testInferno,
[PREACT_APP]: testPreact,
[REACT_APP]: testReact,
[REACT_COMPONENT]: testReact,
[REACT_COMPONENT]: testReactComponent,
[WEB_MODULE]: testWebModule,
}

/**
Expand Down

0 comments on commit 0f2434e

Please sign in to comment.