From 37f60ba0af86e64fc1c00b91cfddb4f616cd0e7a Mon Sep 17 00:00:00 2001 From: dannyrb Date: Fri, 19 Jul 2019 14:54:34 -0400 Subject: [PATCH] Generate example for codecov issue --- .webpack/webpack.common.js | 90 ++++++++++++++++++++++++++++++++++++ README.md | 9 ++-- package.json | 4 +- platform/core/package.json | 2 +- platform/ui/package.json | 2 +- platform/viewer/package.json | 5 +- 6 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 .webpack/webpack.common.js diff --git a/.webpack/webpack.common.js b/.webpack/webpack.common.js new file mode 100644 index 000000000..ac7dc08b2 --- /dev/null +++ b/.webpack/webpack.common.js @@ -0,0 +1,90 @@ +const path = require("path"); +const ExtractCssChunks = require("extract-css-chunks-webpack-plugin"); + +const SRC_DIR = path.join(__dirname, "../src"); +const PUBLIC_DIR = path.join(__dirname, "../public"); +const DIST_DIR = path.join(__dirname, "../dist"); + +module.exports = (env, argv, { SRC_DIR, DIST_DIR }) => { + return { + entry: { + app: `${SRC_DIR}/index.js` + }, + context: SRC_DIR, + module: { + rules: [ + { + test: /\.jsx?$/, + exclude: [/node_modules/, /packages\\extension/], + loader: "babel-loader", + options: { + // Find babel.config.js in monorepo root + // https://babeljs.io/docs/en/options#rootmode + rootMode: "upward", + presets: [ + [ + "@babel/preset-env", + { + // Do not transform ES6 modules to another format. + // Webpack will take care of that. + modules: false + } + ] + ] + } + }, + { + test: /\.css$/, + use: [ + "style-loader", + ExtractCssChunks.loader, + { loader: "css-loader", options: { importLoaders: 1 } }, + { + loader: "postcss-loader", + options: { + config: { + path: "./postcss.config.js" + } + } + } + ] + }, + /** + * This allows us to include web workers in our bundle, and VTK.js + * web workers in our bundle. While this increases bundle size, it + * cuts down on the number of includes we need for `script tag` usage. + */ + { + test: /\.worker\.js$/, + include: /vtk\.js[\/\\]Sources/, + use: [ + { + loader: "worker-loader", + options: { inline: true, fallback: false } + } + ] + }, + /** + * This is exclusively used by `vtk.js` to bundle glsl files. + */ + { + test: /\.glsl$/i, + include: /vtk\.js[\/\\]Sources/, + loader: "shader-loader" + } + ] + }, + resolve: { + // Which directories to search when resolving modules + modules: [ + path.resolve(__dirname, "../node_modules"), + path.resolve(__dirname, "../../../node_modules"), + SRC_DIR + ], + // Attempt to resolve these extensions in order. + extensions: [".js", ".jsx", ".json", "*"], + // symlinked resources are resolved to their real path, not their symlinked location + symlinks: true + } + }; +}; diff --git a/README.md b/README.md index 584097578..d83d3e0f5 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,11 @@ ### Global -| Commands | | | -| -------------- | --- | ----------------------------------------------------- | -| `test:unit` | | Jest multi-project test runner; overall coverage | -| `test:unit:ci` | | Runs tests in parallel. Reports coverage per project. | +| Commands | | | +| --------------- | --- | ----------------------------------------------------- | +| `build:package` | | Builds commonjs bundles for all projects | +| `test:unit` | | Jest multi-project test runner; overall coverage | +| `test:unit:ci` | | Runs tests in parallel. Reports coverage per project. | ### Local diff --git a/package.json b/package.json index 070384ef5..a53c26d4f 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,12 @@ "scripts": { "cm": "npx git-cz", "start": "lerna run lerna:start --parallel", - "build": "lerna run lerna:build --parallel", + "build:package": "lerna run build:package --parallel", "test:ci": "", "test:unit": "jest --collectCoverage", "test:unit:ci": "lerna run test:unit:ci --parallel", "test:e2e": "", - "test:e2e:ci": "lerna run lerna:test:e2e --parallel && codecov", + "test:e2e:ci": "lerna run lerna:test:e2e --parallel", "new-version": "lerna version --conventional-commits --yes", "build:pwa:ci": "" }, diff --git a/platform/core/package.json b/platform/core/package.json index eeb966cf0..666cb9e3b 100644 --- a/platform/core/package.json +++ b/platform/core/package.json @@ -16,7 +16,7 @@ }, "scripts": { "test:unit": "jest --watch", - "test:unit:ci": "jest --ci --runInBand --collectCoverage", + "test:unit:ci": "jest --ci --runInBand --collectCoverage && codecov --flags=core", "build": "rollup -c", "lerna:build": "webpack --config config/webpack.prod.js -w -d", "dev": "jest --watch", diff --git a/platform/ui/package.json b/platform/ui/package.json index 1391bece4..aaa5c2ee7 100644 --- a/platform/ui/package.json +++ b/platform/ui/package.json @@ -16,7 +16,7 @@ ], "scripts": { "test:unit": "jest --watch", - "test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests", + "test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests && codecov --flags=ui", "dev": "docz dev", "lerna:build": "webpack --config config/webpack.prod.js -w -d", "build": "rollup -c", diff --git a/platform/viewer/package.json b/platform/viewer/package.json index a936200d1..0a85d2b16 100644 --- a/platform/viewer/package.json +++ b/platform/viewer/package.json @@ -14,12 +14,11 @@ "proxy": "http://localhost:8042", "scripts": { "lerna:start": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.dev.js --mode development -w -d", + "build:package": "webpack --config config/webpack.prod.js", "test:unit": "jest --watch", - "test:unit:ci": "jest --ci --runInBand --collectCoverage", + "test:unit:ci": "jest --ci --runInBand --collectCoverage && codecov --flags=viewer", "dev": "yarn run preBuild && react-scripts start", "dev:debug": "react-scripts start", - "build:package": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c", - "build:package:ci": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c", "build:web": "yarn run preBuild && react-scripts --max_old_space_size=4096 build", "build:demo:ci": "yarn run preBuild && cross-env PUBLIC_URL=/ REACT_APP_CONFIG=config/demo.js react-scripts --max_old_space_size=4096 build", "test:e2e:ci": "start-server-and-test start http://localhost:5000 cy:run:ci",