chore: 移除 js 文件

pull/41/head
zjx0905 2023-04-17 00:00:45 +08:00
parent f2d855d25a
commit d065103c70
8 changed files with 61 additions and 19 deletions

View File

@ -44,7 +44,7 @@ jobs:
- name: Build asset
run: pnpm build:asset
- name: Test
- name: Typecheck
run: pnpm typecheck
- name: Test

View File

@ -17,12 +17,8 @@
"axios",
"miniprogram",
"request",
"promise",
"alipay",
"uni-app",
"wechat",
"fetch",
"network"
"wechat"
],
"author": "zjx0905 <954270063@qq.com>",
"bugs": {
@ -54,6 +50,7 @@
"devDependencies": {
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@rollup/plugin-typescript": "^11.1.0",
"@types/node": "^18.15.5",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
@ -78,6 +75,7 @@
"rollup-plugin-esbuild": "^5.0.0",
"semver": "^7.3.8",
"simple-git-hooks": "^2.8.1",
"tslib": "^2.5.0",
"typescript": "^5.0.2",
"vitest": "^0.30.0"
},

View File

@ -6,6 +6,7 @@ importers:
specifiers:
'@commitlint/cli': ^17.4.4
'@commitlint/config-conventional': ^17.4.4
'@rollup/plugin-typescript': ^11.1.0
'@types/node': ^18.15.5
'@typescript-eslint/eslint-plugin': ^5.55.0
'@typescript-eslint/parser': ^5.55.0
@ -30,11 +31,13 @@ importers:
rollup-plugin-esbuild: ^5.0.0
semver: ^7.3.8
simple-git-hooks: ^2.8.1
tslib: ^2.5.0
typescript: ^5.0.2
vitest: ^0.30.0
devDependencies:
'@commitlint/cli': 17.5.0
'@commitlint/config-conventional': 17.4.4
'@rollup/plugin-typescript': 11.1.0_7sniqkrn5rmxrmax2dmiqcv3qu
'@types/node': 18.15.5
'@typescript-eslint/eslint-plugin': 5.56.0_2hcjazgfnbtq42tcc73br2vup4
'@typescript-eslint/parser': 5.56.0_j4766f7ecgqbon3u7zlxn5zszu
@ -59,6 +62,7 @@ importers:
rollup-plugin-esbuild: 5.0.0_rollup@3.20.0
semver: 7.3.8
simple-git-hooks: 2.8.1
tslib: 2.5.0
typescript: 5.0.2
vitest: 0.30.0
@ -2136,6 +2140,26 @@ packages:
rollup: 3.20.0
dev: true
/@rollup/plugin-typescript/11.1.0_7sniqkrn5rmxrmax2dmiqcv3qu:
resolution: {integrity: sha512-86flrfE+bSHB69znnTV6kVjkncs2LBMhcTCyxWgRxLyfXfQrxg4UwlAqENnjrrxnSNS/XKCDJCl8EkdFJVHOxw==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^2.14.0||^3.0.0
tslib: '*'
typescript: '>=3.7.0'
peerDependenciesMeta:
rollup:
optional: true
tslib:
optional: true
dependencies:
'@rollup/pluginutils': 5.0.2_rollup@3.20.0
resolve: 1.22.1
rollup: 3.20.0
tslib: 2.5.0
typescript: 5.0.2
dev: true
/@rollup/pluginutils/3.1.0_rollup@2.79.1:
resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==}
engines: {node: '>= 8.0.0'}

View File

@ -1,7 +1,8 @@
import { readFileSync } from 'node:fs';
import { RollupOptions, OutputOptions, Plugin, ModuleFormat } from 'rollup';
import esbuildPlugin from 'rollup-plugin-esbuild';
import dtsPlugin from 'rollup-plugin-dts';
import { __dirname, distPath, getPkgJSON, resolve } from './scripts/utils.js';
import { __dirname, distPath, getPkgJSON, resolve } from './scripts/utils';
const pkg = getPkgJSON();
const inputPath = resolve('src/index.ts');
@ -19,9 +20,9 @@ function main() {
return configs;
}
function buildConfig(format) {
function buildConfig(format: ModuleFormat | 'dts'): RollupOptions {
const isDts = format === 'dts';
const output = {
const output: OutputOptions = {
file: resolveOutput(format, isDts),
format: isDts ? 'es' : format,
name: pkg.name,
@ -43,7 +44,7 @@ function buildConfig(format) {
]
: esbuildPlugin({
tsconfig: resolve('tsconfig.json'),
sourceMap: output.sourcemap,
sourceMap: output.sourcemap as boolean,
target: 'es2015',
minify: true,
}),
@ -51,11 +52,11 @@ function buildConfig(format) {
};
}
function resolveOutput(format, isDts) {
function resolveOutput(format: string, isDts?: boolean) {
return resolve(distPath, `${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`);
}
function compleTypePlugin(files) {
function compleTypePlugin(files: string[]): Plugin {
return {
name: 'comple-type',
renderChunk: (code) =>

View File

@ -16,7 +16,7 @@ function main() {
consola.info('Rollup');
try {
exec(
`rollup -c ${
`rollup -c rollup.config.ts --configPlugin typescript ${
watch ? '-w' : ''
} --environment SOURCE_MAP:${sourceMap},DTS:${dts}`,
);

View File

@ -36,6 +36,7 @@ function checkBranch() {
const releaseBranch = 'main';
const currentBranch = exec('git branch --show-current', {
stdio: 'pipe',
encoding: 'utf-8',
})
.toString()
.trim();

View File

@ -1,15 +1,25 @@
import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
import { execSync } from 'node:child_process';
import {
ExecSyncOptionsWithStringEncoding,
execSync,
} from 'node:child_process';
export const __dirname = fileURLToPath(new URL('../', import.meta.url));
export const require = createRequire(import.meta.url);
export const pkgPath = path.resolve(__dirname, 'package.json');
export const distPath = path.resolve(__dirname, 'dist');
export const resolve = (...paths) => path.resolve(__dirname, ...paths);
export const exec = (command, options) =>
execSync(command, { stdio: 'inherit', ...(options ?? {}) });
export const resolve = (...paths: string[]) =>
path.resolve(__dirname, ...paths);
export const exec = (
command: string,
options?: ExecSyncOptionsWithStringEncoding,
) => execSync(command, { stdio: 'inherit', ...(options ?? {}) });
export const getPkgJSON = () => require(pkgPath);
export const getFileName = (filePath) => filePath.match(/\/([^/]*)$/)[1];
export const getFileName = (filePath: string) =>
filePath.match(/\/([^/]*)$/)![1];

View File

@ -10,10 +10,18 @@
"moduleResolution": "node",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true,
"paths": {
"@/*": ["src/*"]
}
},
"include": ["./src", "./test", "./global.d.ts", "./global.variables.d.ts"],
"include": [
"./src",
"./test",
"./rollup.config.ts",
"./vitest.config.ts",
"./global.d.ts",
"./global.variables.d.ts"
],
"exclude": ["node_modules", "**/*.md", "**/dist"]
}