2018-05-08 03:02:19 +00:00
|
|
|
// @no-flow
|
2018-03-19 05:43:23 +00:00
|
|
|
const webpack = require("webpack");
|
|
|
|
const eslintFormatter = require("react-dev-utils/eslintFormatter");
|
|
|
|
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
|
|
|
|
const paths = require("./paths");
|
2018-05-04 23:31:39 +00:00
|
|
|
const nodeExternals = require("webpack-node-externals");
|
2018-03-19 05:43:23 +00:00
|
|
|
|
|
|
|
// This is the backend configuration. It builds applications that target
|
|
|
|
// Node and will not run in a browser.
|
Don’t erase the `bin/` folder in CI (#317)
Summary:
Previously, our CI script would run `yarn backend`, which has the
side-effect of erasing the `bin/` directory. By itself, this is not
great, but not awful. However, this frequently triggers a race condition
in Prettier, causing the `check-pretty` step of the build to fail. (More
details: https://github.com/prettier/prettier/issues/4468.)
This patch changes the CI script to build the backend scripts into a
temporary directory.
Test Plan:
Before applying this patch: `yarn backend` and then `yarn travis`. If
this consistently causes a Travis failure due to `check-pretty`, then
your machine can reproduce the race condition that we‛re trying to
eliminate. (Otherwise, you can try creating a bunch more Git history…
I’m not really sure what to say. It is a race condition, after all.)
Then, apply this patch, and repeat the above steps; note that the error
no longer occurs, and that the build output is to a temporary directory.
wchargin-branch: ci-preserve-bin
2018-05-29 22:40:42 +00:00
|
|
|
module.exports = (outputPath) => ({
|
2018-03-19 05:43:23 +00:00
|
|
|
// Don't attempt to continue if there are any errors.
|
|
|
|
bail: true,
|
|
|
|
// Target Node instead of the browser.
|
|
|
|
target: "node",
|
|
|
|
entry: paths.backendEntryPoints,
|
2018-05-04 23:31:39 +00:00
|
|
|
externals: [nodeExternals()],
|
2018-03-19 05:43:23 +00:00
|
|
|
output: {
|
Don’t erase the `bin/` folder in CI (#317)
Summary:
Previously, our CI script would run `yarn backend`, which has the
side-effect of erasing the `bin/` directory. By itself, this is not
great, but not awful. However, this frequently triggers a race condition
in Prettier, causing the `check-pretty` step of the build to fail. (More
details: https://github.com/prettier/prettier/issues/4468.)
This patch changes the CI script to build the backend scripts into a
temporary directory.
Test Plan:
Before applying this patch: `yarn backend` and then `yarn travis`. If
this consistently causes a Travis failure due to `check-pretty`, then
your machine can reproduce the race condition that we‛re trying to
eliminate. (Otherwise, you can try creating a bunch more Git history…
I’m not really sure what to say. It is a race condition, after all.)
Then, apply this patch, and repeat the above steps; note that the error
no longer occurs, and that the build output is to a temporary directory.
wchargin-branch: ci-preserve-bin
2018-05-29 22:40:42 +00:00
|
|
|
path: outputPath,
|
2018-03-19 05:43:23 +00:00
|
|
|
// Generated JS file names (with nested folders).
|
|
|
|
// There will be one main bundle, and one file per asynchronous chunk.
|
|
|
|
// We don't currently advertise code splitting but Webpack supports it.
|
|
|
|
filename: "[name].js",
|
|
|
|
chunkFilename: "[name].[chunkhash:8].chunk.js",
|
2018-05-05 02:28:37 +00:00
|
|
|
libraryTarget: "umd",
|
2018-03-19 05:43:23 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [".js", ".json"],
|
|
|
|
plugins: [
|
|
|
|
// Prevents users from importing files from outside of src/ (or node_modules/).
|
|
|
|
// This often causes confusion because we only process files within src/ with babel.
|
|
|
|
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
|
|
|
// please link the files into your node_modules/ and let module-resolution kick in.
|
|
|
|
// Make sure your source files are compiled, as they will not be processed in any way.
|
|
|
|
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
strictExportPresence: true,
|
|
|
|
rules: [
|
|
|
|
// First, run the linter.
|
|
|
|
// It's important to do this before Babel processes the JS.
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx|mjs)$/,
|
|
|
|
enforce: "pre",
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
options: {
|
|
|
|
formatter: eslintFormatter,
|
|
|
|
eslintPath: require.resolve("eslint"),
|
|
|
|
},
|
|
|
|
loader: require.resolve("eslint-loader"),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
include: paths.appSrc,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// "oneOf" will traverse all following loaders until one will
|
|
|
|
// match the requirements. If no loader matches, it will fail.
|
|
|
|
oneOf: [
|
|
|
|
// Process JS with Babel.
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx|mjs)$/,
|
|
|
|
include: paths.appSrc,
|
|
|
|
loader: require.resolve("babel-loader"),
|
|
|
|
options: {
|
|
|
|
compact: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
"process.env.NODE_ENV": JSON.stringify(
|
|
|
|
process.env.NODE_ENV || "development"
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
],
|
Don’t erase the `bin/` folder in CI (#317)
Summary:
Previously, our CI script would run `yarn backend`, which has the
side-effect of erasing the `bin/` directory. By itself, this is not
great, but not awful. However, this frequently triggers a race condition
in Prettier, causing the `check-pretty` step of the build to fail. (More
details: https://github.com/prettier/prettier/issues/4468.)
This patch changes the CI script to build the backend scripts into a
temporary directory.
Test Plan:
Before applying this patch: `yarn backend` and then `yarn travis`. If
this consistently causes a Travis failure due to `check-pretty`, then
your machine can reproduce the race condition that we‛re trying to
eliminate. (Otherwise, you can try creating a bunch more Git history…
I’m not really sure what to say. It is a race condition, after all.)
Then, apply this patch, and repeat the above steps; note that the error
no longer occurs, and that the build output is to a temporary directory.
wchargin-branch: ci-preserve-bin
2018-05-29 22:40:42 +00:00
|
|
|
});
|