-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from balancer/develop
Release 4.1.1-beta.10
- Loading branch information
Showing
11 changed files
with
2,349 additions
and
2,561 deletions.
There are no files selected for viewing
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,29 +1,69 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import { readFileSync } from 'node:fs'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import dts from 'rollup-plugin-dts'; | ||
import analyze from 'rollup-plugin-analyzer'; | ||
import terser from '@rollup/plugin-terser'; | ||
|
||
import pkg from './package.json'; | ||
const pkg = JSON.parse( | ||
readFileSync(new URL('./package.json', import.meta.url)).toString() | ||
); | ||
|
||
const external = [ | ||
...Object.keys(pkg.dependencies), | ||
...Object.keys(pkg.peerDependencies), | ||
]; | ||
|
||
export default [ | ||
{ | ||
treeshake: { moduleSideEffects: false }, | ||
input: 'src/index.ts', | ||
output: [ | ||
{ file: pkg.main, format: 'cjs', sourcemap: true }, | ||
{ file: pkg.module, format: 'es', sourcemap: true }, | ||
{ | ||
format: 'cjs', | ||
sourcemap: true, | ||
file: 'dist/cjs/index.js', | ||
}, | ||
{ | ||
format: 'es', | ||
sourcemap: true, | ||
dir: 'dist/esm', | ||
preserveModules: true, | ||
// preserveModulesRoot is needed to be compatible with nodeResolve plugin: | ||
// https://github.com/rollup/rollup/issues/3684 | ||
preserveModulesRoot: 'src', | ||
}, | ||
], | ||
plugins: [ | ||
json(), | ||
nodeResolve(), | ||
commonjs(), | ||
typescript(), | ||
terser({ | ||
compress: true, | ||
}), | ||
analyze({ | ||
hideDeps: true, | ||
limit: 5, | ||
summaryOnly: true, | ||
onAnalysis, | ||
}), | ||
], | ||
plugins: [nodeResolve(), json(), commonjs(), typescript()], | ||
external, | ||
}, | ||
{ | ||
treeshake: { moduleSideEffects: false }, | ||
input: 'src/index.ts', | ||
output: [{ file: 'dist/index.d.ts', format: 'es' }], | ||
plugins: [dts()], | ||
}, | ||
]; | ||
|
||
const limitKB = 750; | ||
|
||
function onAnalysis({ bundleSize }) { | ||
if (bundleSize / 1000 < limitKB) return; | ||
console.warn(`Bundle size exceeds ${limitKB} KB: ${bundleSize / 1000} KB`); | ||
return process.exit(1); | ||
} |
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
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
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
Oops, something went wrong.