fix(esm): add tsc alias

This commit is contained in:
Mauricio Siu 2024-09-29 21:43:25 -06:00
parent bd243d79e2
commit e99666f4c0
4 changed files with 37 additions and 26 deletions

View File

@ -1,25 +1,27 @@
// import esbuild from "esbuild";
import { build } from "esbuild";
import TsconfigPathsPlugin from "@esbuild-plugins/tsconfig-paths";
import path from "node:path";
// try {
// esbuild
// .build({
// entryPoints: ["./src/**/*.ts"],
// bundle: true,
// platform: "node",
// format: "cjs",
// target: "node18",
// outExtension: { ".js": ".js" },
// minify: true,
// outdir: "dist",
// tsconfig: "tsconfig.server.json",
// packages: "external",
// alias: {
// "@/server": "./src",
// },
// })
// .catch(() => {
// return process.exit(1);
// });
// } catch (error) {
// console.log(error);
// }
build({
entryPoints: ["./src/**/*.ts", "./src/**/*.tsx"], // Punto de entrada principal de tu aplicación
outdir: "dist",
bundle: false, // Cambia a true si deseas bundlear tu código
platform: "node",
format: "esm",
target: ["esnext"],
sourcemap: false,
tsconfig: "./tsconfig.server.json",
plugins: [
// TsconfigPathsPlugin({ tsconfig: "./tsconfig.server.json" }),
{
name: "AddJsExtensions",
setup(build) {
build.onResolve({ filter: /.*/ }, (args) => {
if (args.path.startsWith(".") && !path.extname(args.path)) {
return { path: `${args.path}.js` };
}
});
},
},
],
}).catch(() => process.exit(1));

View File

@ -7,7 +7,7 @@
"scripts": {
"dev": "tsup --config ./tsup.ts --watch",
"build": "tsc --project tsconfig.server.json && tsc-alias -p tsconfig.server.json",
"tsc": "tsc --project tsconfig.server.json",
"esbuild": "tsx ./esbuild.config.ts",
"build:types": "tsc --emitDeclarationOnly --experimenta-dts"
},
"dependencies": {
@ -48,6 +48,7 @@
"ssh2": "1.15.0"
},
"devDependencies": {
"tsx": "^4.7.1",
"tsc-alias": "1.8.10",
"@types/adm-zip": "^0.5.5",
"@types/bcrypt": "5.0.2",

View File

@ -10,10 +10,15 @@
"moduleResolution": "Node",
"baseUrl": ".",
"incremental": false,
"jsx": "react-jsx",
"paths": {
"@/server/*": ["src/*"]
}
},
"include": ["next-env.d.ts", "./src/**/*"],
"exclude": ["**/dist", "tsup.ts"]
"exclude": ["**/dist", "tsup.ts"],
"tsc-alias": {
"resolveFullPaths": true,
"verbose": false
}
}

View File

@ -695,6 +695,9 @@ importers:
tsup:
specifier: 6.4.0
version: 6.4.0(postcss@8.4.40)(typescript@5.5.3)
tsx:
specifier: ^4.7.1
version: 4.16.2
typescript:
specifier: ^5.4.2
version: 5.5.3