Skip to content

Commit

Permalink
Use Babel to fix Jest ES6 issue (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
stereobooster committed May 27, 2019
1 parent cb34823 commit 4cdcbc1
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 181 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -20,6 +20,10 @@

## Tools

Info in this section is stale:
- **Problem 2** is resolved in PR [#5](https://github.com/stereobooster/typescript-monorepo/pull/5)
- **Problem 4** is resolved in PR [#4](https://github.com/stereobooster/typescript-monorepo/pull/4)

### yarn

`yarn` instead of `npm`, because it supports `workspaces` to link cross-dependencies.
Expand Down Expand Up @@ -183,7 +187,7 @@ Add command to `package.json`
}
```

**Problem 2**: we will publish modules as ES5 + CommonJS, which makes no sense for React package, which would require some kind of bundler to consume packages, like Parcel or Webpack.
~~**Problem 2**: we will publish modules as ES5 + CommonJS, which makes no sense for React package, which would require some kind of bundler to consume packages, like Parcel or Webpack.~~

**Problem 3**: there are sub-dependencies, so we need to build all packages first and only after we can run tests. That is why we need `pretest` script.

Expand Down
7 changes: 7 additions & 0 deletions babel.config.js
@@ -0,0 +1,7 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-react"
// "@babel/preset-typescript"
]
};
3 changes: 2 additions & 1 deletion jest.json
@@ -1,6 +1,7 @@
{
"moduleFileExtensions": ["ts", "tsx", "js"],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx"],
"transform": {
"\\.jsx?$": "babel-jest",
"\\.tsx?$": "ts-jest"
},
"testMatch": ["**/__tests__/**/*.test.*"],
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -18,10 +18,14 @@
"clean": "rimraf packages/*/{tsconfig.tsbuildinfo,lib,dist}"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@types/jest": "^24.0.13",
"@types/react": "^16.8.18",
"@types/react-dom": "^16.8.4",
"@types/react-test-renderer": "^16.8.1",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"lerna": "^3.14.1",
"react": "^16.8.6",
Expand Down
12 changes: 6 additions & 6 deletions packages/stories/package.json
Expand Up @@ -21,16 +21,16 @@
"react-dom": "^16.8.0"
},
"devDependencies": {
"@babel/core": "7.4.3",
"@babel/core": "7.4.5",
"@storybook/addon-info": "^5.0.11",
"@storybook/addons": "5.0.6",
"@storybook/core": "5.0.6",
"@storybook/react": "5.0.6",
"@storybook/addons": "5.0.11",
"@storybook/core": "5.0.11",
"@storybook/react": "5.0.11",
"@types/storybook__addon-info": "^4.1.1",
"@types/storybook__react": "4.0.1",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "8.0.5",
"babel-loader": "8.0.6",
"react-docgen-typescript-loader": "^3.1.0",
"storybook-chromatic": "1.3.2"
"storybook-chromatic": "1.3.3"
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Expand Up @@ -3,8 +3,8 @@
"files": [],
"compilerOptions": {
"skipLibCheck": false,
"target": "es5",
"module": "commonjs",
"target": "esnext",
"module": "esnext",
"lib": ["dom", "esnext"],
"jsx": "react",
"declaration": true,
Expand Down

0 comments on commit 4cdcbc1

Please sign in to comment.