feat: 添加bun-test项目并配置Rollup打包
新增bun-test项目,包含Rollup配置、lodash-es依赖及示例代码,同时更新pnpm-lock.yaml
This commit is contained in:
2
bun-test/.gitignore
vendored
Normal file
2
bun-test/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
||||
22
bun-test/package.json
Normal file
22
bun-test/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "bun-test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@10.25.0",
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.3.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
"esbuild": "^0.27.2",
|
||||
"lodash-es": "^4.17.22",
|
||||
"rollup": "^4.54.0"
|
||||
}
|
||||
}
|
||||
31
bun-test/rollup.config.ts
Normal file
31
bun-test/rollup.config.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// rollup.config.ts
|
||||
import type { Plugin, RollupOptions } from 'rollup';
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
|
||||
const cdnRewritePlugin: Plugin = {
|
||||
name: 'rewrite-lodash-to-cdn',
|
||||
resolveId(id) {
|
||||
if (id === 'lodash-es') {
|
||||
return 'https://esm.sh/lodash-es@5';
|
||||
}
|
||||
if (id.startsWith('lodash-es/')) {
|
||||
const [, sub] = id.split('/', 2);
|
||||
return `https://esm.sh/lodash-es@5/${sub}`;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
const config: RollupOptions = {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
dir: 'dist',
|
||||
format: 'esm',
|
||||
},
|
||||
plugins: [cdnRewritePlugin, nodeResolve({ browser: true })],
|
||||
external(id) {
|
||||
return id.startsWith('https://');
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
3
bun-test/src/index.ts
Normal file
3
bun-test/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { debounce } from 'lodash-es';
|
||||
|
||||
export const debounceFn = debounce;
|
||||
Reference in New Issue
Block a user