diff --git a/package-lock.json b/package-lock.json index bc85799..ec9242f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,9 +14,12 @@ "npm-run-path": "^4.0.1" }, "devDependencies": { + "@sindresorhus/tsconfig": "^3.0.1", "@types/debug": "^4.1.7", + "@types/node": "^18.0.0", "prettier": "2.7.1", "tsup": "^6.1.3", + "typescript": "^4.7.4", "vite": "^2.5.3", "vitest": "^0.1.16" }, @@ -64,6 +67,15 @@ "node": ">= 8" } }, + "node_modules/@sindresorhus/tsconfig": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/tsconfig/-/tsconfig-3.0.1.tgz", + "integrity": "sha512-0/gtPNTY3++0J2BZM5nHHULg0BIMw886gqdn8vWN+Av6bgF5ZU2qIcHubAn+Z9KNvJhO8WFE+9kDOU3n6OcKtA==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@types/chai": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz", @@ -94,6 +106,12 @@ "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==", "dev": true }, + "node_modules/@types/node": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz", + "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==", + "dev": true + }, "node_modules/abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", @@ -2973,12 +2991,10 @@ } }, "node_modules/typescript": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", - "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", "dev": true, - "optional": true, - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -3260,6 +3276,12 @@ "fastq": "^1.6.0" } }, + "@sindresorhus/tsconfig": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/tsconfig/-/tsconfig-3.0.1.tgz", + "integrity": "sha512-0/gtPNTY3++0J2BZM5nHHULg0BIMw886gqdn8vWN+Av6bgF5ZU2qIcHubAn+Z9KNvJhO8WFE+9kDOU3n6OcKtA==", + "dev": true + }, "@types/chai": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz", @@ -3290,6 +3312,12 @@ "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==", "dev": true }, + "@types/node": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz", + "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==", + "dev": true + }, "abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", @@ -5330,12 +5358,10 @@ "dev": true }, "typescript": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", - "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", - "dev": true, - "optional": true, - "peer": true + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true }, "uri-js": { "version": "4.4.1", diff --git a/package.json b/package.json index 1ddb262..9fd7f3a 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,14 @@ }, "version": "2.1.0", "license": "MIT", + "type": "module", + "source": "src/index.ts", + "exports": { + "require": "dist/index.cjs", + "default": "dist/index.js" + }, "main": "dist/index.js", - "module": "dist/vite-plugin-rescript.esm.js", + "module": "dist/index.js", "typings": "dist/index.d.ts", "keywords": [ "rollup-plugin", @@ -19,17 +25,16 @@ "BuckleScript" ], "files": [ - "dist", - "src" + "dist" ], "engines": { "node": "^14 || ^16 || ^18", "npm": "^7 || ^8" }, "scripts": { - "build": "tsup src/index.ts", + "build": "tsup", "format": "prettier --write src test", - "start": "npm run build -- --watch", + "start": "tsup --watch", "test": "vitest run" }, "dependencies": { @@ -38,9 +43,12 @@ "npm-run-path": "^4.0.1" }, "devDependencies": { + "@sindresorhus/tsconfig": "^3.0.1", "@types/debug": "^4.1.7", + "@types/node": "^18.0.0", "prettier": "2.7.1", "tsup": "^6.1.3", + "typescript": "^4.7.4", "vite": "^2.5.3", "vitest": "^0.1.16" }, diff --git a/src/index.ts b/src/index.ts index f183ddb..e3c402f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import { Plugin } from 'vite'; import execa from 'execa'; import npmRunPath from 'npm-run-path'; import chalk from 'chalk'; -import parseCompilerLog from './parseCompilerLog'; +import parseCompilerLog from './parseCompilerLog.js'; const logPrefix = chalk.cyan('[@jihchi/vite-plugin-rescript]'); diff --git a/tsconfig.json b/tsconfig.json index 2c85b2d..55d6d8c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,35 +1,3 @@ { - // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], - "compilerOptions": { - "module": "esnext", - "lib": ["dom", "esnext"], - "importHelpers": true, - // output .d.ts declaration files for consumers - "declaration": true, - // output .js.map sourcemap files for consumers - "sourceMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - // stricter type-checking for stronger correctness. Recommended by TS - "strict": true, - // linter checks for common issues - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative - "noUnusedLocals": true, - "noUnusedParameters": true, - // use Node's module resolution algorithm, instead of the legacy TS one - "moduleResolution": "node", - // transpile JSX to React.createElement - "jsx": "react", - // interop between ESM and CJS modules. Recommended by TS - "esModuleInterop": true, - // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS - "skipLibCheck": true, - // error out if import and file system have a casing mismatch. Recommended by TS - "forceConsistentCasingInFileNames": true, - // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` - "noEmit": true, - } + "extends": "@sindresorhus/tsconfig" } diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..94fd364 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['cjs', 'esm'], + minify: true, + dts: true, +});