Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby): Port build-javascript to TypeScript #22028

Merged
merged 2 commits into from
Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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