diff --git a/packages/gatsby/src/commands/build-javascript.js b/packages/gatsby/src/commands/build-javascript.ts similarity index 59% rename from packages/gatsby/src/commands/build-javascript.js rename to packages/gatsby/src/commands/build-javascript.ts index 885ad0c0736f5..21bf971741ff4 100644 --- a/packages/gatsby/src/commands/build-javascript.js +++ b/packages/gatsby/src/commands/build-javascript.ts @@ -1,10 +1,14 @@ -/* @flow */ -const webpack = require(`webpack`) -const webpackConfig = require(`../utils/webpack.config`) +import webpack from "webpack" +import webpackConfig from "../utils/webpack.config" +import { IProgram } from "./types" +import { Span } from "opentracing" -const { reportWebpackWarnings } = require(`../utils/webpack-error-utils`) +import { reportWebpackWarnings } from "../utils/webpack-error-utils" -module.exports = async (program, { parentSpan }) => { +export const buildProductionBundle = async ( + program: IProgram, + parentSpan: Span +): Promise => { const { directory } = program const compilerConfig = await webpackConfig( diff --git a/packages/gatsby/src/commands/build.js b/packages/gatsby/src/commands/build.js index aa39e7dd43f81..1ce3e58c3f677 100644 --- a/packages/gatsby/src/commands/build.js +++ b/packages/gatsby/src/commands/build.js @@ -4,7 +4,7 @@ const path = require(`path`) const report = require(`gatsby-cli/lib/reporter`) const fs = require(`fs-extra`) import { buildHTML } from "./build-html" -const buildProductionBundle = require(`./build-javascript`) +import { buildProductionBundle } from "./build-javascript" const bootstrap = require(`../bootstrap`) const apiRunnerNode = require(`../utils/api-runner-node`) const { copyStaticDirs } = require(`../utils/get-static-dir`) @@ -111,11 +111,11 @@ module.exports = async function build(program: BuildArgs) { { parentSpan: buildSpan } ) activity.start() - const stats = await buildProductionBundle(program, { - parentSpan: activity.span, - }).catch(err => { - activity.panic(structureWebpackErrors(`build-javascript`, err)) - }) + const stats = await buildProductionBundle(program, activity.span).catch( + err => { + activity.panic(structureWebpackErrors(`build-javascript`, err)) + } + ) activity.end() const workerPool = WorkerPool.create()