Skip to content

Commit

Permalink
build: fix 'Error: 'default' is not exported by ajv'
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Jul 21, 2022
1 parent 30e56aa commit d92e5eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/pro/config/src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const defaultConfig: ProGlobalConfig = {
ajvOptions: {
allErrors: true,
loopEnum: 50,
code: { esm: true },
},
autoId: true,
autoLabelFor: true,
Expand Down
13 changes: 10 additions & 3 deletions scripts/gulp/build/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import vuePlugin from '@vitejs/plugin-vue'
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line import/no-unresolved
import { upperFirst } from 'lodash'
import { RollupOptions } from 'rollup'
import typescript from 'rollup-plugin-typescript2'
Expand All @@ -21,9 +22,10 @@ interface Options {
minify?: boolean
}

const externalDeps = ['vue', '@vue', '@idux', '@popperjs/core', 'date-fns', 'lodash-es', 'ajv']

export const getRollupSingleOptions = (options: Options): RollupOptions => {
const { targetDirname, distDirname, compName = '', minify = false } = options
const externalDeps = ['vue', '@vue', '@idux', '@popperjs/core', 'date-fns', 'lodash-es']

const input = join(targetDirname, compName, 'index.ts')
const outputFile = join(distDirname, compName, 'index.js')
Expand Down Expand Up @@ -88,6 +90,12 @@ export const getRollupFullOptions = (options: Options): RollupOptions => {
if (name === 'vue') {
return 'Vue'
}
if (name === 'ajv') {
return 'Ajv'
}
if (name === 'ajv-formats') {
return 'AjvFormats'
}
if (name.startsWith('@idux')) {
const [, _packageName] = name.split('/')
return `IDux${upperFirst(_packageName)}`
Expand All @@ -101,15 +109,14 @@ export const getRollupFullOptions = (options: Options): RollupOptions => {
},
],
external: id => {
return id === 'vue' || (id.startsWith('@idux') && !id.startsWith(`@idux/${packageName}`))
return id === 'vue' || id.startsWith('ajv') || (id.startsWith('@idux') && !id.startsWith(`@idux/${packageName}`))
},
plugins,
}
}

export const getRollupDeclarationOptions = (options: Options): RollupOptions => {
const { targetDirname, distDirname, packageName } = options
const externalDeps = ['vue', '@vue', '@idux', '@popperjs/core', 'date-fns', 'lodash-es']

const input = join(targetDirname, 'index.ts')
const outputFile = join(distDirname, packageName, 'temp.js')
Expand Down

0 comments on commit d92e5eb

Please sign in to comment.