Skip to content

Commit 36cfd65

Browse files
committed
✨ build with unbuild
1 parent 18052a9 commit 36cfd65

File tree

6 files changed

+32
-22
lines changed

6 files changed

+32
-22
lines changed

bin/cli.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {main} from "../dist/index.mjs";
2+
3+
main();

build.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineBuildConfig } from "unbuild";
2+
3+
export default defineBuildConfig({
4+
entries: ["./src/index.ts"],
5+
});

index.cjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "0.1.7",
44
"description": "A CLI for scaffolding Babylon.js Web App.",
55
"type": "commonjs",
6-
"main": "index.cjs",
6+
"main": "./bin/cli.mjs",
77
"bin": {
8-
"create-babylon-app": "index.cjs"
8+
"create-babylon-app": "./bin/cli.mjs"
99
},
1010
"homepage": "https://github.com/drumath2237/create-babylon-app",
1111
"repository": {
@@ -14,8 +14,8 @@
1414
},
1515
"scripts": {
1616
"dev": "vite-node src/index.ts",
17-
"build": "tsc -b",
18-
"start": "node ./index.cjs",
17+
"build": "unbuild",
18+
"start": "node ./bin/cli.mjs",
1919
"version:set": "pnpm exec lerna version",
2020
"lint": "biome lint ./src",
2121
"format": "biome format --write ./src",

src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { log } from "node:console";
22
import { mkdir } from "node:fs/promises";
33
import path from "node:path";
44
import { input, select } from "@inquirer/prompts";
5-
import { copy, readJSON, writeJson } from "fs-extra";
5+
import { copy, readJSON, writeJson } from "fs-extra/esm";
6+
import { fileURLToPath } from "node:url";
67

7-
const main = async (): Promise<void> => {
8+
export const main = async (): Promise<void> => {
89
const projectName = await input({
910
message: "Project Name:",
1011
default: "Babylon-App",
@@ -28,7 +29,7 @@ const main = async (): Promise<void> => {
2829
});
2930

3031
const templateDir = path.resolve(
31-
__filename,
32+
fileURLToPath(import.meta.url),
3233
"../..",
3334
"templates",
3435
`${buildTool}-${language}`,
@@ -48,5 +49,3 @@ const main = async (): Promise<void> => {
4849
log("\nDone!");
4950
log(` cd ${projectName}\n`);
5051
};
51-
52-
main();

tsconfig.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4-
"module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
5-
"outDir": "./dist" /* Redirect output structure to the directory. */,
6-
"strict": true /* Enable all strict type-checking options. */,
7-
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
8-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
9-
"skipLibCheck": true
10-
},
11-
"include": ["src/**/*"],
12-
"exclude": ["node_modules"]
2+
"compilerOptions": {
3+
"esModuleInterop": false,
4+
"allowSyntheticDefaultImports": true,
5+
"skipLibCheck": true,
6+
"target": "ESNext",
7+
"module": "ESNext",
8+
"moduleResolution": "Bundler",
9+
"strict": true,
10+
"noImplicitAny": true,
11+
"allowJs": true,
12+
"noEmit": true,
13+
"noUnusedLocals": true,
14+
"resolveJsonModule": true
15+
},
16+
"include": ["src"],
17+
"exclude": ["node_modules"]
1318
}

0 commit comments

Comments
 (0)