chore(popperjs): use Rslib to build (#13252)

This commit is contained in:
neverland 2024-12-08 16:44:55 +08:00 committed by GitHub
parent e825175615
commit 8018fc19e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 23 additions and 63 deletions

View File

@ -1 +0,0 @@
lib

View File

@ -1 +0,0 @@
require('../vant-use/build.cjs');

View File

@ -2,13 +2,15 @@
"name": "@vant/popperjs", "name": "@vant/popperjs",
"version": "1.3.0", "version": "1.3.0",
"description": "Pre-compiled popperjs core", "description": "Pre-compiled popperjs core",
"main": "dist/index.cjs.js", "type": "module",
"module": "dist/index.esm.mjs", "main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"import": "./dist/index.esm.mjs", "types": "./dist/index.d.ts",
"require": "./dist/index.cjs.js" "import": "./dist/index.js",
"require": "./dist/index.cjs"
} }
}, },
"sideEffects": false, "sideEffects": false,
@ -20,11 +22,8 @@
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
}, },
"scripts": { "scripts": {
"clean": "rimraf ./dist", "dev": "rslib dev",
"dev": "node ./build.js -w", "build": "rslib build",
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
"build:bundle": "node ./build.js",
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
"release": "vant-cli release", "release": "vant-cli release",
"prepare": "pnpm build" "prepare": "pnpm build"
}, },
@ -38,8 +37,7 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@popperjs/core": "^2.11.8", "@popperjs/core": "^2.11.8",
"esbuild": "^0.24.0", "@rslib/core": "^0.1.3",
"rimraf": "^6.0.1",
"typescript": "^5.7.2" "typescript": "^5.7.2"
} }
} }

View File

@ -0,0 +1,11 @@
import { defineConfig } from '@rslib/core';
export default defineConfig({
lib: [
{ format: 'esm', syntax: ['Chrome 53'], dts: true },
{ format: 'cjs', syntax: ['Chrome 53'] },
],
output: {
target: 'web',
},
});

View File

@ -1,40 +0,0 @@
const { build, context } = require('esbuild');
async function bundle(format) {
const ext = format === 'esm' ? '.mjs' : '.js';
const outfile = `dist/index.${format}${ext}`;
const finish = () => console.log('Build finished:', outfile);
const options = {
format,
bundle: true,
target: ['chrome53'],
outfile,
// preserve Chinese character
charset: 'utf8',
external: ['vue', 'vant'],
entryPoints: ['./src/index.ts'],
};
if (process.argv.includes('-w')) {
const loggerPlugin = {
name: 'loggerPlugin',
setup(build) {
build.onEnd(finish);
},
};
const ctx = await context({
...options,
plugins: [loggerPlugin],
});
await ctx.watch();
} else {
await build(options);
finish();
}
}
bundle('esm');
bundle('cjs');

View File

@ -37,7 +37,6 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@rslib/core": "^0.1.3", "@rslib/core": "^0.1.3",
"esbuild": "^0.24.0",
"typescript": "^5.7.2", "typescript": "^5.7.2",
"vue": "^3.5.13" "vue": "^3.5.13"
}, },

12
pnpm-lock.yaml generated
View File

@ -329,12 +329,9 @@ importers:
'@popperjs/core': '@popperjs/core':
specifier: ^2.11.8 specifier: ^2.11.8
version: 2.11.8 version: 2.11.8
esbuild: '@rslib/core':
specifier: ^0.24.0 specifier: ^0.1.3
version: 0.24.0 version: 0.1.3(typescript@5.7.2)
rimraf:
specifier: ^6.0.1
version: 6.0.1
typescript: typescript:
specifier: ^5.7.2 specifier: ^5.7.2
version: 5.7.2 version: 5.7.2
@ -346,9 +343,6 @@ importers:
'@rslib/core': '@rslib/core':
specifier: ^0.1.3 specifier: ^0.1.3
version: 0.1.3(typescript@5.7.2) version: 0.1.3(typescript@5.7.2)
esbuild:
specifier: ^0.24.0
version: 0.24.0
typescript: typescript:
specifier: ^5.7.2 specifier: ^5.7.2
version: 5.7.2 version: 5.7.2