Update library build and test configuration.
This commit is contained in:
parent
13c852cd52
commit
0876c59c98
38
build.ts
38
build.ts
@ -1,38 +0,0 @@
|
|||||||
import {build} from "esbuild";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the library.
|
|
||||||
* @param devMode - Dev mode.
|
|
||||||
*/
|
|
||||||
function buildLibrary(devMode: boolean = false): void
|
|
||||||
{
|
|
||||||
// Compilation de l'application.
|
|
||||||
build({
|
|
||||||
entryPoints: ["src/index.ts"],
|
|
||||||
outfile: "lib/index.js",
|
|
||||||
bundle: true,
|
|
||||||
minify: true,
|
|
||||||
sourcemap: true,
|
|
||||||
format: "esm",
|
|
||||||
loader: {
|
|
||||||
".ts": "ts",
|
|
||||||
},
|
|
||||||
watch: devMode ? {
|
|
||||||
// Affichage suite à une recompilation.
|
|
||||||
onRebuild(error, result) {
|
|
||||||
console.log(new Date());
|
|
||||||
if (!error && result.errors.length == 0)
|
|
||||||
console.log("Successfully built.");
|
|
||||||
else
|
|
||||||
console.error("Error!");
|
|
||||||
}
|
|
||||||
} : false,
|
|
||||||
})
|
|
||||||
// Fonction lancée pour une compilation réussie.
|
|
||||||
.then(() => { console.log(new Date()); console.log("Success."); })
|
|
||||||
// Fonction lancée pour une compilation échouée.
|
|
||||||
.catch((e) => console.error(e.message));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
buildLibrary(process.argv?.[2] == "dev");
|
|
@ -1,5 +1,6 @@
|
|||||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||||
module.exports = {
|
|
||||||
|
export default {
|
||||||
preset: "ts-jest",
|
preset: "ts-jest",
|
||||||
testEnvironment: "node",
|
testEnvironment: "node",
|
||||||
|
|
||||||
|
29
package.json
29
package.json
@ -15,24 +15,29 @@
|
|||||||
"author": "Madeorsk <madeorsk@protonmail.com>",
|
"author": "Madeorsk <madeorsk@protonmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "parcel build",
|
"build": "tsc && vite build",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
|
"type": "module",
|
||||||
"source": "src/index.ts",
|
"source": "src/index.ts",
|
||||||
"main": "lib/index.js",
|
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
"main": "lib/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"lib/**/*"
|
"lib/**/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@parcel/packager-ts": "2.7.0",
|
"@types/jest": "^29.5.13",
|
||||||
"@parcel/transformer-typescript-types": "2.7.0",
|
"@types/node": "^22.7.4",
|
||||||
"@types/jest": "^28.1.6",
|
"jest": "^29.7.0",
|
||||||
"esbuild": "^0.15.8",
|
"reflect-metadata": "^0.2.2",
|
||||||
"jest": "^28.1.3",
|
"ts-jest": "^29.2.5",
|
||||||
"parcel": "^2.7.0",
|
"ts-node": "^10.9.2",
|
||||||
"ts-jest": "^28.0.7",
|
"typescript": "^5.6.2",
|
||||||
"ts-node": "^10.9.1",
|
"vite": "^5.4.8",
|
||||||
"typescript": "^4.7.4"
|
"vite-plugin-dts": "^4.2.2"
|
||||||
}
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"reflect-metadata": "^0.2.2"
|
||||||
|
},
|
||||||
|
"packageManager": "yarn@4.5.0"
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
export * from "./Model/Model";
|
export * from "./Model/Model";
|
||||||
|
|
||||||
export * from "./Model/Definition";
|
export * from "./Model/Definition";
|
||||||
|
@ -33,7 +33,7 @@ class Author extends Model<Author>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(name: string = undefined, firstName: string = undefined, email: string = undefined, createdAt: Date = undefined)
|
constructor(name: string = "", firstName: string = "", email: string = "", createdAt: Date = new Date())
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -1,25 +1,29 @@
|
|||||||
{
|
{
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "CommonJS"
|
"module": "ESNext",
|
||||||
|
"types": ["node"],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"files": ["src/index.ts"],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./lib/",
|
"outDir": "./lib/",
|
||||||
|
"incremental": true,
|
||||||
|
"sourceMap": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"sourceMap": true,
|
|
||||||
"module": "ES6",
|
"module": "ES6",
|
||||||
"moduleResolution": "Node",
|
|
||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
"lib": [
|
"lib": [
|
||||||
"ESNext",
|
"ESNext",
|
||||||
"DOM"
|
"DOM"
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
vite.config.ts
Normal file
30
vite.config.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import {ConfigEnv, defineConfig, UserConfig} from "vite";
|
||||||
|
import dts from "vite-plugin-dts";
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
|
||||||
|
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||||
|
return ({
|
||||||
|
build: {
|
||||||
|
outDir: "lib",
|
||||||
|
sourcemap: true,
|
||||||
|
minify: "esbuild",
|
||||||
|
lib: {
|
||||||
|
entry: "src/index.ts",
|
||||||
|
formats: ["es"],
|
||||||
|
fileName: "index",
|
||||||
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
external: ["reflect-metadata"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
dts({
|
||||||
|
insertTypesEntry: true,
|
||||||
|
rollupTypes: true,
|
||||||
|
exclude: ["node_modules"],
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user