-
Notifications
You must be signed in to change notification settings - Fork 138
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 #391 from balancer/develop
4.1.1-beta.11
- Loading branch information
Showing
12 changed files
with
2,564 additions
and
2,352 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
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,69 +1,29 @@ | ||
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'; | ||
|
||
const pkg = JSON.parse( | ||
readFileSync(new URL('./package.json', import.meta.url)).toString() | ||
); | ||
import pkg from './package.json'; | ||
|
||
const external = [ | ||
...Object.keys(pkg.dependencies), | ||
...Object.keys(pkg.peerDependencies), | ||
]; | ||
|
||
export default [ | ||
{ | ||
treeshake: { moduleSideEffects: false }, | ||
input: 'src/index.ts', | ||
output: [ | ||
{ | ||
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, | ||
}), | ||
{ file: pkg.main, format: 'cjs', sourcemap: true }, | ||
{ file: pkg.module, format: 'es', sourcemap: true }, | ||
], | ||
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.