Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jaywcjlove/tsbb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0
Choose a base ref
...
head repository: jaywcjlove/tsbb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.1
Choose a head ref
  • 4 commits
  • 20 files changed
  • 1 contributor

Commits on Mar 29, 2023

  1. Copy the full SHA
    fa0d90c View commit details
  2. Copy the full SHA
    1f0747e View commit details
  3. released v4.0.1

    jaywcjlove committed Mar 29, 2023
    Copy the full SHA
    95b8981 View commit details
  4. Copy the full SHA
    b3d6865 View commit details
4 changes: 2 additions & 2 deletions examples/babel-transform-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@template/babel-transform-ts",
"private": true,
"version": "4.0.0",
"version": "4.0.1",
"description": "Transform Typescript Example.",
"scripts": {
"watch": "tsbb watch 'src/**/*.ts' --use-babel --no-esm",
@@ -17,6 +17,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
4 changes: 2 additions & 2 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/basic",
"version": "4.0.0",
"version": "4.0.1",
"description": "Basic Example.",
"license": "MIT",
"private": true,
@@ -17,6 +17,6 @@
},
"keywords": [],
"devDependencies": {
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
4 changes: 2 additions & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/express",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"description": "Express Example.",
"scripts": {
@@ -31,7 +31,7 @@
"@types/http-errors": "~2.0.1",
"nodemon": "~2.0.22",
"ts-node-dev": "~2.0.0",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
},
"dependencies": {
"compression": "~1.7.4",
4 changes: 2 additions & 2 deletions examples/hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/hapi",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"description": "hapi Example.",
"main": "index.js",
@@ -29,7 +29,7 @@
},
"devDependencies": {
"nodemon": "~2.0.22",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
},
"dependencies": {
"@hapi/hapi": "^21.3.0"
4 changes: 2 additions & 2 deletions examples/koa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/koa",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"description": "Koa Example",
"scripts": {
@@ -28,7 +28,7 @@
"devDependencies": {
"@types/koa": "^2.13.5",
"nodemon": "~2.0.22",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
},
"dependencies": {
"koa": "^2.14.1"
4 changes: 2 additions & 2 deletions examples/react-component-tsx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/react-component-tsx",
"version": "4.0.0",
"version": "4.0.1",
"description": "React Component Example for TypeScript.",
"private": true,
"main": "lib/index.js",
@@ -51,7 +51,7 @@
"prettier": "^2.8.6",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
},
"eslintConfig": {
"extends": [
4 changes: 2 additions & 2 deletions examples/react-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@template/react-component",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"description": "React Component Example.",
"scripts": {
@@ -43,7 +43,7 @@
"less": "~4.1.3",
"parcel": "~2.8.3",
"react-test-renderer": "~18.2.0",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
},
"dependencies": {
"@parcel/transformer-react-refresh-wrap": "~2.8.3",
4 changes: 2 additions & 2 deletions examples/typenexus/package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "@template/typenexus",
"private": true,
"type": "module",
"version": "4.0.0",
"version": "4.0.1",
"description": "TypeNexus Example.",
"scripts": {
"start": "npm run build && node dist/main.js",
@@ -32,6 +32,6 @@
"supertest": "^6.3.3",
"supertest-session": "^4.1.0",
"ts-node": "^10.9.1",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
4 changes: 2 additions & 2 deletions examples/umd/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@template/umd",
"private": true,
"version": "4.0.0",
"version": "4.0.1",
"description": "UMD Example.",
"scripts": {
"watch": "tsbb watch",
@@ -16,6 +16,6 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
4 changes: 2 additions & 2 deletions examples/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@template/vue",
"private": true,
"version": "4.0.0",
"version": "4.0.1",
"description": "",
"main": "./cjs/index.js",
"module": "./esm/index.js",
@@ -15,6 +15,6 @@
"vue": "^3.0.0"
},
"devDependencies": {
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.0.0",
"version": "4.0.1",
"packages": ["examples/*", "packages/*"],
"useWorkspaces": true
}
4 changes: 2 additions & 2 deletions packages/babel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/babel",
"version": "4.0.0",
"version": "4.0.1",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
@@ -38,7 +38,7 @@
"@babel/preset-env": "~7.20.2",
"@babel/preset-react": "~7.18.6",
"@babel/preset-typescript": "~7.21.0",
"@tsbb/typescript": "4.0.0",
"@tsbb/typescript": "4.0.1",
"@types/babel__core": "^7.20.0",
"@types/semver": "~7.3.13",
"@vue/babel-plugin-jsx": "~1.1.1",
130 changes: 66 additions & 64 deletions packages/babel/src/index.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import path from 'node:path';
import { Log, __dirname } from '@tsbb/typescript';
import { TransformOptions } from '@babel/core';
import babelPluginJsx from '@vue/babel-plugin-jsx';
// import { TransformOptions } from '@babel/core';
import { transform } from './transform.js';
import { getOutputPath } from './utils.js';
import { getCjsTransformOption, getESMTransformOption } from './config.js';
@@ -74,77 +75,78 @@ export default async function compile(fileName: string, options: BabelCompileOpt
if ((options.sourceMaps as string) === 'true') {
options.sourceMaps = true;
}
let babelOptions =
typeof esm === 'string' ? getESMTransformOption() : typeof cjs === 'string' ? getCjsTransformOption() : {};

let esmBabelOptions = getESMTransformOption();
if (useVue) {
// @ts-ignore
babelOptions.plugins?.push(babelPluginJsx.default);
babelOptions.sourceMaps = options.sourceMaps || babelOptions.sourceMaps;
esmBabelOptions.plugins?.push(babelPluginJsx.default);
}
babelOptions.babelrc = true;
babelOptions.cwd = dt.projectDirectory;
if (envName) {
babelOptions = {};
babelOptions.envName = envName;
esmBabelOptions = {};
esmBabelOptions.envName = envName;
}
esmBabelOptions.sourceMaps = options.sourceMaps || esmBabelOptions.sourceMaps;
esmBabelOptions.babelrc = true;
esmBabelOptions.cwd = dt.projectDirectory;

if (typeof esm === 'string') {
babelOptions.sourceFileName = path.relative(path.dirname(dt.esm.path), fileName);
transform(fileName, { ...babelOptions })
.then((result) => {
fs.ensureFileSync(dt.esm.path);
fs.writeFile(dt.esm.path, result?.code || '');
log.icon('🐶').success(`┈┈▶ \x1b[32;1m${dt.folderFilePath}\x1b[0m => \x1b[34;1m${dt.esm.fileName}\x1b[0m`);
if (babelOptions.sourceMaps === 'both' || babelOptions.sourceMaps) {
if (result?.map) {
const sourceMapPath = path.join(dt.esm.path + '.map');
fs.writeFileSync(sourceMapPath, JSON.stringify(result?.map, null, 2));
log
.icon('🐶')
.success(
`┈┈▶ \x1b[32;1m${dt.folderFilePath}\x1b[0m => \x1b[34;1m${path.relative(
dt.projectDirectory,
sourceMapPath,
)}\x1b[0m`,
);
}
}
})
.catch((error) => {
if (error instanceof Error) {
log.icon('\n🚨').error(`\x1b[33;1m ${error.message}\x1b[0m\n`);
} else {
log.icon('\n🚨').error(`\x1b[33;1m ${JSON.stringify(error)}\x1b[0m\n`);
}
});
transformFile(fileName, dt.esm.path, dt.folderFilePath, dt.projectDirectory, dt.esm.fileName, esmBabelOptions);
}

let cjsBabelOptions = getCjsTransformOption();
if (useVue) {
// @ts-ignore
cjsBabelOptions.plugins?.push(babelPluginJsx.default);
}
if (envName) {
cjsBabelOptions = {};
cjsBabelOptions.envName = envName;
}
cjsBabelOptions.sourceMaps = options.sourceMaps || cjsBabelOptions.sourceMaps;
cjsBabelOptions.babelrc = true;
cjsBabelOptions.cwd = dt.projectDirectory;

if (typeof cjs === 'string') {
babelOptions.sourceFileName = path.relative(path.dirname(dt.cjs.path), fileName);
transform(fileName, { ...babelOptions })
.then((result) => {
fs.ensureFileSync(dt.cjs.path);
fs.writeFile(dt.cjs.path, result?.code || '');
log.icon('🐶').success(`┈┈▶ \x1b[33;1m${dt.folderFilePath}\x1b[0m => \x1b[33;1m${dt.cjs.fileName}\x1b[0m`);
if (babelOptions.sourceMaps === 'both' || babelOptions.sourceMaps) {
if (result?.map) {
const sourceMapPath = path.join(dt.cjs.path + '.map');
fs.writeFileSync(sourceMapPath, JSON.stringify(result?.map, null, 2));
log
.icon('🐶')
.success(
`┈┈▶ \x1b[33;1m${dt.folderFilePath}\x1b[0m => \x1b[33;1m${path.relative(
dt.projectDirectory,
sourceMapPath,
)}\x1b[0m`,
);
}
}
})
.catch((error) => {
if (error instanceof Error) {
log.icon('\n🚨').error(`\x1b[33;1m ${error.message}\x1b[0m\n`);
} else {
log.icon('\n🚨').error(`\x1b[33;1m ${JSON.stringify(error)}\x1b[0m\n`);
}
});
transformFile(fileName, dt.cjs.path, dt.folderFilePath, dt.projectDirectory, dt.cjs.fileName, cjsBabelOptions);
}
}

function transformFile(
fileName: string,
outputFile: string,
folderFilePath: string,
projectDirectory: string,
outFileName: string,
options: TransformOptions,
) {
const log = new Log();
log.name();
options.sourceFileName = path.relative(path.dirname(outputFile), fileName);
transform(fileName, { ...options })
.then((result) => {
fs.ensureFileSync(outputFile);
fs.writeFile(outputFile, result?.code || '');
log.icon('🐶').success(`┈┈▶ \x1b[33;1m${folderFilePath}\x1b[0m => \x1b[33;1m${outFileName}\x1b[0m`);
if (options.sourceMaps === 'both' || options.sourceMaps) {
if (result?.map) {
const sourceMapPath = path.join(outputFile + '.map');
fs.writeFileSync(sourceMapPath, JSON.stringify(result?.map, null, 2));
log
.icon('🐶')
.success(
`┈┈▶ \x1b[33;1m${folderFilePath}\x1b[0m => \x1b[33;1m${path.relative(
projectDirectory,
sourceMapPath,
)}\x1b[0m`,
);
}
}
})
.catch((error) => {
if (error instanceof Error) {
log.icon('\n🚨').error(`\x1b[33;1m ${error.message}\x1b[0m\n`);
} else {
log.icon('\n🚨').error(`\x1b[33;1m ${JSON.stringify(error)}\x1b[0m\n`);
}
});
}
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/core",
"version": "4.0.0",
"version": "4.0.1",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
@@ -32,9 +32,9 @@
"node": ">=16.0.0"
},
"dependencies": {
"@tsbb/babel": "4.0.0",
"@tsbb/jest": "4.0.0",
"@tsbb/typescript": "4.0.0",
"@tsbb/babel": "4.0.1",
"@tsbb/jest": "4.0.1",
"@tsbb/typescript": "4.0.1",
"@types/fs-extra": "^11.0.1",
"chokidar": "~3.5.3",
"fs-extra": "^11.1.1",
2 changes: 1 addition & 1 deletion packages/core/src/watcher/babelTransform.ts
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ export function babelTransform(options: CompileOptions = {}) {
onWriteFile,
});
}
watcherCopyFiles(entry, { isWatch: options.watch, onFilesChange, onReady });
watcherCopyFiles(entry, { isWatch: options.watch, onFilesChange, onReady, rootDirsRelative });
}

const writeFile = (to: string, target: string, fileName: string, content: string, writeByteOrderMark?: boolean) => {
4 changes: 2 additions & 2 deletions packages/create-tsbb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-tsbb",
"version": "4.0.0",
"version": "4.0.1",
"description": "Creates a TSBB application using the command line.",
"homepage": "https://jaywcjlove.github.io/tsbb/create-tsbb.html",
"author": "Kenny Wong <wowohoo@qq.com> (https://github.com/jaywcjlove)",
@@ -55,6 +55,6 @@
},
"devDependencies": {
"cpy": "^9.0.1",
"tsbb": "4.0.0"
"tsbb": "4.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsbb/jest",
"version": "4.0.0",
"version": "4.0.1",
"description": "TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.",
"author": "kenny wang <wowohoo@qq.com>",
"homepage": "https://jaywcjlove.github.io/tsbb",
Loading