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

12
pnpm-lock.yaml generated
View File

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