Skip to content

Commit

Permalink
chore(gatsby): Port build-javascript to TypeScript (#22028)
Browse files Browse the repository at this point in the history
* chore(gatsby): Port build-javascript to TypeScript

* refactor(gatsby): unwrap span object
  • Loading branch information
mottox2 authored Mar 7, 2020
1 parent 28a0c9c commit 66d3333
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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<webpack.Stats> => {
const { directory } = program

const compilerConfig = await webpackConfig(
Expand Down
12 changes: 6 additions & 6 deletions packages/gatsby/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 66d3333

Please sign in to comment.