Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
Add option in fusionConfig to configure jsExtPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Monar committed Feb 19, 2019
1 parent 19546eb commit 338bb68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build/get-webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const EXCLUDE_TRANSPILATION_PATTERNS = [
/node_modules\/react\//,
/node_modules\/core-js\//,
];

const JS_EXT_PATTERN = /\.jsx?$/;

/*::
Expand Down Expand Up @@ -99,6 +100,8 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
const {id, dev, dir, watch, state, fusionConfig, legacyPkgConfig = {}} = opts;
const main = 'src/main.js';

const jsExtPattern = fusionConfig.jsExtPattern || JS_EXT_PATTERN;

if (!fs.existsSync(path.join(dir, main))) {
throw new Error(`Project directory must contain a ${main} file`);
}
Expand Down Expand Up @@ -269,7 +272,7 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
*/
runtime === 'server' && {
compiler: id => id === 'server',
test: JS_EXT_PATTERN,
test: jsExtPattern,
exclude: EXCLUDE_TRANSPILATION_PATTERNS,
use: [
{
Expand Down Expand Up @@ -299,7 +302,7 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
*/
(runtime === 'client' || runtime === 'sw') && {
compiler: id => id === 'client' || id === 'sw',
test: JS_EXT_PATTERN,
test: jsExtPattern,
exclude: EXCLUDE_TRANSPILATION_PATTERNS,
use: [
{
Expand Down Expand Up @@ -329,7 +332,7 @@ function getWebpackConfig(opts /*: WebpackConfigOpts */) {
*/
runtime === 'client' && {
compiler: id => id === 'client-legacy',
test: JS_EXT_PATTERN,
test: jsExtPattern,
exclude: EXCLUDE_TRANSPILATION_PATTERNS,
use: [
{
Expand Down
1 change: 1 addition & 0 deletions build/load-fusionrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let loggedNotice = false;
/*::
export type FusionRC = {
babel?: {plugins?: Array<any>, presets?: Array<any>},
jsExtPattern?: RegExp,
assumeNoImportSideEffects?: boolean,
experimentalCompile?: boolean,
nodeBuiltins?: {[string]: any},
Expand Down
15 changes: 15 additions & 0 deletions docs/fusionrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Fusion supports a `.fusionrc.js` in the root directory of your application. This

This configuration object supports the following fields:

## `jsExtPattern`

By default this is `/\.jsx?$/`

For example, this enables to handle typescript files with addition to Babel plugins/preset:

```js
module.exports = {
jsExtPattern: \[jt]sx?$\,
babel: {
presets: ["@babel/preset-typescript"],
}
};
```

## `babel`

### Adding plugins/presets
Expand Down

0 comments on commit 338bb68

Please sign in to comment.