From de1d3f2bb201d1deb0ce925153def0040a48dc37 Mon Sep 17 00:00:00 2001 From: JeromeLin Date: Mon, 13 Mar 2023 17:51:01 +0800 Subject: [PATCH] chore(cli): build by tsc --- .gitignore | 25 ++++++++++++------------- packages/zarm-cli/babel.config.js | 11 ----------- packages/zarm-cli/bin/zarm.js | 2 +- packages/zarm-cli/package.json | 15 +++++++-------- packages/zarm-cli/src/cli.ts | 4 +++- packages/zarm-cli/tsconfig.json | 20 ++++++++++++++++---- yarn.lock | 4 ++-- 7 files changed, 41 insertions(+), 40 deletions(-) delete mode 100644 packages/zarm-cli/babel.config.js diff --git a/.gitignore b/.gitignore index 8cf6ba49f..c963a3c26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,20 @@ -_book +*.log* .DS_Store .idea .vscode .history -.prettierrc.yaml -*.log -*.iml + +# npm package-lock.json -/node_modules/ -/packages/*/node_modules/ +node_modules # bundle files -/packages/*/dist/ -/packages/*/es/ -/packages/*/lib/ -/packages/*/native/ -/packages/*/types/ +es +lib +dist +types + +# test +coverage -# test coverage -/packages/*/coverage/ +*.tsbuildinfo diff --git a/packages/zarm-cli/babel.config.js b/packages/zarm-cli/babel.config.js deleted file mode 100644 index 0fbae32f3..000000000 --- a/packages/zarm-cli/babel.config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - presets: [ - require.resolve('@babel/preset-env'), - require.resolve('@babel/preset-react'), - require.resolve('@babel/preset-typescript'), - ], - plugins: [ - require.resolve('@babel/plugin-transform-runtime'), - [require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }], - ], -}; diff --git a/packages/zarm-cli/bin/zarm.js b/packages/zarm-cli/bin/zarm.js index 11a72256c..de1823099 100755 --- a/packages/zarm-cli/bin/zarm.js +++ b/packages/zarm-cli/bin/zarm.js @@ -3,5 +3,5 @@ const importLocal = require('import-local'); if (!importLocal(__filename)) { - require('../lib/cli'); + require('../dist/cli'); } diff --git a/packages/zarm-cli/package.json b/packages/zarm-cli/package.json index a9f592db4..54ffca194 100644 --- a/packages/zarm-cli/package.json +++ b/packages/zarm-cli/package.json @@ -10,7 +10,8 @@ ], "license": "MIT", "author": "jerome.lin@zhongan.com", - "typings": "types/index.d.ts", + "main": "dist/index.js", + "typings": "dist/index.d.ts", "bin": { "zarm": "./bin/zarm.js" }, @@ -20,16 +21,13 @@ "types" ], "scripts": { - "build": "yarn build:types && yarn build:lib", - "build:lib": "rimraf lib && babel src --extensions .ts --out-dir lib --copy-files", - "build:types": "rimraf types && tsc", - "clean": "rimraf types lib coverage", - "dev": "yarn build:lib -w", + "build": "rimraf dist/ && tsc --build --force", + "clean": "rimraf dist/ && tsc --build --clean", + "dev": "tsc -w", "prepare": "yarn build", "test": "jest" }, "dependencies": { - "@babel/cli": "^7.13.10", "@babel/core": "^7.13.10", "@babel/plugin-proposal-class-properties": "^7.13.0", "@babel/plugin-proposal-decorators": "^7.13.5", @@ -81,7 +79,8 @@ }, "devDependencies": { "@types/node": "^15.3.0", - "@types/webpack": "^5.28.0" + "@types/webpack": "^5.28.0", + "ts-node": "^10.9.1" }, "tags": [ "zarm", diff --git a/packages/zarm-cli/src/cli.ts b/packages/zarm-cli/src/cli.ts index b84d67542..889a71adb 100644 --- a/packages/zarm-cli/src/cli.ts +++ b/packages/zarm-cli/src/cli.ts @@ -1,11 +1,13 @@ import commander from 'commander'; +import path from 'path'; import build from './build'; import development from './development'; import deploy from './deploy'; import template from './template'; import test from './test'; -import { version } from '../package.json'; + +const { version } = require(path.resolve('./package.json')); commander.version(version); diff --git a/packages/zarm-cli/tsconfig.json b/packages/zarm-cli/tsconfig.json index 2b26c5748..af055ee0d 100644 --- a/packages/zarm-cli/tsconfig.json +++ b/packages/zarm-cli/tsconfig.json @@ -1,9 +1,21 @@ { - "extends": "../../tsconfig", + "include": ["src"], "compilerOptions": { - "outFile": "types/index.d.ts", + "module": "CommonJS", + "target": "ES2018", + "moduleResolution": "node", + "esModuleInterop": true, "declaration": true, - "emitDeclarationOnly": true + "sourceMap": true, + "declarationMap": true, + "composite": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "outDir": "dist", + "rootDir": "src" }, - "include": ["src"] + "ts-node": { + "transpileOnly": true, + "swc": true + } } diff --git a/yarn.lock b/yarn.lock index 4952bfef4..aa222fddf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -60,7 +60,7 @@ lodash "^4.17.21" resize-observer-polyfill "^1.5.1" -"@babel/cli@^7.13.10", "@babel/cli@^7.13.16": +"@babel/cli@^7.13.16": version "7.13.16" resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.13.16.tgz#9d372e943ced0cc291f068204a9b010fd9cfadbc" integrity sha512-cL9tllhqvsQ6r1+d9Invf7nNXg/3BlfL1vvvL/AdH9fZ2l5j0CeBcoq6UjsqHpvyN1v5nXSZgqJZoGeK+ZOAbw== @@ -18776,7 +18776,7 @@ ts-jest@^26.5.0: semver "7.x" yargs-parser "20.x" -ts-node@^10.8.1: +ts-node@^10.8.1, ts-node@^10.9.1: version "10.9.1" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==