Skip to content

Commit

Permalink
fix: 修复 commonjs 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Nov 23, 2020
1 parent d5669fe commit dc91321
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/generatePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import fs from 'fs-extra'
import rawPackageInfo from '../package.json'
import { join } from 'path'
import { omit } from 'lodash-uni'
import { PackageJson } from '../src/types'

async function main(rootDir: string) {
const packageDir = join(rootDir, './lib')
const packageJsonFile = join(packageDir, './package.json')
const cjsPackageJsonFile = join(packageDir, './_cjs/package.json')

const packageInfo = omit(rawPackageInfo, ([
'husky',
Expand All @@ -18,6 +20,13 @@ async function main(rootDir: string) {

await Promise.all([
fs.writeJSON(packageJsonFile, packageInfo, { spaces: 2 }),
fs.outputJSON(
cjsPackageJsonFile,
{
type: 'commonjs',
} as PackageJson,
{ spaces: 2 },
),
...['LICENSE', 'README.md'].map(file => {
return fs.copyFile(join(rootDir, file), join(packageDir, file))
}),
Expand Down

0 comments on commit dc91321

Please sign in to comment.