-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use @coze-infra/rslib-config feat: rush update
- Loading branch information
wfc
committed
Dec 3, 2024
1 parent
626591e
commit 69d92c2
Showing
9 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { defineConfig, LibConfig } from '@rslib/core'; | ||
|
||
type LibFormat = LibConfig['format']; | ||
export type BundleType = Boolean | 'excludeExternal'; | ||
|
||
interface Options { | ||
format?: LibFormat[]; | ||
bundle?: BundleType; | ||
tsconfigPath?: string; | ||
umdName?: string; | ||
} | ||
const defaultOptions = { | ||
format: ['esm', 'cjs'] as LibFormat[], | ||
bundle: true, | ||
}; | ||
|
||
function getRslibConfig(options: Options) { | ||
const { format, bundle, umdName, tsconfigPath } = { | ||
...defaultOptions, | ||
...options, | ||
}; | ||
|
||
const libs = format.map(libFormat => { | ||
const lib = getLibShared(libFormat, bundle!); | ||
if (libFormat === 'umd') { | ||
lib.umdName = umdName; | ||
lib.bundle = true; | ||
} | ||
return lib; | ||
}); | ||
|
||
libs[0].dts = { | ||
distPath: './dist/types', | ||
}; | ||
|
||
return defineConfig({ | ||
source: { | ||
tsconfigPath, | ||
}, | ||
lib: libs, | ||
}); | ||
} | ||
|
||
function getLibShared(format: LibFormat, bundleType: BundleType) { | ||
const shared: LibConfig = { | ||
output: { | ||
distPath: { | ||
root: `./dist/${format}`, | ||
}, | ||
}, | ||
format, | ||
syntax: 'es6', | ||
bundle: !!bundleType, | ||
autoExternal: bundleType === 'excludeExternal', | ||
}; | ||
return shared; | ||
} | ||
|
||
export default getRslibConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "@coze-infra/rslib-config", | ||
"version": "0.0.1", | ||
"author": "[email protected]", | ||
"maintainers": [], | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"scripts": { | ||
"build": "exit", | ||
"lint": "exit", | ||
"test": "exit", | ||
"test:cov": "exit 0" | ||
}, | ||
"dependencies": { | ||
"@rslib/core": "0.0.18" | ||
}, | ||
"devDependencies": { | ||
"@coze-infra/eslint-config": "workspace:*", | ||
"@coze-infra/ts-config": "workspace:*", | ||
"@types/node": "^20", | ||
"@vitejs/plugin-react": "~4.3.3", | ||
"@vitest/coverage-v8": "~2.1.4", | ||
"happy-dom": "~15.11.0", | ||
"sucrase": "^3.32.0", | ||
"typescript": "^5.5.3", | ||
"vitest": "~2.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,10 @@ | ||
import { defineConfig, type LibConfig } from '@rslib/core'; | ||
|
||
function getLibShared(format: LibConfig['format']) { | ||
const shared: LibConfig = { | ||
output: { | ||
distPath: { | ||
root: `./dist/${format}`, | ||
}, | ||
}, | ||
format, | ||
syntax: 'es6', | ||
}; | ||
return shared; | ||
} | ||
|
||
export default defineConfig({ | ||
source: { | ||
import { defineConfig } from '@rslib/core'; | ||
import getRslibConfig from '@coze-infra/rslib-config'; | ||
export default defineConfig( | ||
getRslibConfig({ | ||
format: ['esm', 'cjs', 'umd'], | ||
bundle: 'excludeExternal', | ||
umdName: 'CozeJs', | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
lib: [ | ||
{ | ||
...getLibShared('esm'), | ||
dts: { | ||
distPath: './dist/types', | ||
}, | ||
}, | ||
{ | ||
...getLibShared('umd'), | ||
umdName: 'CozeJs', | ||
}, | ||
getLibShared('cjs'), | ||
], | ||
}); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,9 @@ | ||
import { defineConfig, type LibConfig } from '@rslib/core'; | ||
|
||
function getLibShared(format: LibConfig['format']) { | ||
const shared: LibConfig = { | ||
output: { | ||
distPath: { | ||
root: `./dist/${format}`, | ||
}, | ||
}, | ||
format, | ||
syntax: 'es6', | ||
autoExternal: false, | ||
}; | ||
return shared; | ||
} | ||
|
||
export default defineConfig({ | ||
source: { | ||
import { defineConfig } from '@rslib/core'; | ||
import getRslibConfig from '@coze-infra/rslib-config'; | ||
export default defineConfig( | ||
getRslibConfig({ | ||
format: ['esm', 'cjs', 'umd'], | ||
umdName: 'CozeRealtimeApi', | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
output: { | ||
target: 'web', | ||
}, | ||
lib: [ | ||
{ | ||
...getLibShared('esm'), | ||
dts: { | ||
distPath: './dist/types', | ||
}, | ||
}, | ||
{ | ||
...getLibShared('umd'), | ||
umdName: 'CozeRealtimeApi', | ||
}, | ||
getLibShared('cjs'), | ||
], | ||
}); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters