Skip to content

Commit

Permalink
migrate to vite for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mgpai22 committed Feb 2, 2024
1 parent 7e09080 commit 230f2f8
Show file tree
Hide file tree
Showing 16 changed files with 829 additions and 5,892 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"env": { "es6": true },
"ignorePatterns": ["node_modules", "dist", "coverage"],
"ignorePatterns": ["node_modules", "dist", "coverage", "vite.config.ts", ".eslintrc", "tests"],
"plugins": ["import", "eslint-comments", "functional"],
"extends": [
"eslint:recommended",
Expand Down
67 changes: 31 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,59 @@
{
"version": "0.0.2-alpha",
"version": "0.0.14-alpha",
"license": "GPL-3.0-only",
"main": "dist/winter-cardano.cjs.production.min.js",
"module": "dist/winter-cardano.esm.js",
"typings": "dist/index.d.ts",
"type": "module",
"types": "./dist/index.d.ts",
"typings": "./dist/index.d.ts",
"files": [
"dist",
"src"
"./dist",
"./src"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/winter-cardano.cjs",
"default": "./dist/winter-cardano.js"
}
},
"engines": {
"node": ">=18"
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"format": "prettier --log-level silent --write src/**/*.ts test/**/*.ts",
"clean": "rm -r dist/*",
"build": "vite build",
"lint": "tsdx lint src",
"format": "prettier --log-level log --write src/**/*.ts tests/**/*.ts",
"test": "vitest run",
"fix:lint": "eslint ./ --ext .ts --fix",
"test:lint": "eslint ./ --ext .ts",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
"release": "npm run build && npm publish"
},
"name": "winter-cardano",
"author": "Zengate",
"description": "TypeScript implementation of the WINTER traceability protocol for Cardano blockchain.",
"size-limit": [
{
"path": "dist/winter-cardano.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/winter-cardano.esm.js",
"limit": "10 KB"
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^8.2.6",
"@types/node": "^20.10.7",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.18.0",
"esbuild": "^0.20.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^6.0.0",
"eslint-plugin-import": "^2.29.0",
"husky": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.0.3",
"size-limit": "^8.2.6",
"tsdx": "^0.14.1",
"tslib": "^2.6.1",
"rollup": "^4.9.6",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.1",
"typescript": "^5.3.3",
"typescript-eslint-parser": "^22.0.0",
"vitest": "^0.34.2"
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
},
"dependencies": {
"lucid-cardano": "^0.10.7"
"lucid-cardano": "^0.10.7",
"tsx": "^4.7.0"
}
}
16 changes: 8 additions & 8 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {
Data,
fromText,
Lucid,
MintingPolicy,
Network,
OutRef,
PrivateKey,
type MintingPolicy,
type Network,
type OutRef,
type PrivateKey,
Provider,
SpendingValidator,
type SpendingValidator,
TxComplete,
UTxO
type UTxO
} from 'lucid-cardano';
import { WINTER_FEE, WINTER_FEE_ADDRESS_MAINNET, WINTER_FEE_ADDRESS_TESTNET } from './fee';
import { Koios } from './koios/api';
import { ObjectDatumParameters, Seed, Validators } from './models/event.types';
import { PlutusJson } from './models/plutus.types';
import type { ObjectDatumParameters, Seed, Validators } from './models';
import type { PlutusJson } from './models';
import { PLUTUSJSON } from './plutus';

const ObjectDatum = Data.Object({
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './fee';
export * from './koios/api';
export * from './models';
export * from './events';
export * from './fee';
export * from './plutus';
2 changes: 1 addition & 1 deletion src/koios/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScriptInfo } from '../models/koios.types';
import type { ScriptInfo } from '../models';

export class Koios {
private readonly baseUrl: string;
Expand Down
2 changes: 1 addition & 1 deletion src/models/event.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MintingPolicy, SpendingValidator } from 'lucid-cardano';
import type { MintingPolicy, SpendingValidator } from 'lucid-cardano';

export interface ObjectDatumParameters {
protocolVersion: bigint;
Expand Down
3 changes: 3 additions & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './event.types';
export * from './koios.types';
export * from './plutus.types';
2 changes: 1 addition & 1 deletion src/plutus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlutusJson } from './models/plutus.types';
import type { PlutusJson } from './models';

export const PLUTUSJSON: PlutusJson = {
preamble: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions tsconfig.cjs.json

This file was deleted.

9 changes: 0 additions & 9 deletions tsconfig.esm.json

This file was deleted.

52 changes: 25 additions & 27 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
{
"compilerOptions": {
// "incremental": true,
"rootDir": "./src",
"strictPropertyInitialization": false,
"target": "ESNext",
"moduleResolution": "Node",
"module": "ESNext",
"declaration": true,
"inlineSourceMap": false,
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"traceResolution": false,
"listEmittedFiles": false,
"sourceMap": true,
"skipLibCheck": true,
"listFiles": false,
"pretty": true,
"lib": ["ESNext", "DOM"],
"typeRoots": ["node_modules/@types"],
"baseUrl": ".",
"paths": {
"_test-vectors": ["./packages/_test-vectors/"]
}

"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2022", "dom"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"module": "ES2022", /* Specify what module code is generated. */
"rootDir": "src", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"resolveJsonModule": true, /* Enable importing .json files. */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"declaration": false, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "noEmit": true, /* Disable emitting files from a compilation. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"noUnusedLocals": false,
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
"strictNullChecks": true,
"strictPropertyInitialization": false, /* Check for class properties that are declared but not set in the constructor. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"compileOnSave": false,
"exclude": ["**/node_modules", "**/dist", "test"]
"include": [
"src/**.ts"
]
}
39 changes: 39 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { basename, extname } from 'node:path'

import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
// @ts-ignore
import pkg from './package.json' assert { type: 'json' }

const defaultExport = pkg.exports['.'].default
const entryName = basename(defaultExport, extname(defaultExport))

export default defineConfig(({ mode }) => ({
build: {
lib: {
entry: {
[entryName]: 'src/index.ts'
},
formats: ['cjs', 'es']
},
rollupOptions: {
external: [
...Object.keys(pkg.dependencies), // Use package.json dependencies as externals
]
},
sourcemap: true,
minify: true
},
plugins: [tsconfigPaths(), dts()],
define: {
'import.meta.vitest': 'undefined',
},
test: {
includeSource: ['src/**/*.{js,ts}'],
coverage: {
enabled: true,
reporter: ['html', 'json', 'text'],
},
},
}))
Loading

0 comments on commit 230f2f8

Please sign in to comment.