Skip to content

Commit

Permalink
fix: repair build script
Browse files Browse the repository at this point in the history
Changes:
- allow empty `dependencies` field
- add `peerDependencies` field
  • Loading branch information
ym-project committed Jan 14, 2022
1 parent 80de99c commit f463a57
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const {build} = require('esbuild')
const path = require('path')
const {dependencies} = require('../package.json')
const {
dependencies,
peerDependencies,
} = require('../package.json')
const DIST_FOLDER = 'npm'

let external = []

if (dependencies) {
Object.entries(dependencies)
.forEach(([name]) => external.push(name))
}

if (peerDependencies) {
Object.entries(peerDependencies)
.forEach(([name]) => external.push(name))
}

external = external.filter((value, index, self) => self.indexOf(value) === index)

const commonConfig = {
entryPoints: [
path.resolve(__dirname, '..', 'src', 'index.ts'),
Expand All @@ -14,7 +31,7 @@ const commonConfig = {
loader: {
'.ts': 'ts',
},
external: Object.entries(dependencies).map(([name]) => name),
external,
}

function buildCjs() {
Expand Down

0 comments on commit f463a57

Please sign in to comment.