Skip to content

Commit

Permalink
fix pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Jan 16, 2023
1 parent a36fcc0 commit 3225eea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions scripts/build/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import {BundleDef, BundleType} from "./bundles"
import {getBundleOutputPaths} from "./packaging"
import {asyncMkDirP, getPackageDir} from "./utils"

import {transformFileSync} from '@babel/core';
const fs = require("fs")
const path = require("path")
const chalk = require("chalk")
const babel = require("babel-core")
const ora = require("ora")

const babelConfig = require("./babel.config")

const ignorePatterns = [/\.test.[jt]s$/, /fixtures/]

function walk(base: string, relativePath = "") {
let files = []
function walk(base: string, relativePath = ""): string[] {
let files: string[] = []

fs.readdirSync(path.join(base, relativePath)).forEach(dirname => {
const directory = path.join(relativePath, dirname)
Expand Down Expand Up @@ -64,7 +64,7 @@ export default async function(bundle: BundleDef) {
await asyncMkDirP(outputDir)

if (!filename.endsWith(".d.ts")) {
const { code } = babel.transformFileSync(
const { code } = transformFileSync(
path.join(srcDir, filename),
babelConfig({ modules: true })
)
Expand Down
10 changes: 4 additions & 6 deletions scripts/build/packaging.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import {existsSync, readdirSync, unlinkSync} from "fs"
import {existsSync, readdirSync} from "fs"
import {BundleType as BundleType} from "./bundles"

import {
asyncCopyTo,
} from "./utils"

export function getBundleOutputPaths(bundleType: BundleType, filename: string, packageName: string) {
const _filename = filename.replace(/^@lingui\//, "")

switch (bundleType) {
case BundleType.NOOP:
case BundleType.NODE:
return [`packages/${packageName}/build/${_filename}`]
return [`packages/${packageName}/build/${filename}`]
case BundleType.ESM:
return [`packages/${packageName}/build/esm/${_filename}`]
return [`packages/${packageName}/build/esm/${filename}`]
case BundleType.UNIVERSAL:
return [`packages/${packageName}/build/cjs/${_filename}`]
return [`packages/${packageName}/build/cjs/${filename}`]
// case BundleType.UMD_DEV:
// case BundleType.UMD_PROD:
// return [
Expand Down
1 change: 0 additions & 1 deletion scripts/build/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ async function build(bundle: BundleDef, bundleType: RollupBundleType) {

export default async function (bundle: BundleDef) {
await build(bundle, RollupBundleType.NODE_DEV)

await build(bundle, RollupBundleType.NODE_PROD)
await build(bundle, RollupBundleType.ESM_DEV)
await build(bundle, RollupBundleType.ESM_PROD)
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function asyncCopyTo(from: string, to: string) {

await asyncMkDirP(path.dirname(to))

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
ncp(from, to, error => {
if (error) {
// Wrap to have a useful stack trace.
Expand All @@ -30,7 +30,7 @@ export function asyncMkDirP(filepath: string) {
}

export function asyncRimRaf(filepath: string) {
return new Promise((resolve, reject) =>
return new Promise<void>((resolve, reject) =>
rimraf(filepath, error => {
if (error) {
reject(error)
Expand Down

0 comments on commit 3225eea

Please sign in to comment.